blob: 29b7521f38673ffa4c55dbb93446e6463ee6b96d [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Marshall Dawson3edc9e22019-08-16 08:45:20 -06002
3#include <console/console.h>
4#include <device/device.h>
5#include <device/pci.h>
6#include <device/pci_ids.h>
7#include <device/pci_ops.h>
8#include "chip.h"
Raul E Rangel4c7e0d72020-05-07 15:14:09 -06009#include <soc/acp.h>
Marshall Dawson3edc9e22019-08-16 08:45:20 -060010#include <soc/acpi.h>
11#include <soc/pci_devs.h>
Marshall Dawson3edc9e22019-08-16 08:45:20 -060012#include <soc/southbridge.h>
13#include <amdblocks/acpimmio.h>
14#include <commonlib/helpers.h>
15
Aaron Durbina6e3b5a2020-06-09 07:56:43 -060016static void init(struct device *dev)
Marshall Dawson3edc9e22019-08-16 08:45:20 -060017{
18 const struct soc_amd_picasso_config *cfg;
Marshall Dawson3edc9e22019-08-16 08:45:20 -060019 struct resource *res;
20 uintptr_t bar;
21
Marshall Dawson3edc9e22019-08-16 08:45:20 -060022 /* Set the proper I2S_PIN_CONFIG state */
Felix Held71800902020-06-17 19:59:53 +020023 cfg = config_of_soc();
Marshall Dawson3edc9e22019-08-16 08:45:20 -060024
25 res = dev->resource_list;
26 if (!res || !res->base) {
27 printk(BIOS_ERR, "Error, unable to configure pin in %s\n", __func__);
28 return;
29 }
30
31 bar = (uintptr_t)res->base;
32 write32((void *)(bar + ACP_I2S_PIN_CONFIG), cfg->acp_pin_cfg);
33
34 if (cfg->acp_pin_cfg == I2S_PINS_I2S_TDM)
35 sb_clk_output_48Mhz(); /* Internal connection to I2S */
36}
37
Marshall Dawson3edc9e22019-08-16 08:45:20 -060038static struct device_operations acp_ops = {
39 .read_resources = pci_dev_read_resources,
40 .set_resources = pci_dev_set_resources,
Aaron Durbina6e3b5a2020-06-09 07:56:43 -060041 .enable_resources = pci_dev_enable_resources,
42 .init = init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020043 .ops_pci = &pci_dev_ops_pci,
Marshall Dawson3edc9e22019-08-16 08:45:20 -060044};
45
46static const struct pci_driver acp_driver __pci_driver = {
47 .ops = &acp_ops,
48 .vendor = PCI_VENDOR_ID_AMD,
Furquan Shaikha1cd7eb2020-04-15 23:58:22 -070049 .device = PCI_DEVICE_ID_AMD_FAM17H_ACP,
Marshall Dawson3edc9e22019-08-16 08:45:20 -060050};