From 800d1a3ea30c2edbe5d60f24c4e21073b616a5c4 Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Tue, 13 Aug 2019 07:51:04 +0200 Subject: [PATCH] nmhw24: fix PMIC accesses PMIC access needs to be enclosed in claim/release bus functions. --- board/nm/nmhw24/board.c | 60 ++++++++++++----------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/board/nm/nmhw24/board.c b/board/nm/nmhw24/board.c index 574eb9b5c1..a9f91075a0 100644 --- a/board/nm/nmhw24/board.c +++ b/board/nm/nmhw24/board.c @@ -158,14 +158,20 @@ static void init_leds(void) // TODO: Only green color available static void set_status_led(int red, int green) { - /* LED outputs are active low, invert state */ + int bus; + + bus = da9063_claim_i2c_bus(); da9063_set_gpio(PMIC_LED0, red | green); + da9063_release_i2c_bus(bus); } -// TODO: Remove? static void set_indicator_led(int red, int green) { + int bus; + + bus = da9063_claim_i2c_bus(); da9063_set_gpio(PMIC_LED1, red | green); + da9063_release_i2c_bus(bus); } @@ -298,42 +304,6 @@ struct dpll_params dpll_ddr = { static void pmic_fix_config(void) { /* TODO: Update later, currently no fixes are required */ - -#if 0 - int rc; - uint8_t val; - - /* Workaround for pre v1.3 config (reports ID 0x3e -> 3.14) */ - rc = da9063_get_reg(PMIC_REG_CONFIG_ID, &val); - if (!rc && ((val == 0x3E) || (val == 0x12))) { - printf("Detected pre v1.3 PMIC config. Fixing registers\n"); - - /* Include +3V3_SENSORS (LDO3) in sequencing and enable manually */ - (void)da9063_set_reg(PMIC_REG_ID_4_3, 0x07 /* Slot 7 */); - (void)da9063_set_reg(PMIC_REG_LDO3_CONT, PMIC_LDOx_EN_MASK); - - /* - * Set AUTO Bit for sequencer controlled supplies, so that they get - * enabled when leaving power down state - */ - (void)da9063_set_reg(PMIC_REG_CONFIG_E, 0x3B); - (void)da9063_set_reg(PMIC_REG_CONFIG_G, 0x44); - - /* - * Clear sequencer target state bit (xxx_CONT::xxx_CONF bit), so that - * regulators are disabled when entering power down state. - * Keep EN bit enabled in order not to disable supply. - */ - (void)da9063_set_reg(PMIC_REG_LDO3_CONT, PMIC_LDOx_EN_MASK); - (void)da9063_set_reg(PMIC_REG_LDO7_CONT, PMIC_LDOx_EN_MASK); - - (void)da9063_set_reg(PMIC_REG_BCORE1_CONT, PMIC_LDOx_EN_MASK); - (void)da9063_set_reg(PMIC_REG_BCORE2_CONT, PMIC_LDOx_EN_MASK); - (void)da9063_set_reg(PMIC_REG_BPERI_CONT, PMIC_LDOx_EN_MASK); - (void)da9063_set_reg(PMIC_REG_BIO_CONT, PMIC_LDOx_EN_MASK); - (void)da9063_set_reg(PMIC_REG_BMEM_CONT, PMIC_LDOx_EN_MASK); - } -#endif } static void pmic_ignition_gate_on(void) @@ -377,7 +347,12 @@ static void init_pmic_spl(void) /* Trim RTC to compensate +18ppm crystal deviation */ // TODO: Check, caps have been changed + /* (void)da9063_set_reg(PMIC_REG_TRIM_CLDR, (-18*10)/19); + */ + + /* Enable charging of RTC backup capacitor (1mA, 3.1V) */ + (void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xAF); da9063_release_i2c_bus(bus); } @@ -558,8 +533,12 @@ static void init_gnss(void) static void init_wifi(void) { + int bus; + /* Enable WiFi power supply */ + bus = da9063_claim_i2c_bus(); da9063_set_gpio(PMIC_WIFI_SUPPLY_EN_IO, 1); + da9063_release_i2c_bus(bus); } #endif /* !defined(CONFIG_SPL_BUILD) */ @@ -915,11 +894,6 @@ int board_late_init(void) init_gnss(); init_wifi(); - // TODO: Check and activate if required - // Move to some other place? PMIC init() - /* Enable charging of RTC backup capacitor (1mA, 3.1V) */ - //(void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xCF); - /* * Check if a user action is requested * - Short press: factory reset