Debian Codegraph @

src/mainboard/siemens/mc_ehl/variants/mc_ehl5/mainboard.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <baseboard/variants.h>
4 #include <bootstate.h>
5 #include <device/pci_ids.h>
6 #include <gpio.h>
7 #include <intelblocks/pcr.h>
8 #include <soc/pci_devs.h>
9 #include <soc/pcr_ids.h>
10
11 #define HOSTCTRL2 0x3E
12 #define HOSTCTRL2_PRESET (1 << 15)
13 #define MMC_CAP_BYP 0x810
14 #define MMC_CAP_BYP_EN 0x5A
15 #define MMC_CAP_BYP_REG1 0x814
16 #define MMC_CAP_BYP_SDR50 (1 << 13)
17 #define MMC_CAP_BYP_SDR104 (1 << 14)
18 #define MMC_CAP_BYP_DDR50 (1 << 15)
19
20 /* Disable SDR104 and SDR50 mode while keeping DDR50 mode enabled. */
21 static void disable_sdr_modes(struct resource *res)
22 {
23 write32(res2mmio(res, MMC_CAP_BYP, 0), MMC_CAP_BYP_EN);
24 clrsetbits32(res2mmio(res, MMC_CAP_BYP_REG1, 0),
25 MMC_CAP_BYP_SDR104 | MMC_CAP_BYP_SDR50,
26 MMC_CAP_BYP_DDR50);
27 }
28
29 void variant_mainboard_final(void)
30 {
31 struct device *dev;
32
33 /* PIR8 register mapping for PCIe root ports
34 INTA#->PIRQC#, INTB#->PIRQD#, INTC#->PIRQA#, INTD#-> PIRQB# */
35 pcr_write16(PID_ITSS, 0x3150, 0x1032);
36
37 /* Disable clock outputs 1-5 (CLKOUT) for XIO2001 PCIe to PCI Bridge. */
38 dev = dev_find_device(PCI_VID_TI, PCI_DID_TI_XIO2001, 0);
39 if (dev)
40 pci_write_config8(dev, 0xd8, 0x3e);
41
42 dev = pcidev_path_on_root(PCH_DEVFN_SDCARD);
43 if (dev) {
44 struct resource *res = probe_resource(dev, PCI_BASE_ADDRESS_0);
45 if (res) {
46 disable_sdr_modes(res);
47
48 /* Use preset driver strength from preset value
49 registers. */
50 clrsetbits16(res2mmio(res, HOSTCTRL2, 0), 0,
51 HOSTCTRL2_PRESET);
52 }
53 }
54
55 dev = pcidev_path_on_root(PCH_DEVFN_EMMC);
56 if (dev) {
57 struct resource *res = probe_resource(dev, PCI_BASE_ADDRESS_0);
58 if (res)
59 disable_sdr_modes(res);
60 }
61 }
62
63 static void finalize_boot(void *unused)
64 {
65 /* Set coreboot ready LED. */
66 gpio_output(GPP_F20, 1);
67 }
68
69 BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, finalize_boot, NULL);