coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
scc.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 <reg_script.h>
8 
9 #include <soc/iosf.h>
10 #include <soc/device_nvs.h>
11 #include <soc/ramstage.h>
12 
13 static const struct reg_script scc_start_dll[] = {
14  /* Configure master DLL. */
15  REG_IOSF_WRITE(IOSF_PORT_SCORE, 0x4964, 0x00078000),
16  /* Configure Swing,FSM for Master DLL */
17  REG_IOSF_WRITE(IOSF_PORT_SCORE, 0x4970, 0x00000133),
18  /* Run+Local Reset on Master DLL */
19  REG_IOSF_WRITE(IOSF_PORT_SCORE, 0x4970, 0x00001933),
21 };
22 
23 static const struct reg_script scc_after_dll[] = {
24  /* Configure Write Path */
25  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x4954, ~0x7fff, 0x35ad),
26  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x4958, ~0x7fff, 0x35ad),
27  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x495c, ~0x7fff, 0x35ad),
28  /* Configure Read Path */
29  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x43e4, ~0x7fff, 0x35ad),
30  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x4324, ~0x7fff, 0x35ad),
31  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x42b4, ~0x7fff, 0x35ad),
32  /* eMMC 4.5 TX and RX DLL */
33  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x49a4, ~0x1f001f, 0xa000d),
34  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x49a8, ~0x1f001f, 0xd000d),
35  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x49ac, ~0x1f001f, 0xd000d),
36  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x49b0, ~0x1f001f, 0xd000d),
37  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x49b4, ~0x1f001f, 0xd000d),
38  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x49b8, ~0x1, 0x0),
39  /* cfio_regs_mmc1_ELECTRICAL.nslew/pslew */
40  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c0, ~0x3c, 0x0),
41  REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c4, ~0x3c, 0x0),
42  /*
43  * iosf2ocp_private.GENREGRW1.cr_clock_enable_clk_ocp = 01
44  * iosf2ocp_private.GENREGRW1.cr_clock_enable_clk_xin = 01
45  */
46  REG_IOSF_RMW(IOSF_PORT_SCC, 0x600, ~0xf, 0x5),
47  /* Enable IOSF Snoop */
48  REG_IOSF_OR(IOSF_PORT_SCC, 0x00, (1 << 7)),
49  /* SDIO 3V Support. */
50  REG_IOSF_RMW(IOSF_PORT_SCC, 0x600, ~0x30, 0x30),
52 };
53 
55 {
56  uint32_t dll_values;
57 
58  printk(BIOS_DEBUG, "Initializing sideband SCC registers.\n");
59 
60  /* Common Sideband Initialization for SCC */
62 
63  /* Override Slave Path - populate DLL settings. */
64  dll_values = iosf_score_read(0x496c) & 0x7ffff;
65  dll_values |= iosf_score_read(0x4950) & ~0xfffff;
66  iosf_score_write(0x4950, dll_values | (1 << 19));
67 
69 }
70 
71 void scc_enable_acpi_mode(struct device *dev, int iosf_reg, int nvs_index)
72 {
73  struct reg_script ops[] = {
74  /* Disable PCI interrupt, enable Memory and Bus Master */
77  /* Enable ACPI mode */
78  REG_IOSF_OR(IOSF_PORT_SCC, iosf_reg,
81  };
82  struct resource *bar;
83  struct device_nvs *dev_nvs = acpi_get_device_nvs();
84 
85  /* Save BAR0 and BAR1 to ACPI NVS */
87  if (bar)
88  dev_nvs->scc_bar0[nvs_index] = (u32)bar->base;
89 
91  if (bar)
92  dev_nvs->scc_bar1[nvs_index] = (u32)bar->base;
93 
94  /* Device is enabled in ACPI mode */
95  dev_nvs->scc_en[nvs_index] = 1;
96 
97  /* Put device in ACPI mode */
99 }
void * acpi_get_device_nvs(void)
Definition: gnvs.c:53
#define IOSF_PORT_SCORE
Definition: iosf.h:104
#define SCC_CTL_PCI_CFG_DIS
Definition: iosf.h:287
uint32_t iosf_score_read(int reg)
Definition: iosf.c:131
#define IOSF_PORT_SCC
Definition: iosf.h:110
void iosf_score_write(int reg, uint32_t val)
Definition: iosf.c:136
#define SCC_CTL_ACPI_INT_EN
Definition: iosf.h:288
static const struct reg_script scc_start_dll[]
Definition: scc.c:13
static const struct reg_script scc_after_dll[]
Definition: scc.c:23
void baytrail_init_scc(void)
Definition: scc.c:54
void scc_enable_acpi_mode(struct device *dev, int iosf_reg, int nvs_index)
Definition: scc.c:71
#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 struct device_operations ops
Definition: ipmi_kcs_ops.c:416
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND_MEMORY
Definition: pci_def.h:12
#define PCI_COMMAND_INT_DISABLE
Definition: pci_def.h:21
#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 reg_script_run(const struct reg_script *script)
Definition: reg_script.c:700
void reg_script_run_on_dev(struct device *dev, const struct reg_script *step)
Definition: reg_script.c:689
#define REG_PCI_OR16(reg_, value_)
Definition: reg_script.h:185
#define REG_SCRIPT_END
Definition: reg_script.h:427
unsigned int uint32_t
Definition: stdint.h:14
uint32_t u32
Definition: stdint.h:51
u32 scc_bar1[3]
Definition: device_nvs.h:40
u8 scc_en[3]
Definition: device_nvs.h:30
u32 scc_bar0[3]
Definition: device_nvs.h:35
Definition: device.h:107
struct device * dev
Definition: reg_script.h:78
resource_t base
Definition: resource.h:45