diff options
author | Julius Werner <jwerner@chromium.org> | 2016-03-31 17:27:05 -0700 |
---|---|---|
committer | David Hendricks <dhendrix@chromium.org> | 2016-04-05 00:50:56 +0200 |
commit | c445b4fc773296be525123eb472ea27ac807339f (patch) | |
tree | f4fc3f0c33a190d3af5b4525bdad76131ed3ff5d /src/mainboard/google/glados | |
parent | e03627095352eb468661994e74ddfc5aa0f25600 (diff) |
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 <furquan@google.com>.
BUG=None
BRANCH=None
TEST=Booted on Oak. Ran abuild -x.
Change-Id: I449974d1c75c8ed187f5e10935495b2f03725811
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/14226
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'src/mainboard/google/glados')
-rw-r--r-- | src/mainboard/google/glados/chromeos.c | 29 |
1 files changed, 11 insertions, 18 deletions
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 */ |