blob: 93a71e06cef5de280c7bec49844390690344234b [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Andrey Petrovc854b492017-06-05 14:10:17 -07002
Dinesh Gehlot8a2c9042023-01-17 05:12:07 +00003#include <gpio.h>
Andrey Petrovc854b492017-06-05 14:10:17 -07004#include <intelblocks/pcr.h>
5#include <soc/pcr_ids.h>
Lijian Zhao031020e2017-12-15 12:58:07 -08006#include <soc/pmc.h>
Andrey Petrovc854b492017-06-05 14:10:17 -07007
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
Duncan Laurie64c9f152018-12-10 11:27:47 -080021/*
22 * The GPIO driver for Cannonlake 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-cannonlake.c
33 */
Bora Guvendik3f672322017-11-22 13:48:12 -080034static const struct pad_group cnl_community0_groups[] = {
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +020035 INTEL_GPP_BASE(GPP_A0, GPP_A0, ESPI_CLK_LOOPBK, 0), /* GPP_A */
36 INTEL_GPP_BASE(GPP_A0, GPP_B0, GSPI1_CLK_LOOPBK, 32), /* GPP_B */
Duncan Laurie64c9f152018-12-10 11:27:47 -080037 INTEL_GPP_BASE(GPP_A0, GPP_G0, GPP_G7, 64), /* GPP_G */
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +020038 INTEL_GPP(GPP_A0, SPI0_IO_2, SPI0_CLK_LOOPBK), /* SPI */
Bora Guvendik3f672322017-11-22 13:48:12 -080039};
40
41static const struct pad_group cnl_community1_groups[] = {
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +020042 INTEL_GPP_BASE(GPP_D0, GPP_D0, GSPI2_CLK_LOOPBK, 96), /* GPP_D */
Duncan Laurie64c9f152018-12-10 11:27:47 -080043 INTEL_GPP_BASE(GPP_D0, GPP_F0, GPP_F23, 128), /* GPP_F */
44 INTEL_GPP_BASE(GPP_D0, GPP_H0, GPP_H23, 160), /* GPP_H */
Rizwan Qureshi74715402019-02-21 14:52:39 +053045 INTEL_GPP_BASE(GPP_D0, CNV_BTEN, vSD3_CD_B, 192), /* VGPIO */
Bora Guvendik3f672322017-11-22 13:48:12 -080046};
47
Duncan Laurie64c9f152018-12-10 11:27:47 -080048/* This community is not visible to the OS */
Bora Guvendik3f672322017-11-22 13:48:12 -080049static const struct pad_group cnl_community2_groups[] = {
Michael Niewöhner5d1a3282020-09-09 21:53:58 +020050 INTEL_GPP(GPD0, GPD0, DRAM_RESET_B), /* GPD */
Bora Guvendik3f672322017-11-22 13:48:12 -080051};
52
Duncan Laurie64c9f152018-12-10 11:27:47 -080053/* This community is not visible to the OS */
Bora Guvendik3f672322017-11-22 13:48:12 -080054static const struct pad_group cnl_community3_groups[] = {
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +020055 INTEL_GPP(HDA_BCLK, HDA_BCLK, I2S1_TXD), /* AZA */
56 INTEL_GPP(HDA_BCLK, HDACPU_SDI, TRIGGER_OUT), /* CPU */
Bora Guvendik3f672322017-11-22 13:48:12 -080057};
58
59static const struct pad_group cnl_community4_groups[] = {
Duncan Laurie64c9f152018-12-10 11:27:47 -080060 INTEL_GPP_BASE(GPP_C0, GPP_C0, GPP_C23, 256), /* GPP_C */
61 INTEL_GPP_BASE(GPP_C0, GPP_E0, GPP_E23, 288), /* GPP_E */
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +020062 INTEL_GPP(GPP_C0, PCH_TDO, ITP_PMODE), /* JTAG */
63 INTEL_GPP(GPP_C0, EDP_BKLTEN, CL_RST_B), /* HVMOS */
Bora Guvendik3f672322017-11-22 13:48:12 -080064};
65
Subrata Banik76a8f9e2019-05-15 21:23:18 +053066static const struct pad_community cnl_communities[TOTAL_GPIO_COMM] = {
67 /* GPP A, B, G, SPI */
68 [COMM_0] = {
Andrey Petrovc854b492017-06-05 14:10:17 -070069 .port = PID_GPIOCOM0,
70 .first_pad = GPP_A0,
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +020071 .last_pad = SPI0_CLK_LOOPBK,
Andrey Petrovc854b492017-06-05 14:10:17 -070072 .num_gpi_regs = NUM_GPIO_COM0_GPI_REGS,
73 .pad_cfg_base = PAD_CFG_BASE,
74 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -060075 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
76 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Maulik V Vaghelaafe84092022-05-06 10:27:50 +053077 .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0,
78 .gpi_gpe_en_reg_0 = GPI_GPE_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -070079 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
80 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +010081 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
82 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -070083 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
84 .name = "GPP_ABG",
85 .acpi_path = "\\_SB.PCI0.GPIO",
86 .reset_map = rst_map_com0,
87 .num_reset_vals = ARRAY_SIZE(rst_map_com0),
Bora Guvendik3f672322017-11-22 13:48:12 -080088 .groups = cnl_community0_groups,
89 .num_groups = ARRAY_SIZE(cnl_community0_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +053090 },
91 /* GPP D, F, H, VGPIO */
92 [COMM_1] = {
Andrey Petrovc854b492017-06-05 14:10:17 -070093 .port = PID_GPIOCOM1,
94 .first_pad = GPP_D0,
Rizwan Qureshi74715402019-02-21 14:52:39 +053095 .last_pad = vSD3_CD_B,
Andrey Petrovc854b492017-06-05 14:10:17 -070096 .num_gpi_regs = NUM_GPIO_COM1_GPI_REGS,
97 .pad_cfg_base = PAD_CFG_BASE,
98 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -060099 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
100 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Maulik V Vaghelaafe84092022-05-06 10:27:50 +0530101 .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0,
102 .gpi_gpe_en_reg_0 = GPI_GPE_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700103 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
104 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100105 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
106 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700107 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
108 .name = "GPP_DFH",
109 .acpi_path = "\\_SB.PCI0.GPIO",
110 .reset_map = rst_map,
111 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800112 .groups = cnl_community1_groups,
113 .num_groups = ARRAY_SIZE(cnl_community1_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +0530114 },
115 /* GPD */
116 [COMM_2] = {
Andrey Petrovc854b492017-06-05 14:10:17 -0700117 .port = PID_GPIOCOM2,
118 .first_pad = GPD0,
Michael Niewöhner5d1a3282020-09-09 21:53:58 +0200119 .last_pad = DRAM_RESET_B,
Andrey Petrovc854b492017-06-05 14:10:17 -0700120 .num_gpi_regs = NUM_GPIO_COM2_GPI_REGS,
121 .pad_cfg_base = PAD_CFG_BASE,
122 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600123 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
124 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Maulik V Vaghelaafe84092022-05-06 10:27:50 +0530125 .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0,
126 .gpi_gpe_en_reg_0 = GPI_GPE_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700127 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
128 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100129 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
130 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700131 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
132 .name = "GPD",
133 .acpi_path = "\\_SB.PCI0.GPIO",
134 .reset_map = rst_map,
135 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800136 .groups = cnl_community2_groups,
137 .num_groups = ARRAY_SIZE(cnl_community2_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +0530138 },
139 /* AZA, CPU */
140 [COMM_3] = {
Lijian Zhaob716e5502017-11-10 17:14:01 -0800141 .port = PID_GPIOCOM3,
142 .first_pad = HDA_BCLK,
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +0200143 .last_pad = TRIGGER_OUT,
Andrey Petrovc854b492017-06-05 14:10:17 -0700144 .num_gpi_regs = NUM_GPIO_COM3_GPI_REGS,
145 .pad_cfg_base = PAD_CFG_BASE,
146 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600147 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
148 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Maulik V Vaghelaafe84092022-05-06 10:27:50 +0530149 .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0,
150 .gpi_gpe_en_reg_0 = GPI_GPE_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700151 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
152 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100153 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
154 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700155 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800156 .name = "GP_AC",
157 .acpi_path = "\\_SB.PCI0.GPIO",
158 .reset_map = rst_map,
159 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800160 .groups = cnl_community3_groups,
161 .num_groups = ARRAY_SIZE(cnl_community3_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +0530162 },
163 /* GPP C, E, JTAG, HVMOS */
164 [COMM_4] = {
Lijian Zhaob716e5502017-11-10 17:14:01 -0800165 .port = PID_GPIOCOM4,
166 .first_pad = GPP_C0,
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +0200167 .last_pad = CL_RST_B,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800168 .num_gpi_regs = NUM_GPIO_COM4_GPI_REGS,
169 .pad_cfg_base = PAD_CFG_BASE,
170 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600171 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
172 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Maulik V Vaghelaafe84092022-05-06 10:27:50 +0530173 .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0,
174 .gpi_gpe_en_reg_0 = GPI_GPE_EN_0,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800175 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
176 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100177 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
178 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800179 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
180 .name = "GPP_CEJ",
Andrey Petrovc854b492017-06-05 14:10:17 -0700181 .acpi_path = "\\_SB.PCI0.GPIO",
182 .reset_map = rst_map,
183 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800184 .groups = cnl_community4_groups,
185 .num_groups = ARRAY_SIZE(cnl_community4_groups),
Andrey Petrovc854b492017-06-05 14:10:17 -0700186 }
187};
188
189const struct pad_community *soc_gpio_get_community(size_t *num_communities)
190{
191 *num_communities = ARRAY_SIZE(cnl_communities);
192 return cnl_communities;
193}
Lijian Zhaoac87a982017-08-28 17:46:55 -0700194
195const struct pmc_to_gpio_route *soc_pmc_gpio_routes(size_t *num)
196{
197 static const struct pmc_to_gpio_route routes[] = {
Lijian Zhao031020e2017-12-15 12:58:07 -0800198 { PMC_GPP_A, GPP_A },
199 { PMC_GPP_B, GPP_B },
200 { PMC_GPP_C, GPP_C },
201 { PMC_GPP_D, GPP_D },
202 { PMC_GPP_E, GPP_E },
203 { PMC_GPP_F, GPP_F },
204 { PMC_GPP_G, GPP_G },
205 { PMC_GPP_H, GPP_H },
206 { PMC_GPD, GPD },
Lijian Zhaoac87a982017-08-28 17:46:55 -0700207 };
208 *num = ARRAY_SIZE(routes);
209 return routes;
210}