storm: do not flood console with the gpio read values
In case a verified boot button is polled, the console is flooded with
repeating messages reporting the same button status.
Add the previously reported value to the gpio_desc structure to allow
reporting only change n state. To avoid initializing the stored value to
non-zero, store the '<read value> + 1', this way the valid values are 1 and 2,
so the uninitilized stored value (set to zero) will guarantee to trigger the
button status report.
BRANCH=storm
BUG=chrome-os-partner:36059
TEST=with the next patch applied verified that only the changes in the
recovery button state are reported on the coreboot console.
Change-Id: I0d6682e2ff418160fc545643a4dfed401b7e4c0b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251710
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/src/mainboard/google/storm/chromeos.c b/src/mainboard/google/storm/chromeos.c
index 819aab5..57e865d 100644
--- a/src/mainboard/google/storm/chromeos.c
+++ b/src/mainboard/google/storm/chromeos.c
@@ -30,6 +30,7 @@
gpio_t gpio_num;
const char *gpio_name;
uint32_t fake_value;
+ int last_reported;
};
/* Actual GPIO switch names */
@@ -37,7 +38,7 @@
#define RECOVERY_GPIO_NAME "recovery"
#define WRITE_PROTECT_GPIO_NAME "write protect"
-static const struct gpio_desc descriptors[] = {
+static struct gpio_desc descriptors[] = {
{ 15, DEVELOPER_GPIO_NAME },
{ 16, RECOVERY_GPIO_NAME },
{ 17, WRITE_PROTECT_GPIO_NAME },
@@ -45,7 +46,7 @@
{ FAKE_GPIO_NUM, "lid", 0 } /* Lid always open. */
};
-static void fill_lb_gpio(struct lb_gpio *pgpio, const struct gpio_desc *pdesc)
+static void fill_lb_gpio(struct lb_gpio *pgpio, struct gpio_desc *pdesc)
{
gpio_t gpio_num = pdesc->gpio_num;
@@ -61,8 +62,11 @@
pgpio->polarity = ACTIVE_LOW;
strncpy((char *)pgpio->name, pdesc->gpio_name, sizeof(pgpio->name));
- printk(BIOS_INFO, "%s: %s: port %d value %d\n",
- __func__, pgpio->name, pgpio->port, pgpio->value);
+ if (pdesc->last_reported != (pgpio->value + 1)) {
+ pdesc->last_reported = (pgpio->value + 1);
+ printk(BIOS_INFO, "%s: %s: port %d value %d\n",
+ __func__, pgpio->name, pgpio->port, pgpio->value);
+ }
}
void fill_lb_gpios(struct lb_gpios *gpios)