Hung-Te Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32263
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include panel identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which panel is installed, and select right kernel device tree. Following Scarlet, the decision is to embed panel ID as part of SKU ID.
BUG=b:129299873 TEST=make -j; boots on Kukui P2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 17 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/1
diff --git a/src/mainboard/google/kukui/boardid.c b/src/mainboard/google/kukui/boardid.c index ff910fe..84a0663 100644 --- a/src/mainboard/google/kukui/boardid.c +++ b/src/mainboard/google/kukui/boardid.c @@ -66,24 +66,37 @@
uint32_t sku_id(void) { + uint32_t sku = BOARD_ID_INIT, lcm = BOARD_ID_INIT; static uint32_t cached_sku_id = BOARD_ID_INIT;
+ if (cached_sku_id != BOARD_ID_INIT) + return cached_sku_id; + /* On Flapjack, getting the SKU via CBI. */ if (CONFIG(BOARD_GOOGLE_FLAPJACK)) { - if (cached_sku_id == BOARD_ID_INIT && - google_chromeec_cbi_get_sku_id(&cached_sku_id)) + if (google_chromeec_cbi_get_sku_id(&cached_sku_id)) cached_sku_id = FLAPJACK_UNDEF_SKU_ID; return cached_sku_id; }
/* Quirk for KUKUI: All P1/SKU0 had incorrectly set SKU=1. */ if (CONFIG(BOARD_GOOGLE_KUKUI)) { - if (cached_sku_id == BOARD_ID_INIT && board_id() == 1) { + if (board_id() == 1) { cached_sku_id = 0; return cached_sku_id; } } - return get_index(4, &cached_sku_id); + + /* + * The SKU is combined from: + * ADC2[4bit] = Panel ID (LCM_ID). + * ADC4[4bit] = SKU ID from board straps. + */ + get_index(2, &lcm); + get_index(4, &sku); + cached_sku_id = lcm << 4 || sku; + + return cached_sku_id; }
uint32_t ram_code(void)
You-Cheng Syu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/32263/1/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/1/src/mainboard/google/kukui/boardid.c... PS1, Line 97: || Should this be bitwise or?
Hello Julius Werner, You-Cheng Syu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32263
to look at the new patch set (#2).
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include panel identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which panel is installed, and select right kernel device tree. Following Scarlet, the decision is to embed panel ID as part of SKU ID.
BUG=b:129299873 TEST=make -j; boots on Kukui P2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 17 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/2
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/#/c/32263/1/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/1/src/mainboard/google/kukui/boardid.c... PS1, Line 97: ||
Should this be bitwise or?
Done
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/#/c/32263/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/#/c/32263/2//COMMIT_MSG@14 PS2, Line 14: boots on Kukui P2 unit with working MIPI display, which did not work before?
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/#/c/32263/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/#/c/32263/2//COMMIT_MSG@14 PS2, Line 14: boots on Kukui P2 unit
with working MIPI display, which did not work before?
With other display patches P2 should work. Although, there was only single LCM ID=0 for P0~P2, so this change can't be fully validated until we have P3. I only tested that it's at least not breaking anything.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 2: Code-Review+2
You-Cheng Syu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/#/c/32263/2/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/2/src/mainboard/google/kukui/boardid.c... PS2, Line 95: get_index(2, &lcm); When we reads this pin on early Kukui boards, what kind of result do we expect? If it's not defined, then we should avoid reading this on early boards.
Hello Julius Werner, You-Cheng Syu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32263
to look at the new patch set (#3).
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include panel identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which panel is installed, and select right kernel device tree. Following Scarlet, the decision is to embed panel ID as part of SKU ID.
BUG=b:129299873 TEST=make -j; boots on Kukui Rev2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 17 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/3
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/#/c/32263/2/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/2/src/mainboard/google/kukui/boardid.c... PS2, Line 95: get_index(2, &lcm);
When we reads this pin on early Kukui boards, what kind of result do we expect? […]
According to Ayo, at least Rev2 will return 0. And I think we can get rid of Rev0/1 since it'll be handled in earlier if-case.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 3:
... and it would be even better if you can verify when building next release of firmware :)
Hello Julius Werner, You-Cheng Syu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32263
to look at the new patch set (#4).
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include panel identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which panel is installed, and select right kernel device tree. Following Scarlet, the decision is to embed panel ID as part of SKU ID.
BUG=b:129299873 TEST=make -j; boots on Kukui P2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 57 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/4
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 4:
(3 comments)
https://review.coreboot.org/#/c/32263/4/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/4/src/mainboard/google/kukui/boardid.c... PS4, Line 26: KUKUI_LCM_ID_CHANNEL=2, spaces required around that '=' (ctx:VxV)
https://review.coreboot.org/#/c/32263/4/src/mainboard/google/kukui/boardid.c... PS4, Line 27: KUKUI_RAM_ID_CHANNEL=3, spaces required around that '=' (ctx:VxV)
https://review.coreboot.org/#/c/32263/4/src/mainboard/google/kukui/boardid.c... PS4, Line 28: KUKUI_SKU_ID_CHANNEL=4, spaces required around that '=' (ctx:VxV)
Hello Julius Werner, You-Cheng Syu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32263
to look at the new patch set (#5).
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include panel identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which panel is installed, and select right kernel device tree. Following Scarlet, the decision is to embed panel ID as part of SKU ID.
The LCM ID is using a different voltage mapping table from the rest. Considering the complexity in computation of SKU ID, it is better to move the cache logic from get_index to caller.
Also revised the mapping table since ADC on 8183 only supports 12 levels.
BUG=b:129299873 TEST=make -j; boots on Kukui Rev2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 53 insertions(+), 18 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/5
You-Cheng Syu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 5: Code-Review+1
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 5: Code-Review+2
(2 comments)
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 26: KUKUI_LCM_ID_CHANNEL = 2, nit: wouldn't calling this PANEL or DISPLAY (rather than LCM) everywhere be a bit more obvious? (what exactly does LCM mean, anyway? liquid crystal mmm...odule? manifold?)
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 33: static const int voltages_default[] = { nit: I think this would look cleaner if the voltages arrays were global and you passed a pointer to the right one through to get_index().
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 26: KUKUI_LCM_ID_CHANNEL = 2,
nit: wouldn't calling this PANEL or DISPLAY (rather than LCM) everywhere be a bit more obvious? (wha […]
LCd Module.
I keep LCM because it's the exactly name on schematics, but I can add a comment here to make it easy to understand.
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 33: static const int voltages_default[] = {
nit: I think this would look cleaner if the voltages arrays were global and you passed a pointer to […]
I thought about that, but then it's harder to choose ARRAY_SIZE. Well let me think about if there's some better way.
You-Cheng Syu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 33: static const int voltages_default[] = {
I thought about that, but then it's harder to choose ARRAY_SIZE. […]
Maybe something like
#define GET_INDEX(channel, table) get_index(channel, ARRAY_SIZE(table), table)
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include panel identifier (LCM ID) into SKU ID ......................................................................
Patch Set 5:
(3 comments)
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 26: KUKUI_LCM_ID_CHANNEL = 2,
LCd Module. […]
okay
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 28: KUKUI_ nit: btw, this is a file-local #define in a kukui-specific file, the KUKUI_ prefix is a bit superfluous.
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 33: static const int voltages_default[] = {
I thought about that, but then it's harder to choose ARRAY_SIZE. […]
You'd need to pass the size in another parameter as well, of course. (If you don't like the duplication you could solve it with a macro, but I don't think that's worth it...
get_index(CHANNEL_SKU, voltages_default, ARRAY_SIZE(voltages_default))
doesn't look that bad.)
Hello Julius Werner, You-Cheng Syu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32263
to look at the new patch set (#6).
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include LCD module identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which LCD module is installed, and to select right kernel device tree. Following Scarlet, the decision is to embed LCD module ID as part of SKU ID.
The LCM ID is using a different voltage mapping table from the rest. Considering the complexity in computation of SKU ID, it is better to move the cache logic from get_index to caller.
Also revised the mapping table since ADC on 8183 only supports 12 levels.
BUG=b:129299873 TEST=make -j; boots on Kukui Rev2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 59 insertions(+), 20 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/6
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
Patch Set 6:
(2 comments)
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c File src/mainboard/google/kukui/boardid.c:
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 28: KUKUI_
nit: btw, this is a file-local #define in a kukui-specific file, the KUKUI_ prefix is a bit superflu […]
Added because we have FLAPJACK doing totally different things; but yes let's try to remove them.
https://review.coreboot.org/#/c/32263/5/src/mainboard/google/kukui/boardid.c... PS5, Line 33: static const int voltages_default[] = {
You'd need to pass the size in another parameter as well, of course. […]
Since all AP ADCs should have 12 levels I think it's no harm to make it a const instead of ARRAY_SIZE. Please see my next version.
Hello Julius Werner, You-Cheng Syu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32263
to look at the new patch set (#7).
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include LCD module identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which LCD module is installed, and to select right kernel device tree. Following Scarlet, the decision is to embed LCD module ID as part of SKU ID.
The LCM ID is using a different voltage mapping table from the rest. Considering the complexity in computation of SKU ID, it is better to move the cache logic from get_index to caller.
Also revised the mapping table since ADC on 8183 only supports 12 levels.
BUG=b:129299873 TEST=make -j; boots on Kukui Rev2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 58 insertions(+), 19 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/7
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
Patch Set 7: Code-Review+1
(1 comment)
https://review.coreboot.org/#/c/32263/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/#/c/32263/7//COMMIT_MSG@18 PS7, Line 18: revised revise
Hello Julius Werner, You-Cheng Syu, Paul Menzel, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32263
to look at the new patch set (#8).
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include LCD module identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which LCD module is installed, and to select right kernel device tree. Following Scarlet, the decision is to embed LCD module ID as part of SKU ID.
The LCM ID is using a different voltage mapping table from the rest. Considering the complexity in computation of SKU ID, it is better to move the cache logic from get_index to caller.
Also revise the mapping table since ADC on 8183 only supports 12 levels.
BUG=b:129299873 TEST=make -j; boots on Kukui Rev2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 58 insertions(+), 19 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32263/8
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
Patch Set 8:
(1 comment)
Patch Set 7: Code-Review+1
(1 comment)
https://review.coreboot.org/#/c/32263/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/#/c/32263/7//COMMIT_MSG@18 PS7, Line 18: revised
revise
Done
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
Patch Set 8: Code-Review+2
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
Patch Set 8:
+Patrick Can we have this merged to unblock incoming build?
Julius Werner has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/32263 )
Change subject: google/kukui: Include LCD module identifier (LCM ID) into SKU ID ......................................................................
google/kukui: Include LCD module identifier (LCM ID) into SKU ID
Kukui is using MIPI display panel and needs some identifier to tell payloads which LCD module is installed, and to select right kernel device tree. Following Scarlet, the decision is to embed LCD module ID as part of SKU ID.
The LCM ID is using a different voltage mapping table from the rest. Considering the complexity in computation of SKU ID, it is better to move the cache logic from get_index to caller.
Also revise the mapping table since ADC on 8183 only supports 12 levels.
BUG=b:129299873 TEST=make -j; boots on Kukui Rev2 unit.
Change-Id: Ib0c00bc8ce3c71c445c5c4561403ce8ef4dd5844 Signed-off-by: Hung-Te Lin hungte@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/32263 Reviewed-by: Julius Werner jwerner@chromium.org Reviewed-by: Paul Menzel paulepanter@users.sourceforge.net Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/mainboard/google/kukui/boardid.c 1 file changed, 58 insertions(+), 19 deletions(-)
Approvals: build bot (Jenkins): Verified Paul Menzel: Looks good to me, but someone else must approve Julius Werner: Looks good to me, approved
diff --git a/src/mainboard/google/kukui/boardid.c b/src/mainboard/google/kukui/boardid.c index ff910fe..b9f1ba2 100644 --- a/src/mainboard/google/kukui/boardid.c +++ b/src/mainboard/google/kukui/boardid.c @@ -22,9 +22,15 @@ /* For CBI un-provisioned/corrupted Flapjack board. */ #define FLAPJACK_UNDEF_SKU_ID 0
-static uint32_t get_index(unsigned int channel, uint32_t *cached_id) -{ - static const int voltages[] = { +#define ADC_LEVELS 12 + +enum { + LCM_ID_CHANNEL = 2, /* ID of LCD Module on schematics. */ + RAM_ID_CHANNEL = 3, + SKU_ID_CHANNEL = 4, +}; + +static const int ram_voltages[ADC_LEVELS] = { /* ID : Voltage (unit: uV) */ /* 0 : */ 74000, /* 1 : */ 212000, @@ -38,27 +44,47 @@ /* 9 : */ 1137000, /* 10 : */ 1240000, /* 11 : */ 1343000, - /* 12 : */ 1457000, - /* 13 : */ 1576000, - /* 14 : */ 1684000, - /* 15 : */ 1800000, - }; +};
- uint32_t id; +static const int lcm_voltages[ADC_LEVELS] = { + /* ID : Voltage (unit: uV) */ + /* 0 : */ 0, + /* 1 : */ 283000, + /* 2 : */ 440000, + /* 3 : */ 503000, + /* 4 : */ 608000, + /* 5 : */ 703000, + /* 6 : */ 830000, + /* 7 : */ 865000, + /* 8 : */ 953000, + /* 9 : */ 1079000, + /* 10 : */ 1128000, + /* 11 : */ 1434000, +};
- if (*cached_id != BOARD_ID_INIT) - return *cached_id; +static const int *adc_voltages[] = { + [LCM_ID_CHANNEL] = lcm_voltages, + [RAM_ID_CHANNEL] = ram_voltages, + [SKU_ID_CHANNEL] = ram_voltages, /* SKU ID is sharing RAM voltages. */ +};
+static uint32_t get_adc_index(unsigned int channel) +{ int value = auxadc_get_voltage(channel); + + assert(channel < ARRAY_SIZE(adc_voltages)); + const int *voltages = adc_voltages[channel]; + assert(voltages); + /* Find the closest voltage */ - for (id = 0; id < ARRAY_SIZE(voltages) - 1; id++) + uint32_t id; + for (id = 0; id < ADC_LEVELS - 1; id++) if (value < (voltages[id] + voltages[id + 1]) / 2) break;
const int tolerance = 10000; /* 10,000 uV */ assert(ABS(value - voltages[id]) < tolerance);
- *cached_id = id; return id; }
@@ -68,26 +94,39 @@ { static uint32_t cached_sku_id = BOARD_ID_INIT;
+ if (cached_sku_id != BOARD_ID_INIT) + return cached_sku_id; + /* On Flapjack, getting the SKU via CBI. */ if (CONFIG(BOARD_GOOGLE_FLAPJACK)) { - if (cached_sku_id == BOARD_ID_INIT && - google_chromeec_cbi_get_sku_id(&cached_sku_id)) + if (google_chromeec_cbi_get_sku_id(&cached_sku_id)) cached_sku_id = FLAPJACK_UNDEF_SKU_ID; return cached_sku_id; }
- /* Quirk for KUKUI: All P1/SKU0 had incorrectly set SKU=1. */ + /* Quirk for Kukui: All Rev1/Sku0 had incorrectly set SKU_ID=1. */ if (CONFIG(BOARD_GOOGLE_KUKUI)) { - if (cached_sku_id == BOARD_ID_INIT && board_id() == 1) { + if (board_id() == 1) { cached_sku_id = 0; return cached_sku_id; } } - return get_index(4, &cached_sku_id); + + /* + * The SKU (later used for device tree matching) is combined from: + * ADC2[4bit/H] = straps on LCD module (type of panel). + * ADC4[4bit/L] = SKU ID from board straps. + */ + cached_sku_id = (get_adc_index(LCM_ID_CHANNEL) << 4 | + get_adc_index(SKU_ID_CHANNEL)); + return cached_sku_id; }
uint32_t ram_code(void) { static uint32_t cached_ram_code = BOARD_ID_INIT; - return get_index(3, &cached_ram_code); + + if (cached_ram_code == BOARD_ID_INIT) + cached_ram_code = get_adc_index(RAM_ID_CHANNEL); + return cached_ram_code; }