aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/common
diff options
context:
space:
mode:
authorBora Guvendik <bora.guvendik@intel.com>2017-11-22 13:48:12 -0800
committerAaron Durbin <adurbin@chromium.org>2018-02-16 03:59:29 +0000
commit3f672323b5f5cd6eaf955a31ebd0f73685f1d257 (patch)
treec619cda6d614a0c37c873a8fe52d68f0439592eb /src/soc/intel/common
parent7e2fe06a46ad3c44b1eb77651c27d4b9166033a6 (diff)
soc/intel/common/block/gpio: Change group offset calculation
Add group information for each gpio community and use it to calculate offset of a pad within its group. Original implementation assumed that the number of gpios in each group is same but that lead to a bug for cnl since numbers differ for each group. BUG=b:69616750 TEST=Need to test again on SKL,CNL,APL,GLK Change-Id: I02ab1d878bc83d32222be074bd2db5e23adaf580 Signed-off-by: Bora Guvendik <bora.guvendik@intel.com> Reviewed-on: https://review.coreboot.org/22571 Reviewed-by: Lijian Zhao <lijian.zhao@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/soc/intel/common')
-rw-r--r--src/soc/intel/common/block/gpio/gpio.c34
-rw-r--r--src/soc/intel/common/block/include/intelblocks/gpio.h16
2 files changed, 43 insertions, 7 deletions
diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c
index 6b6395544e..eea2554690 100644
--- a/src/soc/intel/common/block/gpio/gpio.c
+++ b/src/soc/intel/common/block/gpio/gpio.c
@@ -68,22 +68,42 @@ static inline size_t relative_pad_in_comm(const struct pad_community *comm,
return gpio - comm->first_pad;
}
-static inline size_t gpio_group_index_scaled(const struct pad_community *comm,
- unsigned int relative_pad, size_t scale)
+/* find the group within the community that the pad is a part of */
+static inline size_t gpio_group_index(const struct pad_community *comm,
+ unsigned int relative_pad)
{
- return (relative_pad / comm->max_pads_per_group) * scale;
+ size_t i;
+
+ assert(comm->groups != NULL);
+
+ /* find the base pad number for this pad's group */
+ for (i = 0; i < comm->num_groups; i++) {
+ if (relative_pad >= comm->groups[i].first_pad &&
+ relative_pad < comm->groups[i].first_pad +
+ comm->groups[i].size) {
+ return i;
+ }
+ }
+
+ assert(0);
+
+ return i;
}
-static inline size_t gpio_group_index(const struct pad_community *comm,
- unsigned int relative_pad)
+static inline size_t gpio_group_index_scaled(const struct pad_community *comm,
+ unsigned int relative_pad, size_t scale)
{
- return gpio_group_index_scaled(comm, relative_pad, 1);
+ return gpio_group_index(comm, relative_pad) * scale;
}
static inline size_t gpio_within_group(const struct pad_community *comm,
unsigned int relative_pad)
{
- return relative_pad % comm->max_pads_per_group;
+ size_t i;
+
+ i = gpio_group_index(comm, relative_pad);
+
+ return relative_pad - comm->groups[i].first_pad;
}
static inline uint32_t gpio_bitmask_within_group(
diff --git a/src/soc/intel/common/block/include/intelblocks/gpio.h b/src/soc/intel/common/block/include/intelblocks/gpio.h
index 879d30b469..625ebef881 100644
--- a/src/soc/intel/common/block/include/intelblocks/gpio.h
+++ b/src/soc/intel/common/block/include/intelblocks/gpio.h
@@ -23,6 +23,12 @@
#ifndef __ACPI__
#include <types.h>
+#define INTEL_GPP(first_of_community, start_of_group, end_of_group) \
+ { \
+ .first_pad = (start_of_group) - (first_of_community), \
+ .size = (end_of_group) - (start_of_group) + 1, \
+ }
+
/*
* Following should be defined in soc/gpio.h
* GPIO_MISCCFG - offset to GPIO MISCCFG Register
@@ -55,6 +61,14 @@ struct reset_mapping {
uint32_t chipset;
};
+
+/* Structure describes the groups within each community */
+struct pad_group {
+ int first_pad; /* offset of first pad of the group relative
+ to the community */
+ unsigned int size; /* Size of the group */
+};
+
/* This structure will be used to describe a community or each group within a
* community when multiple groups exist inside a community
*/
@@ -76,6 +90,8 @@ struct pad_community {
const struct reset_mapping *reset_map; /* PADRSTCFG logical to
chipset mapping */
size_t num_reset_vals;
+ const struct pad_group *groups;
+ size_t num_groups;
};
/*