blob: 1e871e99d874b2a47043abd2d9d69ca0fcdb6b0a [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
Furquan Shaikh0d787a12020-06-18 22:20:52 -070038static const char *acp_acpi_name(const struct device *dev)
39{
40 return "ACPD";
41}
42
Marshall Dawson3edc9e22019-08-16 08:45:20 -060043static struct device_operations acp_ops = {
44 .read_resources = pci_dev_read_resources,
45 .set_resources = pci_dev_set_resources,
Aaron Durbina6e3b5a2020-06-09 07:56:43 -060046 .enable_resources = pci_dev_enable_resources,
47 .init = init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020048 .ops_pci = &pci_dev_ops_pci,
Furquan Shaikh0d787a12020-06-18 22:20:52 -070049 .acpi_name = acp_acpi_name,
50 .acpi_fill_ssdt = acpi_device_write_pci_dev,
Marshall Dawson3edc9e22019-08-16 08:45:20 -060051};
52
53static const struct pci_driver acp_driver __pci_driver = {
54 .ops = &acp_ops,
55 .vendor = PCI_VENDOR_ID_AMD,
Furquan Shaikha1cd7eb2020-04-15 23:58:22 -070056 .device = PCI_DEVICE_ID_AMD_FAM17H_ACP,
Marshall Dawson3edc9e22019-08-16 08:45:20 -060057};