Ever wondered where those "setting incorrect section attributes for
[coreboot.git] / src / southbridge / intel / i82801xx / i82801xx_ide.c
1 /*
2  * This file is part of the LinuxBIOS project.
3  *
4  * Copyright (C) 2005 Tyan Computer
5  * (Written by Yinghai Lu <yinghailu@gmail.com> for Tyan Computer)
6  * Copyright (C) 2005 Digital Design Corporation
7  * (Written by Steven J. Magnani <steve@digidescorp.com> for Digital Design)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
22  */
23
24 #include <console/console.h>
25 #include <device/device.h>
26 #include <device/pci.h>
27 #include <device/pci_ids.h>
28 #include "i82801xx.h"
29
30 static void ide_init(struct device *dev)
31 {
32         /* TODO: Needs to be tested for compatibility with ICH5(R). */
33         /* Enable IDE devices so the Linux IDE driver will work. */
34         uint16_t ideTimingConfig;
35         int enable_primary = 1;
36         int enable_secondary = 1;
37
38         ideTimingConfig = pci_read_config16(dev, IDE_TIM_PRI);
39         ideTimingConfig &= ~IDE_DECODE_ENABLE;
40         if (enable_primary) {
41                 /* Enable primary IDE interface. */
42                 ideTimingConfig |= IDE_DECODE_ENABLE;
43                 printk_debug("IDE0 ");
44         }
45         pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig);
46
47         ideTimingConfig = pci_read_config16(dev, IDE_TIM_SEC);
48         ideTimingConfig &= ~IDE_DECODE_ENABLE;
49         if (enable_secondary) {
50                 /* Enable secondary IDE interface. */
51                 ideTimingConfig |= IDE_DECODE_ENABLE;
52                 printk_debug("IDE1 ");
53         }
54         pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig);
55 }
56
57 static struct device_operations ide_ops = {
58         .read_resources         = pci_dev_read_resources,
59         .set_resources          = pci_dev_set_resources,
60         .enable_resources       = pci_dev_enable_resources,
61         .init                   = ide_init,
62         .scan_bus               = 0,
63         .enable                 = i82801xx_enable,
64 };
65
66 /* 82801AA */
67 static const struct pci_driver i82801aa_ide __pci_driver = {
68         .ops    = &ide_ops,
69         .vendor = PCI_VENDOR_ID_INTEL,
70         .device = 0x2411,
71 };
72
73 /* 82801AB */
74 static const struct pci_driver i82801ab_ide __pci_driver = {
75         .ops    = &ide_ops,
76         .vendor = PCI_VENDOR_ID_INTEL,
77         .device = 0x2421,
78 };
79
80 /* 82801BA */
81 static const struct pci_driver i82801ba_ide __pci_driver = {
82         .ops    = &ide_ops,
83         .vendor = PCI_VENDOR_ID_INTEL,
84         .device = 0x244b,
85 };
86
87 /* 82801CA */
88 static const struct pci_driver i82801ca_ide __pci_driver = {
89         .ops    = &ide_ops,
90         .vendor = PCI_VENDOR_ID_INTEL,
91         .device = 0x248b,
92 };
93
94 /* 82801DB */
95 static const struct pci_driver i82801db_ide __pci_driver = {
96         .ops    = &ide_ops,
97         .vendor = PCI_VENDOR_ID_INTEL,
98         .device = 0x24cb,
99 };
100
101 /* 82801DBM */
102 static const struct pci_driver i82801dbm_ide __pci_driver = {
103         .ops    = &ide_ops,
104         .vendor = PCI_VENDOR_ID_INTEL,
105         .device = 0x24ca,
106 };
107
108 /* 82801EB & 82801ER */
109 static const struct pci_driver i82801ex_ide __pci_driver = {
110         .ops    = &ide_ops,
111         .vendor = PCI_VENDOR_ID_INTEL,
112         .device = 0x24db,
113 };