Kyösti Mälkki | 7b73e852 | 2022-11-08 04:43:41 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 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> |
| 8 | #include "chip.h" |
| 9 | #include "i82801dx.h" |
| 10 | |
| 11 | typedef struct southbridge_intel_i82801dx_config config_t; |
| 12 | |
| 13 | static void ide_init(struct device *dev) |
| 14 | { |
| 15 | /* Get the chip configuration */ |
| 16 | config_t *config = dev->chip_info; |
| 17 | |
| 18 | /* Enable IDE devices so the Linux IDE driver will work. */ |
| 19 | uint16_t ideTimingConfig; |
| 20 | |
| 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; |
| 26 | printk(BIOS_DEBUG, "IDE0: Primary IDE interface is enabled\n"); |
| 27 | } else { |
| 28 | printk(BIOS_INFO, "IDE0: Primary IDE interface is disabled\n"); |
| 29 | } |
| 30 | pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig); |
| 31 | |
| 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; |
| 37 | printk(BIOS_DEBUG, "IDE1: Secondary IDE interface is enabled\n"); |
| 38 | } else { |
| 39 | printk(BIOS_INFO, "IDE1: Secondary IDE interface is disabled\n"); |
| 40 | } |
| 41 | pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig); |
| 42 | } |
| 43 | |
| 44 | static struct device_operations ide_ops = { |
| 45 | .read_resources = pci_dev_read_resources, |
| 46 | .set_resources = pci_dev_set_resources, |
| 47 | .enable_resources = pci_dev_enable_resources, |
| 48 | .init = ide_init, |
| 49 | .enable = i82801dx_enable, |
| 50 | }; |
| 51 | |
| 52 | /* 82801DB */ |
| 53 | static const struct pci_driver i82801db_ide __pci_driver = { |
| 54 | .ops = &ide_ops, |
| 55 | .vendor = PCI_VID_INTEL, |
| 56 | .device = 0x24cb, |
| 57 | }; |
| 58 | |
| 59 | /* 82801DBM */ |
| 60 | static const struct pci_driver i82801dbm_ide __pci_driver = { |
| 61 | .ops = &ide_ops, |
| 62 | .vendor = PCI_VID_INTEL, |
| 63 | .device = 0x24ca, |
| 64 | }; |