[GPIO][PCBA]Add PCBA stage to system properties
PCB Variant Table:
GPIO_99 GPIO_98 GPIO_97
0 0 0 EP0
0 0 1 EP1
0 1 0 EP2
0 1 1 FP
1 0 0 MP
RiskArea: GPIO
Change-Id: Id6ca2ce6573e42d09ddf3eae82f4e39fdbf25233
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index f7ec3c8..80dcf2f 100755
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -215,6 +215,16 @@
static const char *android_boot_dtb_idx = " androidboot.dtb_idx=";
#endif
+//<20200424-michaellin, Add PCBA stage to system properties
+#include <platform/gpio.h>
+static const char *PCBA_STAGE_0 = " androidboot.pcbastage=EP0";
+static const char *PCBA_STAGE_1 = " androidboot.pcbastage=EP1";
+static const char *PCBA_STAGE_2 = " androidboot.pcbastage=EP2";
+static const char *PCBA_STAGE_3 = " androidboot.pcbastage=FP";
+static const char *PCBA_STAGE_4 = " androidboot.pcbastage=MP";
+static const char *PCBA_STAGE_F = " androidboot.pcbastage=Reserved";
+//>20200424-michaellin
+
#if VERIFIED_BOOT
static const char *verity_mode = " androidboot.veritymode=";
static const char *verified_state= " androidboot.verifiedbootstate=";
@@ -444,6 +454,39 @@
}
#endif
+//<20200424-michaellin, Add PCBA stage to system properties
+uint32_t GetPcbaVariant(void)
+{
+ uint8_t GPIO_97=10;
+ uint8_t GPIO_98=10;
+ uint8_t GPIO_99=10;
+
+ uint8_t pcba_stage = 0;
+
+ // Config GPIO
+ gpio_tlmm_config(97, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA, GPIO_ENABLE);
+ gpio_tlmm_config(98, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA, GPIO_ENABLE);
+ gpio_tlmm_config(99, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA, GPIO_ENABLE);
+
+ /* Wait for the gpio config to take effect - debounce time */
+ thread_sleep(10);
+
+ /* Get status of GPIO */
+ GPIO_97 = gpio_status(97);
+ GPIO_98 = gpio_status(98);
+ GPIO_99 = gpio_status(99);
+
+ pcba_stage = (GPIO_99 << 2) + (GPIO_98 << 1) + GPIO_97;
+ dprintf(ALWAYS, "pcba_stage status: %u\n", pcba_stage);
+ // GPIO_99 GPIO_98 GPIO_97
+ // 0 0 0 EP0
+ // 0 0 1 EP1
+ // 0 1 0 EP2
+ // 0 1 1 PP
+ return pcba_stage;
+}
+//>20200424-michaellin
+
unsigned char *update_cmdline(const char * cmdline)
{
int cmdline_len = 0;
@@ -625,6 +668,35 @@
break;
}
+ //<20200424-michaellin, Add PCBA stage to system properties
+ switch(GetPcbaVariant())
+ {
+ case 0: // EP0
+ cmdline_len += strlen(PCBA_STAGE_0);
+ break;
+
+ case 1: // EP1
+ cmdline_len += strlen(PCBA_STAGE_1);
+ break;
+
+ case 2: // EP2
+ cmdline_len += strlen(PCBA_STAGE_2);
+ break;
+
+ case 3: // FP/PP
+ cmdline_len += strlen(PCBA_STAGE_3);
+ break;
+
+ case 4: // MP
+ cmdline_len += strlen(PCBA_STAGE_4);
+ break;
+
+ default:// Reserved
+ cmdline_len += strlen(PCBA_STAGE_F);
+ break;
+ }
+ //>20200424-michaellin
+
#if ENABLE_DISPLAY
if (cmdline) {
if ((strstr(cmdline, DISPLAY_DEFAULT_PREFIX) == NULL) &&
@@ -793,6 +865,42 @@
}
}
+ //<20200424-michaellin, Add PCBA stage to system properties
+ switch(GetPcbaVariant())
+ {
+ case 0:
+ src = PCBA_STAGE_0;
+ if (have_cmdline) --dst;
+ while ((*dst++ = *src++));
+ break;
+ case 1:
+ src = PCBA_STAGE_1;
+ if (have_cmdline) --dst;
+ while ((*dst++ = *src++));
+ break;
+ case 2:
+ src = PCBA_STAGE_2;
+ if (have_cmdline) --dst;
+ while ((*dst++ = *src++));
+ break;
+ case 3:
+ src = PCBA_STAGE_3;
+ if (have_cmdline) --dst;
+ while ((*dst++ = *src++));
+ break;
+ case 4:
+ src = PCBA_STAGE_4;
+ if (have_cmdline) --dst;
+ while ((*dst++ = *src++));
+ break;
+ default:
+ src = PCBA_STAGE_F;
+ if (have_cmdline) --dst;
+ while ((*dst++ = *src++));
+ break;
+ }
+ //>20200424-michaellin
+
#if VERIFIED_BOOT
if (VB_M <= target_get_vb_version())
{