blob: 4da705da73d2246a3162a8e838e795ca8d14fb15 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
Hannah Williams1760cd32017-04-06 20:54:11 -07005 * Copyright (C) 2015 - 2017 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Lee Leahyb0005132015-05-12 18:19:47 -070015 */
16
Hannah Williams1760cd32017-04-06 20:54:11 -070017#include <assert.h>
18#include <intelblocks/gpio.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053019#include <intelblocks/pcr.h>
20#include <soc/pcr_ids.h>
Lee Leahyb0005132015-05-12 18:19:47 -070021#include <soc/pm.h>
22
Bora Guvendik3f672322017-11-22 13:48:12 -080023
Hannah Williams1760cd32017-04-06 20:54:11 -070024static const struct reset_mapping rst_map[] = {
25 { .logical = PAD_CFG0_LOGICAL_RESET_RSMRST, .chipset = 0U << 30},
26 { .logical = PAD_CFG0_LOGICAL_RESET_DEEP, .chipset = 1U << 30},
27 { .logical = PAD_CFG0_LOGICAL_RESET_PLTRST, .chipset = 2U << 30},
Aaron Durbinffdf9012015-07-24 13:00:36 -050028};
29
Hannah Williams1760cd32017-04-06 20:54:11 -070030static const struct reset_mapping rst_map_com2[] = {
31 { .logical = PAD_CFG0_LOGICAL_RESET_PWROK, .chipset = 0U << 30},
32 { .logical = PAD_CFG0_LOGICAL_RESET_DEEP, .chipset = 1U << 30},
33 { .logical = PAD_CFG0_LOGICAL_RESET_PLTRST, .chipset = 2U << 30},
34 { .logical = PAD_CFG0_LOGICAL_RESET_RSMRST, .chipset = 3U << 30},
35};
36
Bora Guvendik3f672322017-11-22 13:48:12 -080037static const struct pad_group skl_community_com0_groups[] = {
38 INTEL_GPP(GPP_A0, GPP_A0, GPP_A23), /* GPP A */
39 INTEL_GPP(GPP_A0, GPP_B0, GPP_B23), /* GPP B */
40};
41
42static const struct pad_group skl_community_com1_groups[] = {
43 INTEL_GPP(GPP_C0, GPP_C0, GPP_C23), /* GPP C */
44#if IS_ENABLED(CONFIG_SKYLAKE_SOC_PCH_H)
45 INTEL_GPP(GPP_C0, GPP_D0, GPP_D23), /* GPP D */
46 INTEL_GPP(GPP_C0, GPP_E0, GPP_E12), /* GPP E */
47 INTEL_GPP(GPP_C0, GPP_F0, GPP_F23), /* GPP F */
48 INTEL_GPP(GPP_C0, GPP_G0, GPP_G23), /* GPP G */
49 INTEL_GPP(GPP_C0, GPP_H0, GPP_H23), /* GPP H */
50#else
51 INTEL_GPP(GPP_C0, GPP_D0, GPP_D23), /* GPP D */
52 INTEL_GPP(GPP_C0, GPP_E0, GPP_E23), /* GPP E */
53#endif
54};
55
56static const struct pad_group skl_community_com3_groups[] = {
57#if IS_ENABLED(CONFIG_SKYLAKE_SOC_PCH_H)
58 INTEL_GPP(GPP_I0, GPP_I0, GPP_I10), /* GPP I */
59#else
60 INTEL_GPP(GPP_F0, GPP_F0, GPP_F23), /* GPP F */
61 INTEL_GPP(GPP_F0, GPP_G0, GPP_G7), /* GPP G */
62#endif
63};
64
65static const struct pad_group skl_community_com2_groups[] = {
66 INTEL_GPP(GPD0, GPD0, GPD11), /* GPP GDP */
67};
68
Hannah Williams1760cd32017-04-06 20:54:11 -070069static const struct pad_community skl_gpio_communities[] = {
Aaron Durbinffdf9012015-07-24 13:00:36 -050070 {
Hannah Williams1760cd32017-04-06 20:54:11 -070071 .port = PID_GPIOCOM0,
72 .first_pad = GPP_A0,
73 .last_pad = GPP_B23,
74 .num_gpi_regs = NUM_GPIO_COM0_GPI_REGS,
75 .pad_cfg_base = PAD_CFG_BASE,
76 .host_own_reg_0 = HOSTSW_OWN_REG_0,
77 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
78 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
79 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
80 .name = "GPIO_COM0",
81 .acpi_path = "\\_SB.PCI0.GPIO",
82 .reset_map = rst_map,
83 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -080084 .groups = skl_community_com0_groups,
85 .num_groups = ARRAY_SIZE(skl_community_com0_groups),
Hannah Williams1760cd32017-04-06 20:54:11 -070086 }, {
87 .port = PID_GPIOCOM1,
88 .first_pad = GPP_C0,
Li Cheng Sooi6a740532017-01-04 09:48:39 +080089#if IS_ENABLED(CONFIG_SKYLAKE_SOC_PCH_H)
Hannah Williams1760cd32017-04-06 20:54:11 -070090 .last_pad = GPP_H23,
Li Cheng Sooi6a740532017-01-04 09:48:39 +080091#else
Hannah Williams1760cd32017-04-06 20:54:11 -070092 .last_pad = GPP_E23,
Li Cheng Sooi6a740532017-01-04 09:48:39 +080093#endif
Hannah Williams1760cd32017-04-06 20:54:11 -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,
97 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
98 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
99 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
100 .name = "GPIO_COM1",
101 .acpi_path = "\\_SB.PCI0.GPIO",
102 .reset_map = rst_map,
103 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800104 .groups = skl_community_com1_groups,
105 .num_groups = ARRAY_SIZE(skl_community_com1_groups),
Hannah Williams1760cd32017-04-06 20:54:11 -0700106 }, {
107 .port = PID_GPIOCOM3,
Li Cheng Sooi6a740532017-01-04 09:48:39 +0800108#if IS_ENABLED(CONFIG_SKYLAKE_SOC_PCH_H)
Hannah Williams1760cd32017-04-06 20:54:11 -0700109 .first_pad = GPP_I0,
110 .last_pad = GPP_I10,
Li Cheng Sooi6a740532017-01-04 09:48:39 +0800111#else
Hannah Williams1760cd32017-04-06 20:54:11 -0700112 .first_pad = GPP_F0,
113 .last_pad = GPP_G7,
Li Cheng Sooi6a740532017-01-04 09:48:39 +0800114#endif
Hannah Williams1760cd32017-04-06 20:54:11 -0700115 .num_gpi_regs = NUM_GPIO_COM3_GPI_REGS,
116 .pad_cfg_base = PAD_CFG_BASE,
117 .host_own_reg_0 = HOSTSW_OWN_REG_0,
118 .gpi_smi_sts_reg_0 = GPI_SMI_STS_0,
119 .gpi_smi_en_reg_0 = GPI_SMI_EN_0,
120 .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP,
121 .name = "GPIO_COM3",
122 .acpi_path = "\\_SB.PCI0.GPIO",
123 .reset_map = rst_map,
124 .num_reset_vals = ARRAY_SIZE(rst_map),
Bora Guvendik3f672322017-11-22 13:48:12 -0800125 .groups = skl_community_com3_groups,
126 .num_groups = ARRAY_SIZE(skl_community_com3_groups),
Hannah Williams1760cd32017-04-06 20:54:11 -0700127 }, {
128 .port = PID_GPIOCOM2,
129 .first_pad = GPD0,
130 .last_pad = GPD11,
131 .num_gpi_regs = NUM_GPIO_COM2_GPI_REGS,
132 .pad_cfg_base = PAD_CFG_BASE,
133 .host_own_reg_0 = HOSTSW_OWN_REG_0,
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,
137 .name = "GPIO_COM2",
138 .acpi_path = "\\_SB.PCI0.GPIO",
139 .reset_map = rst_map_com2,
140 .num_reset_vals = ARRAY_SIZE(rst_map_com2),
Bora Guvendik3f672322017-11-22 13:48:12 -0800141 .groups = skl_community_com2_groups,
142 .num_groups = ARRAY_SIZE(skl_community_com2_groups),
Hannah Williams1760cd32017-04-06 20:54:11 -0700143 }
Aaron Durbinffdf9012015-07-24 13:00:36 -0500144};
145
Hannah Williams1760cd32017-04-06 20:54:11 -0700146const struct pad_community *soc_gpio_get_community(size_t *num_communities)
147{
148 *num_communities = ARRAY_SIZE(skl_gpio_communities);
149 return skl_gpio_communities;
150}
151
152const struct pmc_to_gpio_route *soc_pmc_gpio_routes(size_t *num)
153{
154 static const struct pmc_to_gpio_route routes[] = {
155 { GPP_A, GPP_A},
156 { GPP_B, GPP_B},
157 { GPP_C, GPP_C},
158 { GPP_D, GPP_D},
159 { GPP_E, GPP_E},
160 { GPP_F, GPP_F},
161 { GPP_G, GPP_G},
Li Cheng Sooi6a740532017-01-04 09:48:39 +0800162#if IS_ENABLED(CONFIG_SKYLAKE_SOC_PCH_H)
Hannah Williams1760cd32017-04-06 20:54:11 -0700163 { GPP_H, GPP_H},
164 { GPP_I, GPP_I},
Li Cheng Sooi6a740532017-01-04 09:48:39 +0800165#endif
Hannah Williams1760cd32017-04-06 20:54:11 -0700166 { GPD, GPD},
167 };
168 *num = ARRAY_SIZE(routes);
169 return routes;
Duncan Laurieabdbed92016-06-30 09:34:24 -0700170}
Kane Chen223ddc22019-02-12 21:14:13 +0800171
172uint32_t soc_gpio_pad_config_fixup(const struct pad_config *cfg,
173 int dw_reg, uint32_t reg_val)
174{
175 if (IS_ENABLED(CONFIG_SKYLAKE_SOC_PCH_H))
176 return reg_val;
177 /*
178 * For U/Y series, clear PAD_CFG1_TOL_1V8 in GPP_F4
179 * ~ GPP_F11.
180 */
181 if (cfg->pad >= GPP_F4 && cfg->pad <= GPP_F11 && dw_reg == 1)
182 reg_val = reg_val & ~(PAD_CFG1_TOL_1V8);
183 return reg_val;
184
185}