From f9acd37d7f15290240d4fb9e365a7b79af57b925 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Wed, 20 Jan 2021 23:25:59 +0100 Subject: mb/google/auron: Use `get_gpios` function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I91424a45ae67186987630b7686102f467f57e7ee Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/49779 Tested-by: build bot (Jenkins) Reviewed-by: Michael Niewöhner --- src/mainboard/google/auron/spd.c | 2 ++ .../google/auron/variants/auron_paine/spd/spd.c | 19 ++++--------------- .../google/auron/variants/auron_yuna/spd/spd.c | 19 ++++--------------- .../google/auron/variants/gandof/spd/spd.c | 19 ++++--------------- src/mainboard/google/auron/variants/lulu/spd/spd.c | 22 ++++------------------ .../google/auron/variants/samus/spd/spd.c | 20 ++++---------------- 6 files changed, 22 insertions(+), 79 deletions(-) diff --git a/src/mainboard/google/auron/spd.c b/src/mainboard/google/auron/spd.c index 20d7498a7b..e5c3dbd955 100644 --- a/src/mainboard/google/auron/spd.c +++ b/src/mainboard/google/auron/spd.c @@ -74,6 +74,8 @@ void fill_spd_for_index(uint8_t spd[], unsigned int spd_index) size_t spd_file_len; uint8_t *spd_file = cbfs_map("spd.bin", &spd_file_len); + printk(BIOS_DEBUG, "SPD index %d\n", spd_index); + if (!spd_file) die("SPD data not found."); diff --git a/src/mainboard/google/auron/variants/auron_paine/spd/spd.c b/src/mainboard/google/auron/variants/auron_paine/spd/spd.c index ba829d0a78..88487d5a5a 100644 --- a/src/mainboard/google/auron/variants/auron_paine/spd/spd.c +++ b/src/mainboard/google/auron/variants/auron_paine/spd/spd.c @@ -19,25 +19,14 @@ /* Copy SPD data for on-board memory */ void mainboard_fill_spd_data(struct pei_data *pei_data) { - int spd_bits[3] = { + const int gpio_vector[] = { SPD_GPIO_BIT0, SPD_GPIO_BIT1, - SPD_GPIO_BIT2 + SPD_GPIO_BIT2, + -1, }; - int spd_gpio[3]; - int spd_index; - spd_gpio[0] = get_gpio(SPD_GPIO_BIT0); - spd_gpio[1] = get_gpio(SPD_GPIO_BIT1); - spd_gpio[2] = get_gpio(SPD_GPIO_BIT2); - - spd_index = spd_gpio[2] << 2 | spd_gpio[1] << 1 | spd_gpio[0]; - - printk(BIOS_DEBUG, "SPD: index %d (GPIO%d=%d GPIO%d=%d GPIO%d=%d)\n", - spd_index, - spd_bits[2], spd_gpio[2], - spd_bits[1], spd_gpio[1], - spd_bits[0], spd_gpio[0]); + const unsigned int spd_index = get_gpios(gpio_vector); fill_spd_for_index(pei_data->spd_data[0][0], spd_index); diff --git a/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c b/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c index ba829d0a78..88487d5a5a 100644 --- a/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c +++ b/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c @@ -19,25 +19,14 @@ /* Copy SPD data for on-board memory */ void mainboard_fill_spd_data(struct pei_data *pei_data) { - int spd_bits[3] = { + const int gpio_vector[] = { SPD_GPIO_BIT0, SPD_GPIO_BIT1, - SPD_GPIO_BIT2 + SPD_GPIO_BIT2, + -1, }; - int spd_gpio[3]; - int spd_index; - spd_gpio[0] = get_gpio(SPD_GPIO_BIT0); - spd_gpio[1] = get_gpio(SPD_GPIO_BIT1); - spd_gpio[2] = get_gpio(SPD_GPIO_BIT2); - - spd_index = spd_gpio[2] << 2 | spd_gpio[1] << 1 | spd_gpio[0]; - - printk(BIOS_DEBUG, "SPD: index %d (GPIO%d=%d GPIO%d=%d GPIO%d=%d)\n", - spd_index, - spd_bits[2], spd_gpio[2], - spd_bits[1], spd_gpio[1], - spd_bits[0], spd_gpio[0]); + const unsigned int spd_index = get_gpios(gpio_vector); fill_spd_for_index(pei_data->spd_data[0][0], spd_index); diff --git a/src/mainboard/google/auron/variants/gandof/spd/spd.c b/src/mainboard/google/auron/variants/gandof/spd/spd.c index 5cd3ddcb15..9c323144e4 100644 --- a/src/mainboard/google/auron/variants/gandof/spd/spd.c +++ b/src/mainboard/google/auron/variants/gandof/spd/spd.c @@ -19,25 +19,14 @@ /* Copy SPD data for on-board memory */ void mainboard_fill_spd_data(struct pei_data *pei_data) { - int spd_bits[3] = { + const int gpio_vector[] = { SPD_GPIO_BIT0, SPD_GPIO_BIT1, - SPD_GPIO_BIT2 + SPD_GPIO_BIT2, + -1, }; - int spd_gpio[3]; - int spd_index; - spd_gpio[0] = get_gpio(SPD_GPIO_BIT0); - spd_gpio[1] = get_gpio(SPD_GPIO_BIT1); - spd_gpio[2] = get_gpio(SPD_GPIO_BIT2); - - spd_index = spd_gpio[2] << 2 | spd_gpio[1] << 1 | spd_gpio[0]; - - printk(BIOS_DEBUG, "SPD: index %d (GPIO%d=%d GPIO%d=%d GPIO%d=%d)\n", - spd_index, - spd_bits[2], spd_gpio[2], - spd_bits[1], spd_gpio[1], - spd_bits[0], spd_gpio[0]); + const unsigned int spd_index = get_gpios(gpio_vector); fill_spd_for_index(pei_data->spd_data[0][0], spd_index); diff --git a/src/mainboard/google/auron/variants/lulu/spd/spd.c b/src/mainboard/google/auron/variants/lulu/spd/spd.c index d80d3c0424..8d43464648 100644 --- a/src/mainboard/google/auron/variants/lulu/spd/spd.c +++ b/src/mainboard/google/auron/variants/lulu/spd/spd.c @@ -20,29 +20,15 @@ /* Copy SPD data for on-board memory */ void mainboard_fill_spd_data(struct pei_data *pei_data) { - int spd_bits[4] = { + const int gpio_vector[] = { SPD_GPIO_BIT0, SPD_GPIO_BIT1, SPD_GPIO_BIT2, - SPD_GPIO_BIT3 + SPD_GPIO_BIT3, + -1, }; - int spd_gpio[4]; - int spd_index; - spd_gpio[0] = get_gpio(SPD_GPIO_BIT0); - spd_gpio[1] = get_gpio(SPD_GPIO_BIT1); - spd_gpio[2] = get_gpio(SPD_GPIO_BIT2); - spd_gpio[3] = get_gpio(SPD_GPIO_BIT3); - - spd_index = (spd_gpio[3] << 3) | (spd_gpio[2] << 2) | - (spd_gpio[1] << 1) | spd_gpio[0]; - - printk(BIOS_DEBUG, "SPD: index %d (GPIO%d=%d GPIO%d=%d GPIO%d=%d GPIO%d=%d)\n", - spd_index, - spd_bits[3], spd_gpio[3], - spd_bits[2], spd_gpio[2], - spd_bits[1], spd_gpio[1], - spd_bits[0], spd_gpio[0]); + const unsigned int spd_index = get_gpios(gpio_vector); /* CH0 */ fill_spd_for_index(pei_data->spd_data[0][0], spd_index); diff --git a/src/mainboard/google/auron/variants/samus/spd/spd.c b/src/mainboard/google/auron/variants/samus/spd/spd.c index 25ff928b6d..06270b8ebb 100644 --- a/src/mainboard/google/auron/variants/samus/spd/spd.c +++ b/src/mainboard/google/auron/variants/samus/spd/spd.c @@ -20,27 +20,15 @@ /* Copy SPD data for on-board memory */ void mainboard_fill_spd_data(struct pei_data *pei_data) { - int spd_bits[4] = { + const int gpio_vector[] = { SPD_GPIO_BIT0, SPD_GPIO_BIT1, SPD_GPIO_BIT2, - SPD_GPIO_BIT3 + SPD_GPIO_BIT3, + -1, }; - int spd_gpio[4]; - int spd_index; - spd_gpio[0] = get_gpio(spd_bits[0]); - spd_gpio[1] = get_gpio(spd_bits[1]); - spd_gpio[2] = get_gpio(spd_bits[2]); - spd_gpio[3] = get_gpio(spd_bits[3]); - - spd_index = (spd_gpio[3] << 3) | (spd_gpio[2] << 2) | - (spd_gpio[1] << 1) | spd_gpio[0]; - - printk(BIOS_DEBUG, "SPD: index %d (GPIO%d=%d GPIO%d=%d " - "GPIO%d=%d GPIO%d=%d)\n", spd_index, - spd_bits[3], spd_gpio[3], spd_bits[2], spd_gpio[2], - spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]); + const unsigned int spd_index = get_gpios(gpio_vector); fill_spd_for_index(pei_data->spd_data[0][0], spd_index); -- cgit v1.2.3