blob: 09de609a8a3a96451614bd6231917ad0ad2c4db0 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +05302
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
Subrata Banikda245352018-12-17 16:53:33 +053021/*
22 * The GPIO driver for Icelake 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 CNL-LP at:
32 * linux/drivers/pinctrl/intel/pinctrl-icelake.c
33 */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053034static const struct pad_group icl_community0_groups[] = {
Subrata Banikda245352018-12-17 16:53:33 +053035 INTEL_GPP_BASE(GPP_G0, GPP_G0, GPP_G7, 0), /* GPP_G */
36 INTEL_GPP_BASE(GPP_G0, GPP_B0, GPP_B23, 32), /* GPP_B */
Aamir Bohra6efa5c32018-11-06 11:37:44 +053037 INTEL_GPP(GPP_G0, GPIO_RSVD_0, GPIO_RSVD_1),
Subrata Banikda245352018-12-17 16:53:33 +053038 INTEL_GPP_BASE(GPP_G0, GPP_A0, GPP_A23, 64), /* GPP_A */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053039};
40
41static const struct pad_group icl_community1_groups[] = {
Subrata Banikda245352018-12-17 16:53:33 +053042 INTEL_GPP_BASE(GPP_H0, GPP_H0, GPP_H23, 96), /* GPP_H */
43 INTEL_GPP_BASE(GPP_H0, GPP_D0, GPIO_RSVD_2, 128), /* GPP_D */
44 INTEL_GPP_BASE(GPP_H0, GPP_F0, GPP_F19, 160), /* GPP_F */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053045};
46
Subrata Banikda245352018-12-17 16:53:33 +053047/* This community is not visible to the OS */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053048static const struct pad_group icl_community2_groups[] = {
Aamir Bohra6efa5c32018-11-06 11:37:44 +053049 INTEL_GPP(GPD0, GPD0, GPD11), /* GPD */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053050};
51
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053052static const struct pad_group icl_community4_groups[] = {
Subrata Banikda245352018-12-17 16:53:33 +053053 INTEL_GPP_BASE(GPP_C0, GPP_C0, GPP_C23, 224), /* GPP_C */
54 INTEL_GPP_BASE(GPP_C0, GPP_E0, GPP_E23, 256), /* GPP_E */
Aamir Bohra6efa5c32018-11-06 11:37:44 +053055 INTEL_GPP(GPP_C0, GPIO_RSVD_3, GPIO_RSVD_8),
56};
57
Aamir Bohra6efa5c32018-11-06 11:37:44 +053058static const struct pad_group icl_community5_groups[] = {
Subrata Banikda245352018-12-17 16:53:33 +053059 INTEL_GPP_BASE(GPP_R0, GPP_R0, GPP_R7, 288), /* GPP_R */
60 INTEL_GPP_BASE(GPP_C0, GPP_S0, GPP_S7, 320), /* GPP_S */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053061};
62
Subrata Banikdd5fa022019-05-15 21:04:37 +053063static const struct pad_community icl_communities[TOTAL_GPIO_COMM] = {
64 /* GPP G, B, A */
65 [COMM_0] = {
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053066 .port = PID_GPIOCOM0,
Aamir Bohra6efa5c32018-11-06 11:37:44 +053067 .first_pad = GPP_G0,
68 .last_pad = GPP_A23,
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053069 .num_gpi_regs = NUM_GPIO_COM0_GPI_REGS,
70 .pad_cfg_base = PAD_CFG_BASE,
71 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -060072 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
73 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053074 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
75 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
76 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Aamir Bohra6efa5c32018-11-06 11:37:44 +053077 .name = "GPP_GBA",
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053078 .acpi_path = "\\_SB.PCI0.GPIO",
79 .reset_map = rst_map_com0,
80 .num_reset_vals = ARRAY_SIZE(rst_map_com0),
81 .groups = icl_community0_groups,
82 .num_groups = ARRAY_SIZE(icl_community0_groups),
Subrata Banikdd5fa022019-05-15 21:04:37 +053083 },
84 /* GPP H, D, F */
85 [COMM_1] = {
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053086 .port = PID_GPIOCOM1,
Aamir Bohra6efa5c32018-11-06 11:37:44 +053087 .first_pad = GPP_H0,
88 .last_pad = GPP_F19,
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053089 .num_gpi_regs = NUM_GPIO_COM1_GPI_REGS,
90 .pad_cfg_base = PAD_CFG_BASE,
91 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -060092 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
93 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053094 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
95 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
96 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Aamir Bohra6efa5c32018-11-06 11:37:44 +053097 .name = "GPP_HDF",
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053098 .acpi_path = "\\_SB.PCI0.GPIO",
99 .reset_map = rst_map,
100 .num_reset_vals = ARRAY_SIZE(rst_map),
101 .groups = icl_community1_groups,
102 .num_groups = ARRAY_SIZE(icl_community1_groups),
Subrata Banikdd5fa022019-05-15 21:04:37 +0530103 },
104 /* GPD */
105 [COMM_2] = {
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530106 .port = PID_GPIOCOM2,
107 .first_pad = GPD0,
108 .last_pad = GPD11,
109 .num_gpi_regs = NUM_GPIO_COM2_GPI_REGS,
110 .pad_cfg_base = PAD_CFG_BASE,
111 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600112 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
113 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530114 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
115 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
116 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
117 .name = "GPD",
118 .acpi_path = "\\_SB.PCI0.GPIO",
119 .reset_map = rst_map,
120 .num_reset_vals = ARRAY_SIZE(rst_map),
121 .groups = icl_community2_groups,
122 .num_groups = ARRAY_SIZE(icl_community2_groups),
Subrata Banikdd5fa022019-05-15 21:04:37 +0530123 },
124 /* GPP C, E */
125 [COMM_3] = {
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530126 .port = PID_GPIOCOM4,
127 .first_pad = GPP_C0,
Aamir Bohra6efa5c32018-11-06 11:37:44 +0530128 .last_pad = GPP_E23,
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530129 .num_gpi_regs = NUM_GPIO_COM4_GPI_REGS,
130 .pad_cfg_base = PAD_CFG_BASE,
131 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600132 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
133 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530134 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
135 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
136 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Aamir Bohra6efa5c32018-11-06 11:37:44 +0530137 .name = "GPP_CE",
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530138 .acpi_path = "\\_SB.PCI0.GPIO",
139 .reset_map = rst_map,
140 .num_reset_vals = ARRAY_SIZE(rst_map),
141 .groups = icl_community4_groups,
142 .num_groups = ARRAY_SIZE(icl_community4_groups),
Subrata Banikdd5fa022019-05-15 21:04:37 +0530143 },
144 /* GPP R, S */
145 [COMM_4] = {
Aamir Bohra6efa5c32018-11-06 11:37:44 +0530146 .port = PID_GPIOCOM5,
147 .first_pad = GPP_R0,
148 .last_pad = GPP_S7,
149 .num_gpi_regs = NUM_GPIO_COM5_GPI_REGS,
150 .pad_cfg_base = PAD_CFG_BASE,
151 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600152 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
153 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Aamir Bohra6efa5c32018-11-06 11:37:44 +0530154 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
155 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
156 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
157 .name = "GPP_RS",
158 .acpi_path = "\\_SB.PCI0.GPIO",
159 .reset_map = rst_map,
160 .num_reset_vals = ARRAY_SIZE(rst_map),
161 .groups = icl_community5_groups,
162 .num_groups = ARRAY_SIZE(icl_community5_groups),
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530163 }
164};
165
166const struct pad_community *soc_gpio_get_community(size_t *num_communities)
167{
168 *num_communities = ARRAY_SIZE(icl_communities);
169 return icl_communities;
170}
171
172const struct pmc_to_gpio_route *soc_pmc_gpio_routes(size_t *num)
173{
174 static const struct pmc_to_gpio_route routes[] = {
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530175 { PMC_GPP_G, GPP_G },
Aamir Bohra6efa5c32018-11-06 11:37:44 +0530176 { PMC_GPP_B, GPP_B },
177 { PMC_GPP_A, GPP_A },
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530178 { PMC_GPP_H, GPP_H },
Aamir Bohra6efa5c32018-11-06 11:37:44 +0530179 { PMC_GPP_D, GPP_D },
180 { PMC_GPP_F, GPP_F },
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530181 { PMC_GPD, GPD },
Aamir Bohra6efa5c32018-11-06 11:37:44 +0530182 { PMC_GPP_C, GPP_C },
183 { PMC_GPP_E, GPP_E },
184 { PMC_GPP_R, GPP_R },
185 { PMC_GPP_S, GPP_S }
186
Aamir Bohra3ee54bb2018-10-17 11:55:01 +0530187 };
188 *num = ARRAY_SIZE(routes);
189 return routes;
190}