coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
adsp.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <acpi/acpi_gnvs.h>
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 <device/mmio.h>
10 #include <soc/adsp.h>
11 #include <soc/device_nvs.h>
12 #include <soc/pch.h>
13 #include <soc/rcba.h>
16 
17 static void adsp_init(struct device *dev)
18 {
19  const struct soc_intel_broadwell_pch_config *config = config_of(dev);
20  struct resource *bar0, *bar1;
21  u32 tmp32;
22 
23  /* Ensure memory and bus master are enabled */
25 
26  /* Find BAR0 and BAR1 */
28  if (!bar0)
29  return;
31  if (!bar1)
32  return;
33 
34  /*
35  * Set LTR value in DSP shim LTR control register to 3ms
36  * SNOOP_REQ[13]=1b SNOOP_SCALE[12:10]=100b (1ms) SNOOP_VAL[9:0]=3h
37  */
39  write32(res2mmio(bar0, tmp32 + ADSP_SHIM_LTRC, 0),
41 
42  /* Program VDRTCTL2 D19:F0:A8[31:0] = 0x00000fff */
44 
45  /* Program ADSP IOBP VDLDAT1 to 0x040100 */
47 
48  /* Set D3 Power Gating Enable in D19:F0:A0 based on PCH type */
50  if (pch_is_wpt()) {
51  if (config->adsp_d3_pg_enable) {
52  tmp32 &= ~ADSP_VDRTCTL0_D3PGD_WPT;
53  if (config->adsp_sram_pg_enable)
55  else
57  } else {
58  tmp32 |= ADSP_VDRTCTL0_D3PGD_WPT;
59  }
60  } else {
61  if (config->adsp_d3_pg_enable) {
62  tmp32 &= ~ADSP_VDRTCTL0_D3PGD_LPT;
63  if (config->adsp_sram_pg_enable)
65  else
67  } else {
68  tmp32 |= ADSP_VDRTCTL0_D3PGD_LPT;
69  }
70  }
72 
73  /* Set PSF Snoop to SA, RCBA+0x3350[10]=1b */
74  RCBA32_OR(0x3350, (1 << 10));
75 
76  /* Set DSP IOBP PMCTL 0x1e0=0x3f */
78 
79  if (config->sio_acpi_mode) {
80  struct device_nvs *dev_nvs = acpi_get_device_nvs();
81 
82  /* Configure for ACPI mode */
83  printk(BIOS_INFO, "ADSP: Enable ACPI Mode IRQ3\n");
84 
85  /* Save BAR0 and BAR1 to ACPI NVS */
86  dev_nvs->bar0[SIO_NVS_ADSP] = (u32)bar0->base;
87  dev_nvs->bar1[SIO_NVS_ADSP] = (u32)bar1->base;
88  dev_nvs->enable[SIO_NVS_ADSP] = 1;
89 
90  /* Set PCI Config Disable Bit */
92 
93  /* Set interrupt de-assert/assert opcode override to IRQ3 */
95 
96  /* Enable IRQ3 in RCBA */
98 
99  /* Set ACPI Interrupt Enable Bit */
102 
103  /* Put ADSP in D3hot */
104  tmp32 = read32(res2mmio(bar1, PCH_PCS, 0));
105  tmp32 |= PCH_PCS_PS_D3HOT;
106  write32(res2mmio(bar1, PCH_PCS, 0), tmp32);
107  } else {
108  printk(BIOS_INFO, "ADSP: Enable PCI Mode IRQ23\n");
109 
110  /* Configure for PCI mode */
112 
113  /* Clear ACPI Interrupt Enable Bit */
116  }
117 }
118 
119 static struct device_operations adsp_ops = {
121  .set_resources = pci_dev_set_resources,
122  .enable_resources = pci_dev_enable_resources,
123  .init = adsp_init,
124  .ops_pci = &pci_dev_ops_pci,
125 };
126 
127 static const unsigned short pci_device_ids[] = {
128  0x9c36, /* LynxPoint */
129  0x9cb6, /* WildcatPoint */
130  0
131 };
132 
133 static const struct pci_driver pch_adsp __pci_driver = {
134  .ops = &adsp_ops,
135  .vendor = PCI_VID_INTEL,
136  .devices = pci_device_ids,
137 };
void * acpi_get_device_nvs(void)
Definition: gnvs.c:53
static const struct pci_driver pch_adsp __pci_driver
Definition: adsp.c:133
static const unsigned short pci_device_ids[]
Definition: adsp.c:127
static struct device_operations adsp_ops
Definition: adsp.c:119
static void adsp_init(struct device *dev)
Definition: adsp.c:17
#define ADSP_SHIM_LTRC_VALUE
Definition: adsp.h:13
#define ADSP_PCI_VDRTCTL2
Definition: adsp.h:23
#define ADSP_VDRTCTL0_D3SRAMPGD_WPT
Definition: adsp.h:21
#define ADSP_IOBP_PMCTL
Definition: adsp.h:32
#define ADSP_VDRTCTL0_D3PGD_LPT
Definition: adsp.h:18
#define ADSP_PCICFGCTL_SPCBAD
Definition: adsp.h:37
#define ADSP_PCICFGCTL_ACPIIE
Definition: adsp.h:36
#define ADSP_PCICFGCTL_PCICD
Definition: adsp.h:35
#define ADSP_IOBP_VDLDAT2
Definition: adsp.h:28
#define ADSP_VDRTCTL0_D3PGD_WPT
Definition: adsp.h:19
#define ADSP_VDRTCTL0_D3SRAMPGD_LPT
Definition: adsp.h:20
#define ADSP_IOBP_VDLDAT1
Definition: adsp.h:26
#define ADSP_SHIM_BASE_LPT
Definition: adsp.h:10
#define ADSP_SHIM_BASE_WPT
Definition: adsp.h:11
#define ADSP_VDRTCTL2_VALUE
Definition: adsp.h:24
#define ADSP_VDLDAT1_VALUE
Definition: adsp.h:27
#define ADSP_PCI_IRQ
Definition: adsp.h:6
#define ADSP_PCI_VDRTCTL0
Definition: adsp.h:17
#define ADSP_ACPI_IRQEN
Definition: adsp.h:8
#define ADSP_PMCTL_VALUE
Definition: adsp.h:33
#define ADSP_IOBP_PCICFGCTL
Definition: adsp.h:34
#define ADSP_IOBP_ACPI_IRQ3
Definition: adsp.h:29
#define ADSP_SHIM_LTRC
Definition: adsp.h:12
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static uint32_t read32(const void *addr)
Definition: mmio.h:22
#define SIO_NVS_ADSP
Definition: device_nvs.h:16
#define printk(level,...)
Definition: stdlib.h:16
struct resource * probe_resource(const struct device *dev, unsigned int index)
See if a resource structure already exists for a given index.
Definition: device_util.c:323
static DEVTREE_CONST void * config_of(const struct device *dev)
Definition: device.h:382
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
void pch_iobp_write(u32 address, u32 data)
Definition: iobp.c:63
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
enum board_config config
Definition: memory.c:448
#define PCI_INTERRUPT_LINE
Definition: pci_def.h:94
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND_MEMORY
Definition: pci_def.h:12
#define PCI_BASE_ADDRESS_0
Definition: pci_def.h:63
#define PCI_COMMAND
Definition: pci_def.h:10
#define PCI_BASE_ADDRESS_1
Definition: pci_def.h:64
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
static void * res2mmio(const struct resource *res, unsigned long offset, unsigned long mask)
Definition: resource.h:87
int pch_is_wpt(void)
Definition: pch.c:26
#define PCH_PCS_PS_D3HOT
Definition: pch.h:24
#define PCH_PCS
Definition: pch.h:23
#define ACPIIRQEN
Definition: rcba.h:99
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue)
Definition: pch.c:86
#define RCBA32_OR(x, or)
Definition: rcba.h:22
uint32_t u32
Definition: stdint.h:51
u32 bar0[9]
Definition: device_nvs.h:20
u32 bar1[9]
Definition: device_nvs.h:21
u8 enable[9]
Definition: device_nvs.h:19
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107