75350da0582e2deffa2259b669a18ca893b033da
[coreboot.git] / src / southbridge / intel / i82801dx / i82801dx_ide.c
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
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>
26 #include "i82801dx.h"
27
28 typedef struct southbridge_intel_i82801dx_config config_t;
29
30 static void ide_init(struct device *dev)
31 {
32         /* Get the chip configuration */
33         config_t *config = dev->chip_info;
34
35         /* Enable IDE devices so the Linux IDE driver will work. */
36         uint16_t ideTimingConfig;
37
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;
43                 printk(BIOS_DEBUG, "IDE0: Primary IDE interface is enabled\n");
44         } else {
45                 printk(BIOS_INFO, "IDE0: Primary IDE interface is disabled\n");
46         }
47         pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig);
48
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;
54                 printk(BIOS_DEBUG, "IDE1: Secondary IDE interface is enabled\n");
55         } else {
56                 printk(BIOS_INFO, "IDE1: Secondary IDE interface is disabled\n");
57         }
58         pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig);
59 }
60
61 static struct device_operations ide_ops = {
62         .read_resources = pci_dev_read_resources,
63         .set_resources = pci_dev_set_resources,
64         .enable_resources = pci_dev_enable_resources,
65         .init = ide_init,
66         .scan_bus = 0,
67         .enable = i82801dx_enable,
68 };
69
70 /* 82801DB */
71 static const struct pci_driver i82801db_ide __pci_driver = {
72         .ops = &ide_ops,
73         .vendor = PCI_VENDOR_ID_INTEL,
74         .device = 0x24cb,
75 };
76
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 };