diff options
author | Ruihai Zhou <zhouruihai@huaqin.corp-partner.google.com> | 2023-03-30 17:54:12 +0800 |
---|---|---|
committer | Rex-BC Chen <rex-bc.chen@mediatek.com> | 2023-04-27 05:35:06 +0000 |
commit | d0b13a4d962213d88e684f5c1d422b40cb4606d4 (patch) | |
tree | 98ebea93305febd64e0abe12df3e6bb7fb5c7017 /src/mainboard | |
parent | 121d3d57adc35ed34204f983a72590f978939b1c (diff) |
mb/google/corsola: Report SKU and panel ID for unprovisioned devices
The MIPI panels will be used on the detachable variant starmie, and
there will be different MIPI panels used on starmie. In order to make
the different panels functional on unprovisioned devices, it needs
to pass the SKU ID and panel ID to the payload to load the matched
device tree for kernel. From the schematic, the starmie variant
will read the LCM ID from ADC channel 5.
BRANCH=corsola
BUG=b:275470328
TEST=boot starmie and see FW screen display
Signed-off-by: Ruihai Zhou <zhouruihai@huaqin.corp-partner.google.com>
Change-Id: I6339dc3c177fb8982f77fb3bd32dc00da735fce4
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74135
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: cong yang <yangcong5@huaqin.corp-partner.google.com>
Diffstat (limited to 'src/mainboard')
-rw-r--r-- | src/mainboard/google/corsola/boardid.c | 71 | ||||
-rw-r--r-- | src/mainboard/google/corsola/display.h | 1 |
2 files changed, 63 insertions, 9 deletions
diff --git a/src/mainboard/google/corsola/boardid.c b/src/mainboard/google/corsola/boardid.c index 96031ef408..a0c08abb54 100644 --- a/src/mainboard/google/corsola/boardid.c +++ b/src/mainboard/google/corsola/boardid.c @@ -6,6 +6,8 @@ #include <ec/google/chromeec/ec.h> #include <soc/auxadc.h> +#include "display.h" + /* board_id is provided by ec/google/chromeec/ec_boardid.c */ #define ADC_LEVELS 12 @@ -19,6 +21,22 @@ enum { SKU_ID_HIGH_CHANNEL = 5, }; +static const unsigned int lcm_voltages[ADC_LEVELS] = { + /* ID : Voltage (unit: uV) */ + [0] = 0, + [1] = 283000, + [2] = 394000, + [3] = 490000, + [4] = 640000, + [5] = 712000, + [6] = 800000, + [7] = 867000, + [8] = 960000, + [9] = 1070000, + [10] = 1190000, + [11] = 1434000, +}; + static const unsigned int ram_voltages[ADC_LEVELS] = { /* ID : Voltage (unit: uV) */ [0] = 74300, @@ -42,12 +60,26 @@ static const unsigned int *adc_voltages[] = { [SKU_ID_HIGH_CHANNEL] = ram_voltages, }; +static const unsigned int *adc_voltages_detachable[] = { + [RAM_ID_LOW_CHANNEL] = ram_voltages, + [RAM_ID_HIGH_CHANNEL] = ram_voltages, + [SKU_ID_LOW_CHANNEL] = ram_voltages, + [SKU_ID_HIGH_CHANNEL] = lcm_voltages, +}; + static uint32_t get_adc_index(unsigned int channel) { unsigned int value = auxadc_get_voltage_uv(channel); + const unsigned int *voltages; + + if (CONFIG(BOARD_GOOGLE_STARYU_COMMON)) { + assert(channel < ARRAY_SIZE(adc_voltages_detachable)); + voltages = adc_voltages_detachable[channel]; + } else { + assert(channel < ARRAY_SIZE(adc_voltages)); + voltages = adc_voltages[channel]; + } - assert(channel < ARRAY_SIZE(adc_voltages)); - const unsigned int *voltages = adc_voltages[channel]; assert(voltages); /* Find the closest voltage */ @@ -60,21 +92,42 @@ static uint32_t get_adc_index(unsigned int channel) return id; } +/* Detachables use ADC channel 5 for panel ID */ +uint32_t panel_id(void) +{ + static uint32_t cached_panel_id = BOARD_ID_INIT; + + if (cached_panel_id == BOARD_ID_INIT) + cached_panel_id = get_adc_index(SKU_ID_HIGH_CHANNEL); + + return cached_panel_id; +} + uint32_t sku_id(void) { static uint32_t cached_sku_code = BOARD_ID_INIT; - if (cached_sku_code == BOARD_ID_INIT) { - cached_sku_code = google_chromeec_get_board_sku(); + if (cached_sku_code != BOARD_ID_INIT) + return cached_sku_code; + + cached_sku_code = google_chromeec_get_board_sku(); - if (cached_sku_code == CROS_SKU_UNKNOWN) { - printk(BIOS_WARNING, "Failed to get SKU code from EC\n"); - cached_sku_code = (get_adc_index(SKU_ID_HIGH_CHANNEL) << 4 | - get_adc_index(SKU_ID_LOW_CHANNEL)); + if (CONFIG(BOARD_GOOGLE_STARYU_COMMON)) { + if (cached_sku_code == CROS_SKU_UNPROVISIONED || + cached_sku_code == CROS_SKU_UNKNOWN) { + printk(BIOS_WARNING, "SKU code from EC: %s\n", + (cached_sku_code == CROS_SKU_UNKNOWN) ? + "CROS_SKU_UNKNOWN" : "CROS_SKU_UNPROVISIONED"); + /* Reserve last 4 bits to report PANEL_ID */ + cached_sku_code = 0x7FFFFFF0UL | panel_id(); } - printk(BIOS_DEBUG, "SKU Code: %#02x\n", cached_sku_code); + } else if (cached_sku_code == CROS_SKU_UNKNOWN) { + printk(BIOS_WARNING, "Failed to get SKU code from EC\n"); + cached_sku_code = (get_adc_index(SKU_ID_HIGH_CHANNEL) << 4 | + get_adc_index(SKU_ID_LOW_CHANNEL)); } + printk(BIOS_DEBUG, "SKU Code: %#02x\n", cached_sku_code); return cached_sku_code; } diff --git a/src/mainboard/google/corsola/display.h b/src/mainboard/google/corsola/display.h index 4e883f2b88..929ddf7002 100644 --- a/src/mainboard/google/corsola/display.h +++ b/src/mainboard/google/corsola/display.h @@ -12,5 +12,6 @@ struct edp_bridge { }; int configure_display(void); +uint32_t panel_id(void); #endif |