181181/* Triton Core internal information (END) */
182182
183183
184+ /* subchip/slave 0 0x48 - POWER */
185+ #define TWL6030_BASEADD_RTC 0x0000
186+ #define TWL6030_BASEADD_MEM 0x0017
187+ #define TWL6030_BASEADD_PM_MASTER 0x001F
188+ #define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 /* PM_RECEIVER */
189+ #define TWL6030_BASEADD_PM_MISC 0x00E2
190+ #define TWL6030_BASEADD_PM_PUPD 0x00F0
191+
192+ /* subchip/slave 1 0x49 - FEATURE */
193+ #define TWL6030_BASEADD_USB 0x0000
194+ #define TWL6030_BASEADD_GPADC_CTRL 0x002E
195+ #define TWL6030_BASEADD_AUX 0x0090
196+ #define TWL6030_BASEADD_PWM 0x00BA
197+ #define TWL6030_BASEADD_GASGAUGE 0x00C0
198+ #define TWL6030_BASEADD_PIH 0x00D0
199+ #define TWL6030_BASEADD_CHARGER 0x00E0
200+
201+ /* subchip/slave 2 0x4A - DFT */
202+ #define TWL6030_BASEADD_DIEID 0x00C0
203+
204+ /* subchip/slave 3 0x4B - AUDIO */
205+ #define TWL6030_BASEADD_AUDIO 0x0000
206+ #define TWL6030_BASEADD_RSV 0x0000
207+
184208/* Few power values */
185209#define R_CFG_BOOT 0x05
186210#define R_PROTECT_KEY 0x0E
202226#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */
203227#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */
204228#define TWL5031 BIT(2) /* twl5031 has different registers */
229+ #define TWL6030_CLASS BIT(3) /* TWL6030 class */
205230
206231/*----------------------------------------------------------------------*/
207232
208233/* is driver active, bound to a chip? */
209234static bool inuse ;
210235
211- /* Structure for each TWL4030 Slave */
236+ static unsigned int twl_id ;
237+ unsigned int twl_rev (void )
238+ {
239+ return twl_id ;
240+ }
241+ EXPORT_SYMBOL (twl_rev );
242+
243+ /* Structure for each TWL4030/TWL6030 Slave */
212244struct twl_client {
213245 struct i2c_client * client ;
214246 u8 address ;
@@ -228,11 +260,12 @@ struct twl_mapping {
228260 unsigned char sid ; /* Slave ID */
229261 unsigned char base ; /* base address */
230262};
263+ struct twl_mapping * twl_map ;
231264
232265static struct twl_mapping twl4030_map [TWL4030_MODULE_LAST + 1 ] = {
233266 /*
234267 * NOTE: don't change this table without updating the
235- * <linux/i2c/twl4030 .h> defines for TWL4030_MODULE_*
268+ * <linux/i2c/twl .h> defines for TWL4030_MODULE_*
236269 * so they continue to match the order in this table.
237270 */
238271
@@ -265,6 +298,40 @@ static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
265298 { 3 , TWL4030_BASEADD_SECURED_REG },
266299};
267300
301+ static struct twl_mapping twl6030_map [] = {
302+ /*
303+ * NOTE: don't change this table without updating the
304+ * <linux/i2c/twl.h> defines for TWL4030_MODULE_*
305+ * so they continue to match the order in this table.
306+ */
307+ { SUB_CHIP_ID1 , TWL6030_BASEADD_USB },
308+ { SUB_CHIP_ID3 , TWL6030_BASEADD_AUDIO },
309+ { SUB_CHIP_ID2 , TWL6030_BASEADD_DIEID },
310+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
311+ { SUB_CHIP_ID1 , TWL6030_BASEADD_PIH },
312+
313+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
314+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
315+ { SUB_CHIP_ID1 , TWL6030_BASEADD_GPADC_CTRL },
316+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
317+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
318+
319+ { SUB_CHIP_ID1 , TWL6030_BASEADD_CHARGER },
320+ { SUB_CHIP_ID1 , TWL6030_BASEADD_GASGAUGE },
321+ { SUB_CHIP_ID1 , TWL6030_BASEADD_PWM },
322+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
323+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
324+
325+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
326+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
327+ { SUB_CHIP_ID2 , TWL6030_BASEADD_RSV },
328+ { SUB_CHIP_ID0 , TWL6030_BASEADD_PM_MASTER },
329+ { SUB_CHIP_ID0 , TWL6030_BASEADD_PM_SLAVE_MISC },
330+
331+ { SUB_CHIP_ID0 , TWL6030_BASEADD_RTC },
332+ { SUB_CHIP_ID0 , TWL6030_BASEADD_MEM },
333+ };
334+
268335/*----------------------------------------------------------------------*/
269336
270337/* Exported Functions */
@@ -292,7 +359,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
292359 pr_err ("%s: invalid module number %d\n" , DRIVER_NAME , mod_no );
293360 return - EPERM ;
294361 }
295- sid = twl4030_map [mod_no ].sid ;
362+ sid = twl_map [mod_no ].sid ;
296363 twl = & twl_modules [sid ];
297364
298365 if (unlikely (!inuse )) {
@@ -310,7 +377,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
310377 msg -> flags = 0 ;
311378 msg -> buf = value ;
312379 /* over write the first byte of buffer with the register address */
313- * value = twl4030_map [mod_no ].base + reg ;
380+ * value = twl_map [mod_no ].base + reg ;
314381 ret = i2c_transfer (twl -> client -> adapter , twl -> xfer_msg , 1 );
315382 mutex_unlock (& twl -> xfer_lock );
316383
@@ -349,7 +416,7 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
349416 pr_err ("%s: invalid module number %d\n" , DRIVER_NAME , mod_no );
350417 return - EPERM ;
351418 }
352- sid = twl4030_map [mod_no ].sid ;
419+ sid = twl_map [mod_no ].sid ;
353420 twl = & twl_modules [sid ];
354421
355422 if (unlikely (!inuse )) {
@@ -362,7 +429,7 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
362429 msg -> addr = twl -> address ;
363430 msg -> len = 1 ;
364431 msg -> flags = 0 ; /* Read the register value */
365- val = twl4030_map [mod_no ].base + reg ;
432+ val = twl_map [mod_no ].base + reg ;
366433 msg -> buf = & val ;
367434 /* [MSG2] fill the data rx buffer */
368435 msg = & twl -> xfer_msg [1 ];
@@ -486,6 +553,7 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
486553 struct regulator_consumer_supply * consumers ,
487554 unsigned num_consumers )
488555{
556+ unsigned sub_chip_id ;
489557 /* regulator framework demands init_data ... */
490558 if (!pdata )
491559 return NULL ;
@@ -496,7 +564,8 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
496564 }
497565
498566 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */
499- return add_numbered_child (3 , "twl_reg" , num ,
567+ sub_chip_id = twl_map [TWL_MODULE_PM_MASTER ].sid ;
568+ return add_numbered_child (sub_chip_id , "twl_reg" , num ,
500569 pdata , sizeof (* pdata ), false, 0 , 0 );
501570}
502571
@@ -516,6 +585,7 @@ static int
516585add_children (struct twl4030_platform_data * pdata , unsigned long features )
517586{
518587 struct device * child ;
588+ unsigned sub_chip_id ;
519589
520590 if (twl_has_bci () && pdata -> bci &&
521591 !(features & (TPS_SUBSET | TWL5031 ))) {
@@ -561,7 +631,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
561631 * Eventually, Linux might become more aware of such
562632 * HW security concerns, and "least privilege".
563633 */
564- child = add_child (3 , "twl_rtc" ,
634+ sub_chip_id = twl_map [TWL_MODULE_RTC ].sid ;
635+ child = add_child (sub_chip_id , "twl_rtc" ,
565636 NULL , 0 ,
566637 true, pdata -> irq_base + RTC_INTR_OFFSET , 0 );
567638 if (IS_ERR (child ))
@@ -812,16 +883,22 @@ static void clocks_init(struct device *dev,
812883
813884/*----------------------------------------------------------------------*/
814885
815- int twl_init_irq (int irq_num , unsigned irq_base , unsigned irq_end );
816- int twl_exit_irq (void );
817- int twl_init_chip_irq (const char * chip );
886+ int twl4030_init_irq (int irq_num , unsigned irq_base , unsigned irq_end );
887+ int twl4030_exit_irq (void );
888+ int twl4030_init_chip_irq (const char * chip );
889+ int twl6030_init_irq (int irq_num , unsigned irq_base , unsigned irq_end );
890+ int twl6030_exit_irq (void );
818891
819892static int twl_remove (struct i2c_client * client )
820893{
821894 unsigned i ;
822895 int status ;
823896
824- status = twl_exit_irq ();
897+ if (twl_class_is_4030 ())
898+ status = twl4030_exit_irq ();
899+ else
900+ status = twl6030_exit_irq ();
901+
825902 if (status < 0 )
826903 return status ;
827904
@@ -878,6 +955,13 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
878955 mutex_init (& twl -> xfer_lock );
879956 }
880957 inuse = true;
958+ if ((id -> driver_data ) & TWL6030_CLASS ) {
959+ twl_id = TWL6030_CLASS_ID ;
960+ twl_map = & twl6030_map [0 ];
961+ } else {
962+ twl_id = TWL4030_CLASS_ID ;
963+ twl_map = & twl4030_map [0 ];
964+ }
881965
882966 /* setup clock framework */
883967 clocks_init (& client -> dev , pdata -> clock );
@@ -890,8 +974,15 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
890974 if (client -> irq
891975 && pdata -> irq_base
892976 && pdata -> irq_end > pdata -> irq_base ) {
893- twl_init_chip_irq (id -> name );
894- status = twl_init_irq (client -> irq , pdata -> irq_base , pdata -> irq_end );
977+ if (twl_class_is_4030 ()) {
978+ twl4030_init_chip_irq (id -> name );
979+ status = twl4030_init_irq (client -> irq , pdata -> irq_base ,
980+ pdata -> irq_end );
981+ } else {
982+ status = twl6030_init_irq (client -> irq , pdata -> irq_base ,
983+ pdata -> irq_end );
984+ }
985+
895986 if (status < 0 )
896987 goto fail ;
897988 }
@@ -910,6 +1001,7 @@ static const struct i2c_device_id twl_ids[] = {
9101001 { "tps65950" , 0 }, /* catalog version of twl5030 */
9111002 { "tps65930" , TPS_SUBSET }, /* fewer LDOs and DACs; no charger */
9121003 { "tps65920" , TPS_SUBSET }, /* fewer LDOs; no codec or charger */
1004+ { "twl6030" , TWL6030_CLASS }, /* "Phoenix power chip" */
9131005 { /* end of list */ },
9141006};
9151007MODULE_DEVICE_TABLE (i2c , twl_ids );
0 commit comments