Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
twl-core.c File Reference
#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/regulator/machine.h>
#include <linux/i2c.h>
#include <linux/i2c/twl.h>
#include "twl-core.h"

Go to the source code of this file.

Data Structures

struct  twl_client
 
struct  twl_mapping
 

Macros

#define DRIVER_NAME   "twl"
 
#define TWL4030_MODULE_LAST   TWL4030_MODULE_SECURED_REG
 
#define TWL_NUM_SLAVES   4
 
#define SUB_CHIP_ID0   0
 
#define SUB_CHIP_ID1   1
 
#define SUB_CHIP_ID2   2
 
#define SUB_CHIP_ID3   3
 
#define SUB_CHIP_ID_INVAL   0xff
 
#define TWL_MODULE_LAST   TWL4030_MODULE_LAST
 
#define TWL4030_BASEADD_USB   0x0000
 
#define TWL4030_BASEADD_AUDIO_VOICE   0x0000
 
#define TWL4030_BASEADD_GPIO   0x0098
 
#define TWL4030_BASEADD_INTBR   0x0085
 
#define TWL4030_BASEADD_PIH   0x0080
 
#define TWL4030_BASEADD_TEST   0x004C
 
#define TWL4030_BASEADD_INTERRUPTS   0x00B9
 
#define TWL4030_BASEADD_LED   0x00EE
 
#define TWL4030_BASEADD_MADC   0x0000
 
#define TWL4030_BASEADD_MAIN_CHARGE   0x0074
 
#define TWL4030_BASEADD_PRECHARGE   0x00AA
 
#define TWL4030_BASEADD_PWM0   0x00F8
 
#define TWL4030_BASEADD_PWM1   0x00FB
 
#define TWL4030_BASEADD_PWMA   0x00EF
 
#define TWL4030_BASEADD_PWMB   0x00F1
 
#define TWL4030_BASEADD_KEYPAD   0x00D2
 
#define TWL5031_BASEADD_ACCESSORY   0x0074 /* Replaces Main Charge */
 
#define TWL5031_BASEADD_INTERRUPTS
 
#define TWL4030_BASEADD_BACKUP   0x0014
 
#define TWL4030_BASEADD_INT   0x002E
 
#define TWL4030_BASEADD_PM_MASTER   0x0036
 
#define TWL4030_BASEADD_PM_RECEIVER   0x005B
 
#define TWL4030_BASEADD_RTC   0x001C
 
#define TWL4030_BASEADD_SECURED_REG   0x0000
 
#define TWL6030_BASEADD_RTC   0x0000
 
#define TWL6030_BASEADD_MEM   0x0017
 
#define TWL6030_BASEADD_PM_MASTER   0x001F
 
#define TWL6030_BASEADD_PM_SLAVE_MISC   0x0030 /* PM_RECEIVER */
 
#define TWL6030_BASEADD_PM_MISC   0x00E2
 
#define TWL6030_BASEADD_PM_PUPD   0x00F0
 
#define TWL6030_BASEADD_USB   0x0000
 
#define TWL6030_BASEADD_GPADC_CTRL   0x002E
 
#define TWL6030_BASEADD_AUX   0x0090
 
#define TWL6030_BASEADD_PWM   0x00BA
 
#define TWL6030_BASEADD_GASGAUGE   0x00C0
 
#define TWL6030_BASEADD_PIH   0x00D0
 
#define TWL6030_BASEADD_CHARGER   0x00E0
 
#define TWL6025_BASEADD_CHARGER   0x00DA
 
#define TWL6030_BASEADD_DIEID   0x00C0
 
#define TWL6030_BASEADD_AUDIO   0x0000
 
#define TWL6030_BASEADD_RSV   0x0000
 
#define TWL6030_BASEADD_ZERO   0x0000
 
#define R_CFG_BOOT   0x05
 
#define HFCLK_FREQ_19p2_MHZ   (1 << 0)
 
#define HFCLK_FREQ_26_MHZ   (2 << 0)
 
#define HFCLK_FREQ_38p4_MHZ   (3 << 0)
 
#define HIGH_PERF_SQ   (1 << 3)
 
#define CK32K_LOWPWR_EN   (1 << 7)
 

Functions

unsigned int twl_rev (void)
 
 EXPORT_SYMBOL (twl_rev)
 
