apollolake: Find GPIO bank offset for write protect pin

Specify function to find GPIO bank offset for write protect pin in
Broxton.

BUG=chrome-os-partner:55604
BRANCH=none
TEST=verify crossystem output with and without WP screw.

Change-Id: Ied41f31e59e0dfc699fbcd1b6bb8688f1fea549c
Signed-off-by: sselvar2 <susendra.selvaraj@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/358124
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
sselvar2
2016-06-09 21:20:08 +05:30
committed by chrome-bot
parent 085c20557c
commit bba272a877

View File

@@ -493,6 +493,7 @@ static int FindGpioChipOffsetByLabel(unsigned *gpio_num, unsigned *offset,
char filename[128];
char chiplabel[128];
int match = 0;
unsigned controller_offset = 0;
dir = opendir(GPIO_BASE_PATH);
if (!dir) {
@@ -500,16 +501,21 @@ static int FindGpioChipOffsetByLabel(unsigned *gpio_num, unsigned *offset,
}
while(0 != (ent = readdir(dir))) {
if (1 == sscanf(ent->d_name, "gpiochip%u", offset)) {
if (1 == sscanf(ent->d_name, "gpiochip%u", &controller_offset)) {
/*
* Read the file at gpiochip<O>/label to get the identifier
* for this bank of GPIOs.
*/
snprintf(filename, sizeof(filename), "%s/gpiochip%u/label",
GPIO_BASE_PATH, *offset);
GPIO_BASE_PATH, controller_offset);
if (ReadFileString(chiplabel, sizeof(chiplabel), filename)) {
if (!strncasecmp(chiplabel, name, strlen(name)))
if (!strncasecmp(chiplabel, name, strlen(name))) {
/*
* Store offset when chip label is matched.
*/
*offset = controller_offset;
match++;
}
}
}
}
@@ -629,6 +635,10 @@ static const struct GpioChipset chipsets_supported[] = {
{ "PCH-LP", FindGpioChipOffset },
{ "INT3437:00", FindGpioChipOffsetByLabel },
{ "INT344B:00", FindGpioChipOffsetByLabel },
{ "INT3452:00", FindGpioChipOffsetByLabel }, /* INT3452 are for Apollolake */
{ "INT3452:01", FindGpioChipOffsetByLabel },
{ "INT3452:02", FindGpioChipOffsetByLabel },
{ "INT3452:03", FindGpioChipOffsetByLabel },
{ "BayTrail", BayTrailFindGpioChipOffset },
{ "Braswell", BraswellFindGpioChipOffset },
{ NULL },