blob: cc9470e04bcb08c18c51d9f330ef03dbc4f9f99d [file] [log] [blame]
Dave Frodinea909632013-05-31 08:15:57 -06001/*
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.
Dave Frodinea909632013-05-31 08:15:57 -060014 */
15
16#include <device/device.h>
Dave Frodinea909632013-05-31 08:15:57 -060017#include <device/pci.h>
18#include <device/pci_ids.h>
19#include <device/pci_ops.h>
Elyes HAOUASbf0970e2019-03-21 11:10:03 +010020
Dave Frodinea909632013-05-31 08:15:57 -060021#include "hudson.h"
22
23static void sd_init(struct device *dev)
24{
25 u32 stepping;
26
Kyösti Mälkki4ad7f5b2018-05-22 01:15:17 +030027 stepping = pci_read_config32(pcidev_on_root(0x18, 3), 0xFC);
Dave Frodinea909632013-05-31 08:15:57 -060028
29 struct southbridge_amd_agesa_hudson_config *sd_chip =
30 (struct southbridge_amd_agesa_hudson_config *)(dev->chip_info);
31
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 */
45 pci_write_config32(dev, 0xA4, 0x31FE3FB2);
46 pci_write_config32(dev, 0xB0, 0x01180C19);
47 pci_write_config32(dev, 0xD0, 0x0000078B);
48 }
49 }
50}
51
52static struct device_operations sd_ops = {
53 .read_resources = pci_dev_read_resources,
54 .set_resources = pci_dev_set_resources,
55 .enable_resources = pci_dev_enable_resources,
56 .init = sd_init,
57 .scan_bus = 0,
58};
59
60static const struct pci_driver sd_driver __pci_driver = {
61 .ops = &sd_ops,
62 .vendor = PCI_VENDOR_ID_AMD,
63 .device = PCI_DEVICE_ID_AMD_YANGTZE_SD,
64};