Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 1 | /* |
| 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. |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 17 | #include <console/console.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <device/pci_ids.h> |
| 21 | #include <device/pci_ops.h> |
Kyösti Mälkki | 12b121c | 2019-08-18 16:33:39 +0300 | [diff] [blame^] | 22 | #include "chip.h" |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 23 | #include "i82801dx.h" |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 24 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 25 | typedef struct southbridge_intel_i82801dx_config config_t; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 26 | |
| 27 | static void ide_init(struct device *dev) |
| 28 | { |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 29 | /* Get the chip configuration */ |
| 30 | config_t *config = dev->chip_info; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 31 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 32 | /* Enable IDE devices so the Linux IDE driver will work. */ |
| 33 | uint16_t ideTimingConfig; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 34 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 35 | ideTimingConfig = pci_read_config16(dev, IDE_TIM_PRI); |
| 36 | ideTimingConfig &= ~IDE_DECODE_ENABLE; |
| 37 | if (!config || config->ide0_enable) { |
| 38 | /* Enable primary IDE interface. */ |
| 39 | ideTimingConfig |= IDE_DECODE_ENABLE; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 40 | printk(BIOS_DEBUG, "IDE0: Primary IDE interface is enabled\n"); |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 41 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 42 | printk(BIOS_INFO, "IDE0: Primary IDE interface is disabled\n"); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 43 | } |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 44 | pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 45 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 46 | ideTimingConfig = pci_read_config16(dev, IDE_TIM_SEC); |
| 47 | ideTimingConfig &= ~IDE_DECODE_ENABLE; |
| 48 | if (!config || config->ide1_enable) { |
| 49 | /* Enable secondary IDE interface. */ |
| 50 | ideTimingConfig |= IDE_DECODE_ENABLE; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 51 | printk(BIOS_DEBUG, "IDE1: Secondary IDE interface is enabled\n"); |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 52 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 53 | printk(BIOS_INFO, "IDE1: Secondary IDE interface is disabled\n"); |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 54 | } |
| 55 | pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 58 | static struct device_operations ide_ops = { |
| 59 | .read_resources = pci_dev_read_resources, |
| 60 | .set_resources = pci_dev_set_resources, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 61 | .enable_resources = pci_dev_enable_resources, |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 62 | .init = ide_init, |
| 63 | .scan_bus = 0, |
| 64 | .enable = i82801dx_enable, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 67 | /* 82801DB */ |
| 68 | static const struct pci_driver i82801db_ide __pci_driver = { |
| 69 | .ops = &ide_ops, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 70 | .vendor = PCI_VENDOR_ID_INTEL, |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 71 | .device = 0x24cb, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 74 | /* 82801DBM */ |
| 75 | static const struct pci_driver i82801dbm_ide __pci_driver = { |
| 76 | .ops = &ide_ops, |
| 77 | .vendor = PCI_VENDOR_ID_INTEL, |
| 78 | .device = 0x24ca, |
| 79 | }; |