blob: 90efacc3f3cc4f70ecdabc53a347485c4febb7bb [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
3#include <intelblocks/gpio.h>
4#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,
Andrey Petrovc854b492017-06-05 14:10:17 -070077 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
78 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +010079 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
80 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -070081 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
82 .name = "GPP_ABG",
83 .acpi_path = "\\_SB.PCI0.GPIO",
84 .reset_map = rst_map_com0,
85 .num_reset_vals = ARRAY_SIZE(rst_map_com0),
Bora Guvendik3f672322017-11-22 13:48:12 -080086 .groups = cnl_community0_groups,
87 .num_groups = ARRAY_SIZE(cnl_community0_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +053088 },
89 /* GPP D, F, H, VGPIO */
90 [COMM_1] = {
Andrey Petrovc854b492017-06-05 14:10:17 -070091 .port = PID_GPIOCOM1,
92 .first_pad = GPP_D0,
Rizwan Qureshi74715402019-02-21 14:52:39 +053093 .last_pad = vSD3_CD_B,
Andrey Petrovc854b492017-06-05 14:10:17 -070094 .num_gpi_regs = NUM_GPIO_COM1_GPI_REGS,
95 .pad_cfg_base = PAD_CFG_BASE,
96 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -060097 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
98 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -070099 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
100 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100101 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
102 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700103 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
104 .name = "GPP_DFH",
105 .acpi_path = "\\_SB.PCI0.GPIO",
106 .reset_map = rst_map,
107 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800108 .groups = cnl_community1_groups,
109 .num_groups = ARRAY_SIZE(cnl_community1_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +0530110 },
111 /* GPD */
112 [COMM_2] = {
Andrey Petrovc854b492017-06-05 14:10:17 -0700113 .port = PID_GPIOCOM2,
114 .first_pad = GPD0,
Michael Niewöhner5d1a3282020-09-09 21:53:58 +0200115 .last_pad = DRAM_RESET_B,
Andrey Petrovc854b492017-06-05 14:10:17 -0700116 .num_gpi_regs = NUM_GPIO_COM2_GPI_REGS,
117 .pad_cfg_base = PAD_CFG_BASE,
118 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600119 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
120 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700121 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
122 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100123 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
124 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700125 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
126 .name = "GPD",
127 .acpi_path = "\\_SB.PCI0.GPIO",
128 .reset_map = rst_map,
129 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800130 .groups = cnl_community2_groups,
131 .num_groups = ARRAY_SIZE(cnl_community2_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +0530132 },
133 /* AZA, CPU */
134 [COMM_3] = {
Lijian Zhaob716e5502017-11-10 17:14:01 -0800135 .port = PID_GPIOCOM3,
136 .first_pad = HDA_BCLK,
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +0200137 .last_pad = TRIGGER_OUT,
Andrey Petrovc854b492017-06-05 14:10:17 -0700138 .num_gpi_regs = NUM_GPIO_COM3_GPI_REGS,
139 .pad_cfg_base = PAD_CFG_BASE,
140 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600141 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
142 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700143 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
144 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100145 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
146 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Andrey Petrovc854b492017-06-05 14:10:17 -0700147 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800148 .name = "GP_AC",
149 .acpi_path = "\\_SB.PCI0.GPIO",
150 .reset_map = rst_map,
151 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800152 .groups = cnl_community3_groups,
153 .num_groups = ARRAY_SIZE(cnl_community3_groups),
Subrata Banik76a8f9e2019-05-15 21:23:18 +0530154 },
155 /* GPP C, E, JTAG, HVMOS */
156 [COMM_4] = {
Lijian Zhaob716e5502017-11-10 17:14:01 -0800157 .port = PID_GPIOCOM4,
158 .first_pad = GPP_C0,
Michael Niewöhner1c2b1b92020-09-09 21:34:05 +0200159 .last_pad = CL_RST_B,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800160 .num_gpi_regs = NUM_GPIO_COM4_GPI_REGS,
161 .pad_cfg_base = PAD_CFG_BASE,
162 .host_own_reg_0 = HOSTSW_OWN_REG_0,
Karthikeyan Ramasubramanianc1260842019-04-23 15:18:51 -0600163 .gpi_int_sts_reg_0 = GPI_INT_STS_0,
164 .gpi_int_en_reg_0 = GPI_INT_EN_0,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800165 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
166 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
Michael Niewöhner51f5ff62020-11-23 22:05:36 +0100167 .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0,
168 .gpi_nmi_en_reg_0 = GPI_NMI_EN_0,
Lijian Zhaob716e5502017-11-10 17:14:01 -0800169 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
170 .name = "GPP_CEJ",
Andrey Petrovc854b492017-06-05 14:10:17 -0700171 .acpi_path = "\\_SB.PCI0.GPIO",
172 .reset_map = rst_map,
173 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800174 .groups = cnl_community4_groups,
175 .num_groups = ARRAY_SIZE(cnl_community4_groups),
Andrey Petrovc854b492017-06-05 14:10:17 -0700176 }
177};
178
179const struct pad_community *soc_gpio_get_community(size_t *num_communities)
180{
181 *num_communities = ARRAY_SIZE(cnl_communities);
182 return cnl_communities;
183}
Lijian Zhaoac87a982017-08-28 17:46:55 -0700184
185const struct pmc_to_gpio_route *soc_pmc_gpio_routes(size_t *num)
186{
187 static const struct pmc_to_gpio_route routes[] = {
Lijian Zhao031020e2017-12-15 12:58:07 -0800188 { PMC_GPP_A, GPP_A },
189 { PMC_GPP_B, GPP_B },
190 { PMC_GPP_C, GPP_C },
191 { PMC_GPP_D, GPP_D },
192 { PMC_GPP_E, GPP_E },
193 { PMC_GPP_F, GPP_F },
194 { PMC_GPP_G, GPP_G },
195 { PMC_GPP_H, GPP_H },
196 { PMC_GPD, GPD },
Lijian Zhaoac87a982017-08-28 17:46:55 -0700197 };
198 *num = ARRAY_SIZE(routes);
199 return routes;
200}