blob: b0c7b0fbb383fa7048136c0e0d48dd8ae9d92932 [file] [log] [blame]
Marshall Dawson3edc9e22019-08-16 08:45:20 -06001/*
2 * This file is part of the coreboot project.
3 *
Marshall Dawson3edc9e22019-08-16 08:45:20 -06004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <console/console.h>
16#include <device/device.h>
17#include <device/pci.h>
18#include <device/pci_ids.h>
19#include <device/pci_ops.h>
20#include "chip.h"
21#include <soc/acpi.h>
22#include <soc/pci_devs.h>
23#include <soc/northbridge.h>
24#include <soc/southbridge.h>
25#include <amdblocks/acpimmio.h>
26#include <commonlib/helpers.h>
27
28static void enable(struct device *dev)
29{
30 const struct soc_amd_picasso_config *cfg;
31 const struct device *nb_dev = pcidev_path_on_root(GNB_DEVFN);
32 struct resource *res;
33 uintptr_t bar;
34
35 pci_dev_enable_resources(dev);
36
37 /* Set the proper I2S_PIN_CONFIG state */
38 if (!nb_dev || !nb_dev->chip_info)
39 return;
40
41 cfg = nb_dev->chip_info;
42
43 res = dev->resource_list;
44 if (!res || !res->base) {
45 printk(BIOS_ERR, "Error, unable to configure pin in %s\n", __func__);
46 return;
47 }
48
49 bar = (uintptr_t)res->base;
50 write32((void *)(bar + ACP_I2S_PIN_CONFIG), cfg->acp_pin_cfg);
51
52 if (cfg->acp_pin_cfg == I2S_PINS_I2S_TDM)
53 sb_clk_output_48Mhz(); /* Internal connection to I2S */
54}
55
56static struct pci_operations lops_pci = {
57 .set_subsystem = pci_dev_set_subsystem,
58};
59
60static struct device_operations acp_ops = {
61 .read_resources = pci_dev_read_resources,
62 .set_resources = pci_dev_set_resources,
63 .enable_resources = enable,
64 .ops_pci = &lops_pci,
65};
66
67static const struct pci_driver acp_driver __pci_driver = {
68 .ops = &acp_ops,
69 .vendor = PCI_VENDOR_ID_AMD,
70 .device = PCI_DEVICD_ID_AMD_PCO_ACP,
71};