i2c.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /*
  2. * arch/arm/mach-u300/i2c.c
  3. *
  4. * Copyright (C) 2009 ST-Ericsson AB
  5. * License terms: GNU General Public License (GPL) version 2
  6. *
  7. * Register board i2c devices
  8. * Author: Linus Walleij <linus.walleij@stericsson.com>
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/i2c.h>
  12. #include <linux/mfd/abx500.h>
  13. #include <linux/regulator/machine.h>
  14. #include <linux/amba/bus.h>
  15. #include <mach/irqs.h>
  16. /*
  17. * Initial settings of ab3100 registers.
  18. * Common for below LDO regulator settings are that
  19. * bit 7-5 controls voltage. Bit 4 turns regulator ON(1) or OFF(0).
  20. * Bit 3-2 controls sleep enable and bit 1-0 controls sleep mode.
  21. */
  22. /* LDO_A 0x16: 2.75V, ON, SLEEP_A, SLEEP OFF GND */
  23. #define LDO_A_SETTING 0x16
  24. /* LDO_C 0x10: 2.65V, ON, SLEEP_A or B, SLEEP full power */
  25. #define LDO_C_SETTING 0x10
  26. /* LDO_D 0x10: 2.65V, ON, sleep mode not used */
  27. #define LDO_D_SETTING 0x10
  28. /* LDO_E 0x10: 1.8V, ON, SLEEP_A or B, SLEEP full power */
  29. #define LDO_E_SETTING 0x10
  30. /* LDO_E SLEEP 0x00: 1.8V, not used, SLEEP_A or B, not used */
  31. #define LDO_E_SLEEP_SETTING 0x00
  32. /* LDO_F 0xD0: 2.5V, ON, SLEEP_A or B, SLEEP full power */
  33. #define LDO_F_SETTING 0xD0
  34. /* LDO_G 0x00: 2.85V, OFF, SLEEP_A or B, SLEEP full power */
  35. #define LDO_G_SETTING 0x00
  36. /* LDO_H 0x18: 2.75V, ON, SLEEP_B, SLEEP full power */
  37. #define LDO_H_SETTING 0x18
  38. /* LDO_K 0x00: 2.75V, OFF, SLEEP_A or B, SLEEP full power */
  39. #define LDO_K_SETTING 0x00
  40. /* LDO_EXT 0x00: Voltage not set, OFF, not used, not used */
  41. #define LDO_EXT_SETTING 0x00
  42. /* BUCK 0x7D: 1.2V, ON, SLEEP_A and B, SLEEP low power */
  43. #define BUCK_SETTING 0x7D
  44. /* BUCK SLEEP 0xAC: 1.05V, Not used, SLEEP_A and B, Not used */
  45. #define BUCK_SLEEP_SETTING 0xAC
  46. #ifdef CONFIG_AB3100_CORE
  47. static struct regulator_consumer_supply supply_ldo_c[] = {
  48. {
  49. .dev_name = "ab3100-codec",
  50. .supply = "vaudio", /* Powers the codec */
  51. },
  52. };
  53. /*
  54. * This one needs to be a supply so we can turn it off
  55. * in order to shut down the system.
  56. */
  57. static struct regulator_consumer_supply supply_ldo_d[] = {
  58. {
  59. .dev = NULL,
  60. .supply = "vana15", /* Powers the SoC (CPU etc) */
  61. },
  62. };
  63. static struct regulator_consumer_supply supply_ldo_g[] = {
  64. {
  65. .dev_name = "mmci",
  66. .supply = "vmmc", /* Powers MMC/SD card */
  67. },
  68. };
  69. static struct regulator_consumer_supply supply_ldo_h[] = {
  70. {
  71. .dev_name = "xgam_pdi",
  72. .supply = "vdisp", /* Powers camera, display etc */
  73. },
  74. };
  75. static struct regulator_consumer_supply supply_ldo_k[] = {
  76. {
  77. .dev_name = "irda",
  78. .supply = "vir", /* Power IrDA */
  79. },
  80. };
  81. /*
  82. * This is a placeholder for whoever wish to use the
  83. * external power.
  84. */
  85. static struct regulator_consumer_supply supply_ldo_ext[] = {
  86. {
  87. .dev = NULL,
  88. .supply = "vext", /* External power */
  89. },
  90. };
  91. /* Preset (hardware defined) voltages for these regulators */
  92. #define LDO_A_VOLTAGE 2750000
  93. #define LDO_C_VOLTAGE 2650000
  94. #define LDO_D_VOLTAGE 2650000
  95. static struct ab3100_platform_data ab3100_plf_data = {
  96. .reg_constraints = {
  97. /* LDO A routing and constraints */
  98. {
  99. .constraints = {
  100. .name = "vrad",
  101. .min_uV = LDO_A_VOLTAGE,
  102. .max_uV = LDO_A_VOLTAGE,
  103. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  104. .always_on = 1,
  105. .boot_on = 1,
  106. },
  107. },
  108. /* LDO C routing and constraints */
  109. {
  110. .constraints = {
  111. .min_uV = LDO_C_VOLTAGE,
  112. .max_uV = LDO_C_VOLTAGE,
  113. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  114. },
  115. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_c),
  116. .consumer_supplies = supply_ldo_c,
  117. },
  118. /* LDO D routing and constraints */
  119. {
  120. .constraints = {
  121. .min_uV = LDO_D_VOLTAGE,
  122. .max_uV = LDO_D_VOLTAGE,
  123. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  124. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  125. /*
  126. * Actually this is boot_on but we need
  127. * to reference count it externally to
  128. * be able to shut down the system.
  129. */
  130. },
  131. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_d),
  132. .consumer_supplies = supply_ldo_d,
  133. },
  134. /* LDO E routing and constraints */
  135. {
  136. .constraints = {
  137. .name = "vio",
  138. .min_uV = 1800000,
  139. .max_uV = 1800000,
  140. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  141. .valid_ops_mask =
  142. REGULATOR_CHANGE_VOLTAGE |
  143. REGULATOR_CHANGE_STATUS,
  144. .always_on = 1,
  145. .boot_on = 1,
  146. },
  147. },
  148. /* LDO F routing and constraints */
  149. {
  150. .constraints = {
  151. .name = "vana25",
  152. .min_uV = 2500000,
  153. .max_uV = 2500000,
  154. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  155. .valid_ops_mask =
  156. REGULATOR_CHANGE_VOLTAGE |
  157. REGULATOR_CHANGE_STATUS,
  158. .always_on = 1,
  159. .boot_on = 1,
  160. },
  161. },
  162. /* LDO G routing and constraints */
  163. {
  164. .constraints = {
  165. .min_uV = 1500000,
  166. .max_uV = 2850000,
  167. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  168. .valid_ops_mask =
  169. REGULATOR_CHANGE_VOLTAGE |
  170. REGULATOR_CHANGE_STATUS,
  171. },
  172. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_g),
  173. .consumer_supplies = supply_ldo_g,
  174. },
  175. /* LDO H routing and constraints */
  176. {
  177. .constraints = {
  178. .min_uV = 1200000,
  179. .max_uV = 2750000,
  180. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  181. .valid_ops_mask =
  182. REGULATOR_CHANGE_VOLTAGE |
  183. REGULATOR_CHANGE_STATUS,
  184. },
  185. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_h),
  186. .consumer_supplies = supply_ldo_h,
  187. },
  188. /* LDO K routing and constraints */
  189. {
  190. .constraints = {
  191. .min_uV = 1800000,
  192. .max_uV = 2750000,
  193. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  194. .valid_ops_mask =
  195. REGULATOR_CHANGE_VOLTAGE |
  196. REGULATOR_CHANGE_STATUS,
  197. },
  198. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_k),
  199. .consumer_supplies = supply_ldo_k,
  200. },
  201. /* External regulator interface. No fixed voltage specified.
  202. * If we knew the voltage of the external regulator and it
  203. * was connected on the board, we could add the (fixed)
  204. * voltage for it here.
  205. */
  206. {
  207. .constraints = {
  208. .min_uV = 0,
  209. .max_uV = 0,
  210. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  211. .valid_ops_mask =
  212. REGULATOR_CHANGE_STATUS,
  213. },
  214. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_ext),
  215. .consumer_supplies = supply_ldo_ext,
  216. },
  217. /* Buck converter routing and constraints */
  218. {
  219. .constraints = {
  220. .name = "vcore",
  221. .min_uV = 1200000,
  222. .max_uV = 1800000,
  223. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  224. .valid_ops_mask =
  225. REGULATOR_CHANGE_VOLTAGE |
  226. REGULATOR_CHANGE_STATUS,
  227. .always_on = 1,
  228. .boot_on = 1,
  229. },
  230. },
  231. },
  232. .reg_initvals = {
  233. LDO_A_SETTING,
  234. LDO_C_SETTING,
  235. LDO_E_SETTING,
  236. LDO_E_SLEEP_SETTING,
  237. LDO_F_SETTING,
  238. LDO_G_SETTING,
  239. LDO_H_SETTING,
  240. LDO_K_SETTING,
  241. LDO_EXT_SETTING,
  242. BUCK_SETTING,
  243. BUCK_SLEEP_SETTING,
  244. LDO_D_SETTING,
  245. },
  246. };
  247. #endif
  248. #ifdef CONFIG_AB3550_CORE
  249. static struct abx500_init_settings ab3550_init_settings[] = {
  250. {
  251. .bank = 0,
  252. .reg = AB3550_IMR1,
  253. .setting = 0xff
  254. },
  255. {
  256. .bank = 0,
  257. .reg = AB3550_IMR2,
  258. .setting = 0xff
  259. },
  260. {
  261. .bank = 0,
  262. .reg = AB3550_IMR3,
  263. .setting = 0xff
  264. },
  265. {
  266. .bank = 0,
  267. .reg = AB3550_IMR4,
  268. .setting = 0xff
  269. },
  270. {
  271. .bank = 0,
  272. .reg = AB3550_IMR5,
  273. /* The two most significant bits are not used */
  274. .setting = 0x3f
  275. },
  276. };
  277. static struct ab3550_platform_data ab3550_plf_data = {
  278. .irq = {
  279. .base = IRQ_AB3550_BASE,
  280. .count = (IRQ_AB3550_END - IRQ_AB3550_BASE + 1),
  281. },
  282. .dev_data = {
  283. },
  284. .init_settings = ab3550_init_settings,
  285. .init_settings_sz = ARRAY_SIZE(ab3550_init_settings),
  286. };
  287. #endif
  288. static struct i2c_board_info __initdata bus0_i2c_board_info[] = {
  289. #if defined(CONFIG_AB3550_CORE)
  290. {
  291. .type = "ab3550",
  292. .addr = 0x4A,
  293. .irq = IRQ_U300_IRQ0_EXT,
  294. .platform_data = &ab3550_plf_data,
  295. },
  296. #elif defined(CONFIG_AB3100_CORE)
  297. {
  298. .type = "ab3100",
  299. .addr = 0x48,
  300. .irq = IRQ_U300_IRQ0_EXT,
  301. .platform_data = &ab3100_plf_data,
  302. },
  303. #else
  304. { },
  305. #endif
  306. };
  307. static struct i2c_board_info __initdata bus1_i2c_board_info[] = {
  308. #ifdef CONFIG_MACH_U300_BS335
  309. {
  310. .type = "fwcam",
  311. .addr = 0x10,
  312. },
  313. {
  314. .type = "fwcam",
  315. .addr = 0x5d,
  316. },
  317. #else
  318. { },
  319. #endif
  320. };
  321. void __init u300_i2c_register_board_devices(void)
  322. {
  323. i2c_register_board_info(0, bus0_i2c_board_info,
  324. ARRAY_SIZE(bus0_i2c_board_info));
  325. /*
  326. * This makes the core shut down all unused regulators
  327. * after all the initcalls have completed.
  328. */
  329. regulator_has_full_constraints();
  330. i2c_register_board_info(1, bus1_i2c_board_info,
  331. ARRAY_SIZE(bus1_i2c_board_info));
  332. }