diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2015-09-08 18:27:08 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-18 01:25:56 -0700 |
commit | 3c862e7f39506100d5bd8258ce744bfe67374c5f (patch) | |
tree | 50244799419ee4bffa5d844e0b171be246b0552c | |
parent | 0ed9b91d4cb61244be8b09de6561a88be7a68067 (diff) | |
download | chrome-ec-3c862e7f39506100d5bd8258ce744bfe67374c5f.tar.gz |
Kunimitsu: PMIC: Emergency reset on long press of power button
Configured the power button configuration register to issue an emergency
reset on long press of the power button (8s time).
There's no need to re-initialize the PMIC on sysjump.
Ported this change from Glados
Change-Id: I1839e1bd357759ae2800d812b27bf4e0cd7772b4
Reviewed-on: https://chromium-review.googlesource.com/293012
BUG=none
TEST=Hold the power button for 8s and DUT turns off the DSW rails.
BRANCH=none
Change-Id: Ibc0064e8ee88127cc6e3e418b97370e617b61b1d
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/298148
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | board/kunimitsu/board.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/board/kunimitsu/board.c b/board/kunimitsu/board.c index 1a32d45994..eac89ffac8 100644 --- a/board/kunimitsu/board.c +++ b/board/kunimitsu/board.c @@ -14,6 +14,7 @@ #include "driver/accel_kionix.h" #include "driver/accel_kxcj9.h" #include "driver/als_opt3001.h" +#include "driver/pmic_tps650830.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" @@ -29,6 +30,7 @@ #include "power_button.h" #include "spi.h" #include "switch.h" +#include "system.h" #include "task.h" #include "temp_sensor.h" #include "temp_sensor_chip.h" @@ -47,7 +49,7 @@ #define GPIO_KB_OUTPUT (GPIO_ODR_HIGH) #define GPIO_KB_OUTPUT_COL2 (GPIO_OUT_LOW) -#define TPS650830_I2C_ADDR 0x60 +#define TPS650830_I2C_ADDR TPS650830_I2C_ADDR1 /* Exchange status with PD MCU. */ static void pd_mcu_interrupt(enum gpio_signal signal) @@ -303,15 +305,51 @@ const struct button_config buttons[CONFIG_BUTTON_COUNT] = { BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT); /* Initialize PMIC */ +#define I2C_PMIC_READ(reg, data) \ + i2c_read8(I2C_PORT_PMIC, TPS650830_I2C_ADDR, (reg), (data)) + +#define I2C_PMIC_WRITE(reg, data) \ + i2c_write8(I2C_PORT_PMIC, TPS650830_I2C_ADDR, (reg), (data)) + static void board_pmic_init(void) { + int ret; + int data; + + /* No need to re-init PMIC since settings are sticky across sysjump */ + if (system_jumped_to_this_image()) + return; + + /* Read vendor ID */ + ret = I2C_PMIC_READ(TPS650830_REG_VENDORID, &data); + if (ret || data != TPS650830_VENDOR_ID) + goto pmic_error; + /* * PWFAULT_MASK1 Register settings * [2] : 1b V9 Power Fault Masked * [0] : 1b V13 Power Fault Masked */ - if (i2c_write8(I2C_PORT_PMIC, TPS650830_I2C_ADDR, 0xE5, 0x5)) - CPRINTS("PMIC write failed"); + ret = I2C_PMIC_WRITE(TPS650830_REG_PWFAULT_MASK1, 0x5); + if (ret) + goto pmic_error; + + /* + * Power button configuration + * [7] : 0b Power button debounce time, 30ms + * [6] : 0b Reset of power button timer logic, no action + * [5:0]: 1000b Time that the button must be held to force an + * emergency reset, 8s + */ + ret = I2C_PMIC_WRITE(TPS650830_REG_PBCONFIG, 0x08); + if (ret) + goto pmic_error; + + CPRINTS("PMIC initialization done"); + return; + +pmic_error: + CPRINTS("PMIC initialization failed"); } DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_INIT_I2C + 1); |