1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <intelblocks/gpio.h>
4 #include <intelblocks/pcr.h>
5 #include <soc/pcr_ids.h>
8 static 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 },
14 static 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 },
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.
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.
29 * Not all pins are usable as GPIO and those groups do not have a pad base.
31 * This layout matches the Linux kernel pinctrl map for MCC at:
32 * linux/drivers/pinctrl/intel/pinctrl-elkhartlake.c
34 static const struct pad_group ehl_community0_groups
[] = {
35 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 */
41 static const struct pad_group ehl_community1_groups
[] = {
42 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 */
50 /* This community is not visible to the OS */
51 static const struct pad_group ehl_community2_groups
[] = {
52 INTEL_GPP(GPD0
, GPD0
, GPIO_RSVD_12
), /* GPD */
55 static 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
),
62 static const struct pad_group ehl_community4_groups
[] = {
63 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 */
69 static const struct pad_group ehl_community5_groups
[] = {
70 INTEL_GPP_BASE(GPP_R0
, GPP_R0
, GPP_R7
, 448), /* GPP_R */
73 static const struct pad_community ehl_communities
[TOTAL_GPIO_COMM
] = {
77 .first_pad
= GPIO_COM0_START
,
78 .last_pad
= GPIO_COM0_END
,
79 .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
,
88 .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
),
94 /* GPP V, H, D, U, VGPIO */
97 .first_pad
= GPIO_COM1_START
,
98 .last_pad
= GPIO_COM1_END
,
99 .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
,
108 .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
),
116 .port
= PID_GPIOCOM2
,
117 .first_pad
= GPIO_COM2_START
,
118 .last_pad
= GPIO_COM2_END
,
119 .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
,
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
),
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
,
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
),
156 .port
= PID_GPIOCOM4
,
157 .first_pad
= GPIO_COM4_START
,
158 .last_pad
= GPIO_COM4_END
,
159 .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
,
168 .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
),
176 .port
= PID_GPIOCOM5
,
177 .first_pad
= GPIO_COM5_START
,
178 .last_pad
= GPIO_COM5_END
,
179 .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
,
188 .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
),
196 const struct pad_community
*soc_gpio_get_community(size_t *num_communities
)
198 *num_communities
= ARRAY_SIZE(ehl_communities
);
199 return ehl_communities
;
202 const struct pmc_to_gpio_route
*soc_pmc_gpio_routes(size_t *num
)
204 static const struct pmc_to_gpio_route routes
[] = {
205 { PMC_GPP_B
, GPP_B
},
206 { PMC_GPP_T
, GPP_T
},
207 { PMC_GPP_D
, GPP_D
},
208 { PMC_GPP_A
, GPP_A
},
209 { PMC_GPP_R
, GPP_R
},
210 { PMC_GPP_V
, GPP_V
},
212 { PMC_GPP_H
, GPP_H
},
213 { PMC_GPP_U
, GPP_U
},
214 { PMC_VGPIO
, VGPIO
},
215 { PMC_GPP_F
, GPP_F
},
216 { PMC_GPP_C
, GPP_C
},
217 { PMC_GPP_E
, GPP_E
},
218 { PMC_GPP_G
, GPP_G
},
222 *num
= ARRAY_SIZE(routes
);