Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 3 | |
| 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 | |
| 17 | static 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 | |
| 45 | static struct pci_operations lops_pci = { |
| 46 | .set_subsystem = pci_dev_set_subsystem, |
| 47 | }; |
| 48 | |
| 49 | static 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 | |
| 56 | static 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 | }; |