blob: c22b988f53a265831078485faefd2a626a953a53 [file] [log] [blame]
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +03001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Sage Electronic Engineering, LLC
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030014 */
15
16#include <device/device.h>
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030017#include <device/pci.h>
18#include <device/pci_ids.h>
19#include <device/pci_ops.h>
Elyes HAOUASbf0970e2019-03-21 11:10:03 +010020
Kyösti Mälkki830e0de2019-08-19 13:29:46 +030021#include "chip.h"
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030022#include "hudson.h"
23
24static void sd_init(struct device *dev)
25{
Kyösti Mälkki830e0de2019-08-19 13:29:46 +030026 struct southbridge_amd_pi_hudson_config *sd_chip = dev->chip_info;
27 u32 stepping = pci_read_config32(pcidev_on_root(0x18, 3), 0xFC);
28 u8 sd_mode = 0;
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030029
Kyösti Mälkki830e0de2019-08-19 13:29:46 +030030 if (sd_chip)
31 sd_mode = sd_chip->sd_mode;
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030032
Kyösti Mälkki830e0de2019-08-19 13:29:46 +030033 if (sd_mode == 3) { /* SD 3.0 mode */
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030034 pci_write_config32(dev, 0xA4, 0x31FEC8B2);
35 pci_write_config32(dev, 0xA8, 0x00002503);
36 pci_write_config32(dev, 0xB0, 0x02180C19);
37 pci_write_config32(dev, 0xD0, 0x0000078B);
38 }
39 else { /* SD 2.0 mode */
40 if ((stepping & 0x0000000F) == 0) { /* Stepping A0 */
41 pci_write_config32(dev, 0xA4, 0x31DE32B2);
42 pci_write_config32(dev, 0xB0, 0x01180C19);
43 pci_write_config32(dev, 0xD0, 0x0000058B);
44 }
45 else { /* Stepping >= A1 */
Michał Żygowski654a45d2018-07-05 16:53:44 +020046 pci_write_config32(dev, 0xA4, 0x31FE32B2);
47 pci_write_config32(dev, 0xA8, 0x00000070);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030048 pci_write_config32(dev, 0xB0, 0x01180C19);
49 pci_write_config32(dev, 0xD0, 0x0000078B);
50 }
51 }
52}
53
54static struct device_operations sd_ops = {
55 .read_resources = pci_dev_read_resources,
56 .set_resources = pci_dev_set_resources,
57 .enable_resources = pci_dev_enable_resources,
58 .init = sd_init,
59 .scan_bus = 0,
60};
61
62static const struct pci_driver sd_driver __pci_driver = {
63 .ops = &sd_ops,
64 .vendor = PCI_VENDOR_ID_AMD,
65 .device = PCI_DEVICE_ID_AMD_YANGTZE_SD,
66};