Please bear with me - another rename checkin. This qualifies as trivial, no
[coreboot.git] / src / southbridge / amd / cs5530 / cs5530_ide.c
1 /*
2  * This file is part of the coreboot 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 "cs5530.h"
26
27 /**
28  * Initialize the IDE controller.
29  *
30  * Depending on the configuration variables 'ide0_enable' and 'ide1_enable'
31  * 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         uint8_t reg8;
38         struct southbridge_amd_cs5530_config *conf = dev->chip_info;
39
40         reg8 = pci_read_config8(dev, DECODE_CONTROL_REG2);
41
42         /* Enable/disable the primary IDE interface. */
43         if (conf->ide0_enable) {
44                 reg8 |= PRIMARY_IDE_ENABLE;
45         } else {
46                 reg8 &= ~(PRIMARY_IDE_ENABLE);
47         }
48
49         /* Enable/disable the secondary IDE interface. */
50         if (conf->ide1_enable) {
51                 reg8 |= SECONDARY_IDE_ENABLE;
52         } else {
53                 reg8 &= ~(SECONDARY_IDE_ENABLE);
54         }
55
56         pci_write_config8(dev, DECODE_CONTROL_REG2, reg8);
57
58         printk_info("%s IDE interface %s\n", "Primary",
59                     conf->ide0_enable ? "enabled" : "disabled");
60         printk_info("%s IDE interface %s\n", "Secondary",
61                     conf->ide1_enable ? "enabled" : "disabled");
62 }
63
64 static struct device_operations ide_ops = {
65         .read_resources         = pci_dev_read_resources,
66         .set_resources          = pci_dev_set_resources,
67         .enable_resources       = pci_dev_enable_resources,
68         .init                   = ide_init,
69         .enable                 = 0,
70         .scan_bus               = scan_static_bus,
71         .ops_pci                = 0,
72 };
73
74 static const struct pci_driver ide_driver __pci_driver = {
75         .ops    = &ide_ops,
76         .vendor = PCI_VENDOR_ID_CYRIX,
77         .device = PCI_DEVICE_ID_CYRIX_5530_IDE,
78 };