blob: 452f7cfbf29c2b350cf978f77541c228a20461fc [file] [log] [blame]
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -07001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#include <intelblocks/gpio.h>
4#include <intelblocks/pcr.h>
5#include <soc/pcr_ids.h>
6#include <soc/pmc.h>
7
8static const struct reset_mapping rst_map[] = {
9 { .logical = PAD_CFG0_LOGICAL_RESET_RSMRST, .chipset = 0U << 30 },
10 { .logical = PAD_CFG0_LOGICAL_RESET_DEEP, .chipset = 1U << 30 },
11 { .logical = PAD_CFG0_LOGICAL_RESET_PLTRST, .chipset = 2U << 30 },
12};
13
14static const struct reset_mapping rst_map_com0[] = {
15 { .logical = PAD_CFG0_LOGICAL_RESET_PWROK, .chipset = 0U << 30 },
16 { .logical = PAD_CFG0_LOGICAL_RESET_DEEP, .chipset = 1U << 30 },
17 { .logical = PAD_CFG0_LOGICAL_RESET_PLTRST, .chipset = 2U << 30 },
18 { .logical = PAD_CFG0_LOGICAL_RESET_RSMRST, .chipset = 3U << 30 },
19};
20
21/*
22 * The GPIO driver for Elkhartlake on Windows/Linux expects 32 GPIOs per pad
23 * group, regardless of whether or not there is a physical pad for each
24 * exposed GPIO number.
25 *
26 * This results in the OS having a sparse GPIO map, and devices that need
27 * to export an ACPI GPIO must use the OS expected number.
28 *
29 * Not all pins are usable as GPIO and those groups do not have a pad base.
30 *
31 * This layout matches the Linux kernel pinctrl map for MCC at:
32 * linux/drivers/pinctrl/intel/pinctrl-elkhartlake.c
33 */
34static const struct pad_group ehl_community0_groups[] = {
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080035 INTEL_GPP_BASE(GPP_B0, GPP_B0, GPP_B23, 0), /* GPP_B */
36 INTEL_GPP(GPP_B0, GPIO_RSVD_0, GPIO_RSVD_1),
37 INTEL_GPP_BASE(GPP_B0, GPP_T0, GPP_T15, 32), /* GPP_T */
38 INTEL_GPP_BASE(GPP_B0, GPP_G0, GPIO_RSVD_2, 64), /* GPP_G */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070039};
40
41static const struct pad_group ehl_community1_groups[] = {
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080042 INTEL_GPP_BASE(GPP_V0, GPP_V0, GPP_V15, 96), /* GPP_V */
43 INTEL_GPP_BASE(GPP_V0, GPP_H0, GPP_H23, 128), /* GPP_H */
44 INTEL_GPP_BASE(GPP_V0, GPP_D0, GPIO_RSVD_3, 160), /* GPP_D */
45 INTEL_GPP_BASE(GPP_V0, GPP_U0, GPP_U19, 192), /* GPP_U */
46 INTEL_GPP(GPP_V0, GPIO_RSVD_4, GPIO_RSVD_7),
47 INTEL_GPP_BASE(GPP_V0, VGPIO_0, VGPIO_39, 224), /* VGPIO */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070048};
49
50/* This community is not visible to the OS */
51static const struct pad_group ehl_community2_groups[] = {
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080052 INTEL_GPP(GPD0, GPD0, GPIO_RSVD_12), /* GPD */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070053};
54
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080055static const struct pad_group ehl_community3_groups[] = {
56 INTEL_GPP(GPIO_RSVD_13, GPIO_RSVD_13, GPIO_RSVD_29),
57 INTEL_GPP_BASE(GPIO_RSVD_13, GPP_S0, GPP_S1, 288), /* GPP_S */
58 INTEL_GPP_BASE(GPIO_RSVD_13, GPP_A0, GPP_A23, 320), /* GPP_A */
59 INTEL_GPP(GPIO_RSVD_13, VGPIO_USB_0, VGPIO_USB_3),
60};
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070061
62static const struct pad_group ehl_community4_groups[] = {
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080063 INTEL_GPP_BASE(GPP_C0, GPP_C0, GPP_C23, 352), /* GPP_C */
64 INTEL_GPP_BASE(GPP_C0, GPP_F0, GPP_F23, 384), /* GPP_F */
65 INTEL_GPP(GPP_C0, GPIO_RSVD_30, GPIO_RSVD_36),
66 INTEL_GPP_BASE(GPP_C0, GPP_E0, GPP_E23, 416), /* GPP_E */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070067};
68
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070069static const struct pad_group ehl_community5_groups[] = {
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080070 INTEL_GPP_BASE(GPP_R0, GPP_R0, GPP_R7, 448), /* GPP_R */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070071};
72
73static const struct pad_community ehl_communities[TOTAL_GPIO_COMM] = {
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080074 /* GPP B, T, G */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070075 [COMM_0] = {
76 .port = PID_GPIOCOM0,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080077 .first_pad = GPIO_COM0_START,
78 .last_pad = GPIO_COM0_END,
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070079 .num_gpi_regs = NUM_GPIO_COM0_GPI_REGS,
80 .pad_cfg_base = PAD_CFG_BASE,
81 .host_own_reg_0 = HOSTSW_OWN_REG_0,
82 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
83 .gpi_int_en_reg_0 = GPI_INT_EN_0,
84 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
85 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
86 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080087 .name = "GPP_BTG",
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070088 .acpi_path = "\\_SB.PCI0.GPIO",
89 .reset_map = rst_map_com0,
90 .num_reset_vals = ARRAY_SIZE(rst_map_com0),
91 .groups = ehl_community0_groups,
92 .num_groups = ARRAY_SIZE(ehl_community0_groups),
93 },
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080094 /* GPP V, H, D, U, VGPIO */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070095 [COMM_1] = {
96 .port = PID_GPIOCOM1,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -080097 .first_pad = GPIO_COM1_START,
98 .last_pad = GPIO_COM1_END,
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070099 .num_gpi_regs = NUM_GPIO_COM1_GPI_REGS,
100 .pad_cfg_base = PAD_CFG_BASE,
101 .host_own_reg_0 = HOSTSW_OWN_REG_0,
102 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
103 .gpi_int_en_reg_0 = GPI_INT_EN_0,
104 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
105 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
106 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800107 .name = "GPP_VHDU",
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700108 .acpi_path = "\\_SB.PCI0.GPIO",
109 .reset_map = rst_map,
110 .num_reset_vals = ARRAY_SIZE(rst_map),
111 .groups = ehl_community1_groups,
112 .num_groups = ARRAY_SIZE(ehl_community1_groups),
113 },
114 /* GPD */
115 [COMM_2] = {
116 .port = PID_GPIOCOM2,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800117 .first_pad = GPIO_COM2_START,
118 .last_pad = GPIO_COM2_END,
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700119 .num_gpi_regs = NUM_GPIO_COM2_GPI_REGS,
120 .pad_cfg_base = PAD_CFG_BASE,
121 .host_own_reg_0 = HOSTSW_OWN_REG_0,
122 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
123 .gpi_int_en_reg_0 = GPI_INT_EN_0,
124 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
125 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
126 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
127 .name = "GPD",
128 .acpi_path = "\\_SB.PCI0.GPIO",
129 .reset_map = rst_map,
130 .num_reset_vals = ARRAY_SIZE(rst_map),
131 .groups = ehl_community2_groups,
132 .num_groups = ARRAY_SIZE(ehl_community2_groups),
133 },
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800134 /* GPP S, A */
135 [COMM_3] = {
136 .port = PID_GPIOCOM3,
137 .first_pad = GPIO_COM3_START,
138 .last_pad = GPIO_COM3_END,
139 .num_gpi_regs = NUM_GPIO_COM3_GPI_REGS,
140 .pad_cfg_base = PAD_CFG_BASE,
141 .host_own_reg_0 = HOSTSW_OWN_REG_0,
142 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
143 .gpi_int_en_reg_0 = GPI_INT_EN_0,
144 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
145 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
146 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
147 .name = "GPP_SA",
148 .acpi_path = "\\_SB.PCI0.GPIO",
149 .reset_map = rst_map,
150 .num_reset_vals = ARRAY_SIZE(rst_map),
151 .groups = ehl_community3_groups,
152 .num_groups = ARRAY_SIZE(ehl_community3_groups),
153 },
154 /* GPP C, F, E */
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700155 [COMM_4] = {
156 .port = PID_GPIOCOM4,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800157 .first_pad = GPIO_COM4_START,
158 .last_pad = GPIO_COM4_END,
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700159 .num_gpi_regs = NUM_GPIO_COM4_GPI_REGS,
160 .pad_cfg_base = PAD_CFG_BASE,
161 .host_own_reg_0 = HOSTSW_OWN_REG_0,
162 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
163 .gpi_int_en_reg_0 = GPI_INT_EN_0,
164 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
165 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
166 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800167 .name = "GPP_CFE",
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700168 .acpi_path = "\\_SB.PCI0.GPIO",
169 .reset_map = rst_map,
170 .num_reset_vals = ARRAY_SIZE(rst_map),
171 .groups = ehl_community4_groups,
172 .num_groups = ARRAY_SIZE(ehl_community4_groups),
173 },
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800174 /* GPP R*/
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700175 [COMM_5] = {
176 .port = PID_GPIOCOM5,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800177 .first_pad = GPIO_COM5_START,
178 .last_pad = GPIO_COM5_END,
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700179 .num_gpi_regs = NUM_GPIO_COM5_GPI_REGS,
180 .pad_cfg_base = PAD_CFG_BASE,
181 .host_own_reg_0 = HOSTSW_OWN_REG_0,
182 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
183 .gpi_int_en_reg_0 = GPI_INT_EN_0,
184 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
185 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
186 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800187 .name = "GPP_RR",
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700188 .acpi_path = "\\_SB.PCI0.GPIO",
189 .reset_map = rst_map,
190 .num_reset_vals = ARRAY_SIZE(rst_map),
191 .groups = ehl_community5_groups,
192 .num_groups = ARRAY_SIZE(ehl_community5_groups),
193 }
194};
195
196const struct pad_community *soc_gpio_get_community(size_t *num_communities)
197{
198 *num_communities = ARRAY_SIZE(ehl_communities);
199 return ehl_communities;
200}
201
202const struct pmc_to_gpio_route *soc_pmc_gpio_routes(size_t *num)
203{
204 static const struct pmc_to_gpio_route routes[] = {
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700205 { PMC_GPP_B, GPP_B },
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800206 { PMC_GPP_T, GPP_T },
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700207 { PMC_GPP_D, GPP_D },
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800208 { PMC_GPP_A, GPP_A },
209 { PMC_GPP_R, GPP_R },
210 { PMC_GPP_V, GPP_V },
211 { PMC_GPD, GPD },
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700212 { PMC_GPP_H, GPP_H },
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800213 { PMC_GPP_U, GPP_U },
214 { PMC_VGPIO, VGPIO },
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700215 { PMC_GPP_F, GPP_F },
Tan, Lean Sheng6e9d8062020-12-10 22:31:00 -0800216 { PMC_GPP_C, GPP_C },
217 { PMC_GPP_E, GPP_E },
218 { PMC_GPP_G, GPP_G },
219 { PMC_GPP_S, GPP_S }
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -0700220 };
221
222 *num = ARRAY_SIZE(routes);
223 return routes;
224}