i2c.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. .supply = "vana15", /* Powers the SoC (CPU etc) */
  60. },
  61. };
  62. static struct regulator_consumer_supply supply_ldo_g[] = {
  63. {
  64. .dev_name = "mmci",
  65. .supply = "vmmc", /* Powers MMC/SD card */
  66. },
  67. };
  68. static struct regulator_consumer_supply supply_ldo_h[] = {
  69. {
  70. .dev_name = "xgam_pdi",
  71. .supply = "vdisp", /* Powers camera, display etc */
  72. },
  73. };
  74. static struct regulator_consumer_supply supply_ldo_k[] = {
  75. {
  76. .dev_name = "irda",
  77. .supply = "vir", /* Power IrDA */
  78. },
  79. };
  80. /*
  81. * This is a placeholder for whoever wish to use the
  82. * external power.
  83. */
  84. static struct regulator_consumer_supply supply_ldo_ext[] = {
  85. {
  86. .supply = "vext", /* External power */
  87. },
  88. };
  89. /* Preset (hardware defined) voltages for these regulators */
  90. #define LDO_A_VOLTAGE 2750000
  91. #define LDO_C_VOLTAGE 2650000
  92. #define LDO_D_VOLTAGE 2650000
  93. static struct ab3100_platform_data ab3100_plf_data = {
  94. .reg_constraints = {
  95. /* LDO A routing and constraints */
  96. {
  97. .constraints = {
  98. .name = "vrad",
  99. .min_uV = LDO_A_VOLTAGE,
  100. .max_uV = LDO_A_VOLTAGE,
  101. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  102. .always_on = 1,
  103. .boot_on = 1,
  104. },
  105. },
  106. /* LDO C routing and constraints */
  107. {
  108. .constraints = {
  109. .min_uV = LDO_C_VOLTAGE,
  110. .max_uV = LDO_C_VOLTAGE,
  111. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  112. },
  113. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_c),
  114. .consumer_supplies = supply_ldo_c,
  115. },
  116. /* LDO D routing and constraints */
  117. {
  118. .constraints = {
  119. .min_uV = LDO_D_VOLTAGE,
  120. .max_uV = LDO_D_VOLTAGE,
  121. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  122. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  123. /*
  124. * Actually this is boot_on but we need
  125. * to reference count it externally to
  126. * be able to shut down the system.
  127. */
  128. },
  129. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_d),
  130. .consumer_supplies = supply_ldo_d,
  131. },
  132. /* LDO E routing and constraints */
  133. {
  134. .constraints = {
  135. .name = "vio",
  136. .min_uV = 1800000,
  137. .max_uV = 1800000,
  138. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  139. .always_on = 1,
  140. .boot_on = 1,
  141. },
  142. },
  143. /* LDO F routing and constraints */
  144. {
  145. .constraints = {
  146. .name = "vana25",
  147. .min_uV = 2500000,
  148. .max_uV = 2500000,
  149. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  150. .always_on = 1,
  151. .boot_on = 1,
  152. },
  153. },
  154. /* LDO G routing and constraints */
  155. {
  156. .constraints = {
  157. .min_uV = 1500000,
  158. .max_uV = 2850000,
  159. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  160. .valid_ops_mask =
  161. REGULATOR_CHANGE_VOLTAGE |
  162. REGULATOR_CHANGE_STATUS,
  163. },
  164. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_g),
  165. .consumer_supplies = supply_ldo_g,
  166. },
  167. /* LDO H routing and constraints */
  168. {
  169. .constraints = {
  170. .min_uV = 1200000,
  171. .max_uV = 2750000,
  172. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  173. .valid_ops_mask =
  174. REGULATOR_CHANGE_VOLTAGE |
  175. REGULATOR_CHANGE_STATUS,
  176. },
  177. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_h),
  178. .consumer_supplies = supply_ldo_h,
  179. },
  180. /* LDO K routing and constraints */
  181. {
  182. .constraints = {
  183. .min_uV = 1800000,
  184. .max_uV = 2750000,
  185. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  186. .valid_ops_mask =
  187. REGULATOR_CHANGE_VOLTAGE |
  188. REGULATOR_CHANGE_STATUS,
  189. },
  190. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_k),
  191. .consumer_supplies = supply_ldo_k,
  192. },
  193. /* External regulator interface. No fixed voltage specified.
  194. * If we knew the voltage of the external regulator and it
  195. * was connected on the board, we could add the (fixed)
  196. * voltage for it here.
  197. */
  198. {
  199. .constraints = {
  200. .min_uV = 0,
  201. .max_uV = 0,
  202. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  203. .valid_ops_mask =
  204. REGULATOR_CHANGE_STATUS,
  205. },
  206. .num_consumer_supplies = ARRAY_SIZE(supply_ldo_ext),
  207. .consumer_supplies = supply_ldo_ext,
  208. },
  209. /* Buck converter routing and constraints */
  210. {
  211. .constraints = {
  212. .name = "vcore",
  213. .min_uV = 1200000,
  214. .max_uV = 1800000,
  215. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  216. .valid_ops_mask =
  217. REGULATOR_CHANGE_VOLTAGE,
  218. .always_on = 1,
  219. .boot_on = 1,
  220. },
  221. },
  222. },
  223. .reg_initvals = {
  224. LDO_A_SETTING,
  225. LDO_C_SETTING,
  226. LDO_E_SETTING,
  227. LDO_E_SLEEP_SETTING,
  228. LDO_F_SETTING,
  229. LDO_G_SETTING,
  230. LDO_H_SETTING,
  231. LDO_K_SETTING,
  232. LDO_EXT_SETTING,
  233. BUCK_SETTING,
  234. BUCK_SLEEP_SETTING,
  235. LDO_D_SETTING,
  236. },
  237. };
  238. #endif
  239. static struct i2c_board_info __initdata bus0_i2c_board_info[] = {
  240. #ifdef CONFIG_AB3100_CORE
  241. {
  242. .type = "ab3100",
  243. .addr = 0x48,
  244. .irq = IRQ_U300_IRQ0_EXT,
  245. .platform_data = &ab3100_plf_data,
  246. },
  247. #else
  248. { },
  249. #endif
  250. };
  251. static struct i2c_board_info __initdata bus1_i2c_board_info[] = {
  252. #ifdef CONFIG_MACH_U300_BS335
  253. {
  254. .type = "fwcam",
  255. .addr = 0x10,
  256. },
  257. {
  258. .type = "fwcam",
  259. .addr = 0x5d,
  260. },
  261. #else
  262. { },
  263. #endif
  264. };
  265. void __init u300_i2c_register_board_devices(void)
  266. {
  267. i2c_register_board_info(0, bus0_i2c_board_info,
  268. ARRAY_SIZE(bus0_i2c_board_info));
  269. /*
  270. * This makes the core shut down all unused regulators
  271. * after all the initcalls have completed.
  272. */
  273. regulator_has_full_constraints();
  274. i2c_register_board_info(1, bus1_i2c_board_info,
  275. ARRAY_SIZE(bus1_i2c_board_info));
  276. }