int twl_i2c_write (u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
 
 EXPORT_SYMBOL (twl_i2c_write)
 
int twl_i2c_read (u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
 
 EXPORT_SYMBOL (twl_i2c_read)
 
int twl_i2c_write_u8 (u8 mod_no, u8 value, u8 reg)
 
 EXPORT_SYMBOL (twl_i2c_write_u8)
 
int twl_i2c_read_u8 (u8 mod_no, u8 *value, u8 reg)
 
 EXPORT_SYMBOL (twl_i2c_read_u8)
 
int twl_get_type (void)
 
 EXPORT_SYMBOL_GPL (twl_get_type)
 
int twl_get_version (void)
 
 EXPORT_SYMBOL_GPL (twl_get_version)
 
int twl_get_hfclk_rate (void)
 
 EXPORT_SYMBOL_GPL (twl_get_hfclk_rate)
 
 MODULE_DEVICE_TABLE (i2c, twl_ids)
 
 subsys_initcall (twl_init)
 
 module_exit (twl_exit)
 
 MODULE_AUTHOR ("Texas Instruments, Inc.")
 
 MODULE_DESCRIPTION ("I2C Core interface for TWL")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define CK32K_LOWPWR_EN   (1 << 7)

Definition at line 153 of file twl-core.c.

#define DRIVER_NAME   "twl"

Definition at line 64 of file twl-core.c.

#define HFCLK_FREQ_19p2_MHZ   (1 << 0)

Definition at line 149 of file twl-core.c.

#define HFCLK_FREQ_26_MHZ   (2 << 0)

Definition at line 150 of file twl-core.c.

#define HFCLK_FREQ_38p4_MHZ   (3 << 0)

Definition at line 151 of file twl-core.c.

#define HIGH_PERF_SQ   (1 << 3)

Definition at line 152 of file twl-core.c.

#define R_CFG_BOOT   0x05

Definition at line 146 of file twl-core.c.

#define SUB_CHIP_ID0   0

Definition at line 73 of file twl-core.c.

#define SUB_CHIP_ID1   1

Definition at line 74 of file twl-core.c.

#define SUB_CHIP_ID2   2

Definition at line 75 of file twl-core.c.

#define SUB_CHIP_ID3   3

Definition at line 76 of file twl-core.c.

#define SUB_CHIP_ID_INVAL   0xff

Definition at line 77 of file twl-core.c.

#define TWL4030_BASEADD_AUDIO_VOICE   0x0000

Definition at line 87 of file twl-core.c.

#define TWL4030_BASEADD_BACKUP   0x0014

Definition at line 109 of file twl-core.c.

#define TWL4030_BASEADD_GPIO   0x0098

Definition at line 88 of file twl-core.c.

#define TWL4030_BASEADD_INT   0x002E

Definition at line 110 of file twl-core.c.

#define TWL4030_BASEADD_INTBR   0x0085

Definition at line 89 of file twl-core.c.

#define TWL4030_BASEADD_INTERRUPTS   0x00B9

Definition at line 94 of file twl-core.c.

#define TWL4030_BASEADD_KEYPAD   0x00D2

Definition at line 103 of file twl-core.c.

#define TWL4030_BASEADD_LED   0x00EE

Definition at line 95 of file twl-core.c.

#define TWL4030_BASEADD_MADC   0x0000

Definition at line 96 of file twl-core.c.

#define TWL4030_BASEADD_MAIN_CHARGE   0x0074

Definition at line 97 of file twl-core.c.

#define TWL4030_BASEADD_PIH   0x0080

Definition at line 90 of file twl-core.c.

#define TWL4030_BASEADD_PM_MASTER   0x0036

Definition at line 111 of file twl-core.c.

#define TWL4030_BASEADD_PM_RECEIVER   0x005B

Definition at line 112 of file twl-core.c.

#define TWL4030_BASEADD_PRECHARGE   0x00AA

Definition at line 98 of file twl-core.c.

#define TWL4030_BASEADD_PWM0   0x00F8

Definition at line 99 of file twl-core.c.

#define TWL4030_BASEADD_PWM1   0x00FB

Definition at line 100 of file twl-core.c.

#define TWL4030_BASEADD_PWMA   0x00EF

Definition at line 101 of file twl-core.c.

#define TWL4030_BASEADD_PWMB   0x00F1

Definition at line 102 of file twl-core.c.

#define TWL4030_BASEADD_RTC   0x001C

Definition at line 113 of file twl-core.c.

#define TWL4030_BASEADD_SECURED_REG   0x0000

Definition at line 114 of file twl-core.c.

#define TWL4030_BASEADD_TEST   0x004C

Definition at line 91 of file twl-core.c.

#define TWL4030_BASEADD_USB   0x0000

Definition at line 84 of file twl-core.c.

#define TWL4030_MODULE_LAST   TWL4030_MODULE_SECURED_REG

Definition at line 69 of file twl-core.c.

#define TWL5031_BASEADD_ACCESSORY   0x0074 /* Replaces Main Charge */

Definition at line 105 of file twl-core.c.

#define TWL5031_BASEADD_INTERRUPTS
Value:
0x00B9 /* Different than TWL4030's
one */

Definition at line 106 of file twl-core.c.

#define TWL6025_BASEADD_CHARGER   0x00DA

Definition at line 135 of file twl-core.c.

#define TWL6030_BASEADD_AUDIO   0x0000

Definition at line 141 of file twl-core.c.

#define TWL6030_BASEADD_AUX   0x0090

Definition at line 130 of file twl-core.c.

#define TWL6030_BASEADD_CHARGER   0x00E0

Definition at line 134 of file twl-core.c.

#define TWL6030_BASEADD_DIEID   0x00C0

Definition at line 138 of file twl-core.c.

#define TWL6030_BASEADD_GASGAUGE   0x00C0

Definition at line 132 of file twl-core.c.

#define TWL6030_BASEADD_GPADC_CTRL   0x002E

Definition at line 129 of file twl-core.c.

#define TWL6030_BASEADD_MEM   0x0017

Definition at line 121 of file twl-core.c.

#define TWL6030_BASEADD_PIH   0x00D0

Definition at line 133 of file twl-core.c.

#define TWL6030_BASEADD_PM_MASTER   0x001F

Definition at line 122 of file twl-core.c.

#define TWL6030_BASEADD_PM_MISC   0x00E2

Definition at line 124 of file twl-core.c.

#define TWL6030_BASEADD_PM_PUPD   0x00F0

Definition at line 125 of file twl-core.c.

#define TWL6030_BASEADD_PM_SLAVE_MISC   0x0030 /* PM_RECEIVER */

Definition at line 123 of file twl-core.c.

#define TWL6030_BASEADD_PWM   0x00BA

Definition at line 131 of file twl-core.c.

#define TWL6030_BASEADD_RSV   0x0000

Definition at line 142 of file twl-core.c.

#define TWL6030_BASEADD_RTC   0x0000

Definition at line 120 of file twl-core.c.

#define TWL6030_BASEADD_USB   0x0000

Definition at line 128 of file twl-core.c.

#define TWL6030_BASEADD_ZERO   0x0000

Definition at line 143 of file twl-core.c.

#define TWL_MODULE_LAST   TWL4030_MODULE_LAST

Definition at line 79 of file twl-core.c.

#define TWL_NUM_SLAVES   4

Definition at line 71 of file twl-core.c.

Function Documentation

EXPORT_SYMBOL ( twl_rev  )
EXPORT_SYMBOL ( twl_i2c_write  )
EXPORT_SYMBOL ( twl_i2c_read  )
EXPORT_SYMBOL ( twl_i2c_write_u8  )
EXPORT_SYMBOL ( twl_i2c_read_u8  )
EXPORT_SYMBOL_GPL ( twl_get_type  )
EXPORT_SYMBOL_GPL ( twl_get_version  )
EXPORT_SYMBOL_GPL ( twl_get_hfclk_rate  )
MODULE_AUTHOR ( "Texas  Instruments,
Inc."   
)
MODULE_DESCRIPTION ( "I2C Core interface for TWL"  )
MODULE_DEVICE_TABLE ( i2c  ,
twl_ids   
)
module_exit ( twl_exit  )
MODULE_LICENSE ( "GPL"  )
subsys_initcall ( twl_init  )
int twl_get_hfclk_rate ( void  )

twl_get_hfclk_rate - API to get TWL external HFCLK clock rate.

Api to get the TWL HFCLK rate based on BOOT_CFG register.

Definition at line 488 of file twl-core.c.

int twl_get_type ( void  )

twl_get_type - API to get TWL Si type.

Api to get the TWL Si type from IDCODE value.

Definition at line 466 of file twl-core.c.

int twl_get_version ( void  )

twl_get_version - API to get TWL Si version.

Api to get the TWL Si version from IDCODE value.

Definition at line 477 of file twl-core.c.

int twl_i2c_read ( u8  mod_no,
u8 value,
u8  reg,
unsigned  num_bytes 
)

twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0 : module number : an array of num_bytes containing data to be read : register address (just offset will do) : number of bytes to transfer

Returns result of operation - num_bytes is success else failure.

Definition at line 341 of file twl-core.c.

int twl_i2c_read_u8 ( u8  mod_no,
u8 value,
u8  reg 
)

twl_i2c_read_u8 - Reads a 8 bit register from TWL4030/TWL5030/TWL60X0 : module number : the value read 8 bit : register address (just offset will do)

Returns result of operation - 0 is success

Definition at line 423 of file twl-core.c.

int twl_i2c_write ( u8  mod_no,
u8 value,
u8  reg,
unsigned  num_bytes 
)

twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0 : module number : an array of num_bytes+1 containing data to write : register address (just offset will do) : number of bytes to transfer

IMPORTANT: for 'value' parameter: Allocate value num_bytes+1 and valid data starts at Offset 1.

Returns the result of operation - 0 is success

Definition at line 280 of file twl-core.c.

int twl_i2c_write_u8 ( u8  mod_no,
u8  value,
u8  reg 
)

twl_i2c_write_u8 - Writes a 8 bit register in TWL4030/TWL5030/TWL60X0 : module number : the value to be written 8 bit : register address (just offset will do)

Returns result of operation - 0 is success

Definition at line 404 of file twl-core.c.

unsigned int twl_rev ( void  )

Definition at line 164 of file twl-core.c.