blob: 3dbc9f7a7af672f913ec6d3707dbec891accd177 [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Marshall Dawson3edc9e22019-08-16 08:45:20 -06003
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
7#include <device/pci_ids.h>
8#include <device/pci_ops.h>
9#include "chip.h"
10#include <soc/acpi.h>
11#include <soc/pci_devs.h>
12#include <soc/northbridge.h>
13#include <soc/southbridge.h>
14#include <amdblocks/acpimmio.h>
15#include <commonlib/helpers.h>
16
17static void enable(struct device *dev)
18{
19 const struct soc_amd_picasso_config *cfg;
20 const struct device *nb_dev = pcidev_path_on_root(GNB_DEVFN);
21 struct resource *res;
22 uintptr_t bar;
23
24 pci_dev_enable_resources(dev);
25
26 /* Set the proper I2S_PIN_CONFIG state */
27 if (!nb_dev || !nb_dev->chip_info)
28 return;
29
30 cfg = nb_dev->chip_info;
31
32 res = dev->resource_list;
33 if (!res || !res->base) {
34 printk(BIOS_ERR, "Error, unable to configure pin in %s\n", __func__);
35 return;
36 }
37
38 bar = (uintptr_t)res->base;
39 write32((void *)(bar + ACP_I2S_PIN_CONFIG), cfg->acp_pin_cfg);
40
41 if (cfg->acp_pin_cfg == I2S_PINS_I2S_TDM)
42 sb_clk_output_48Mhz(); /* Internal connection to I2S */
43}
44
45static struct pci_operations lops_pci = {
46 .set_subsystem = pci_dev_set_subsystem,
47};
48
49static struct device_operations acp_ops = {
50 .read_resources = pci_dev_read_resources,
51 .set_resources = pci_dev_set_resources,
52 .enable_resources = enable,
53 .ops_pci = &lops_pci,
54};
55
56static const struct pci_driver acp_driver __pci_driver = {
57 .ops = &acp_ops,
58 .vendor = PCI_VENDOR_ID_AMD,
59 .device = PCI_DEVICD_ID_AMD_PCO_ACP,
60};