diff options
-rw-r--r-- | common/pmu_tps65090.c | 46 | ||||
-rw-r--r-- | include/ec_commands.h | 31 |
2 files changed, 77 insertions, 0 deletions
diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index e6e67a1ead..7a587e1b21 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -8,6 +8,7 @@ #include "clock.h" #include "console.h" #include "common.h" +#include "host_command.h" #include "hooks.h" #include "i2c.h" #include "pmu_tpschrome.h" @@ -601,3 +602,48 @@ DECLARE_CONSOLE_COMMAND(pmu, command_pmu, "Print PMU info or force a hard reset", NULL); #endif + +/*****************************************************************************/ +/* TPSchrome LDO pass-through + */ +#ifdef CONFIG_I2C_PASSTHROUGH +static int host_command_ldo_get(struct host_cmd_handler_args *args) +{ + int rv; + int val; + const struct ec_params_ldo_get *p = args->params; + struct ec_response_ldo_get *r = args->response; + + /* is this an existing TPSchrome FET ? */ + if ((p->index < 1) || (p->index > 7)) + return EC_RES_ERROR; + + rv = pmu_read(FET_CTRL_BASE + p->index, &val); + if (rv) + return EC_RES_ERROR; + + r->state = !!(val & FET_CTRL_PGFET); + args->response_size = sizeof(struct ec_response_ldo_get); + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_LDO_GET, + host_command_ldo_get, + EC_VER_MASK(0)); + +static int host_command_ldo_set(struct host_cmd_handler_args *args) +{ + int rv; + const struct ec_params_ldo_set *p = args->params; + + /* is this an existing TPSchrome FET ? */ + if ((p->index < 1) || (p->index > 7)) + return EC_RES_ERROR; + rv = pmu_enable_fet(p->index, p->state & EC_LDO_STATE_ON, NULL); + + return rv ? EC_RES_ERROR : EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_LDO_SET, + host_command_ldo_set, + EC_VER_MASK(0)); +#endif diff --git a/include/ec_commands.h b/include/ec_commands.h index 9459800693..02fa46f1bf 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -1211,6 +1211,37 @@ struct ec_params_usb_mux { } __packed; /*****************************************************************************/ +/* LDOs / FETs control. */ + +enum ec_ldo_state { + EC_LDO_STATE_OFF = 0, /* the LDO / FET is shut down */ + EC_LDO_STATE_ON = 1, /* the LDO / FET is ON / providing power */ +}; + +/* + * Switch on/off a LDO. + */ +#define EC_CMD_LDO_SET 0x9b + +struct ec_params_ldo_set { + uint8_t index; + uint8_t state; +} __packed; + +/* + * Get LDO state. + */ +#define EC_CMD_LDO_GET 0x9c + +struct ec_params_ldo_get { + uint8_t index; +} __packed; + +struct ec_response_ldo_get { + uint8_t state; +} __packed; + +/*****************************************************************************/ /* Temporary debug commands. TODO: remove this crosbug.com/p/13849 */ /* |