04a7a12a488c5ccc4ab99d8250b738d5a794d94a
[coreboot.git] / src / southbridge / intel / i82801ax / i82801ax_ide.c
1 /*
2  * This file is part of the coreboot 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 "i82801ax.h"
29
30 typedef struct southbridge_intel_i82801ax_config config_t;
31
32 static void ide_init(struct device *dev)
33 {
34         /* Get the chip configuration */
35         config_t *config = dev->chip_info;
36
37         /* Enable IDE devices so the Linux IDE driver will work. */
38         uint16_t ideTimingConfig;
39
40         ideTimingConfig = pci_read_config16(dev, IDE_TIM_PRI);
41         ideTimingConfig &= ~IDE_DECODE_ENABLE;
42         if (!config || config->ide0_enable) {
43                 /* Enable primary IDE interface. */
44                 ideTimingConfig |= IDE_DECODE_ENABLE;
45                 printk(BIOS_DEBUG, "IDE0: Primary IDE interface is enabled\n");
46         } else {
47                 printk(BIOS_INFO, "IDE0: Primary IDE interface is disabled\n");
48         }
49         pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig);
50
51         ideTimingConfig = pci_read_config16(dev, IDE_TIM_SEC);
52         ideTimingConfig &= ~IDE_DECODE_ENABLE;
53         if (!config || config->ide1_enable) {
54                 /* Enable secondary IDE interface. */
55                 ideTimingConfig |= IDE_DECODE_ENABLE;
56                 printk(BIOS_DEBUG, "IDE1: Secondary IDE interface is enabled\n");
57         } else {
58                 printk(BIOS_INFO, "IDE1: Secondary IDE interface is disabled\n");
59         }
60         pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig);
61 }
62
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,
69         .enable                 = i82801ax_enable,
70 };
71
72 /* 82801AA */
73 static const struct pci_driver i82801aa_ide __pci_driver = {
74         .ops    = &ide_ops,
75         .vendor = PCI_VENDOR_ID_INTEL,
76         .device = 0x2411,
77 };
78
79 /* 82801AB */
80 static const struct pci_driver i82801ab_ide __pci_driver = {
81         .ops    = &ide_ops,
82         .vendor = PCI_VENDOR_ID_INTEL,
83         .device = 0x2421,
84 };
85