From c445b4fc773296be525123eb472ea27ac807339f Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Thu, 31 Mar 2016 17:27:05 -0700 Subject: chromeos: Simplify fill_lb_gpios even further A long time ago many Chrome OS boards had pages full of duplicated boilerplate code for the fill_lb_gpios() function, and we spent a lot of time bikeshedding a proper solution that passes a table of lb_gpio structs which can be concisely written with a static struct initializer in http://crosreview.com/234648. Unfortunately we never really finished that patch and in the mean time a different solution using the fill_lb_gpio() helper got standardized onto most boards. Still, that solution is not quite as clean and concise as the one we had already designed, and it also wasn't applied consistently to all recent boards (causing more boards with bad code to get added afterwards). This patch switches all boards newer than Link to the better solution and also adds some nicer debug output for the GPIOs while I'm there. If more boards need to be converted from fill_lb_gpio() to this model later (e.g. from a branch), it's quite easy to do with: s/fill_lb_gpio(gpio++,\n\?\s*\([^,]*\),\n\?\s*\([^,]*\),\n\?\s*\([^,]*\),\n\?\s*\([^,]*\));/\t{\1, \2, \4, \3},/ Based on a patch by Furquan Shaikh . BUG=None BRANCH=None TEST=Booted on Oak. Ran abuild -x. Change-Id: I449974d1c75c8ed187f5e10935495b2f03725811 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/14226 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks --- src/mainboard/google/auron/chromeos.c | 39 +++--------- src/mainboard/google/auron_paine/chromeos.c | 26 +++----- src/mainboard/google/bolt/chromeos.c | 26 +++----- src/mainboard/google/chell/chromeos.c | 29 ++++----- src/mainboard/google/cyan/chromeos.c | 25 +++----- src/mainboard/google/falco/chromeos.c | 26 +++----- src/mainboard/google/glados/chromeos.c | 29 ++++----- src/mainboard/google/guado/chromeos.c | 26 +++----- src/mainboard/google/jecht/chromeos.c | 28 ++++----- src/mainboard/google/lars/chromeos.c | 29 ++++----- src/mainboard/google/nyan/chromeos.c | 71 +++------------------ src/mainboard/google/nyan_big/chromeos.c | 71 +++------------------ src/mainboard/google/nyan_blaze/chromeos.c | 71 +++------------------ src/mainboard/google/oak/chromeos.c | 72 ++++----------------- src/mainboard/google/panther/chromeos.c | 26 +++----- src/mainboard/google/peppy/chromeos.c | 26 +++----- src/mainboard/google/rambi/chromeos.c | 26 +++----- src/mainboard/google/rush/chromeos.c | 63 +++---------------- src/mainboard/google/rush_ryu/chromeos.c | 68 ++++---------------- src/mainboard/google/samus/chromeos.c | 26 +++----- src/mainboard/google/slippy/chromeos.c | 26 +++----- src/mainboard/google/smaug/chromeos.c | 66 +++----------------- src/mainboard/google/storm/chromeos.c | 20 +++--- src/mainboard/google/tidus/chromeos.c | 26 +++----- src/mainboard/google/veyron/chromeos.c | 90 ++++----------------------- src/mainboard/google/veyron_brain/chromeos.c | 55 +++------------- src/mainboard/google/veyron_danger/chromeos.c | 56 +++-------------- src/mainboard/google/veyron_emile/chromeos.c | 46 +++----------- src/mainboard/google/veyron_mickey/chromeos.c | 46 +++----------- src/mainboard/google/veyron_rialto/chromeos.c | 60 ++++-------------- src/mainboard/google/veyron_romy/chromeos.c | 55 +++------------- src/mainboard/intel/kunimitsu/chromeos.c | 29 ++++----- src/mainboard/intel/strago/chromeos.c | 25 +++----- src/mainboard/intel/wtm2/chromeos.c | 23 +++---- 34 files changed, 333 insertions(+), 1093 deletions(-) (limited to 'src/mainboard') diff --git a/src/mainboard/google/auron/chromeos.c b/src/mainboard/google/auron/chromeos.c index 2f0e0254eb..4447ddcbbb 100644 --- a/src/mainboard/google/auron/chromeos.c +++ b/src/mainboard/google/auron/chromeos.c @@ -29,38 +29,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - -/*static void fill_lb_gpio(struct lb_gpio *gpio, int num, - int polarity, const char *name, int force) -{ - memset(gpio, 0, sizeof(*gpio)); - gpio->port = num; - gpio->polarity = polarity; - if (force >= 0) - gpio->value = force; - else if (num >= 0) - gpio->value = get_gpio(num); - strncpy((char *)gpio->name, name, GPIO_MAX_NAME_LENGTH); -} -*/ void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, CROS_WP_GPIO, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {CROS_WP_GPIO, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/auron_paine/chromeos.c b/src/mainboard/google/auron_paine/chromeos.c index 160cc1a475..4447ddcbbb 100644 --- a/src/mainboard/google/auron_paine/chromeos.c +++ b/src/mainboard/google/auron_paine/chromeos.c @@ -29,25 +29,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, CROS_WP_GPIO, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {CROS_WP_GPIO, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/bolt/chromeos.c b/src/mainboard/google/bolt/chromeos.c index ff0a1f748c..4bf2a784f2 100644 --- a/src/mainboard/google/bolt/chromeos.c +++ b/src/mainboard/google/bolt/chromeos.c @@ -32,25 +32,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, CROS_WP_GPIO, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {CROS_WP_GPIO, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/chell/chromeos.c b/src/mainboard/google/chell/chromeos.c index 853fc7f400..f0b3613f55 100644 --- a/src/mainboard/google/chell/chromeos.c +++ b/src/mainboard/google/chell/chromeos.c @@ -33,24 +33,17 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *start_gpio = gpios->gpios; - struct lb_gpio *gpio = start_gpio; - - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", - get_write_protect_state()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); - fill_lb_gpio(gpio++, GPIO_EC_IN_RW, ACTIVE_HIGH, "EC in RW", - gpio_get(GPIO_EC_IN_RW)); - - gpios->count = gpio - start_gpio; - gpios->size = sizeof(*gpios) + (gpios->count * sizeof(*gpio)); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + {GPIO_EC_IN_RW, ACTIVE_HIGH, + gpio_get(GPIO_EC_IN_RW), "EC in RW"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif /* ENV_RAMSTAGE */ diff --git a/src/mainboard/google/cyan/chromeos.c b/src/mainboard/google/cyan/chromeos.c index 08d7363cb6..a038d1ff7f 100644 --- a/src/mainboard/google/cyan/chromeos.c +++ b/src/mainboard/google/cyan/chromeos.c @@ -33,27 +33,20 @@ #if ENV_RAMSTAGE #include -#define GPIO_COUNT 6 #define ACTIVE_LOW 0 #define ACTIVE_HIGH 1 void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", - get_write_protect_state()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - recovery_mode_enabled()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, + {-1, ACTIVE_HIGH, recovery_mode_enabled(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif /* ENV_RAMSTAGE */ diff --git a/src/mainboard/google/falco/chromeos.c b/src/mainboard/google/falco/chromeos.c index f0e6a5aa85..1659d9cc87 100644 --- a/src/mainboard/google/falco/chromeos.c +++ b/src/mainboard/google/falco/chromeos.c @@ -29,25 +29,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, 58, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {58, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/glados/chromeos.c b/src/mainboard/google/glados/chromeos.c index 853fc7f400..f0b3613f55 100644 --- a/src/mainboard/google/glados/chromeos.c +++ b/src/mainboard/google/glados/chromeos.c @@ -33,24 +33,17 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *start_gpio = gpios->gpios; - struct lb_gpio *gpio = start_gpio; - - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", - get_write_protect_state()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); - fill_lb_gpio(gpio++, GPIO_EC_IN_RW, ACTIVE_HIGH, "EC in RW", - gpio_get(GPIO_EC_IN_RW)); - - gpios->count = gpio - start_gpio; - gpios->size = sizeof(*gpios) + (gpios->count * sizeof(*gpio)); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + {GPIO_EC_IN_RW, ACTIVE_HIGH, + gpio_get(GPIO_EC_IN_RW), "EC in RW"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif /* ENV_RAMSTAGE */ diff --git a/src/mainboard/google/guado/chromeos.c b/src/mainboard/google/guado/chromeos.c index 094447de0d..13fbfc3dea 100644 --- a/src/mainboard/google/guado/chromeos.c +++ b/src/mainboard/google/guado/chromeos.c @@ -33,24 +33,18 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, GPIO_SPI_WP, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, GPIO_REC_MODE, ACTIVE_LOW, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", 1); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {GPIO_SPI_WP, ACTIVE_HIGH, 0, "write protect"}, + {GPIO_REC_MODE, ACTIVE_LOW, + get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, 1, "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/jecht/chromeos.c b/src/mainboard/google/jecht/chromeos.c index 84a6abcf50..cc19666d15 100644 --- a/src/mainboard/google/jecht/chromeos.c +++ b/src/mainboard/google/jecht/chromeos.c @@ -33,25 +33,19 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, GPIO_SPI_WP, ACTIVE_HIGH, "write protect", - get_gpio(GPIO_SPI_WP)); - fill_lb_gpio(gpio++, GPIO_REC_MODE, ACTIVE_LOW, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", 1); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {GPIO_SPI_WP, ACTIVE_HIGH, + get_gpio(GPIO_SPI_WP), "write protect"}, + {GPIO_REC_MODE, ACTIVE_LOW, + get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, 1, "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/lars/chromeos.c b/src/mainboard/google/lars/chromeos.c index 1cb97679f9..1e0bd3c093 100644 --- a/src/mainboard/google/lars/chromeos.c +++ b/src/mainboard/google/lars/chromeos.c @@ -33,24 +33,17 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *start_gpio = gpios->gpios; - struct lb_gpio *gpio = start_gpio; - - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", - get_write_protect_state()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); - fill_lb_gpio(gpio++, GPIO_EC_IN_RW, ACTIVE_HIGH, "EC in RW", - gpio_get(GPIO_EC_IN_RW)); - - gpios->count = gpio - start_gpio; - gpios->size = sizeof(*gpios) + (gpios->count * sizeof(*gpio)); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + {GPIO_EC_IN_RW, ACTIVE_HIGH, + gpio_get(GPIO_EC_IN_RW), "EC in RW"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif /* ENV_RAMSTAGE */ diff --git a/src/mainboard/google/nyan/chromeos.c b/src/mainboard/google/nyan/chromeos.c index 5b423907f4..9d5d6b248e 100644 --- a/src/mainboard/google/nyan/chromeos.c +++ b/src/mainboard/google/nyan/chromeos.c @@ -24,67 +24,16 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO(R1); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO(R1)); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Lid: active high */ - gpios->gpios[count].port = GPIO(R4); - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH); - count++; - - /* Power: active low */ - gpios->gpios[count].port = GPIO(Q0); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: virtual GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC in RW: active high */ - gpios->gpios[count].port = GPIO(U4); - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC in RW", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: active low (output) */ - gpios->gpios[count].port = GPIO(I5); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO(R1), ACTIVE_LOW, gpio_get(GPIO(R1)), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {GPIO(R4), ACTIVE_HIGH, -1, "lid"}, + {GPIO(Q0), ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO(U4), ACTIVE_HIGH, -1, "EC in RW"}, + {GPIO(I5), ACTIVE_LOW, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/nyan_big/chromeos.c b/src/mainboard/google/nyan_big/chromeos.c index a11c493415..e9df4e3bda 100644 --- a/src/mainboard/google/nyan_big/chromeos.c +++ b/src/mainboard/google/nyan_big/chromeos.c @@ -24,67 +24,16 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO(R1); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO(R1)); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Lid: active high */ - gpios->gpios[count].port = GPIO(R4); - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH); - count++; - - /* Power: active low */ - gpios->gpios[count].port = GPIO(Q0); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: virtual GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC in RW: active high */ - gpios->gpios[count].port = GPIO(U4); - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC in RW", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: active low (output) */ - gpios->gpios[count].port = GPIO(I5); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO(R1), ACTIVE_LOW, gpio_get(GPIO(R1)), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {GPIO(R4), ACTIVE_HIGH, -1, "lid"}, + {GPIO(Q0), ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO(U4), ACTIVE_HIGH, -1, "EC in RW"}, + {GPIO(I5), ACTIVE_LOW, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/nyan_blaze/chromeos.c b/src/mainboard/google/nyan_blaze/chromeos.c index 6d3e0e99a8..eddf15005b 100644 --- a/src/mainboard/google/nyan_blaze/chromeos.c +++ b/src/mainboard/google/nyan_blaze/chromeos.c @@ -28,67 +28,16 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO(R1); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO(R1)); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Lid: active high */ - gpios->gpios[count].port = GPIO(R4); - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH); - count++; - - /* Power: active low */ - gpios->gpios[count].port = GPIO(Q0); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: virtual GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC in RW: active high */ - gpios->gpios[count].port = GPIO(U4); - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC in RW", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: active low (output) */ - gpios->gpios[count].port = GPIO(I5); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO(R1), ACTIVE_LOW, gpio_get(GPIO(R1)), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {GPIO(R4), ACTIVE_HIGH, -1, "lid"}, + {GPIO(Q0), ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO(U4), ACTIVE_HIGH, -1, "EC in RW"}, + {GPIO(I5), ACTIVE_LOW, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/oak/chromeos.c b/src/mainboard/google/oak/chromeos.c index 8ea975a397..ea6d21ffc3 100644 --- a/src/mainboard/google/oak/chromeos.c +++ b/src/mainboard/google/oak/chromeos.c @@ -37,67 +37,17 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write protect : active low */ - gpios->gpios[count].port = WRITE_PROTECT; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(WRITE_PROTECT); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Lid: active high */ - gpios->gpios[count].port = LID; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH); - count++; - - /* Power: active high */ - gpios->gpios[count].port = POWER_BUTTON; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: virtual GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC in RW: active high */ - gpios->gpios[count].port = EC_IN_RW; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC in RW", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC interrupt: GPIO active low */ - gpios->gpios[count].port = EC_IRQ; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC interrupt", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {WRITE_PROTECT, ACTIVE_LOW, + gpio_get(WRITE_PROTECT), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {LID, ACTIVE_HIGH, -1, "lid"}, + {POWER_BUTTON, ACTIVE_HIGH, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {EC_IN_RW, ACTIVE_HIGH, -1, "EC in RW"}, + {EC_IRQ, ACTIVE_LOW, -1, "EC interrupt"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/panther/chromeos.c b/src/mainboard/google/panther/chromeos.c index 17917b1a8e..014bb7e7e4 100644 --- a/src/mainboard/google/panther/chromeos.c +++ b/src/mainboard/google/panther/chromeos.c @@ -32,24 +32,18 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, GPIO_SPI_WP, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, GPIO_REC_MODE, ACTIVE_LOW, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", 1); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {GPIO_SPI_WP, ACTIVE_HIGH, 0, "write protect"}, + {GPIO_REC_MODE, ACTIVE_LOW, + get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, 1, "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/peppy/chromeos.c b/src/mainboard/google/peppy/chromeos.c index f0e6a5aa85..1659d9cc87 100644 --- a/src/mainboard/google/peppy/chromeos.c +++ b/src/mainboard/google/peppy/chromeos.c @@ -29,25 +29,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, 58, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {58, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/rambi/chromeos.c b/src/mainboard/google/rambi/chromeos.c index 3f2e9c0a0d..f2a2ab7abb 100644 --- a/src/mainboard/google/rambi/chromeos.c +++ b/src/mainboard/google/rambi/chromeos.c @@ -31,25 +31,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", - get_write_protect_state()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - recovery_mode_enabled()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, + {-1, ACTIVE_HIGH, recovery_mode_enabled(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/rush/chromeos.c b/src/mainboard/google/rush/chromeos.c index cc2cfda21b..9ebc58de3c 100644 --- a/src/mainboard/google/rush/chromeos.c +++ b/src/mainboard/google/rush/chromeos.c @@ -23,59 +23,16 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO(R1); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO(R1)); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Lid: active high */ - gpios->gpios[count].port = GPIO(R4); - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH); - count++; - - /* Power: active low */ - gpios->gpios[count].port = GPIO(Q0); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: virtual GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: active low (output) */ - gpios->gpios[count].port = GPIO(I5); - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO(R1), ACTIVE_LOW, gpio_get(GPIO(R1)), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {GPIO(R4), ACTIVE_HIGH, -1, "lid"}, + {GPIO(Q0), ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO(I5), ACTIVE_LOW, -1, "reset"}, + }; + + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/rush_ryu/chromeos.c b/src/mainboard/google/rush_ryu/chromeos.c index 213fd858f1..9f4ec6bb7c 100644 --- a/src/mainboard/google/rush_ryu/chromeos.c +++ b/src/mainboard/google/rush_ryu/chromeos.c @@ -33,62 +33,18 @@ static inline uint32_t get_pwr_btn_polarity(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = WRITE_PROTECT_L; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(WRITE_PROTECT_L); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* TODO(adurbin): add lid switch */ - - /* Power: active low / high depending on board id */ - gpios->gpios[count].port = POWER_BUTTON; - gpios->gpios[count].polarity = get_pwr_btn_polarity(); - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: virtual GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC in RW: active high */ - gpios->gpios[count].port = EC_IN_RW; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC in RW", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: active low (output) */ - gpios->gpios[count].port = AP_SYS_RESET_L; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {WRITE_PROTECT_L, ACTIVE_LOW, gpio_get(WRITE_PROTECT_L), + "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + /* TODO(adurbin): add lid switch */ + {POWER_BUTTON, get_pwr_btn_polarity(), -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {EC_IN_RW, ACTIVE_HIGH, -1, "EC in RW"}, + {AP_SYS_RESET_L, ACTIVE_LOW, -1, "reset"}, + }; + + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/samus/chromeos.c b/src/mainboard/google/samus/chromeos.c index 327690c5b7..51f2f2ebf6 100644 --- a/src/mainboard/google/samus/chromeos.c +++ b/src/mainboard/google/samus/chromeos.c @@ -31,25 +31,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, CROS_WP_GPIO, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {CROS_WP_GPIO, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/slippy/chromeos.c b/src/mainboard/google/slippy/chromeos.c index f0e6a5aa85..1659d9cc87 100644 --- a/src/mainboard/google/slippy/chromeos.c +++ b/src/mainboard/google/slippy/chromeos.c @@ -29,25 +29,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, 58, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {58, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/smaug/chromeos.c b/src/mainboard/google/smaug/chromeos.c index 088a036e75..8688937fd6 100644 --- a/src/mainboard/google/smaug/chromeos.c +++ b/src/mainboard/google/smaug/chromeos.c @@ -25,62 +25,16 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = WRITE_PROTECT_L; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(WRITE_PROTECT_L); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* TODO(furquan): add lid switch */ - - /* Power: active low / high depending on board id */ - gpios->gpios[count].port = POWER_BUTTON; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: virtual GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC in RW: active high */ - gpios->gpios[count].port = EC_IN_RW; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC in RW", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: active low (output) */ - gpios->gpios[count].port = AP_SYS_RESET_L; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {WRITE_PROTECT_L, ACTIVE_LOW, + gpio_get(WRITE_PROTECT_L), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {POWER_BUTTON, ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {EC_IN_RW, ACTIVE_HIGH, -1, "EC in RW"}, + {AP_SYS_RESET_L, ACTIVE_LOW, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/storm/chromeos.c b/src/mainboard/google/storm/chromeos.c index 2640c6a253..a379280ca5 100644 --- a/src/mainboard/google/storm/chromeos.c +++ b/src/mainboard/google/storm/chromeos.c @@ -42,18 +42,14 @@ static int read_gpio(gpio_t gpio_num) void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - const int GPIO_COUNT = 5; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, DEV_SW, ACTIVE_LOW, "developer", read_gpio(DEV_SW)); - fill_lb_gpio(gpio++, REC_SW, ACTIVE_LOW, "recovery", read_gpio(REC_SW)); - fill_lb_gpio(gpio++, WP_SW, ACTIVE_LOW, "write protect", read_gpio(WP_SW)); - fill_lb_gpio(gpio++, -1, ACTIVE_LOW, "power", 1); - fill_lb_gpio(gpio++, -1, ACTIVE_LOW, "lid", 0); + struct lb_gpio chromeos_gpios[] = { + {DEV_SW, ACTIVE_LOW, read_gpio(DEV_SW), "developer"}, + {REC_SW, ACTIVE_LOW, read_gpio(REC_SW), "recovery"}, + {WP_SW, ACTIVE_LOW, read_gpio(WP_SW), "write protect"}, + {-1, ACTIVE_LOW, 1, "power"}, + {-1, ACTIVE_LOW, 0, "lid"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/tidus/chromeos.c b/src/mainboard/google/tidus/chromeos.c index 094447de0d..13fbfc3dea 100644 --- a/src/mainboard/google/tidus/chromeos.c +++ b/src/mainboard/google/tidus/chromeos.c @@ -33,24 +33,18 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, GPIO_SPI_WP, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, GPIO_REC_MODE, ACTIVE_LOW, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", 1); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {GPIO_SPI_WP, ACTIVE_HIGH, 0, "write protect"}, + {GPIO_REC_MODE, ACTIVE_LOW, + get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, 1, "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif diff --git a/src/mainboard/google/veyron/chromeos.c b/src/mainboard/google/veyron/chromeos.c index c9450ec805..42be8ca5ff 100644 --- a/src/mainboard/google/veyron/chromeos.c +++ b/src/mainboard/google/veyron/chromeos.c @@ -41,83 +41,19 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO_WP.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_WP); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active low */ - gpios->gpios[count].port = GPIO_RECOVERY.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Lid: active high */ - gpios->gpios[count].port = GPIO_LID.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH); - count++; - - /* Power:GPIO active high */ - gpios->gpios[count].port = GPIO_POWER.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC in RW: GPIO active high */ - gpios->gpios[count].port = GPIO_ECINRW.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC in RW", - GPIO_MAX_NAME_LENGTH); - count++; - - /* EC interrupt: GPIO active high */ - gpios->gpios[count].port = GPIO_ECIRQ.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "EC interrupt", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_RESET.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Backlight: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_BACKLIGHT.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "backlight", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO_WP.raw, ACTIVE_LOW, gpio_get(GPIO_WP), "write protect"}, + {GPIO_RECOVERY.raw, ACTIVE_LOW, + get_recovery_mode_switch(), "recovery"}, + {GPIO_LID.raw, ACTIVE_HIGH, -1, "lid"}, + {GPIO_POWER.raw, ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO_ECINRW.raw, ACTIVE_HIGH, -1, "EC in RW"}, + {GPIO_ECIRQ.raw, ACTIVE_LOW, -1, "EC interrupt"}, + {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"}, + {GPIO_BACKLIGHT.raw, ACTIVE_HIGH, -1, "backlight"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/veyron_brain/chromeos.c b/src/mainboard/google/veyron_brain/chromeos.c index ef6cf866c6..1e6d35bc51 100644 --- a/src/mainboard/google/veyron_brain/chromeos.c +++ b/src/mainboard/google/veyron_brain/chromeos.c @@ -34,52 +34,15 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO_WP.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_WP); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active low */ - gpios->gpios[count].port = GPIO_RECOVERY.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_RECOVERY); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Power Button: GPIO active low */ - gpios->gpios[count].port = GPIO_POWER.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_RESET.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO_WP.raw, ACTIVE_LOW, gpio_get(GPIO_WP), "write protect"}, + {GPIO_RECOVERY.raw, ACTIVE_LOW, + gpio_get(GPIO_RECOVERY), "recovery"}, + {GPIO_POWER.raw, ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/veyron_danger/chromeos.c b/src/mainboard/google/veyron_danger/chromeos.c index bc55717f7a..4166654fee 100644 --- a/src/mainboard/google/veyron_danger/chromeos.c +++ b/src/mainboard/google/veyron_danger/chromeos.c @@ -36,52 +36,16 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO_WP.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_WP); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active low */ - gpios->gpios[count].port = GPIO_RECOVERY.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_RECOVERY); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Power Button: GPIO active low */ - gpios->gpios[count].port = GPIO_POWER.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: Danger has a physical dev switch that is active low */ - gpios->gpios[count].port = GPIO_DEV_MODE.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_RESET.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO_WP.raw, ACTIVE_LOW, gpio_get(GPIO_WP), "write protect"}, + {GPIO_RECOVERY.raw, ACTIVE_LOW, + gpio_get(GPIO_RECOVERY), "recovery"}, + {GPIO_POWER.raw, ACTIVE_LOW, -1, "power"}, + {GPIO_DEV_MODE.raw, ACTIVE_HIGH, + get_developer_mode_switch(), "developer"}, + {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/veyron_emile/chromeos.c b/src/mainboard/google/veyron_emile/chromeos.c index 04dc5d2db9..5cb9ec4c30 100644 --- a/src/mainboard/google/veyron_emile/chromeos.c +++ b/src/mainboard/google/veyron_emile/chromeos.c @@ -32,44 +32,14 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO_WP.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_WP); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active low */ - gpios->gpios[count].port = GPIO_RECOVERY.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_RECOVERY); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_RESET.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO_WP.raw, ACTIVE_LOW, gpio_get(GPIO_WP), "write protect"}, + {GPIO_RECOVERY.raw, ACTIVE_LOW, + gpio_get(GPIO_RECOVERY), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/veyron_mickey/chromeos.c b/src/mainboard/google/veyron_mickey/chromeos.c index 04dc5d2db9..5cb9ec4c30 100644 --- a/src/mainboard/google/veyron_mickey/chromeos.c +++ b/src/mainboard/google/veyron_mickey/chromeos.c @@ -32,44 +32,14 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO_WP.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_WP); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active low */ - gpios->gpios[count].port = GPIO_RECOVERY.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_RECOVERY); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_RESET.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO_WP.raw, ACTIVE_LOW, gpio_get(GPIO_WP), "write protect"}, + {GPIO_RECOVERY.raw, ACTIVE_LOW, + gpio_get(GPIO_RECOVERY), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/veyron_rialto/chromeos.c b/src/mainboard/google/veyron_rialto/chromeos.c index 9099584cde..74f84d4525 100644 --- a/src/mainboard/google/veyron_rialto/chromeos.c +++ b/src/mainboard/google/veyron_rialto/chromeos.c @@ -37,55 +37,17 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO_WP.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_WP); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active low */ - /* Note for early development, we want to support both servo and - * pushkey recovery buttons in firmware boot stages. - */ - gpios->gpios[count].port = GPIO_RECOVERY_PUSHKEY.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = !get_recovery_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Power Button: GPIO active low */ - gpios->gpios[count].port = GPIO_POWER.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_RESET.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO_WP.raw, ACTIVE_LOW, gpio_get(GPIO_WP), "write protect"}, + /* Note for early development, we want to support both servo + * and pushkey recovery buttons in firmware boot stages. */ + {GPIO_RECOVERY_PUSHKEY.raw, ACTIVE_LOW, + !get_recovery_mode_switch(), "recovery"}, + {GPIO_POWER.raw, ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/google/veyron_romy/chromeos.c b/src/mainboard/google/veyron_romy/chromeos.c index ef6cf866c6..1e6d35bc51 100644 --- a/src/mainboard/google/veyron_romy/chromeos.c +++ b/src/mainboard/google/veyron_romy/chromeos.c @@ -34,52 +34,15 @@ void setup_chromeos_gpios(void) void fill_lb_gpios(struct lb_gpios *gpios) { - int count = 0; - - /* Write Protect: active low */ - gpios->gpios[count].port = GPIO_WP.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_WP); - strncpy((char *)gpios->gpios[count].name, "write protect", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Recovery: active low */ - gpios->gpios[count].port = GPIO_RECOVERY.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = gpio_get(GPIO_RECOVERY); - strncpy((char *)gpios->gpios[count].name, "recovery", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Power Button: GPIO active low */ - gpios->gpios[count].port = GPIO_POWER.raw; - gpios->gpios[count].polarity = ACTIVE_LOW; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "power", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Developer: GPIO active high */ - gpios->gpios[count].port = -1; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = get_developer_mode_switch(); - strncpy((char *)gpios->gpios[count].name, "developer", - GPIO_MAX_NAME_LENGTH); - count++; - - /* Reset: GPIO active high (output) */ - gpios->gpios[count].port = GPIO_RESET.raw; - gpios->gpios[count].polarity = ACTIVE_HIGH; - gpios->gpios[count].value = -1; - strncpy((char *)gpios->gpios[count].name, "reset", - GPIO_MAX_NAME_LENGTH); - count++; - - gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio)); - gpios->count = count; - - printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size); + struct lb_gpio chromeos_gpios[] = { + {GPIO_WP.raw, ACTIVE_LOW, gpio_get(GPIO_WP), "write protect"}, + {GPIO_RECOVERY.raw, ACTIVE_LOW, + gpio_get(GPIO_RECOVERY), "recovery"}, + {GPIO_POWER.raw, ACTIVE_LOW, -1, "power"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } int get_developer_mode_switch(void) diff --git a/src/mainboard/intel/kunimitsu/chromeos.c b/src/mainboard/intel/kunimitsu/chromeos.c index 1cb97679f9..1e0bd3c093 100644 --- a/src/mainboard/intel/kunimitsu/chromeos.c +++ b/src/mainboard/intel/kunimitsu/chromeos.c @@ -33,24 +33,17 @@ void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *start_gpio = gpios->gpios; - struct lb_gpio *gpio = start_gpio; - - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", - get_write_protect_state()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - get_recovery_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", - get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); - fill_lb_gpio(gpio++, GPIO_EC_IN_RW, ACTIVE_HIGH, "EC in RW", - gpio_get(GPIO_EC_IN_RW)); - - gpios->count = gpio - start_gpio; - gpios->size = sizeof(*gpios) + (gpios->count * sizeof(*gpio)); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, + {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + {GPIO_EC_IN_RW, ACTIVE_HIGH, + gpio_get(GPIO_EC_IN_RW), "EC in RW"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif /* ENV_RAMSTAGE */ diff --git a/src/mainboard/intel/strago/chromeos.c b/src/mainboard/intel/strago/chromeos.c index 741933fccb..2cc092dc8e 100644 --- a/src/mainboard/intel/strago/chromeos.c +++ b/src/mainboard/intel/strago/chromeos.c @@ -32,27 +32,20 @@ #if ENV_RAMSTAGE #include -#define GPIO_COUNT 6 #define ACTIVE_LOW 0 #define ACTIVE_HIGH 1 void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", - get_write_protect_state()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", - recovery_mode_enabled()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", - get_developer_mode_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", get_lid_switch()); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, get_write_protect_state(), "write protect"}, + {-1, ACTIVE_HIGH, recovery_mode_enabled(), "recovery"}, + {-1, ACTIVE_HIGH, get_developer_mode_switch(), "developer"}, + {-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif /* ENV_RAMSTAGE */ diff --git a/src/mainboard/intel/wtm2/chromeos.c b/src/mainboard/intel/wtm2/chromeos.c index a06ebcf66d..feee0cbc32 100644 --- a/src/mainboard/intel/wtm2/chromeos.c +++ b/src/mainboard/intel/wtm2/chromeos.c @@ -27,22 +27,17 @@ #ifndef __PRE_RAM__ #include -#define GPIO_COUNT 6 - void fill_lb_gpios(struct lb_gpios *gpios) { - struct lb_gpio *gpio; - - gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); - gpios->count = GPIO_COUNT; - - gpio = gpios->gpios; - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "write protect", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "recovery", REC_MODE_SETTING); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "developer", DEV_MODE_SETTING); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "lid", 1); // force open - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "power", 0); - fill_lb_gpio(gpio++, -1, ACTIVE_HIGH, "oprom", gfx_get_init_done()); + struct lb_gpio chromeos_gpios[] = { + {-1, ACTIVE_HIGH, 0, "write protect"}, + {-1, ACTIVE_HIGH, REC_MODE_SETTING, "recovery"}, + {-1, ACTIVE_HIGH, DEV_MODE_SETTING, "developer"}, + {-1, ACTIVE_HIGH, 1, "lid"}, // force open + {-1, ACTIVE_HIGH, 0, "power"}, + {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } #endif -- cgit v1.2.3