From 7336361d5ce80f400a1f5cd3ff957d7afe7b1d1c Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Mon, 15 Jun 2020 14:18:32 +0200 Subject: [PATCH] nmhw21,26: init pmic based on hw type --- board/nm/nmhw21/board.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/board/nm/nmhw21/board.c b/board/nm/nmhw21/board.c index 668426e843..efbd29c03b 100644 --- a/board/nm/nmhw21/board.c +++ b/board/nm/nmhw21/board.c @@ -150,6 +150,8 @@ static int hw_rev = -1; static int hw_patch = -1; static int hw_type = -1; static char hw_variant_name[64]; +#else +static int hw_type = -1; #endif #if !defined(CONFIG_SPL_BUILD) @@ -444,10 +446,12 @@ static void init_pmic_spl(void) bus = da9063_claim_i2c_bus(); /* Fix old configs (mainly prototype boards) */ - pmic_fix_config(); + if (hw_type == 21) { + pmic_fix_config(); - /* Disable automatic mode switching */ - pmic_disable_auto_mode(); + /* Disable automatic mode switching */ + pmic_disable_auto_mode(); + } /* Enable +3V3_GNSS (LDO6) */ (void)da9063_set_reg(PMIC_REG_LDO6_CONT, PMIC_LDOx_EN_MASK); @@ -459,8 +463,14 @@ static void init_pmic_spl(void) pmic_ignition_gate_on(); - /* Trim RTC to compensate +18ppm crystal deviation */ - (void)da9063_set_reg(PMIC_REG_TRIM_CLDR, (-18*10)/19); + if (hw_type == 21) { + /* hw21: trim RTC to compensate +18ppm crystal deviation */ + (void)da9063_set_reg(PMIC_REG_TRIM_CLDR, (-18*10)/19); + } + else { + /* hw26 does not need trimming */ + (void)da9063_set_reg(PMIC_REG_TRIM_CLDR, 0); + } da9063_release_i2c_bus(bus); } @@ -520,6 +530,18 @@ void check_pmic_reset_reason(unsigned int reset_reason_shm_location) #endif +static void init_bd_spl(void) +{ + hw_type = 21; /* Assume hw21, unless BD tells different */ + + if (read_eeprom() >= 0) { + bd_get_hw_type(&hw_type); + } + else { + puts("Could not get board ID.\n"); + } +} + void am33xx_spl_board_init(void) { /* Set CPU speed to 600 MHz (fix) */ @@ -531,6 +553,9 @@ void am33xx_spl_board_init(void) /* Configure both I2C buses used */ init_i2c(); + /* Get board descriptor */ + init_bd_spl(); + /* Setup PMIC */ init_pmic_spl();