Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 2 | |
| 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 Rangel | 4c7e0d7 | 2020-05-07 15:14:09 -0600 | [diff] [blame] | 9 | #include <soc/acp.h> |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 10 | #include <soc/acpi.h> |
| 11 | #include <soc/pci_devs.h> |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 12 | #include <soc/southbridge.h> |
| 13 | #include <amdblocks/acpimmio.h> |
| 14 | #include <commonlib/helpers.h> |
| 15 | |
Aaron Durbin | a6e3b5a | 2020-06-09 07:56:43 -0600 | [diff] [blame] | 16 | static void init(struct device *dev) |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 17 | { |
| 18 | const struct soc_amd_picasso_config *cfg; |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 19 | struct resource *res; |
| 20 | uintptr_t bar; |
| 21 | |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 22 | /* Set the proper I2S_PIN_CONFIG state */ |
Felix Held | 7180090 | 2020-06-17 19:59:53 +0200 | [diff] [blame] | 23 | cfg = config_of_soc(); |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 24 | |
| 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 Shaikh | 0d787a1 | 2020-06-18 22:20:52 -0700 | [diff] [blame^] | 38 | static const char *acp_acpi_name(const struct device *dev) |
| 39 | { |
| 40 | return "ACPD"; |
| 41 | } |
| 42 | |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 43 | static struct device_operations acp_ops = { |
| 44 | .read_resources = pci_dev_read_resources, |
| 45 | .set_resources = pci_dev_set_resources, |
Aaron Durbin | a6e3b5a | 2020-06-09 07:56:43 -0600 | [diff] [blame] | 46 | .enable_resources = pci_dev_enable_resources, |
| 47 | .init = init, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 48 | .ops_pci = &pci_dev_ops_pci, |
Furquan Shaikh | 0d787a1 | 2020-06-18 22:20:52 -0700 | [diff] [blame^] | 49 | .acpi_name = acp_acpi_name, |
| 50 | .acpi_fill_ssdt = acpi_device_write_pci_dev, |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | static const struct pci_driver acp_driver __pci_driver = { |
| 54 | .ops = &acp_ops, |
| 55 | .vendor = PCI_VENDOR_ID_AMD, |
Furquan Shaikh | a1cd7eb | 2020-04-15 23:58:22 -0700 | [diff] [blame] | 56 | .device = PCI_DEVICE_ID_AMD_FAM17H_ACP, |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 57 | }; |