Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 2 | |
| 3 | #include <intelblocks/gpio.h> |
| 4 | #include <intelblocks/pcr.h> |
| 5 | #include <soc/pcr_ids.h> |
| 6 | #include <soc/pmc.h> |
| 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 | |
Subrata Banik | da24535 | 2018-12-17 16:53:33 +0530 | [diff] [blame] | 21 | /* |
| 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 Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 34 | static const struct pad_group icl_community0_groups[] = { |
Subrata Banik | da24535 | 2018-12-17 16:53:33 +0530 | [diff] [blame] | 35 | 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 Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 37 | INTEL_GPP(GPP_G0, GPIO_RSVD_0, GPIO_RSVD_1), |
Subrata Banik | da24535 | 2018-12-17 16:53:33 +0530 | [diff] [blame] | 38 | INTEL_GPP_BASE(GPP_G0, GPP_A0, GPP_A23, 64), /* GPP_A */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static const struct pad_group icl_community1_groups[] = { |
Subrata Banik | da24535 | 2018-12-17 16:53:33 +0530 | [diff] [blame] | 42 | 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 Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 45 | }; |
| 46 | |
Subrata Banik | da24535 | 2018-12-17 16:53:33 +0530 | [diff] [blame] | 47 | /* This community is not visible to the OS */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 48 | static const struct pad_group icl_community2_groups[] = { |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 49 | INTEL_GPP(GPD0, GPD0, GPD11), /* GPD */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 50 | }; |
| 51 | |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 52 | static const struct pad_group icl_community4_groups[] = { |
Subrata Banik | da24535 | 2018-12-17 16:53:33 +0530 | [diff] [blame] | 53 | 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 Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 55 | INTEL_GPP(GPP_C0, GPIO_RSVD_3, GPIO_RSVD_8), |
| 56 | }; |
| 57 | |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 58 | static const struct pad_group icl_community5_groups[] = { |
Subrata Banik | da24535 | 2018-12-17 16:53:33 +0530 | [diff] [blame] | 59 | 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 Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 61 | }; |
| 62 | |
Subrata Banik | dd5fa02 | 2019-05-15 21:04:37 +0530 | [diff] [blame] | 63 | static const struct pad_community icl_communities[TOTAL_GPIO_COMM] = { |
| 64 | /* GPP G, B, A */ |
| 65 | [COMM_0] = { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 66 | .port = PID_GPIOCOM0, |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 67 | .first_pad = GPP_G0, |
| 68 | .last_pad = GPP_A23, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 69 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 72 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 73 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 74 | .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 Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 77 | .name = "GPP_GBA", |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 78 | .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 Banik | dd5fa02 | 2019-05-15 21:04:37 +0530 | [diff] [blame] | 83 | }, |
| 84 | /* GPP H, D, F */ |
| 85 | [COMM_1] = { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 86 | .port = PID_GPIOCOM1, |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 87 | .first_pad = GPP_H0, |
| 88 | .last_pad = GPP_F19, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 89 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 92 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 93 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 94 | .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 Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 97 | .name = "GPP_HDF", |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 98 | .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 Banik | dd5fa02 | 2019-05-15 21:04:37 +0530 | [diff] [blame] | 103 | }, |
| 104 | /* GPD */ |
| 105 | [COMM_2] = { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 106 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 112 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 113 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 114 | .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 Banik | dd5fa02 | 2019-05-15 21:04:37 +0530 | [diff] [blame] | 123 | }, |
| 124 | /* GPP C, E */ |
| 125 | [COMM_3] = { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 126 | .port = PID_GPIOCOM4, |
| 127 | .first_pad = GPP_C0, |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 128 | .last_pad = GPP_E23, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 129 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 132 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 133 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 134 | .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 Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 137 | .name = "GPP_CE", |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 138 | .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 Banik | dd5fa02 | 2019-05-15 21:04:37 +0530 | [diff] [blame] | 143 | }, |
| 144 | /* GPP R, S */ |
| 145 | [COMM_4] = { |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 146 | .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 Ramasubramanian | c126084 | 2019-04-23 15:18:51 -0600 | [diff] [blame] | 152 | .gpi_int_sts_reg_0 = GPI_INT_STS_0, |
| 153 | .gpi_int_en_reg_0 = GPI_INT_EN_0, |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 154 | .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 Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 163 | } |
| 164 | }; |
| 165 | |
| 166 | const 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 | |
| 172 | const struct pmc_to_gpio_route *soc_pmc_gpio_routes(size_t *num) |
| 173 | { |
| 174 | static const struct pmc_to_gpio_route routes[] = { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 175 | { PMC_GPP_G, GPP_G }, |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 176 | { PMC_GPP_B, GPP_B }, |
| 177 | { PMC_GPP_A, GPP_A }, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 178 | { PMC_GPP_H, GPP_H }, |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 179 | { PMC_GPP_D, GPP_D }, |
| 180 | { PMC_GPP_F, GPP_F }, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 181 | { PMC_GPD, GPD }, |
Aamir Bohra | 6efa5c3 | 2018-11-06 11:37:44 +0530 | [diff] [blame] | 182 | { 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 Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 187 | }; |
| 188 | *num = ARRAY_SIZE(routes); |
| 189 | return routes; |
| 190 | } |