blob: e4ace38f05aa714c4b5f42656f7774a70e5d9acf [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älkkie8b4da22014-10-21 18:22:32 +030021#include "hudson.h"
22
23static void sd_init(struct device *dev)
24{
25 u32 stepping;
26
Kyösti Mälkki33ff44c2018-05-22 01:15:22 +030027 stepping = pci_read_config32(pcidev_on_root(0x18, 3), 0xFC);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030028
Dave Frodinbc21a412015-01-19 11:40:38 -070029 struct southbridge_amd_pi_hudson_config *sd_chip =
30 (struct southbridge_amd_pi_hudson_config *)(dev->chip_info);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030031
32 if (sd_chip->sd_mode == 3) { /* SD 3.0 mode */
33 pci_write_config32(dev, 0xA4, 0x31FEC8B2);
34 pci_write_config32(dev, 0xA8, 0x00002503);
35 pci_write_config32(dev, 0xB0, 0x02180C19);
36 pci_write_config32(dev, 0xD0, 0x0000078B);
37 }
38 else { /* SD 2.0 mode */
39 if ((stepping & 0x0000000F) == 0) { /* Stepping A0 */
40 pci_write_config32(dev, 0xA4, 0x31DE32B2);
41 pci_write_config32(dev, 0xB0, 0x01180C19);
42 pci_write_config32(dev, 0xD0, 0x0000058B);
43 }
44 else { /* Stepping >= A1 */
Michał Żygowski654a45d2018-07-05 16:53:44 +020045 pci_write_config32(dev, 0xA4, 0x31FE32B2);
46 pci_write_config32(dev, 0xA8, 0x00000070);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030047 pci_write_config32(dev, 0xB0, 0x01180C19);
48 pci_write_config32(dev, 0xD0, 0x0000078B);
49 }
50 }
51}
52
53static struct device_operations sd_ops = {
54 .read_resources = pci_dev_read_resources,
55 .set_resources = pci_dev_set_resources,
56 .enable_resources = pci_dev_enable_resources,
57 .init = sd_init,
58 .scan_bus = 0,
59};
60
61static const struct pci_driver sd_driver __pci_driver = {
62 .ops = &sd_ops,
63 .vendor = PCI_VENDOR_ID_AMD,
64 .device = PCI_DEVICE_ID_AMD_YANGTZE_SD,
65};