twl-core.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. /*
  2. * twl_core.c - driver for TWL4030/TWL5030/TWL60X0/TPS659x0 PM
  3. * and audio CODEC devices
  4. *
  5. * Copyright (C) 2005-2006 Texas Instruments, Inc.
  6. *
  7. * Modifications to defer interrupt handling to a kernel thread:
  8. * Copyright (C) 2006 MontaVista Software, Inc.
  9. *
  10. * Based on tlv320aic23.c:
  11. * Copyright (c) by Kai Svahn <kai.svahn@nokia.com>
  12. *
  13. * Code cleanup and modifications to IRQ handler.
  14. * by syed khasim <x0khasim@ti.com>
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 2 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  29. */
  30. #include <linux/init.h>
  31. #include <linux/mutex.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/clk.h>
  34. #include <linux/err.h>
  35. #include <linux/regulator/machine.h>
  36. #include <linux/i2c.h>
  37. #include <linux/i2c/twl.h>
  38. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  39. #include <plat/cpu.h>
  40. #endif
  41. /*
  42. * The TWL4030 "Triton 2" is one of a family of a multi-function "Power
  43. * Management and System Companion Device" chips originally designed for
  44. * use in OMAP2 and OMAP 3 based systems. Its control interfaces use I2C,
  45. * often at around 3 Mbit/sec, including for interrupt handling.
  46. *
  47. * This driver core provides genirq support for the interrupts emitted,
  48. * by the various modules, and exports register access primitives.
  49. *
  50. * FIXME this driver currently requires use of the first interrupt line
  51. * (and associated registers).
  52. */
  53. #define DRIVER_NAME "twl"
  54. #if defined(CONFIG_KEYBOARD_TWL4030) || defined(CONFIG_KEYBOARD_TWL4030_MODULE)
  55. #define twl_has_keypad() true
  56. #else
  57. #define twl_has_keypad() false
  58. #endif
  59. #if defined(CONFIG_GPIO_TWL4030) || defined(CONFIG_GPIO_TWL4030_MODULE)
  60. #define twl_has_gpio() true
  61. #else
  62. #define twl_has_gpio() false
  63. #endif
  64. #if defined(CONFIG_REGULATOR_TWL4030) \
  65. || defined(CONFIG_REGULATOR_TWL4030_MODULE)
  66. #define twl_has_regulator() true
  67. #else
  68. #define twl_has_regulator() false
  69. #endif
  70. #if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE)
  71. #define twl_has_madc() true
  72. #else
  73. #define twl_has_madc() false
  74. #endif
  75. #ifdef CONFIG_TWL4030_POWER
  76. #define twl_has_power() true
  77. #else
  78. #define twl_has_power() false
  79. #endif
  80. #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
  81. #define twl_has_rtc() true
  82. #else
  83. #define twl_has_rtc() false
  84. #endif
  85. #if defined(CONFIG_TWL4030_USB) || defined(CONFIG_TWL4030_USB_MODULE) ||\
  86. defined(CONFIG_TWL6030_USB) || defined(CONFIG_TWL6030_USB_MODULE)
  87. #define twl_has_usb() true
  88. #else
  89. #define twl_has_usb() false
  90. #endif
  91. #if defined(CONFIG_TWL4030_WATCHDOG) || \
  92. defined(CONFIG_TWL4030_WATCHDOG_MODULE)
  93. #define twl_has_watchdog() true
  94. #else
  95. #define twl_has_watchdog() false
  96. #endif
  97. #if defined(CONFIG_TWL4030_CODEC) || defined(CONFIG_TWL4030_CODEC_MODULE) ||\
  98. defined(CONFIG_SND_SOC_TWL6040) || defined(CONFIG_SND_SOC_TWL6040_MODULE)
  99. #define twl_has_codec() true
  100. #else
  101. #define twl_has_codec() false
  102. #endif
  103. #if defined(CONFIG_CHARGER_TWL4030) || defined(CONFIG_CHARGER_TWL4030_MODULE)
  104. #define twl_has_bci() true
  105. #else
  106. #define twl_has_bci() false
  107. #endif
  108. /* Triton Core internal information (BEGIN) */
  109. /* Last - for index max*/
  110. #define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG
  111. #define TWL_NUM_SLAVES 4
  112. #if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \
  113. || defined(CONFIG_INPUT_TWL4030_PWRBUTTON_MODULE)
  114. #define twl_has_pwrbutton() true
  115. #else
  116. #define twl_has_pwrbutton() false
  117. #endif
  118. #define SUB_CHIP_ID0 0
  119. #define SUB_CHIP_ID1 1
  120. #define SUB_CHIP_ID2 2
  121. #define SUB_CHIP_ID3 3
  122. #define TWL_MODULE_LAST TWL4030_MODULE_LAST
  123. /* Base Address defns for twl4030_map[] */
  124. /* subchip/slave 0 - USB ID */
  125. #define TWL4030_BASEADD_USB 0x0000
  126. /* subchip/slave 1 - AUD ID */
  127. #define TWL4030_BASEADD_AUDIO_VOICE 0x0000
  128. #define TWL4030_BASEADD_GPIO 0x0098
  129. #define TWL4030_BASEADD_INTBR 0x0085
  130. #define TWL4030_BASEADD_PIH 0x0080
  131. #define TWL4030_BASEADD_TEST 0x004C
  132. /* subchip/slave 2 - AUX ID */
  133. #define TWL4030_BASEADD_INTERRUPTS 0x00B9
  134. #define TWL4030_BASEADD_LED 0x00EE
  135. #define TWL4030_BASEADD_MADC 0x0000
  136. #define TWL4030_BASEADD_MAIN_CHARGE 0x0074
  137. #define TWL4030_BASEADD_PRECHARGE 0x00AA
  138. #define TWL4030_BASEADD_PWM0 0x00F8
  139. #define TWL4030_BASEADD_PWM1 0x00FB
  140. #define TWL4030_BASEADD_PWMA 0x00EF
  141. #define TWL4030_BASEADD_PWMB 0x00F1
  142. #define TWL4030_BASEADD_KEYPAD 0x00D2
  143. #define TWL5031_BASEADD_ACCESSORY 0x0074 /* Replaces Main Charge */
  144. #define TWL5031_BASEADD_INTERRUPTS 0x00B9 /* Different than TWL4030's
  145. one */
  146. /* subchip/slave 3 - POWER ID */
  147. #define TWL4030_BASEADD_BACKUP 0x0014
  148. #define TWL4030_BASEADD_INT 0x002E
  149. #define TWL4030_BASEADD_PM_MASTER 0x0036
  150. #define TWL4030_BASEADD_PM_RECEIVER 0x005B
  151. #define TWL4030_BASEADD_RTC 0x001C
  152. #define TWL4030_BASEADD_SECURED_REG 0x0000
  153. /* Triton Core internal information (END) */
  154. /* subchip/slave 0 0x48 - POWER */
  155. #define TWL6030_BASEADD_RTC 0x0000
  156. #define TWL6030_BASEADD_MEM 0x0017
  157. #define TWL6030_BASEADD_PM_MASTER 0x001F
  158. #define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 /* PM_RECEIVER */
  159. #define TWL6030_BASEADD_PM_MISC 0x00E2
  160. #define TWL6030_BASEADD_PM_PUPD 0x00F0
  161. /* subchip/slave 1 0x49 - FEATURE */
  162. #define TWL6030_BASEADD_USB 0x0000
  163. #define TWL6030_BASEADD_GPADC_CTRL 0x002E
  164. #define TWL6030_BASEADD_AUX 0x0090
  165. #define TWL6030_BASEADD_PWM 0x00BA
  166. #define TWL6030_BASEADD_GASGAUGE 0x00C0
  167. #define TWL6030_BASEADD_PIH 0x00D0
  168. #define TWL6030_BASEADD_CHARGER 0x00E0
  169. /* subchip/slave 2 0x4A - DFT */
  170. #define TWL6030_BASEADD_DIEID 0x00C0
  171. /* subchip/slave 3 0x4B - AUDIO */
  172. #define TWL6030_BASEADD_AUDIO 0x0000
  173. #define TWL6030_BASEADD_RSV 0x0000
  174. #define TWL6030_BASEADD_ZERO 0x0000
  175. /* Few power values */
  176. #define R_CFG_BOOT 0x05
  177. /* some fields in R_CFG_BOOT */
  178. #define HFCLK_FREQ_19p2_MHZ (1 << 0)
  179. #define HFCLK_FREQ_26_MHZ (2 << 0)
  180. #define HFCLK_FREQ_38p4_MHZ (3 << 0)
  181. #define HIGH_PERF_SQ (1 << 3)
  182. #define CK32K_LOWPWR_EN (1 << 7)
  183. /* chip-specific feature flags, for i2c_device_id.driver_data */
  184. #define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */
  185. #define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */
  186. #define TWL5031 BIT(2) /* twl5031 has different registers */
  187. #define TWL6030_CLASS BIT(3) /* TWL6030 class */
  188. /*----------------------------------------------------------------------*/
  189. /* is driver active, bound to a chip? */
  190. static bool inuse;
  191. /* TWL IDCODE Register value */
  192. static u32 twl_idcode;
  193. static unsigned int twl_id;
  194. unsigned int twl_rev(void)
  195. {
  196. return twl_id;
  197. }
  198. EXPORT_SYMBOL(twl_rev);
  199. /* Structure for each TWL4030/TWL6030 Slave */
  200. struct twl_client {
  201. struct i2c_client *client;
  202. u8 address;
  203. /* max numb of i2c_msg required is for read =2 */
  204. struct i2c_msg xfer_msg[2];
  205. /* To lock access to xfer_msg */
  206. struct mutex xfer_lock;
  207. };
  208. static struct twl_client twl_modules[TWL_NUM_SLAVES];
  209. /* mapping the module id to slave id and base address */
  210. struct twl_mapping {
  211. unsigned char sid; /* Slave ID */
  212. unsigned char base; /* base address */
  213. };
  214. static struct twl_mapping *twl_map;
  215. static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
  216. /*
  217. * NOTE: don't change this table without updating the
  218. * <linux/i2c/twl.h> defines for TWL4030_MODULE_*
  219. * so they continue to match the order in this table.
  220. */
  221. { 0, TWL4030_BASEADD_USB },
  222. { 1, TWL4030_BASEADD_AUDIO_VOICE },
  223. { 1, TWL4030_BASEADD_GPIO },
  224. { 1, TWL4030_BASEADD_INTBR },
  225. { 1, TWL4030_BASEADD_PIH },
  226. { 1, TWL4030_BASEADD_TEST },
  227. { 2, TWL4030_BASEADD_KEYPAD },
  228. { 2, TWL4030_BASEADD_MADC },
  229. { 2, TWL4030_BASEADD_INTERRUPTS },
  230. { 2, TWL4030_BASEADD_LED },
  231. { 2, TWL4030_BASEADD_MAIN_CHARGE },
  232. { 2, TWL4030_BASEADD_PRECHARGE },
  233. { 2, TWL4030_BASEADD_PWM0 },
  234. { 2, TWL4030_BASEADD_PWM1 },
  235. { 2, TWL4030_BASEADD_PWMA },
  236. { 2, TWL4030_BASEADD_PWMB },
  237. { 2, TWL5031_BASEADD_ACCESSORY },
  238. { 2, TWL5031_BASEADD_INTERRUPTS },
  239. { 3, TWL4030_BASEADD_BACKUP },
  240. { 3, TWL4030_BASEADD_INT },
  241. { 3, TWL4030_BASEADD_PM_MASTER },
  242. { 3, TWL4030_BASEADD_PM_RECEIVER },
  243. { 3, TWL4030_BASEADD_RTC },
  244. { 3, TWL4030_BASEADD_SECURED_REG },
  245. };
  246. static struct twl_mapping twl6030_map[] = {
  247. /*
  248. * NOTE: don't change this table without updating the
  249. * <linux/i2c/twl.h> defines for TWL4030_MODULE_*
  250. * so they continue to match the order in this table.
  251. */
  252. { SUB_CHIP_ID1, TWL6030_BASEADD_USB },
  253. { SUB_CHIP_ID3, TWL6030_BASEADD_AUDIO },
  254. { SUB_CHIP_ID2, TWL6030_BASEADD_DIEID },
  255. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  256. { SUB_CHIP_ID1, TWL6030_BASEADD_PIH },
  257. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  258. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  259. { SUB_CHIP_ID1, TWL6030_BASEADD_GPADC_CTRL },
  260. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  261. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  262. { SUB_CHIP_ID1, TWL6030_BASEADD_CHARGER },
  263. { SUB_CHIP_ID1, TWL6030_BASEADD_GASGAUGE },
  264. { SUB_CHIP_ID1, TWL6030_BASEADD_PWM },
  265. { SUB_CHIP_ID0, TWL6030_BASEADD_ZERO },
  266. { SUB_CHIP_ID1, TWL6030_BASEADD_ZERO },
  267. { SUB_CHIP_ID2, TWL6030_BASEADD_ZERO },
  268. { SUB_CHIP_ID2, TWL6030_BASEADD_ZERO },
  269. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  270. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  271. { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
  272. { SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER },
  273. { SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC },
  274. { SUB_CHIP_ID0, TWL6030_BASEADD_RTC },
  275. { SUB_CHIP_ID0, TWL6030_BASEADD_MEM },
  276. };
  277. /*----------------------------------------------------------------------*/
  278. /* Exported Functions */
  279. /**
  280. * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
  281. * @mod_no: module number
  282. * @value: an array of num_bytes+1 containing data to write
  283. * @reg: register address (just offset will do)
  284. * @num_bytes: number of bytes to transfer
  285. *
  286. * IMPORTANT: for 'value' parameter: Allocate value num_bytes+1 and
  287. * valid data starts at Offset 1.
  288. *
  289. * Returns the result of operation - 0 is success
  290. */
  291. int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
  292. {
  293. int ret;
  294. int sid;
  295. struct twl_client *twl;
  296. struct i2c_msg *msg;
  297. if (unlikely(mod_no > TWL_MODULE_LAST)) {
  298. pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
  299. return -EPERM;
  300. }
  301. sid = twl_map[mod_no].sid;
  302. twl = &twl_modules[sid];
  303. if (unlikely(!inuse)) {
  304. pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
  305. return -EPERM;
  306. }
  307. mutex_lock(&twl->xfer_lock);
  308. /*
  309. * [MSG1]: fill the register address data
  310. * fill the data Tx buffer
  311. */
  312. msg = &twl->xfer_msg[0];
  313. msg->addr = twl->address;
  314. msg->len = num_bytes + 1;
  315. msg->flags = 0;
  316. msg->buf = value;
  317. /* over write the first byte of buffer with the register address */
  318. *value = twl_map[mod_no].base + reg;
  319. ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1);
  320. mutex_unlock(&twl->xfer_lock);
  321. /* i2c_transfer returns number of messages transferred */
  322. if (ret != 1) {
  323. pr_err("%s: i2c_write failed to transfer all messages\n",
  324. DRIVER_NAME);
  325. if (ret < 0)
  326. return ret;
  327. else
  328. return -EIO;
  329. } else {
  330. return 0;
  331. }
  332. }
  333. EXPORT_SYMBOL(twl_i2c_write);
  334. /**
  335. * twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0
  336. * @mod_no: module number
  337. * @value: an array of num_bytes containing data to be read
  338. * @reg: register address (just offset will do)
  339. * @num_bytes: number of bytes to transfer
  340. *
  341. * Returns result of operation - num_bytes is success else failure.
  342. */
  343. int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
  344. {
  345. int ret;
  346. u8 val;
  347. int sid;
  348. struct twl_client *twl;
  349. struct i2c_msg *msg;
  350. if (unlikely(mod_no > TWL_MODULE_LAST)) {
  351. pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
  352. return -EPERM;
  353. }
  354. sid = twl_map[mod_no].sid;
  355. twl = &twl_modules[sid];
  356. if (unlikely(!inuse)) {
  357. pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
  358. return -EPERM;
  359. }
  360. mutex_lock(&twl->xfer_lock);
  361. /* [MSG1] fill the register address data */
  362. msg = &twl->xfer_msg[0];
  363. msg->addr = twl->address;
  364. msg->len = 1;
  365. msg->flags = 0; /* Read the register value */
  366. val = twl_map[mod_no].base + reg;
  367. msg->buf = &val;
  368. /* [MSG2] fill the data rx buffer */
  369. msg = &twl->xfer_msg[1];
  370. msg->addr = twl->address;
  371. msg->flags = I2C_M_RD; /* Read the register value */
  372. msg->len = num_bytes; /* only n bytes */
  373. msg->buf = value;
  374. ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2);
  375. mutex_unlock(&twl->xfer_lock);
  376. /* i2c_transfer returns number of messages transferred */
  377. if (ret != 2) {
  378. pr_err("%s: i2c_read failed to transfer all messages\n",
  379. DRIVER_NAME);
  380. if (ret < 0)
  381. return ret;
  382. else
  383. return -EIO;
  384. } else {
  385. return 0;
  386. }
  387. }
  388. EXPORT_SYMBOL(twl_i2c_read);
  389. /**
  390. * twl_i2c_write_u8 - Writes a 8 bit register in TWL4030/TWL5030/TWL60X0
  391. * @mod_no: module number
  392. * @value: the value to be written 8 bit
  393. * @reg: register address (just offset will do)
  394. *
  395. * Returns result of operation - 0 is success
  396. */
  397. int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
  398. {
  399. /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
  400. u8 temp_buffer[2] = { 0 };
  401. /* offset 1 contains the data */
  402. temp_buffer[1] = value;
  403. return twl_i2c_write(mod_no, temp_buffer, reg, 1);
  404. }
  405. EXPORT_SYMBOL(twl_i2c_write_u8);
  406. /**
  407. * twl_i2c_read_u8 - Reads a 8 bit register from TWL4030/TWL5030/TWL60X0
  408. * @mod_no: module number
  409. * @value: the value read 8 bit
  410. * @reg: register address (just offset will do)
  411. *
  412. * Returns result of operation - 0 is success
  413. */
  414. int twl_i2c_read_u8(u8 mod_no, u8 *value, u8 reg)
  415. {
  416. return twl_i2c_read(mod_no, value, reg, 1);
  417. }
  418. EXPORT_SYMBOL(twl_i2c_read_u8);
  419. /*----------------------------------------------------------------------*/
  420. /**
  421. * twl_read_idcode_register - API to read the IDCODE register.
  422. *
  423. * Unlocks the IDCODE register and read the 32 bit value.
  424. */
  425. static int twl_read_idcode_register(void)
  426. {
  427. int err;
  428. err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, TWL_EEPROM_R_UNLOCK,
  429. REG_UNLOCK_TEST_REG);
  430. if (err) {
  431. pr_err("TWL4030 Unable to unlock IDCODE registers -%d\n", err);
  432. goto fail;
  433. }
  434. err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_idcode),
  435. REG_IDCODE_7_0, 4);
  436. if (err) {
  437. pr_err("TWL4030: unable to read IDCODE -%d\n", err);
  438. goto fail;
  439. }
  440. err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, 0x0, REG_UNLOCK_TEST_REG);
  441. if (err)
  442. pr_err("TWL4030 Unable to relock IDCODE registers -%d\n", err);
  443. fail:
  444. return err;
  445. }
  446. /**
  447. * twl_get_type - API to get TWL Si type.
  448. *
  449. * Api to get the TWL Si type from IDCODE value.
  450. */
  451. int twl_get_type(void)
  452. {
  453. return TWL_SIL_TYPE(twl_idcode);
  454. }
  455. EXPORT_SYMBOL_GPL(twl_get_type);
  456. /**
  457. * twl_get_version - API to get TWL Si version.
  458. *
  459. * Api to get the TWL Si version from IDCODE value.
  460. */
  461. int twl_get_version(void)
  462. {
  463. return TWL_SIL_REV(twl_idcode);
  464. }
  465. EXPORT_SYMBOL_GPL(twl_get_version);
  466. static struct device *
  467. add_numbered_child(unsigned chip, const char *name, int num,
  468. void *pdata, unsigned pdata_len,
  469. bool can_wakeup, int irq0, int irq1)
  470. {
  471. struct platform_device *pdev;
  472. struct twl_client *twl = &twl_modules[chip];
  473. int status;
  474. pdev = platform_device_alloc(name, num);
  475. if (!pdev) {
  476. dev_dbg(&twl->client->dev, "can't alloc dev\n");
  477. status = -ENOMEM;
  478. goto err;
  479. }
  480. device_init_wakeup(&pdev->dev, can_wakeup);
  481. pdev->dev.parent = &twl->client->dev;
  482. if (pdata) {
  483. status = platform_device_add_data(pdev, pdata, pdata_len);
  484. if (status < 0) {
  485. dev_dbg(&pdev->dev, "can't add platform_data\n");
  486. goto err;
  487. }
  488. }
  489. if (irq0) {
  490. struct resource r[2] = {
  491. { .start = irq0, .flags = IORESOURCE_IRQ, },
  492. { .start = irq1, .flags = IORESOURCE_IRQ, },
  493. };
  494. status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);
  495. if (status < 0) {
  496. dev_dbg(&pdev->dev, "can't add irqs\n");
  497. goto err;
  498. }
  499. }
  500. status = platform_device_add(pdev);
  501. err:
  502. if (status < 0) {
  503. platform_device_put(pdev);
  504. dev_err(&twl->client->dev, "can't add %s dev\n", name);
  505. return ERR_PTR(status);
  506. }
  507. return &pdev->dev;
  508. }
  509. static inline struct device *add_child(unsigned chip, const char *name,
  510. void *pdata, unsigned pdata_len,
  511. bool can_wakeup, int irq0, int irq1)
  512. {
  513. return add_numbered_child(chip, name, -1, pdata, pdata_len,
  514. can_wakeup, irq0, irq1);
  515. }
  516. static struct device *
  517. add_regulator_linked(int num, struct regulator_init_data *pdata,
  518. struct regulator_consumer_supply *consumers,
  519. unsigned num_consumers)
  520. {
  521. unsigned sub_chip_id;
  522. /* regulator framework demands init_data ... */
  523. if (!pdata)
  524. return NULL;
  525. if (consumers) {
  526. pdata->consumer_supplies = consumers;
  527. pdata->num_consumer_supplies = num_consumers;
  528. }
  529. /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */
  530. sub_chip_id = twl_map[TWL_MODULE_PM_MASTER].sid;
  531. return add_numbered_child(sub_chip_id, "twl_reg", num,
  532. pdata, sizeof(*pdata), false, 0, 0);
  533. }
  534. static struct device *
  535. add_regulator(int num, struct regulator_init_data *pdata)
  536. {
  537. return add_regulator_linked(num, pdata, NULL, 0);
  538. }
  539. /*
  540. * NOTE: We know the first 8 IRQs after pdata->base_irq are
  541. * for the PIH, and the next are for the PWR_INT SIH, since
  542. * that's how twl_init_irq() sets things up.
  543. */
  544. static int
  545. add_children(struct twl4030_platform_data *pdata, unsigned long features)
  546. {
  547. struct device *child;
  548. unsigned sub_chip_id;
  549. if (twl_has_gpio() && pdata->gpio) {
  550. child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
  551. pdata->gpio, sizeof(*pdata->gpio),
  552. false, pdata->irq_base + GPIO_INTR_OFFSET, 0);
  553. if (IS_ERR(child))
  554. return PTR_ERR(child);
  555. }
  556. if (twl_has_keypad() && pdata->keypad) {
  557. child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
  558. pdata->keypad, sizeof(*pdata->keypad),
  559. true, pdata->irq_base + KEYPAD_INTR_OFFSET, 0);
  560. if (IS_ERR(child))
  561. return PTR_ERR(child);
  562. }
  563. if (twl_has_madc() && pdata->madc) {
  564. child = add_child(2, "twl4030_madc",
  565. pdata->madc, sizeof(*pdata->madc),
  566. true, pdata->irq_base + MADC_INTR_OFFSET, 0);
  567. if (IS_ERR(child))
  568. return PTR_ERR(child);
  569. }
  570. if (twl_has_rtc()) {
  571. /*
  572. * REVISIT platform_data here currently might expose the
  573. * "msecure" line ... but for now we just expect board
  574. * setup to tell the chip "it's always ok to SET_TIME".
  575. * Eventually, Linux might become more aware of such
  576. * HW security concerns, and "least privilege".
  577. */
  578. sub_chip_id = twl_map[TWL_MODULE_RTC].sid;
  579. child = add_child(sub_chip_id, "twl_rtc",
  580. NULL, 0,
  581. true, pdata->irq_base + RTC_INTR_OFFSET, 0);
  582. if (IS_ERR(child))
  583. return PTR_ERR(child);
  584. }
  585. if (twl_has_usb() && pdata->usb && twl_class_is_4030()) {
  586. static struct regulator_consumer_supply usb1v5 = {
  587. .supply = "usb1v5",
  588. };
  589. static struct regulator_consumer_supply usb1v8 = {
  590. .supply = "usb1v8",
  591. };
  592. static struct regulator_consumer_supply usb3v1 = {
  593. .supply = "usb3v1",
  594. };
  595. /* First add the regulators so that they can be used by transceiver */
  596. if (twl_has_regulator()) {
  597. /* this is a template that gets copied */
  598. struct regulator_init_data usb_fixed = {
  599. .constraints.valid_modes_mask =
  600. REGULATOR_MODE_NORMAL
  601. | REGULATOR_MODE_STANDBY,
  602. .constraints.valid_ops_mask =
  603. REGULATOR_CHANGE_MODE
  604. | REGULATOR_CHANGE_STATUS,
  605. };
  606. child = add_regulator_linked(TWL4030_REG_VUSB1V5,
  607. &usb_fixed, &usb1v5, 1);
  608. if (IS_ERR(child))
  609. return PTR_ERR(child);
  610. child = add_regulator_linked(TWL4030_REG_VUSB1V8,
  611. &usb_fixed, &usb1v8, 1);
  612. if (IS_ERR(child))
  613. return PTR_ERR(child);
  614. child = add_regulator_linked(TWL4030_REG_VUSB3V1,
  615. &usb_fixed, &usb3v1, 1);
  616. if (IS_ERR(child))
  617. return PTR_ERR(child);
  618. }
  619. child = add_child(0, "twl4030_usb",
  620. pdata->usb, sizeof(*pdata->usb),
  621. true,
  622. /* irq0 = USB_PRES, irq1 = USB */
  623. pdata->irq_base + USB_PRES_INTR_OFFSET,
  624. pdata->irq_base + USB_INTR_OFFSET);
  625. if (IS_ERR(child))
  626. return PTR_ERR(child);
  627. /* we need to connect regulators to this transceiver */
  628. if (twl_has_regulator() && child) {
  629. usb1v5.dev = child;
  630. usb1v8.dev = child;
  631. usb3v1.dev = child;
  632. }
  633. }
  634. if (twl_has_usb() && pdata->usb && twl_class_is_6030()) {
  635. static struct regulator_consumer_supply usb3v3 = {
  636. .supply = "vusb",
  637. };
  638. if (twl_has_regulator()) {
  639. /* this is a template that gets copied */
  640. struct regulator_init_data usb_fixed = {
  641. .constraints.valid_modes_mask =
  642. REGULATOR_MODE_NORMAL
  643. | REGULATOR_MODE_STANDBY,
  644. .constraints.valid_ops_mask =
  645. REGULATOR_CHANGE_MODE
  646. | REGULATOR_CHANGE_STATUS,
  647. };
  648. child = add_regulator_linked(TWL6030_REG_VUSB,
  649. &usb_fixed, &usb3v3, 1);
  650. if (IS_ERR(child))
  651. return PTR_ERR(child);
  652. }
  653. child = add_child(0, "twl6030_usb",
  654. pdata->usb, sizeof(*pdata->usb),
  655. true,
  656. /* irq1 = VBUS_PRES, irq0 = USB ID */
  657. pdata->irq_base + USBOTG_INTR_OFFSET,
  658. pdata->irq_base + USB_PRES_INTR_OFFSET);
  659. if (IS_ERR(child))
  660. return PTR_ERR(child);
  661. /* we need to connect regulators to this transceiver */
  662. if (twl_has_regulator() && child)
  663. usb3v3.dev = child;
  664. }
  665. if (twl_has_watchdog() && twl_class_is_4030()) {
  666. child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0);
  667. if (IS_ERR(child))
  668. return PTR_ERR(child);
  669. }
  670. if (twl_has_pwrbutton() && twl_class_is_4030()) {
  671. child = add_child(1, "twl4030_pwrbutton",
  672. NULL, 0, true, pdata->irq_base + 8 + 0, 0);
  673. if (IS_ERR(child))
  674. return PTR_ERR(child);
  675. }
  676. if (twl_has_codec() && pdata->codec && twl_class_is_4030()) {
  677. sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid;
  678. child = add_child(sub_chip_id, "twl4030-audio",
  679. pdata->codec, sizeof(*pdata->codec),
  680. false, 0, 0);
  681. if (IS_ERR(child))
  682. return PTR_ERR(child);
  683. }
  684. /* Phoenix codec driver is probed directly atm */
  685. if (twl_has_codec() && pdata->codec && twl_class_is_6030()) {
  686. sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid;
  687. child = add_child(sub_chip_id, "twl6040-codec",
  688. pdata->codec, sizeof(*pdata->codec),
  689. false, 0, 0);
  690. if (IS_ERR(child))
  691. return PTR_ERR(child);
  692. }
  693. /* twl4030 regulators */
  694. if (twl_has_regulator() && twl_class_is_4030()) {
  695. child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
  696. if (IS_ERR(child))
  697. return PTR_ERR(child);
  698. child = add_regulator(TWL4030_REG_VIO, pdata->vio);
  699. if (IS_ERR(child))
  700. return PTR_ERR(child);
  701. child = add_regulator(TWL4030_REG_VDD1, pdata->vdd1);
  702. if (IS_ERR(child))
  703. return PTR_ERR(child);
  704. child = add_regulator(TWL4030_REG_VDD2, pdata->vdd2);
  705. if (IS_ERR(child))
  706. return PTR_ERR(child);
  707. child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1);
  708. if (IS_ERR(child))
  709. return PTR_ERR(child);
  710. child = add_regulator(TWL4030_REG_VDAC, pdata->vdac);
  711. if (IS_ERR(child))
  712. return PTR_ERR(child);
  713. child = add_regulator((features & TWL4030_VAUX2)
  714. ? TWL4030_REG_VAUX2_4030
  715. : TWL4030_REG_VAUX2,
  716. pdata->vaux2);
  717. if (IS_ERR(child))
  718. return PTR_ERR(child);
  719. child = add_regulator(TWL4030_REG_VINTANA1, pdata->vintana1);
  720. if (IS_ERR(child))
  721. return PTR_ERR(child);
  722. child = add_regulator(TWL4030_REG_VINTANA2, pdata->vintana2);
  723. if (IS_ERR(child))
  724. return PTR_ERR(child);
  725. child = add_regulator(TWL4030_REG_VINTDIG, pdata->vintdig);
  726. if (IS_ERR(child))
  727. return PTR_ERR(child);
  728. }
  729. /* maybe add LDOs that are omitted on cost-reduced parts */
  730. if (twl_has_regulator() && !(features & TPS_SUBSET)
  731. && twl_class_is_4030()) {
  732. child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2);
  733. if (IS_ERR(child))
  734. return PTR_ERR(child);
  735. child = add_regulator(TWL4030_REG_VMMC2, pdata->vmmc2);
  736. if (IS_ERR(child))
  737. return PTR_ERR(child);
  738. child = add_regulator(TWL4030_REG_VSIM, pdata->vsim);
  739. if (IS_ERR(child))
  740. return PTR_ERR(child);
  741. child = add_regulator(TWL4030_REG_VAUX1, pdata->vaux1);
  742. if (IS_ERR(child))
  743. return PTR_ERR(child);
  744. child = add_regulator(TWL4030_REG_VAUX3, pdata->vaux3);
  745. if (IS_ERR(child))
  746. return PTR_ERR(child);
  747. child = add_regulator(TWL4030_REG_VAUX4, pdata->vaux4);
  748. if (IS_ERR(child))
  749. return PTR_ERR(child);
  750. }
  751. /* twl6030 regulators */
  752. if (twl_has_regulator() && twl_class_is_6030()) {
  753. child = add_regulator(TWL6030_REG_VMMC, pdata->vmmc);
  754. if (IS_ERR(child))
  755. return PTR_ERR(child);
  756. child = add_regulator(TWL6030_REG_VPP, pdata->vpp);
  757. if (IS_ERR(child))
  758. return PTR_ERR(child);
  759. child = add_regulator(TWL6030_REG_VUSIM, pdata->vusim);
  760. if (IS_ERR(child))
  761. return PTR_ERR(child);
  762. child = add_regulator(TWL6030_REG_VANA, pdata->vana);
  763. if (IS_ERR(child))
  764. return PTR_ERR(child);
  765. child = add_regulator(TWL6030_REG_VCXIO, pdata->vcxio);
  766. if (IS_ERR(child))
  767. return PTR_ERR(child);
  768. child = add_regulator(TWL6030_REG_VDAC, pdata->vdac);
  769. if (IS_ERR(child))
  770. return PTR_ERR(child);
  771. child = add_regulator(TWL6030_REG_VAUX1_6030, pdata->vaux1);
  772. if (IS_ERR(child))
  773. return PTR_ERR(child);
  774. child = add_regulator(TWL6030_REG_VAUX2_6030, pdata->vaux2);
  775. if (IS_ERR(child))
  776. return PTR_ERR(child);
  777. child = add_regulator(TWL6030_REG_VAUX3_6030, pdata->vaux3);
  778. if (IS_ERR(child))
  779. return PTR_ERR(child);
  780. child = add_regulator(TWL6030_REG_CLK32KG, pdata->clk32kg);
  781. if (IS_ERR(child))
  782. return PTR_ERR(child);
  783. }
  784. if (twl_has_bci() && pdata->bci &&
  785. !(features & (TPS_SUBSET | TWL5031))) {
  786. child = add_child(3, "twl4030_bci",
  787. pdata->bci, sizeof(*pdata->bci), false,
  788. /* irq0 = CHG_PRES, irq1 = BCI */
  789. pdata->irq_base + BCI_PRES_INTR_OFFSET,
  790. pdata->irq_base + BCI_INTR_OFFSET);
  791. if (IS_ERR(child))
  792. return PTR_ERR(child);
  793. }
  794. return 0;
  795. }
  796. /*----------------------------------------------------------------------*/
  797. /*
  798. * These three functions initialize the on-chip clock framework,
  799. * letting it generate the right frequencies for USB, MADC, and
  800. * other purposes.
  801. */
  802. static inline int __init protect_pm_master(void)
  803. {
  804. int e = 0;
  805. e = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
  806. TWL4030_PM_MASTER_PROTECT_KEY);
  807. return e;
  808. }
  809. static inline int __init unprotect_pm_master(void)
  810. {
  811. int e = 0;
  812. e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
  813. TWL4030_PM_MASTER_KEY_CFG1,
  814. TWL4030_PM_MASTER_PROTECT_KEY);
  815. e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
  816. TWL4030_PM_MASTER_KEY_CFG2,
  817. TWL4030_PM_MASTER_PROTECT_KEY);
  818. return e;
  819. }
  820. static void clocks_init(struct device *dev,
  821. struct twl4030_clock_init_data *clock)
  822. {
  823. int e = 0;
  824. struct clk *osc;
  825. u32 rate;
  826. u8 ctrl = HFCLK_FREQ_26_MHZ;
  827. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  828. if (cpu_is_omap2430())
  829. osc = clk_get(dev, "osc_ck");
  830. else
  831. osc = clk_get(dev, "osc_sys_ck");
  832. if (IS_ERR(osc)) {
  833. printk(KERN_WARNING "Skipping twl internal clock init and "
  834. "using bootloader value (unknown osc rate)\n");
  835. return;
  836. }
  837. rate = clk_get_rate(osc);
  838. clk_put(osc);
  839. #else
  840. /* REVISIT for non-OMAP systems, pass the clock rate from
  841. * board init code, using platform_data.
  842. */
  843. osc = ERR_PTR(-EIO);
  844. printk(KERN_WARNING "Skipping twl internal clock init and "
  845. "using bootloader value (unknown osc rate)\n");
  846. return;
  847. #endif
  848. switch (rate) {
  849. case 19200000:
  850. ctrl = HFCLK_FREQ_19p2_MHZ;
  851. break;
  852. case 26000000:
  853. ctrl = HFCLK_FREQ_26_MHZ;
  854. break;
  855. case 38400000:
  856. ctrl = HFCLK_FREQ_38p4_MHZ;
  857. break;
  858. }
  859. ctrl |= HIGH_PERF_SQ;
  860. if (clock && clock->ck32k_lowpwr_enable)
  861. ctrl |= CK32K_LOWPWR_EN;
  862. e |= unprotect_pm_master();
  863. /* effect->MADC+USB ck en */
  864. e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
  865. e |= protect_pm_master();
  866. if (e < 0)
  867. pr_err("%s: clock init err [%d]\n", DRIVER_NAME, e);
  868. }
  869. /*----------------------------------------------------------------------*/
  870. int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
  871. int twl4030_exit_irq(void);
  872. int twl4030_init_chip_irq(const char *chip);
  873. int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
  874. int twl6030_exit_irq(void);
  875. static int twl_remove(struct i2c_client *client)
  876. {
  877. unsigned i;
  878. int status;
  879. if (twl_class_is_4030())
  880. status = twl4030_exit_irq();
  881. else
  882. status = twl6030_exit_irq();
  883. if (status < 0)
  884. return status;
  885. for (i = 0; i < TWL_NUM_SLAVES; i++) {
  886. struct twl_client *twl = &twl_modules[i];
  887. if (twl->client && twl->client != client)
  888. i2c_unregister_device(twl->client);
  889. twl_modules[i].client = NULL;
  890. }
  891. inuse = false;
  892. return 0;
  893. }
  894. /* NOTE: this driver only handles a single twl4030/tps659x0 chip */
  895. static int __devinit
  896. twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
  897. {
  898. int status;
  899. unsigned i;
  900. struct twl4030_platform_data *pdata = client->dev.platform_data;
  901. u8 temp;
  902. int ret = 0;
  903. if (!pdata) {
  904. dev_dbg(&client->dev, "no platform data?\n");
  905. return -EINVAL;
  906. }
  907. if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
  908. dev_dbg(&client->dev, "can't talk I2C?\n");
  909. return -EIO;
  910. }
  911. if (inuse) {
  912. dev_dbg(&client->dev, "driver is already in use\n");
  913. return -EBUSY;
  914. }
  915. for (i = 0; i < TWL_NUM_SLAVES; i++) {
  916. struct twl_client *twl = &twl_modules[i];
  917. twl->address = client->addr + i;
  918. if (i == 0)
  919. twl->client = client;
  920. else {
  921. twl->client = i2c_new_dummy(client->adapter,
  922. twl->address);
  923. if (!twl->client) {
  924. dev_err(&client->dev,
  925. "can't attach client %d\n", i);
  926. status = -ENOMEM;
  927. goto fail;
  928. }
  929. }
  930. mutex_init(&twl->xfer_lock);
  931. }
  932. inuse = true;
  933. if ((id->driver_data) & TWL6030_CLASS) {
  934. twl_id = TWL6030_CLASS_ID;
  935. twl_map = &twl6030_map[0];
  936. } else {
  937. twl_id = TWL4030_CLASS_ID;
  938. twl_map = &twl4030_map[0];
  939. }
  940. /* setup clock framework */
  941. clocks_init(&client->dev, pdata->clock);
  942. /* read TWL IDCODE Register */
  943. if (twl_id == TWL4030_CLASS_ID) {
  944. ret = twl_read_idcode_register();
  945. WARN(ret < 0, "Error: reading twl_idcode register value\n");
  946. }
  947. /* load power event scripts */
  948. if (twl_has_power() && pdata->power)
  949. twl4030_power_init(pdata->power);
  950. /* Maybe init the T2 Interrupt subsystem */
  951. if (client->irq
  952. && pdata->irq_base
  953. && pdata->irq_end > pdata->irq_base) {
  954. if (twl_class_is_4030()) {
  955. twl4030_init_chip_irq(id->name);
  956. status = twl4030_init_irq(client->irq, pdata->irq_base,
  957. pdata->irq_end);
  958. } else {
  959. status = twl6030_init_irq(client->irq, pdata->irq_base,
  960. pdata->irq_end);
  961. }
  962. if (status < 0)
  963. goto fail;
  964. }
  965. /* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
  966. * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
  967. * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
  968. */
  969. if (twl_class_is_4030()) {
  970. twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1);
  971. temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
  972. I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
  973. twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
  974. }
  975. status = add_children(pdata, id->driver_data);
  976. fail:
  977. if (status < 0)
  978. twl_remove(client);
  979. return status;
  980. }
  981. static const struct i2c_device_id twl_ids[] = {
  982. { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */
  983. { "twl5030", 0 }, /* T2 updated */
  984. { "twl5031", TWL5031 }, /* TWL5030 updated */
  985. { "tps65950", 0 }, /* catalog version of twl5030 */
  986. { "tps65930", TPS_SUBSET }, /* fewer LDOs and DACs; no charger */
  987. { "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */
  988. { "twl6030", TWL6030_CLASS }, /* "Phoenix power chip" */
  989. { /* end of list */ },
  990. };
  991. MODULE_DEVICE_TABLE(i2c, twl_ids);
  992. /* One Client Driver , 4 Clients */
  993. static struct i2c_driver twl_driver = {
  994. .driver.name = DRIVER_NAME,
  995. .id_table = twl_ids,
  996. .probe = twl_probe,
  997. .remove = twl_remove,
  998. };
  999. static int __init twl_init(void)
  1000. {
  1001. return i2c_add_driver(&twl_driver);
  1002. }
  1003. subsys_initcall(twl_init);
  1004. static void __exit twl_exit(void)
  1005. {
  1006. i2c_del_driver(&twl_driver);
  1007. }
  1008. module_exit(twl_exit);
  1009. MODULE_AUTHOR("Texas Instruments, Inc.");
  1010. MODULE_DESCRIPTION("I2C Core interface for TWL");
  1011. MODULE_LICENSE("GPL");