twl-common.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*
  2. * twl-common.c
  3. *
  4. * Copyright (C) 2011 Texas Instruments, Inc..
  5. * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. *
  21. */
  22. #include <linux/i2c.h>
  23. #include <linux/i2c/twl.h>
  24. #include <linux/gpio.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/regulator/fixed.h>
  27. #include <plat/i2c.h>
  28. #include <plat/usb.h>
  29. #include "twl-common.h"
  30. static struct i2c_board_info __initdata pmic_i2c_board_info = {
  31. .addr = 0x48,
  32. .flags = I2C_CLIENT_WAKE,
  33. };
  34. void __init omap_pmic_init(int bus, u32 clkrate,
  35. const char *pmic_type, int pmic_irq,
  36. struct twl4030_platform_data *pmic_data)
  37. {
  38. strncpy(pmic_i2c_board_info.type, pmic_type,
  39. sizeof(pmic_i2c_board_info.type));
  40. pmic_i2c_board_info.irq = pmic_irq;
  41. pmic_i2c_board_info.platform_data = pmic_data;
  42. omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
  43. }
  44. #if defined(CONFIG_ARCH_OMAP3)
  45. static struct twl4030_usb_data omap3_usb_pdata = {
  46. .usb_mode = T2_USB_MODE_ULPI,
  47. };
  48. static int omap3_batt_table[] = {
  49. /* 0 C */
  50. 30800, 29500, 28300, 27100,
  51. 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
  52. 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
  53. 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
  54. 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
  55. 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
  56. 4040, 3910, 3790, 3670, 3550
  57. };
  58. static struct twl4030_bci_platform_data omap3_bci_pdata = {
  59. .battery_tmp_tbl = omap3_batt_table,
  60. .tblsize = ARRAY_SIZE(omap3_batt_table),
  61. };
  62. static struct twl4030_madc_platform_data omap3_madc_pdata = {
  63. .irq_line = 1,
  64. };
  65. static struct twl4030_codec_data omap3_codec;
  66. static struct twl4030_audio_data omap3_audio_pdata = {
  67. .audio_mclk = 26000000,
  68. .codec = &omap3_codec,
  69. };
  70. static struct regulator_consumer_supply omap3_vdda_dac_supplies[] = {
  71. REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
  72. };
  73. static struct regulator_init_data omap3_vdac_idata = {
  74. .constraints = {
  75. .min_uV = 1800000,
  76. .max_uV = 1800000,
  77. .valid_modes_mask = REGULATOR_MODE_NORMAL
  78. | REGULATOR_MODE_STANDBY,
  79. .valid_ops_mask = REGULATOR_CHANGE_MODE
  80. | REGULATOR_CHANGE_STATUS,
  81. },
  82. .num_consumer_supplies = ARRAY_SIZE(omap3_vdda_dac_supplies),
  83. .consumer_supplies = omap3_vdda_dac_supplies,
  84. };
  85. static struct regulator_consumer_supply omap3_vpll2_supplies[] = {
  86. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  87. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
  88. };
  89. static struct regulator_init_data omap3_vpll2_idata = {
  90. .constraints = {
  91. .min_uV = 1800000,
  92. .max_uV = 1800000,
  93. .valid_modes_mask = REGULATOR_MODE_NORMAL
  94. | REGULATOR_MODE_STANDBY,
  95. .valid_ops_mask = REGULATOR_CHANGE_MODE
  96. | REGULATOR_CHANGE_STATUS,
  97. },
  98. .num_consumer_supplies = ARRAY_SIZE(omap3_vpll2_supplies),
  99. .consumer_supplies = omap3_vpll2_supplies,
  100. };
  101. void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
  102. u32 pdata_flags, u32 regulators_flags)
  103. {
  104. if (!pmic_data->irq_base)
  105. pmic_data->irq_base = TWL4030_IRQ_BASE;
  106. if (!pmic_data->irq_end)
  107. pmic_data->irq_end = TWL4030_IRQ_END;
  108. /* Common platform data configurations */
  109. if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
  110. pmic_data->usb = &omap3_usb_pdata;
  111. if (pdata_flags & TWL_COMMON_PDATA_BCI && !pmic_data->bci)
  112. pmic_data->bci = &omap3_bci_pdata;
  113. if (pdata_flags & TWL_COMMON_PDATA_MADC && !pmic_data->madc)
  114. pmic_data->madc = &omap3_madc_pdata;
  115. if (pdata_flags & TWL_COMMON_PDATA_AUDIO && !pmic_data->audio)
  116. pmic_data->audio = &omap3_audio_pdata;
  117. /* Common regulator configurations */
  118. if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
  119. pmic_data->vdac = &omap3_vdac_idata;
  120. if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2)
  121. pmic_data->vpll2 = &omap3_vpll2_idata;
  122. }
  123. #endif /* CONFIG_ARCH_OMAP3 */
  124. #if defined(CONFIG_ARCH_OMAP4)
  125. static struct twl4030_usb_data omap4_usb_pdata = {
  126. .phy_init = omap4430_phy_init,
  127. .phy_exit = omap4430_phy_exit,
  128. .phy_power = omap4430_phy_power,
  129. .phy_set_clock = omap4430_phy_set_clk,
  130. .phy_suspend = omap4430_phy_suspend,
  131. };
  132. static struct regulator_init_data omap4_vdac_idata = {
  133. .constraints = {
  134. .min_uV = 1800000,
  135. .max_uV = 1800000,
  136. .valid_modes_mask = REGULATOR_MODE_NORMAL
  137. | REGULATOR_MODE_STANDBY,
  138. .valid_ops_mask = REGULATOR_CHANGE_MODE
  139. | REGULATOR_CHANGE_STATUS,
  140. },
  141. };
  142. static struct regulator_init_data omap4_vaux2_idata = {
  143. .constraints = {
  144. .min_uV = 1200000,
  145. .max_uV = 2800000,
  146. .apply_uV = true,
  147. .valid_modes_mask = REGULATOR_MODE_NORMAL
  148. | REGULATOR_MODE_STANDBY,
  149. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  150. | REGULATOR_CHANGE_MODE
  151. | REGULATOR_CHANGE_STATUS,
  152. },
  153. };
  154. static struct regulator_init_data omap4_vaux3_idata = {
  155. .constraints = {
  156. .min_uV = 1000000,
  157. .max_uV = 3000000,
  158. .apply_uV = true,
  159. .valid_modes_mask = REGULATOR_MODE_NORMAL
  160. | REGULATOR_MODE_STANDBY,
  161. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  162. | REGULATOR_CHANGE_MODE
  163. | REGULATOR_CHANGE_STATUS,
  164. },
  165. };
  166. static struct regulator_consumer_supply omap4_vmmc_supply[] = {
  167. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  168. };
  169. /* VMMC1 for MMC1 card */
  170. static struct regulator_init_data omap4_vmmc_idata = {
  171. .constraints = {
  172. .min_uV = 1200000,
  173. .max_uV = 3000000,
  174. .apply_uV = true,
  175. .valid_modes_mask = REGULATOR_MODE_NORMAL
  176. | REGULATOR_MODE_STANDBY,
  177. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  178. | REGULATOR_CHANGE_MODE
  179. | REGULATOR_CHANGE_STATUS,
  180. },
  181. .num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply),
  182. .consumer_supplies = omap4_vmmc_supply,
  183. };
  184. static struct regulator_init_data omap4_vpp_idata = {
  185. .constraints = {
  186. .min_uV = 1800000,
  187. .max_uV = 2500000,
  188. .apply_uV = true,
  189. .valid_modes_mask = REGULATOR_MODE_NORMAL
  190. | REGULATOR_MODE_STANDBY,
  191. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  192. | REGULATOR_CHANGE_MODE
  193. | REGULATOR_CHANGE_STATUS,
  194. },
  195. };
  196. static struct regulator_init_data omap4_vana_idata = {
  197. .constraints = {
  198. .min_uV = 2100000,
  199. .max_uV = 2100000,
  200. .valid_modes_mask = REGULATOR_MODE_NORMAL
  201. | REGULATOR_MODE_STANDBY,
  202. .valid_ops_mask = REGULATOR_CHANGE_MODE
  203. | REGULATOR_CHANGE_STATUS,
  204. },
  205. };
  206. static struct regulator_init_data omap4_vcxio_idata = {
  207. .constraints = {
  208. .min_uV = 1800000,
  209. .max_uV = 1800000,
  210. .valid_modes_mask = REGULATOR_MODE_NORMAL
  211. | REGULATOR_MODE_STANDBY,
  212. .valid_ops_mask = REGULATOR_CHANGE_MODE
  213. | REGULATOR_CHANGE_STATUS,
  214. },
  215. };
  216. static struct regulator_init_data omap4_vusb_idata = {
  217. .constraints = {
  218. .min_uV = 3300000,
  219. .max_uV = 3300000,
  220. .apply_uV = true,
  221. .valid_modes_mask = REGULATOR_MODE_NORMAL
  222. | REGULATOR_MODE_STANDBY,
  223. .valid_ops_mask = REGULATOR_CHANGE_MODE
  224. | REGULATOR_CHANGE_STATUS,
  225. },
  226. };
  227. static struct regulator_init_data omap4_clk32kg_idata = {
  228. .constraints = {
  229. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  230. },
  231. };
  232. void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
  233. u32 pdata_flags, u32 regulators_flags)
  234. {
  235. if (!pmic_data->irq_base)
  236. pmic_data->irq_base = TWL6030_IRQ_BASE;
  237. if (!pmic_data->irq_end)
  238. pmic_data->irq_end = TWL6030_IRQ_END;
  239. /* Common platform data configurations */
  240. if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
  241. pmic_data->usb = &omap4_usb_pdata;
  242. /* Common regulator configurations */
  243. if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
  244. pmic_data->vdac = &omap4_vdac_idata;
  245. if (regulators_flags & TWL_COMMON_REGULATOR_VAUX2 && !pmic_data->vaux2)
  246. pmic_data->vaux2 = &omap4_vaux2_idata;
  247. if (regulators_flags & TWL_COMMON_REGULATOR_VAUX3 && !pmic_data->vaux3)
  248. pmic_data->vaux3 = &omap4_vaux3_idata;
  249. if (regulators_flags & TWL_COMMON_REGULATOR_VMMC && !pmic_data->vmmc)
  250. pmic_data->vmmc = &omap4_vmmc_idata;
  251. if (regulators_flags & TWL_COMMON_REGULATOR_VPP && !pmic_data->vpp)
  252. pmic_data->vpp = &omap4_vpp_idata;
  253. if (regulators_flags & TWL_COMMON_REGULATOR_VANA && !pmic_data->vana)
  254. pmic_data->vana = &omap4_vana_idata;
  255. if (regulators_flags & TWL_COMMON_REGULATOR_VCXIO && !pmic_data->vcxio)
  256. pmic_data->vcxio = &omap4_vcxio_idata;
  257. if (regulators_flags & TWL_COMMON_REGULATOR_VUSB && !pmic_data->vusb)
  258. pmic_data->vusb = &omap4_vusb_idata;
  259. if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG &&
  260. !pmic_data->clk32kg)
  261. pmic_data->clk32kg = &omap4_clk32kg_idata;
  262. }
  263. #endif /* CONFIG_ARCH_OMAP4 */