mb/google/fatcat/var/fatcat: Refactor GPIO programming for UFS support
[coreboot.git] / src / mainboard / google / brya / variants / bujia / gpio.c
blob484ce292299d5e84f143be9faca6f75e6e58a7ce
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <commonlib/helpers.h>
6 #include <soc/gpio.h>
8 /* Pad configuration in ramstage */
9 static const struct pad_config override_gpio_table[] = {
10 /* A14 : USB_OC1# ==> NC */
11 PAD_NC_LOCK(GPP_A14, NONE, LOCK_CONFIG),
12 /* A15 : USB_OC2# ==> NC */
13 PAD_NC_LOCK(GPP_A15, NONE, LOCK_CONFIG),
14 /* A18 : DDSP_HPDB ==> HDMIB_HPD */
15 PAD_CFG_NF(GPP_A18, NONE, DEEP, NF1),
16 /* A19 : DDSP_HPD1 ==> NC */
17 PAD_NC_LOCK(GPP_A19, NONE, LOCK_CONFIG),
18 /* A20 : DDSP_HPD2 ==> NC */
19 PAD_NC_LOCK(GPP_A20, NONE, LOCK_CONFIG),
20 /* A21 : DDPC_CTRCLK ==> NC */
21 PAD_NC(GPP_A21, NONE),
22 /* A22 : DDPC_CTRLDATA ==> NC */
23 PAD_NC_LOCK(GPP_A22, NONE, LOCK_CONFIG),
25 /* B2 : VRALERT# ==> M2_SSD_PLA_L */
26 PAD_NC(GPP_B2, NONE),
27 /* B7 : ISH_12C1_SDA ==> PCH_I2C_MISCB_SDA */
28 PAD_CFG_NF_LOCK(GPP_B7, NONE, NF2, LOCK_CONFIG),
29 /* B8 : ISH_I2C1_SCL ==> PCH_I2C_MISCB_SCL */
30 PAD_CFG_NF_LOCK(GPP_B8, NONE, NF2, LOCK_CONFIG),
32 /* D0 : ISH_GP0 ==> NC */
33 PAD_NC_LOCK(GPP_D0, NONE, LOCK_CONFIG),
34 /* D1 : ISH_GP1 ==> NC */
35 PAD_NC_LOCK(GPP_D1, NONE, LOCK_CONFIG),
36 /* D2 : ISH_GP2 ==> NC */
37 PAD_NC_LOCK(GPP_D2, NONE, LOCK_CONFIG),
38 /* D3 : ISH_GP3 ==> NC */
39 PAD_NC_LOCK(GPP_D3, NONE, LOCK_CONFIG),
40 /* D8 : SRCCLKREQ3# ==> NC */
41 PAD_NC(GPP_D8, NONE),
42 /* D9 : ISH_SPI_CS# ==> NC */
43 PAD_NC_LOCK(GPP_D9, NONE, LOCK_CONFIG),
44 /* D10 : ISH_SPI_CLK ==> GPI */
45 PAD_CFG_GPI_LOCK(GPP_D10, NONE, LOCK_CONFIG),
46 /* D17 : UART1_RXD */
47 PAD_CFG_NF(GPP_D17, NONE, DEEP, NF1),
48 /* D18 : UART1_TXD */
49 PAD_CFG_NF(GPP_D18, NONE, DEEP, NF1),
51 /* E14 : DDSP_HPDA ==> HDMIA_HPD */
52 PAD_CFG_NF(GPP_E14, NONE, DEEP, NF1),
53 /* E20 : DDP2_CTRLCLK ==> DDIA_HDMI_CTRLCLK */
54 PAD_CFG_NF(GPP_E20, NONE, DEEP, NF1),
55 /* E21 : DDP2_CTRLDATA ==> DDIA_HDMI_CTRLDATA */
56 PAD_CFG_NF(GPP_E21, NONE, DEEP, NF1),
58 /* F11 : THC1_SPI2_CLK ==> NC */
59 PAD_NC_LOCK(GPP_F11, NONE, LOCK_CONFIG),
60 /* F12 : GSXDOUT ==> NC */
61 PAD_NC_LOCK(GPP_F12, NONE, LOCK_CONFIG),
62 /* F13 : GSXDOUT ==> NC */
63 PAD_NC_LOCK(GPP_F13, NONE, LOCK_CONFIG),
64 /* F15 : GSXSRESET# ==> NC */
65 PAD_NC_LOCK(GPP_F15, NONE, LOCK_CONFIG),
66 /* F16 : GSXCLK ==> NC */
67 PAD_NC_LOCK(GPP_F16, NONE, LOCK_CONFIG),
69 /* H12 : I2C7_SDA ==> NC */
70 PAD_NC_LOCK(GPP_H12, NONE, LOCK_CONFIG),
71 /* H13 : I2C7_SCL ==> NC */
72 PAD_NC_LOCK(GPP_H13, NONE, LOCK_CONFIG),
74 /* R4 : HDA_RST# ==> NC */
75 PAD_NC(GPP_R4, NONE),
76 /* R5 : HDA_SDI1 ==> NC */
77 PAD_NC(GPP_R5, NONE),
78 /* R6 : I2S2_TXD ==> NC */
79 PAD_NC(GPP_R6, NONE),
80 /* R7 : I2S2_RXD ==> NC */
81 PAD_NC(GPP_R7, NONE),
84 /* Early pad configuration in bootblock */
85 static const struct pad_config early_gpio_table[] = {
86 /* A13 : PMC_I2C_SCL ==> GSC_PCH_INT_ODL */
87 PAD_CFG_GPI_APIC(GPP_A13, NONE, PLTRST, LEVEL, INVERT),
88 /* B4 : PROC_GP3 ==> SSD_PERST_L */
89 PAD_CFG_GPO(GPP_B4, 0, DEEP),
90 /* E15 : RSVD_TP ==> PCH_WP_OD */
91 PAD_CFG_GPI_GPIO_DRIVER(GPP_E15, NONE, DEEP),
92 /* F14 : GSXDIN ==> EN_PP3300_SSD */
93 PAD_CFG_GPO(GPP_F14, 1, DEEP),
94 /* F18 : THC1_SPI2_INT# ==> EC_IN_RW_OD */
95 PAD_CFG_GPI(GPP_F18, NONE, DEEP),
96 /* H6 : I2C1_SDA ==> PCH_I2C_TPM_SDA */
97 PAD_CFG_NF(GPP_H6, NONE, DEEP, NF1),
98 /* H7 : I2C1_SCL ==> PCH_I2C_TPM_SCL */
99 PAD_CFG_NF(GPP_H7, NONE, DEEP, NF1),
100 /* H10 : UART0_RXD ==> UART_PCH_RX_DBG_TX */
101 PAD_CFG_NF(GPP_H10, NONE, DEEP, NF2),
102 /* H11 : UART0_TXD ==> UART_PCH_TX_DBG_RX */
103 PAD_CFG_NF(GPP_H11, NONE, DEEP, NF2),
105 /* CPU PCIe VGPIO for PEG60 */
106 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_48, NONE, PLTRST, NF1),
107 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_49, NONE, PLTRST, NF1),
108 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_50, NONE, PLTRST, NF1),
109 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_51, NONE, PLTRST, NF1),
110 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_52, NONE, PLTRST, NF1),
111 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_53, NONE, PLTRST, NF1),
112 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_54, NONE, PLTRST, NF1),
113 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_55, NONE, PLTRST, NF1),
114 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_56, NONE, PLTRST, NF1),
115 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_57, NONE, PLTRST, NF1),
116 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_58, NONE, PLTRST, NF1),
117 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_59, NONE, PLTRST, NF1),
118 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_60, NONE, PLTRST, NF1),
119 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_61, NONE, PLTRST, NF1),
120 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_62, NONE, PLTRST, NF1),
121 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_63, NONE, PLTRST, NF1),
122 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_76, NONE, PLTRST, NF1),
123 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_77, NONE, PLTRST, NF1),
124 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_78, NONE, PLTRST, NF1),
125 PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_79, NONE, PLTRST, NF1),
128 static const struct pad_config romstage_gpio_table[] = {
129 /* B4 : PROC_GP3 ==> SSD_PERST_L */
130 PAD_CFG_GPO(GPP_B4, 1, DEEP),
133 const struct pad_config *variant_gpio_override_table(size_t *num)
135 *num = ARRAY_SIZE(override_gpio_table);
136 return override_gpio_table;
139 const struct pad_config *variant_early_gpio_table(size_t *num)
141 *num = ARRAY_SIZE(early_gpio_table);
142 return early_gpio_table;
145 const struct pad_config *variant_romstage_gpio_table(size_t *num)
147 *num = ARRAY_SIZE(romstage_gpio_table);
148 return romstage_gpio_table;