Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the LinuxBIOS project. |
| 3 | * |
| 4 | * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 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 | |
| 21 | #include <console/console.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
| 25 | #include "i82371eb.h" |
| 26 | |
| 27 | /** |
| 28 | * Initialize the IDE controller. |
| 29 | * |
| 30 | * Depending on the configuration variables 'ide0_enable' and 'ide1_enable' |
| 31 | * we enable or disable the primary and secondary IDE interface, respectively. |
| 32 | * |
| 33 | * @param dev The device to use. |
| 34 | */ |
| 35 | static void ide_init(struct device *dev) |
| 36 | { |
| 37 | uint16_t reg; |
Uwe Hermann | 56a9125 | 2007-06-03 16:57:27 +0000 | [diff] [blame^] | 38 | struct southbridge_intel_i82371eb_config *conf = dev->chip_info; |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 39 | |
| 40 | /* Enable/disable the primary IDE interface. */ |
| 41 | reg = pci_read_config16(dev, IDETIM_PRI); |
| 42 | if (conf->ide0_enable) { |
| 43 | reg |= IDE_DECODE_ENABLE; |
| 44 | print_info("Primary IDE interface enabled\n"); |
| 45 | } else { |
| 46 | reg &= ~(IDE_DECODE_ENABLE); |
| 47 | print_info("Primary IDE interface disabled\n"); |
| 48 | } |
| 49 | pci_write_config16(dev, IDETIM_PRI, reg); |
| 50 | |
| 51 | /* Enable/disable the secondary IDE interface. */ |
| 52 | reg = pci_read_config16(dev, IDETIM_SEC); |
| 53 | if (conf->ide1_enable) { |
| 54 | reg |= IDE_DECODE_ENABLE; |
| 55 | print_info("Secondary IDE interface enabled\n"); |
| 56 | } else { |
| 57 | reg &= ~(IDE_DECODE_ENABLE); |
| 58 | print_info("Secondary IDE interface disabled\n"); |
| 59 | } |
| 60 | pci_write_config16(dev, IDETIM_SEC, reg); |
| 61 | } |
| 62 | |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 63 | static struct device_operations ide_ops = { |
| 64 | .read_resources = pci_dev_read_resources, |
| 65 | .set_resources = pci_dev_set_resources, |
| 66 | .enable_resources = pci_dev_enable_resources, |
| 67 | .init = ide_init, |
| 68 | .scan_bus = 0, |
Uwe Hermann | 56a9125 | 2007-06-03 16:57:27 +0000 | [diff] [blame^] | 69 | .ops_pci = 0, /* No subsystem IDs on 82371EB! */ |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | static struct pci_driver ide_driver __pci_driver = { |
| 73 | .ops = &ide_ops, |
| 74 | .vendor = PCI_VENDOR_ID_INTEL, |
| 75 | .device = PCI_DEVICE_ID_INTEL_82371AB_IDE, |
| 76 | }; |