Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 2 | |
| 3 | #include <intelblocks/gpio.h> |
| 4 | #include <intelblocks/pcr.h> |
| 5 | #include <soc/pcr_ids.h> |
Lijian Zhao | 031020e | 2017-12-15 12:58:07 -0800 | [diff] [blame] | 6 | #include <soc/pmc.h> |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 7 | |
| 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 }, |
| 12 | }; |
| 13 | |
| 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 }, |
| 19 | }; |
| 20 | |
Duncan Laurie | 64c9f15 | 2018-12-10 11:27:47 -0800 | [diff] [blame] | 21 | /* |
| 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 Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 34 | static const struct pad_group cnl_community0_groups[] = { |
Michael Niewöhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 35 | 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 Laurie | 64c9f15 | 2018-12-10 11:27:47 -0800 | [diff] [blame] | 37 | INTEL_GPP_BASE(GPP_A0, GPP_G0, GPP_G7, 64), /* GPP_G */ |
Michael Niewöhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 38 | INTEL_GPP(GPP_A0, SPI0_IO_2, SPI0_CLK_LOOPBK), /* SPI */ |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static const struct pad_group cnl_community1_groups[] = { |
Michael Niewöhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 42 | INTEL_GPP_BASE(GPP_D0, GPP_D0, GSPI2_CLK_LOOPBK, 96), /* GPP_D */ |
Duncan Laurie | 64c9f15 | 2018-12-10 11:27:47 -0800 | [diff] [blame] | 43 | 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 Qureshi | 7471540 | 2019-02-21 14:52:39 +0530 | [diff] [blame] | 45 | INTEL_GPP_BASE(GPP_D0, CNV_BTEN, vSD3_CD_B, 192), /* VGPIO */ |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 46 | }; |
| 47 | |
Duncan Laurie | 64c9f15 | 2018-12-10 11:27:47 -0800 | [diff] [blame] | 48 | /* This community is not visible to the OS */ |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 49 | static const struct pad_group cnl_community2_groups[] = { |
Michael Niewöhner | 5d1a328 | 2020-09-09 21:53:58 +0200 | [diff] [blame] | 50 | INTEL_GPP(GPD0, GPD0, DRAM_RESET_B), /* GPD */ |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 51 | }; |
| 52 | |
Duncan Laurie | 64c9f15 | 2018-12-10 11:27:47 -0800 | [diff] [blame] | 53 | /* This community is not visible to the OS */ |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 54 | static const struct pad_group cnl_community3_groups[] = { |
Michael Niewöhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 55 | INTEL_GPP(HDA_BCLK, HDA_BCLK, I2S1_TXD), /* AZA */ |
| 56 | INTEL_GPP(HDA_BCLK, HDACPU_SDI, TRIGGER_OUT), /* CPU */ |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | static const struct pad_group cnl_community4_groups[] = { |
Duncan Laurie | 64c9f15 | 2018-12-10 11:27:47 -0800 | [diff] [blame] | 60 | 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öhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 62 | INTEL_GPP(GPP_C0, PCH_TDO, ITP_PMODE), /* JTAG */ |
| 63 | INTEL_GPP(GPP_C0, EDP_BKLTEN, CL_RST_B), /* HVMOS */ |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
Subrata Banik | 76a8f9e | 2019-05-15 21:23:18 +0530 | [diff] [blame] | 66 | static const struct pad_community cnl_communities[TOTAL_GPIO_COMM] = { |
| 67 | /* GPP A, B, G, SPI */ |
| 68 | [COMM_0] = { |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 69 | .port = PID_GPIOCOM0, |
| 70 | .first_pad = GPP_A0, |
Michael Niewöhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 71 | .last_pad = SPI0_CLK_LOOPBK, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 72 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 75 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 76 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Maulik V Vaghela | afe8409 | 2022-05-06 10:27:50 +0530 | [diff] [blame] | 77 | .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0, |
| 78 | .gpi_gpe_en_reg_0 = GPI_GPE_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 79 | .gpi_smi_sts_reg_0 = GPI_SMI_STS_0, |
| 80 | .gpi_smi_en_reg_0 = GPI_SMI_EN_0, |
Michael Niewöhner | 51f5ff6 | 2020-11-23 22:05:36 +0100 | [diff] [blame] | 81 | .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0, |
| 82 | .gpi_nmi_en_reg_0 = GPI_NMI_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 83 | .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 Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 88 | .groups = cnl_community0_groups, |
| 89 | .num_groups = ARRAY_SIZE(cnl_community0_groups), |
Subrata Banik | 76a8f9e | 2019-05-15 21:23:18 +0530 | [diff] [blame] | 90 | }, |
| 91 | /* GPP D, F, H, VGPIO */ |
| 92 | [COMM_1] = { |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 93 | .port = PID_GPIOCOM1, |
| 94 | .first_pad = GPP_D0, |
Rizwan Qureshi | 7471540 | 2019-02-21 14:52:39 +0530 | [diff] [blame] | 95 | .last_pad = vSD3_CD_B, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 96 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 99 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 100 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Maulik V Vaghela | afe8409 | 2022-05-06 10:27:50 +0530 | [diff] [blame] | 101 | .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0, |
| 102 | .gpi_gpe_en_reg_0 = GPI_GPE_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 103 | .gpi_smi_sts_reg_0 = GPI_SMI_STS_0, |
| 104 | .gpi_smi_en_reg_0 = GPI_SMI_EN_0, |
Michael Niewöhner | 51f5ff6 | 2020-11-23 22:05:36 +0100 | [diff] [blame] | 105 | .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0, |
| 106 | .gpi_nmi_en_reg_0 = GPI_NMI_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 107 | .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 Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 112 | .groups = cnl_community1_groups, |
| 113 | .num_groups = ARRAY_SIZE(cnl_community1_groups), |
Subrata Banik | 76a8f9e | 2019-05-15 21:23:18 +0530 | [diff] [blame] | 114 | }, |
| 115 | /* GPD */ |
| 116 | [COMM_2] = { |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 117 | .port = PID_GPIOCOM2, |
| 118 | .first_pad = GPD0, |
Michael Niewöhner | 5d1a328 | 2020-09-09 21:53:58 +0200 | [diff] [blame] | 119 | .last_pad = DRAM_RESET_B, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 120 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 123 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 124 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Maulik V Vaghela | afe8409 | 2022-05-06 10:27:50 +0530 | [diff] [blame] | 125 | .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0, |
| 126 | .gpi_gpe_en_reg_0 = GPI_GPE_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 127 | .gpi_smi_sts_reg_0 = GPI_SMI_STS_0, |
| 128 | .gpi_smi_en_reg_0 = GPI_SMI_EN_0, |
Michael Niewöhner | 51f5ff6 | 2020-11-23 22:05:36 +0100 | [diff] [blame] | 129 | .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0, |
| 130 | .gpi_nmi_en_reg_0 = GPI_NMI_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 131 | .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 Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 136 | .groups = cnl_community2_groups, |
| 137 | .num_groups = ARRAY_SIZE(cnl_community2_groups), |
Subrata Banik | 76a8f9e | 2019-05-15 21:23:18 +0530 | [diff] [blame] | 138 | }, |
| 139 | /* AZA, CPU */ |
| 140 | [COMM_3] = { |
Lijian Zhao | b716e550 | 2017-11-10 17:14:01 -0800 | [diff] [blame] | 141 | .port = PID_GPIOCOM3, |
| 142 | .first_pad = HDA_BCLK, |
Michael Niewöhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 143 | .last_pad = TRIGGER_OUT, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 144 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 147 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 148 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Maulik V Vaghela | afe8409 | 2022-05-06 10:27:50 +0530 | [diff] [blame] | 149 | .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0, |
| 150 | .gpi_gpe_en_reg_0 = GPI_GPE_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 151 | .gpi_smi_sts_reg_0 = GPI_SMI_STS_0, |
| 152 | .gpi_smi_en_reg_0 = GPI_SMI_EN_0, |
Michael Niewöhner | 51f5ff6 | 2020-11-23 22:05:36 +0100 | [diff] [blame] | 153 | .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0, |
| 154 | .gpi_nmi_en_reg_0 = GPI_NMI_EN_0, |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 155 | .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, |
Lijian Zhao | b716e550 | 2017-11-10 17:14:01 -0800 | [diff] [blame] | 156 | .name = "GP_AC", |
| 157 | .acpi_path = "\\_SB.PCI0.GPIO", |
| 158 | .reset_map = rst_map, |
| 159 | .num_reset_vals = ARRAY_SIZE(rst_map), |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 160 | .groups = cnl_community3_groups, |
| 161 | .num_groups = ARRAY_SIZE(cnl_community3_groups), |
Subrata Banik | 76a8f9e | 2019-05-15 21:23:18 +0530 | [diff] [blame] | 162 | }, |
| 163 | /* GPP C, E, JTAG, HVMOS */ |
| 164 | [COMM_4] = { |
Lijian Zhao | b716e550 | 2017-11-10 17:14:01 -0800 | [diff] [blame] | 165 | .port = PID_GPIOCOM4, |
| 166 | .first_pad = GPP_C0, |
Michael Niewöhner | 1c2b1b9 | 2020-09-09 21:34:05 +0200 | [diff] [blame] | 167 | .last_pad = CL_RST_B, |
Lijian Zhao | b716e550 | 2017-11-10 17:14:01 -0800 | [diff] [blame] | 168 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 171 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 172 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Maulik V Vaghela | afe8409 | 2022-05-06 10:27:50 +0530 | [diff] [blame] | 173 | .gpi_gpe_sts_reg_0 = GPI_GPE_STS_0, |
| 174 | .gpi_gpe_en_reg_0 = GPI_GPE_EN_0, |
Lijian Zhao | b716e550 | 2017-11-10 17:14:01 -0800 | [diff] [blame] | 175 | .gpi_smi_sts_reg_0 = GPI_SMI_STS_0, |
| 176 | .gpi_smi_en_reg_0 = GPI_SMI_EN_0, |
Michael Niewöhner | 51f5ff6 | 2020-11-23 22:05:36 +0100 | [diff] [blame] | 177 | .gpi_nmi_sts_reg_0 = GPI_NMI_STS_0, |
| 178 | .gpi_nmi_en_reg_0 = GPI_NMI_EN_0, |
Lijian Zhao | b716e550 | 2017-11-10 17:14:01 -0800 | [diff] [blame] | 179 | .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, |
| 180 | .name = "GPP_CEJ", |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 181 | .acpi_path = "\\_SB.PCI0.GPIO", |
| 182 | .reset_map = rst_map, |
| 183 | .num_reset_vals = ARRAY_SIZE(rst_map), |
Bora Guvendik | 3f67232 | 2017-11-22 13:48:12 -0800 | [diff] [blame] | 184 | .groups = cnl_community4_groups, |
| 185 | .num_groups = ARRAY_SIZE(cnl_community4_groups), |
Andrey Petrov | c854b49 | 2017-06-05 14:10:17 -0700 | [diff] [blame] | 186 | } |
| 187 | }; |
| 188 | |
| 189 | const 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 Zhao | ac87a98 | 2017-08-28 17:46:55 -0700 | [diff] [blame] | 194 | |
| 195 | const struct pmc_to_gpio_route *soc_pmc_gpio_routes(size_t *num) |
| 196 | { |
| 197 | static const struct pmc_to_gpio_route routes[] = { |
Lijian Zhao | 031020e | 2017-12-15 12:58:07 -0800 | [diff] [blame] | 198 | { 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 Zhao | ac87a98 | 2017-08-28 17:46:55 -0700 | [diff] [blame] | 207 | }; |
| 208 | *num = ARRAY_SIZE(routes); |
| 209 | return routes; |
| 210 | } |