From 0fe5e672ab78a75ca1e35a03bf053476006f74c8 Mon Sep 17 00:00:00 2001 From: Oleksandr Dmytryshyn Date: Mon, 6 Feb 2012 16:37:33 +0200 Subject: MFD: TWL: Regulator: Add support for SYSEN Previously SYSEN pin was configured only for the OMAP4460. SYSEN is added to platform data, so that it can be modelled as an regulator and the state of it can be controlled through drivers and board file. Change-Id: I7ec8d690f94d0143563b904844ef9155eef20a17 Signed-off-by: Oleksandr Dmytryshyn --- drivers/mfd/twl-core.c | 5 +++++ drivers/regulator/twl-regulator.c | 26 ++++++++++++++++++++++++++ include/linux/i2c/twl.h | 6 ++++++ 3 files changed, 37 insertions(+) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 7451699..8992ee7 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -1046,6 +1046,11 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) pdata->clk32kaudio, features); if (IS_ERR(child)) return PTR_ERR(child); + + child = add_regulator(TWL6030_REG_SYSEN, + pdata->sysen, features); + if (IS_ERR(child)) + return PTR_ERR(child); } /* twl6032 regulators */ diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 1632e77..5894487 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -920,6 +920,18 @@ static struct regulator_ops twlsmps_ops = { .set_suspend_disable = twl6030ldo_suspend_disable, }; +static struct regulator_ops twl6030_external_control_pin_ops = { + .enable = twl6030reg_enable, + .disable = twl6030reg_disable, + .is_enabled = twl6030reg_is_enabled, + + .set_mode = twl6030reg_set_mode, + + .get_status = twl6030reg_get_status, + + .set_suspend_enable = twl6030ldo_suspend_enable, + .set_suspend_disable = twl6030ldo_suspend_disable, +}; /*----------------------------------------------------------------------*/ #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ @@ -1032,6 +1044,18 @@ static struct regulator_ops twlsmps_ops = { }, \ } +#define TWL6030_EXTERNAL_CONTROL_PIN(label, offset, turnon_delay) { \ + .base = offset, \ + .delay = turnon_delay, \ + .desc = { \ + .name = #label, \ + .id = TWL6030_REG_##label, \ + .ops = &twl6030_external_control_pin_ops, \ + .type = REGULATOR_VOLTAGE, \ + .owner = THIS_MODULE, \ + }, \ + } + /* * We list regulators here if systems need some level of * software control over them after boot. @@ -1094,6 +1118,8 @@ static struct twlreg_info twl_regs[] = { TWL6032_ADJUSTABLE_SMPS(SMPS3, 0x34), TWL6032_ADJUSTABLE_SMPS(SMPS4, 0x10), TWL6032_ADJUSTABLE_SMPS(VIO, 0x16), + + TWL6030_EXTERNAL_CONTROL_PIN(SYSEN, 0x83, 0), }; static u8 twl_get_smps_offset(void) diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h index bed388f..8717499 100644 --- a/include/linux/i2c/twl.h +++ b/include/linux/i2c/twl.h @@ -822,6 +822,9 @@ struct twl4030_platform_data { struct regulator_init_data *smps3; struct regulator_init_data *smps4; struct regulator_init_data *vio6032; + + /* External control pins */ + struct regulator_init_data *sysen; }; /*----------------------------------------------------------------------*/ @@ -921,4 +924,7 @@ static inline int twl4030charger_usb_en(int enable) { return 0; } #define TWL6030_REG_CLK32KAUDIO 61 +/* External control pins */ +#define TWL6030_REG_SYSEN 62 + #endif /* End of __TWL4030_H */ -- cgit v1.1