blob: f3ea0a5eb473cb7aa546ecee34a99cf37c00a996 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Dave Frodinea909632013-05-31 08:15:57 -06002
3#include <device/device.h>
Dave Frodinea909632013-05-31 08:15:57 -06004#include <device/pci.h>
5#include <device/pci_ids.h>
6#include <device/pci_ops.h>
Elyes HAOUASbf0970e2019-03-21 11:10:03 +01007
Kyösti Mälkki830e0de2019-08-19 13:29:46 +03008#include "chip.h"
Dave Frodinea909632013-05-31 08:15:57 -06009#include "hudson.h"
10
11static void sd_init(struct device *dev)
12{
Kyösti Mälkki830e0de2019-08-19 13:29:46 +030013 struct southbridge_amd_agesa_hudson_config *sd_chip = dev->chip_info;
14 u32 stepping = pci_read_config32(pcidev_on_root(0x18, 3), 0xFC);
15 u8 sd_mode = 0;
Dave Frodinea909632013-05-31 08:15:57 -060016
Kyösti Mälkki830e0de2019-08-19 13:29:46 +030017 if (sd_chip)
18 sd_mode = sd_chip->sd_mode;
Dave Frodinea909632013-05-31 08:15:57 -060019
Kyösti Mälkki830e0de2019-08-19 13:29:46 +030020 if (sd_mode == 3) { /* SD 3.0 mode */
Dave Frodinea909632013-05-31 08:15:57 -060021 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 */
33 pci_write_config32(dev, 0xA4, 0x31FE3FB2);
34 pci_write_config32(dev, 0xB0, 0x01180C19);
35 pci_write_config32(dev, 0xD0, 0x0000078B);
36 }
37 }
38}
39
40static struct device_operations sd_ops = {
41 .read_resources = pci_dev_read_resources,
42 .set_resources = pci_dev_set_resources,
43 .enable_resources = pci_dev_enable_resources,
44 .init = sd_init,
Dave Frodinea909632013-05-31 08:15:57 -060045};
46
47static const struct pci_driver sd_driver __pci_driver = {
48 .ops = &sd_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010049 .vendor = PCI_VID_AMD,
50 .device = PCI_DID_AMD_YANGTZE_SD,
Dave Frodinea909632013-05-31 08:15:57 -060051};