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