Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 2 | |
| 3 | #include <device/device.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 4 | #include <device/pci.h> |
| 5 | #include <device/pci_ids.h> |
| 6 | #include <device/pci_ops.h> |
Elyes HAOUAS | bf0970e | 2019-03-21 11:10:03 +0100 | [diff] [blame] | 7 | |
Kyösti Mälkki | 830e0de | 2019-08-19 13:29:46 +0300 | [diff] [blame] | 8 | #include "chip.h" |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 9 | #include "hudson.h" |
| 10 | |
| 11 | static void sd_init(struct device *dev) |
| 12 | { |
Kyösti Mälkki | 830e0de | 2019-08-19 13:29:46 +0300 | [diff] [blame] | 13 | struct southbridge_amd_pi_hudson_config *sd_chip = dev->chip_info; |
| 14 | u32 stepping = pci_read_config32(pcidev_on_root(0x18, 3), 0xFC); |
| 15 | u8 sd_mode = 0; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 16 | |
Kyösti Mälkki | 830e0de | 2019-08-19 13:29:46 +0300 | [diff] [blame] | 17 | if (sd_chip) |
| 18 | sd_mode = sd_chip->sd_mode; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 19 | |
Kyösti Mälkki | 830e0de | 2019-08-19 13:29:46 +0300 | [diff] [blame] | 20 | if (sd_mode == 3) { /* SD 3.0 mode */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 21 | pci_write_config32(dev, 0xA4, 0x31FEC8B2); |
| 22 | pci_write_config32(dev, 0xA8, 0x00002503); |
| 23 | pci_write_config32(dev, 0xB0, 0x02180C19); |
| 24 | pci_write_config32(dev, 0xD0, 0x0000078B); |
| 25 | } |
| 26 | else { /* SD 2.0 mode */ |
| 27 | if ((stepping & 0x0000000F) == 0) { /* Stepping A0 */ |
| 28 | pci_write_config32(dev, 0xA4, 0x31DE32B2); |
| 29 | pci_write_config32(dev, 0xB0, 0x01180C19); |
| 30 | pci_write_config32(dev, 0xD0, 0x0000058B); |
| 31 | } |
| 32 | else { /* Stepping >= A1 */ |
Michał Żygowski | 654a45d | 2018-07-05 16:53:44 +0200 | [diff] [blame] | 33 | pci_write_config32(dev, 0xA4, 0x31FE32B2); |
| 34 | pci_write_config32(dev, 0xA8, 0x00000070); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 35 | pci_write_config32(dev, 0xB0, 0x01180C19); |
| 36 | pci_write_config32(dev, 0xD0, 0x0000078B); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | static struct device_operations sd_ops = { |
| 42 | .read_resources = pci_dev_read_resources, |
| 43 | .set_resources = pci_dev_set_resources, |
| 44 | .enable_resources = pci_dev_enable_resources, |
| 45 | .init = sd_init, |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | static const struct pci_driver sd_driver __pci_driver = { |
| 49 | .ops = &sd_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 50 | .vendor = PCI_VID_AMD, |
| 51 | .device = PCI_DID_AMD_YANGTZE_SD, |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 52 | }; |