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 | |
| 16 | static void enable(struct device *dev) |
| 17 | { |
| 18 | const struct soc_amd_picasso_config *cfg; |
| 19 | const struct device *nb_dev = pcidev_path_on_root(GNB_DEVFN); |
| 20 | struct resource *res; |
| 21 | uintptr_t bar; |
| 22 | |
| 23 | pci_dev_enable_resources(dev); |
| 24 | |
| 25 | /* Set the proper I2S_PIN_CONFIG state */ |
| 26 | if (!nb_dev || !nb_dev->chip_info) |
| 27 | return; |
| 28 | |
| 29 | cfg = nb_dev->chip_info; |
| 30 | |
| 31 | res = dev->resource_list; |
| 32 | if (!res || !res->base) { |
| 33 | printk(BIOS_ERR, "Error, unable to configure pin in %s\n", __func__); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | bar = (uintptr_t)res->base; |
| 38 | write32((void *)(bar + ACP_I2S_PIN_CONFIG), cfg->acp_pin_cfg); |
| 39 | |
| 40 | if (cfg->acp_pin_cfg == I2S_PINS_I2S_TDM) |
| 41 | sb_clk_output_48Mhz(); /* Internal connection to I2S */ |
| 42 | } |
| 43 | |
| 44 | static struct pci_operations lops_pci = { |
| 45 | .set_subsystem = pci_dev_set_subsystem, |
| 46 | }; |
| 47 | |
| 48 | static struct device_operations acp_ops = { |
| 49 | .read_resources = pci_dev_read_resources, |
| 50 | .set_resources = pci_dev_set_resources, |
| 51 | .enable_resources = enable, |
| 52 | .ops_pci = &lops_pci, |
| 53 | }; |
| 54 | |
| 55 | static const struct pci_driver acp_driver __pci_driver = { |
| 56 | .ops = &acp_ops, |
| 57 | .vendor = PCI_VENDOR_ID_AMD, |
Furquan Shaikh | a1cd7eb | 2020-04-15 23:58:22 -0700 | [diff] [blame] | 58 | .device = PCI_DEVICE_ID_AMD_FAM17H_ACP, |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 59 | }; |