OMAP5: Power: Added more functionality to twl6035 driver
PATCH 1/1 OMAP5: Power: Added more functionality to twl6035 driver
Signed-off-by Lubomir Popov <[email protected]>
---
This patch adds some new functions that were used for the SOM5_EVB bringup, but might be useful for other OMAP5 designs as well.
drivers/power/twl6035.c | 140 +++++++++++++++++++++++++++++++++++++++++++---- include/twl6035.h | 83 ++++++++++++++++++++++++++-- 2 files changed, 206 insertions(+), 17 deletions(-)
drivers/power/twl6035.c +129 -11
@@ -2,6 +2,8 @@* (C) Copyright 2012 * Texas Instruments, <www.ti.com> * +* 02/2013 Modified by Lubomir Popov <[email protected]> +* * See file CREDITS for list of people who contributed to this * project. *
@@ -21,9 +23,12 @@* MA 02111-1307 USA */ #include <config.h> + +#ifdef CONFIG_TWL6035_POWER +#include <twl6035.h> -/* Functions to read and write from TWL6030 */ +/* Functions to read and write from TWL6035 */ int twl6035_i2c_write_u8 (u8 chip_no,u8 val,u8 reg) {return i2c_write (chip_no, reg,1 , &val,1 );
@@ -47,28 +52,141 @@ static inline int palmas_read_u8(u8 chip_no, u8 reg, u8 *val)void twl6035_init_settings (void ) { -return ; +#ifdef CONFIG_TWL6035_SMPS7_FPWM +int err; +/* Set SMPS7 (1.8 V I/O supply) to forced PWM mode */ +u8 val =SMPS_MODE_SLP_FPWM |SMPS_MODE_ACT_FPWM ; +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,SMPS7_CTRL , val))) +printf ("twl6035: Could not force PWM for SMPS7: err = %d\n" , err); +#endif +} + +/* On some hardware the SD card socket and LDO9_IN are powered by an +* external 3.3 V regulator. Therefore VDDS_SDCARD should be 3.3 V +* as well for 3 V cards. This requires that LDO9 is set to 'bypass' +* mode for such cases. +* +* NOTE: Switching LDOs between the 0.9 - 2.1 V and 2.15 - 3.3 V ranges +* cannot be done on the fly and requires restart (off - change +* voltage - on). This should be taken care of at a higher level. +*/ +int twl6035_mmc1_set_ldo9 (u8 vsel) +{ +u8 cval=0 , vval=0 ;/* Off by default */ +int err; + +if (vsel) { +/* Turn on */ +if (vsel >LDO_VOLT_3V3 ) { +/* Put LDO9 in bypass */ + cval =LDO9_BYP_EN |RSC_MODE_SLEEP |RSC_MODE_ACTIVE ; + vval =LDO_VOLT_3V3 ; + } +else { + cval =RSC_MODE_SLEEP |RSC_MODE_ACTIVE ; + vval = vsel &0x3f ; + } + } +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,LDO9_VOLTAGE , vval))) { +printf ("twl6035: could not set LDO9 %s: err = %d\n" , + vsel >LDO_VOLT_3V3 ?"bypass" :"voltage" , err); +return err; + } +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,LDO9_CTRL , cval))) +printf ("twl6035: could not turn on LDO9: err = %d\n" , err); +return err; }int twl6035_mmc1_poweron_ldo (void ) {u8 val =0 ; -/* set LDO9 TWL6035 to 3V */ - val =0x2b ;/* (3 -.9)*28 +1 */ - -if (palmas_write_u8 (0x48 ,LDO9_VOLTAGE , val)) { +/* Set TWL6035 LDO9 to 3.0 V */ + val =LDO_VOLT_3V0 ; +if (palmas_write_u8 (TWL6035_CHIP_P1 ,LDO9_VOLTAGE , val)) {printf ("twl6035: could not set LDO9 voltage.\n" );return 1 ; } -/* TURN ON LDO9 */ - val =LDO_ON |LDO_MODE_SLEEP |LDO_MODE_ACTIVE ; - -if (palmas_write_u8 (0x48 ,LDO9_CTRL , val)) { + val =RSC_MODE_SLEEP |RSC_MODE_ACTIVE ; +if (palmas_write_u8 (TWL6035_CHIP_P1 ,LDO9_CTRL , val)) {printf ("twl6035: could not turn on LDO9.\n" );return 1 ; } -return 0 ; } + +int twl6035_usb_poweron_ldo (void ) +{ +u8 val =0 ; +int err; + +/* Enable external VCC_3v3_AUX supply on the sEVM (SYSEN2) */ + val =RSC_MODE_SLEEP |RSC_MODE_ACTIVE ; +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,SYSEN2_CTRL , val))) { +printf ("twl6035: could not set SYSEN2: err = %d\n" , err); +return err; + } + +/* TURN ON LDO's needed */ + +/* Set LDOUSB to 3.3 V */ + val =LDO_VOLT_3V3 ; +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,LDOUSB_VOLTAGE , val))) { +printf ("twl6035: could not set LDOUSB voltage: err = %d\n" , err); +return err; + } + +/* Enable LDOUSB */ + val =RSC_MODE_SLEEP |RSC_MODE_ACTIVE ; +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,LDOUSB_CTRL , val))) +printf ("twl6035: could not turn on LDOUSB: err = %d\n" , err); +return err; +} + +/* Turn audio codec power and 32 kHz clock on/off +*/ +int twl6035_audio_power (u8 on) +{ +u8 cval=0 , vval=0 , c32k=0 ; +int err; + +if (on) { + vval =SMPS_VOLT_2V1 ; + cval =SMPS_MODE_SLP_AUTO |SMPS_MODE_ACT_AUTO ; + c32k =RSC_MODE_SLEEP |RSC_MODE_ACTIVE ; + } +/* Set SMPS9 to 2.1 V (for TWL604x), or to 0 (off) */ +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,SMPS9_VOLTAGE , vval))) { +printf ("twl6035: could not set SMPS9 voltage: err = %d\n" , err); +return err; + } +/* Turn on or off SMPS9 */ +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,SMPS9_CTRL , cval))) { +printf ("twl6035: could not turn SMPS9 %s: err = %d\n" , + cval ?"on" :"off" , err); +return err; + } +/* Output 32 kHz clock on or off */ +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,CLK32KGAUDIO_CTRL , c32k))) +printf ("twl6035: could not turn CLK32KGAUDIO %s: err = %d\n" , + c32k ?"on" :"off" , err); +return err; +} + +/* Enable/disable back-up battery (or super cap) charging. +* Please use defines. +*/ +int twl6035_enable_bb_charge (u8 bb_fields) +{ +u8 val = bb_fields &0x0f ; +int err; + + val |= (VRTC_EN_SLP |VRTC_EN_OFF |VRTC_PWEN ); +if ((err =palmas_write_u8 (TWL6035_CHIP_P1 ,BB_VRTC_CTRL , val))) +printf ("twl6035: could not set BB_VRTC_CTRL to 0x%02x: err = %d\n" , val, err); +return err; +} + +#endif /* CONFIG_TWL6035_POWER */ +
include/twl6035.h +77 -6
101 lines not on this page · raw message
Signature · 1 line
1.7.9.5