blob: 75350da0582e2deffa2259b669a18ca893b033da [file] [log] [blame]
Stefan Reinauer8702ab52010-03-14 17:01:08 +00001/*
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
Ronald G. Minnich182615d2004-08-24 16:20:46 +000021#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>
Stefan Reinauer138be832010-02-27 01:50:21 +000026#include "i82801dx.h"
Ronald G. Minnich182615d2004-08-24 16:20:46 +000027
Stefan Reinauer8702ab52010-03-14 17:01:08 +000028typedef struct southbridge_intel_i82801dx_config config_t;
Ronald G. Minnich182615d2004-08-24 16:20:46 +000029
30static void ide_init(struct device *dev)
31{
Stefan Reinauer8702ab52010-03-14 17:01:08 +000032 /* Get the chip configuration */
33 config_t *config = dev->chip_info;
Ronald G. Minnich182615d2004-08-24 16:20:46 +000034
Stefan Reinauer8702ab52010-03-14 17:01:08 +000035 /* Enable IDE devices so the Linux IDE driver will work. */
36 uint16_t ideTimingConfig;
Ronald G. Minnich182615d2004-08-24 16:20:46 +000037
Stefan Reinauer8702ab52010-03-14 17:01:08 +000038 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;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000043 printk(BIOS_DEBUG, "IDE0: Primary IDE interface is enabled\n");
Stefan Reinauer8702ab52010-03-14 17:01:08 +000044 } else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000045 printk(BIOS_INFO, "IDE0: Primary IDE interface is disabled\n");
Ronald G. Minnich182615d2004-08-24 16:20:46 +000046 }
Stefan Reinauer8702ab52010-03-14 17:01:08 +000047 pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig);
Ronald G. Minnich182615d2004-08-24 16:20:46 +000048
Stefan Reinauer8702ab52010-03-14 17:01:08 +000049 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;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000054 printk(BIOS_DEBUG, "IDE1: Secondary IDE interface is enabled\n");
Stefan Reinauer8702ab52010-03-14 17:01:08 +000055 } else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000056 printk(BIOS_INFO, "IDE1: Secondary IDE interface is disabled\n");
Stefan Reinauer8702ab52010-03-14 17:01:08 +000057 }
58 pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig);
Ronald G. Minnich182615d2004-08-24 16:20:46 +000059}
60
Stefan Reinauer8702ab52010-03-14 17:01:08 +000061static struct device_operations ide_ops = {
62 .read_resources = pci_dev_read_resources,
63 .set_resources = pci_dev_set_resources,
Ronald G. Minnich182615d2004-08-24 16:20:46 +000064 .enable_resources = pci_dev_enable_resources,
Stefan Reinauer8702ab52010-03-14 17:01:08 +000065 .init = ide_init,
66 .scan_bus = 0,
67 .enable = i82801dx_enable,
Ronald G. Minnich182615d2004-08-24 16:20:46 +000068};
69
Stefan Reinauer8702ab52010-03-14 17:01:08 +000070/* 82801DB */
71static const struct pci_driver i82801db_ide __pci_driver = {
72 .ops = &ide_ops,
Ronald G. Minnich182615d2004-08-24 16:20:46 +000073 .vendor = PCI_VENDOR_ID_INTEL,
Stefan Reinauer8702ab52010-03-14 17:01:08 +000074 .device = 0x24cb,
Ronald G. Minnich182615d2004-08-24 16:20:46 +000075};
76
Stefan Reinauer8702ab52010-03-14 17:01:08 +000077/* 82801DBM */
78static const struct pci_driver i82801dbm_ide __pci_driver = {
79 .ops = &ide_ops,
80 .vendor = PCI_VENDOR_ID_INTEL,
81 .device = 0x24ca,
82};