Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2004 Ronald G. Minnich |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 21 | #include <console/console.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
| 25 | #include <device/pci_ops.h> |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 26 | #include "i82801dx.h" |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 27 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 28 | typedef struct southbridge_intel_i82801dx_config config_t; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 29 | |
| 30 | static void ide_init(struct device *dev) |
| 31 | { |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 32 | /* Get the chip configuration */ |
| 33 | config_t *config = dev->chip_info; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 34 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 35 | /* Enable IDE devices so the Linux IDE driver will work. */ |
| 36 | uint16_t ideTimingConfig; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 37 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 38 | ideTimingConfig = pci_read_config16(dev, IDE_TIM_PRI); |
| 39 | ideTimingConfig &= ~IDE_DECODE_ENABLE; |
| 40 | if (!config || config->ide0_enable) { |
| 41 | /* Enable primary IDE interface. */ |
| 42 | ideTimingConfig |= IDE_DECODE_ENABLE; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame^] | 43 | printk(BIOS_DEBUG, "IDE0: Primary IDE interface is enabled\n"); |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 44 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame^] | 45 | printk(BIOS_INFO, "IDE0: Primary IDE interface is disabled\n"); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 46 | } |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 47 | pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 48 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 49 | ideTimingConfig = pci_read_config16(dev, IDE_TIM_SEC); |
| 50 | ideTimingConfig &= ~IDE_DECODE_ENABLE; |
| 51 | if (!config || config->ide1_enable) { |
| 52 | /* Enable secondary IDE interface. */ |
| 53 | ideTimingConfig |= IDE_DECODE_ENABLE; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame^] | 54 | printk(BIOS_DEBUG, "IDE1: Secondary IDE interface is enabled\n"); |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 55 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame^] | 56 | printk(BIOS_INFO, "IDE1: Secondary IDE interface is disabled\n"); |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 57 | } |
| 58 | pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 61 | static struct device_operations ide_ops = { |
| 62 | .read_resources = pci_dev_read_resources, |
| 63 | .set_resources = pci_dev_set_resources, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 64 | .enable_resources = pci_dev_enable_resources, |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 65 | .init = ide_init, |
| 66 | .scan_bus = 0, |
| 67 | .enable = i82801dx_enable, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 70 | /* 82801DB */ |
| 71 | static const struct pci_driver i82801db_ide __pci_driver = { |
| 72 | .ops = &ide_ops, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 73 | .vendor = PCI_VENDOR_ID_INTEL, |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 74 | .device = 0x24cb, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 77 | /* 82801DBM */ |
| 78 | static const struct pci_driver i82801dbm_ide __pci_driver = { |
| 79 | .ops = &ide_ops, |
| 80 | .vendor = PCI_VENDOR_ID_INTEL, |
| 81 | .device = 0x24ca, |
| 82 | }; |