summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2013-01-15 09:42:31 -0800
committerChromeBot <chrome-bot@google.com>2013-01-16 08:35:03 -0800
commitb24b745f81541554ed7719fdaba9073b4ec40bd9 (patch)
treee81466e0abf39a200310714d5ebf667de2aa8a9b
parentfd29230988fc90e9535b84c8fe65738e17ba50dd (diff)
downloadchrome-ec-b24b745f81541554ed7719fdaba9073b4ec40bd9.tar.gz
Add a pass-through for TPSchrome LDOs
Allow to send commands to switch on/off the TPSchrome LDOs by using EC commands when the TPSchrome chip is connected to an I2C bus behind the EC. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:14314 TEST=on Spring, with an updated bootloader, switch on screen FETs from U-Boot instead of hardcoding them in the EC board code. Change-Id: Ic6cebf04ba73a7c0ca2c54f532f8cf4c953ac0c1 Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/41288 Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--common/pmu_tps65090.c46
-rw-r--r--include/ec_commands.h31
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 */
/*