First round of ICH2/ICH2-M cleanups after split from i82801xx.
[coreboot.git] / src / southbridge / intel / i82801bx / i82801bx_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 "i82801bx.h"
29
30 typedef struct southbridge_intel_i82801bx_config config_t;
31
32 static void ide_init(struct device *dev)
33 {
34         u16 reg16;
35         config_t *conf = dev->chip_info;
36
37         reg16 = pci_read_config16(dev, IDE_TIM_PRI);
38         reg16 &= ~IDE_DECODE_ENABLE;
39         if (!conf || conf->ide0_enable)
40                 reg16 |= IDE_DECODE_ENABLE;
41         printk(BIOS_DEBUG, "IDE: %s IDE interface: %s\n", "Primary",
42                conf->ide0_enable ? "on" : "off");
43         pci_write_config16(dev, IDE_TIM_PRI, reg16);
44
45         reg16 = pci_read_config16(dev, IDE_TIM_SEC);
46         reg16 &= ~IDE_DECODE_ENABLE;
47         if (!conf || conf->ide1_enable)
48                 reg16 |= IDE_DECODE_ENABLE;
49         printk(BIOS_DEBUG, "IDE: %s IDE interface: %s\n", "Secondary",
50                conf->ide0_enable ? "on" : "off");
51         pci_write_config16(dev, IDE_TIM_SEC, reg16);
52 }
53
54 static struct device_operations ide_ops = {
55         .read_resources         = pci_dev_read_resources,
56         .set_resources          = pci_dev_set_resources,
57         .enable_resources       = pci_dev_enable_resources,
58         .init                   = ide_init,
59         .scan_bus               = 0,
60         .enable                 = i82801bx_enable,
61 };
62
63 /* 82801BA/BAM (ICH2/ICH2-M) */
64 static const struct pci_driver i82801ba_ide __pci_driver = {
65         .ops    = &ide_ops,
66         .vendor = PCI_VENDOR_ID_INTEL,
67         .device = 0x244b,
68 };