i2c.c 7.1 KB

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