Commit ebf0bd36 authored by Amit Kucheria's avatar Amit Kucheria Committed by Samuel Ortiz

mfd: Add support for TWL4030/5030 dynamic power switching

The TWL4030/5030 family of multifunction devices allows board-specific
control of the the various regulators, clock and reset lines through
'scripts' that are loaded into its memory. This allows for Dynamic Power
Switching (DPS).

Implement board-independent core support for DPS that is then used by
board-specific code to load custom DPS scripts.
Signed-off-by: default avatarAmit Kucheria <amit.kucheria@verdurent.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 12992dd8
...@@ -108,6 +108,19 @@ config TWL4030_CORE ...@@ -108,6 +108,19 @@ config TWL4030_CORE
high speed USB OTG transceiver, an audio codec (on most high speed USB OTG transceiver, an audio codec (on most
versions) and many other features. versions) and many other features.
config TWL4030_POWER
bool "Support power resources on TWL4030 family chips"
depends on TWL4030_CORE && ARM
help
Say yes here if you want to use the power resources on the
TWL4030 family chips. Most of these resources are regulators,
which have a separate driver; some are control signals, such
as clock request handshaking.
This driver uses board-specific data to initialize the resources
and load scripts controling which resources are switched off/on
or reset when a sleep, wakeup or warm reset event occurs.
config MFD_TMIO config MFD_TMIO
bool bool
default n default n
......
...@@ -25,6 +25,7 @@ obj-$(CONFIG_TPS65010) += tps65010.o ...@@ -25,6 +25,7 @@ obj-$(CONFIG_TPS65010) += tps65010.o
obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_MENELAUS) += menelaus.o
obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o twl4030-irq.o obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o twl4030-irq.o
obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
obj-$(CONFIG_MFD_MC13783) += mc13783-core.o obj-$(CONFIG_MFD_MC13783) += mc13783-core.o
......
...@@ -89,6 +89,12 @@ ...@@ -89,6 +89,12 @@
#define twl_has_madc() false #define twl_has_madc() false
#endif #endif
#ifdef CONFIG_TWL4030_POWER
#define twl_has_power() true
#else
#define twl_has_power() false
#endif
#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE) #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
#define twl_has_rtc() true #define twl_has_rtc() true
#else #else
...@@ -801,6 +807,10 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -801,6 +807,10 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
/* setup clock framework */ /* setup clock framework */
clocks_init(&client->dev); clocks_init(&client->dev);
/* load power event scripts */
if (twl_has_power() && pdata->power)
twl4030_power_init(pdata->power);
/* Maybe init the T2 Interrupt subsystem */ /* Maybe init the T2 Interrupt subsystem */
if (client->irq if (client->irq
&& pdata->irq_base && pdata->irq_base
......
This diff is collapsed.
...@@ -223,19 +223,28 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); ...@@ -223,19 +223,28 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
/* Power bus message definitions */ /* Power bus message definitions */
#define DEV_GRP_NULL 0x0 /* The TWL4030/5030 splits its power-management resources (the various
#define DEV_GRP_P1 0x1 * regulators, clock and reset lines) into 3 processor groups - P1, P2 and
#define DEV_GRP_P2 0x2 * P3. These groups can then be configured to transition between sleep, wait-on
#define DEV_GRP_P3 0x4 * and active states by sending messages to the power bus. See Section 5.4.2
* Power Resources of TWL4030 TRM
*/
#define RES_GRP_RES 0x0 /* Processor groups */
#define RES_GRP_PP 0x1 #define DEV_GRP_NULL 0x0
#define RES_GRP_RC 0x2 #define DEV_GRP_P1 0x1 /* P1: all OMAP devices */
#define DEV_GRP_P2 0x2 /* P2: all Modem devices */
#define DEV_GRP_P3 0x4 /* P3: all peripheral devices */
/* Resource groups */
#define RES_GRP_RES 0x0 /* Reserved */
#define RES_GRP_PP 0x1 /* Power providers */
#define RES_GRP_RC 0x2 /* Reset and control */
#define RES_GRP_PP_RC 0x3 #define RES_GRP_PP_RC 0x3
#define RES_GRP_PR 0x4 #define RES_GRP_PR 0x4 /* Power references */
#define RES_GRP_PP_PR 0x5 #define RES_GRP_PP_PR 0x5
#define RES_GRP_RC_PR 0x6 #define RES_GRP_RC_PR 0x6
#define RES_GRP_ALL 0x7 #define RES_GRP_ALL 0x7 /* All resource groups */
#define RES_TYPE2_R0 0x0 #define RES_TYPE2_R0 0x0
...@@ -246,6 +255,41 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); ...@@ -246,6 +255,41 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
#define RES_STATE_SLEEP 0x8 #define RES_STATE_SLEEP 0x8
#define RES_STATE_OFF 0x0 #define RES_STATE_OFF 0x0
/* Power resources */
/* Power providers */
#define RES_VAUX1 1
#define RES_VAUX2 2
#define RES_VAUX3 3
#define RES_VAUX4 4
#define RES_VMMC1 5
#define RES_VMMC2 6
#define RES_VPLL1 7
#define RES_VPLL2 8
#define RES_VSIM 9
#define RES_VDAC 10
#define RES_VINTANA1 11
#define RES_VINTANA2 12
#define RES_VINTDIG 13
#define RES_VIO 14
#define RES_VDD1 15
#define RES_VDD2 16
#define RES_VUSB_1V5 17
#define RES_VUSB_1V8 18
#define RES_VUSB_3V1 19
#define RES_VUSBCP 20
#define RES_REGEN 21
/* Reset and control */
#define RES_NRES_PWRON 22
#define RES_CLKEN 23
#define RES_SYSEN 24
#define RES_HFCLKOUT 25
#define RES_32KCLKOUT 26
#define RES_RESET 27
/* Power Reference */
#define RES_Main_Ref 28
#define TOTAL_RESOURCES 28
/* /*
* Power Bus Message Format ... these can be sent individually by Linux, * Power Bus Message Format ... these can be sent individually by Linux,
* but are usually part of downloaded scripts that are run when various * but are usually part of downloaded scripts that are run when various
...@@ -327,6 +371,36 @@ struct twl4030_usb_data { ...@@ -327,6 +371,36 @@ struct twl4030_usb_data {
enum twl4030_usb_mode usb_mode; enum twl4030_usb_mode usb_mode;
}; };
struct twl4030_ins {
u16 pmb_message;
u8 delay;
};
struct twl4030_script {
struct twl4030_ins *script;
unsigned size;
u8 flags;
#define TWL4030_WRST_SCRIPT (1<<0)
#define TWL4030_WAKEUP12_SCRIPT (1<<1)
#define TWL4030_WAKEUP3_SCRIPT (1<<2)
#define TWL4030_SLEEP_SCRIPT (1<<3)
};
struct twl4030_resconfig {
u8 resource;
u8 devgroup; /* Processor group that Power resource belongs to */
u8 type; /* Power resource addressed, 6 / broadcast message */
u8 type2; /* Power resource addressed, 3 / broadcast message */
};
struct twl4030_power_data {
struct twl4030_script **scripts;
unsigned num;
struct twl4030_resconfig *resource_config;
};
extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
struct twl4030_platform_data { struct twl4030_platform_data {
unsigned irq_base, irq_end; unsigned irq_base, irq_end;
struct twl4030_bci_platform_data *bci; struct twl4030_bci_platform_data *bci;
...@@ -334,6 +408,7 @@ struct twl4030_platform_data { ...@@ -334,6 +408,7 @@ struct twl4030_platform_data {
struct twl4030_madc_platform_data *madc; struct twl4030_madc_platform_data *madc;
struct twl4030_keypad_data *keypad; struct twl4030_keypad_data *keypad;
struct twl4030_usb_data *usb; struct twl4030_usb_data *usb;
struct twl4030_power_data *power;
/* LDO regulators */ /* LDO regulators */
struct regulator_init_data *vdac; struct regulator_init_data *vdac;
...@@ -364,7 +439,6 @@ int twl4030_sih_setup(int module); ...@@ -364,7 +439,6 @@ int twl4030_sih_setup(int module);
#define TWL4030_VAUX3_DEV_GRP 0x1F #define TWL4030_VAUX3_DEV_GRP 0x1F
#define TWL4030_VAUX3_DEDICATED 0x22 #define TWL4030_VAUX3_DEDICATED 0x22
#if defined(CONFIG_TWL4030_BCI_BATTERY) || \ #if defined(CONFIG_TWL4030_BCI_BATTERY) || \
defined(CONFIG_TWL4030_BCI_BATTERY_MODULE) defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)
extern int twl4030charger_usb_en(int enable); extern int twl4030charger_usb_en(int enable);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment