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