twl-common.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. static struct twl4030_usb_data omap4_usb_pdata = {
  45. .phy_init = omap4430_phy_init,
  46. .phy_exit = omap4430_phy_exit,
  47. .phy_power = omap4430_phy_power,
  48. .phy_set_clock = omap4430_phy_set_clk,
  49. .phy_suspend = omap4430_phy_suspend,
  50. };
  51. static struct twl4030_usb_data omap3_usb_pdata = {
  52. .usb_mode = T2_USB_MODE_ULPI,
  53. };
  54. static int omap3_batt_table[] = {
  55. /* 0 C */
  56. 30800, 29500, 28300, 27100,
  57. 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
  58. 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
  59. 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
  60. 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
  61. 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
  62. 4040, 3910, 3790, 3670, 3550
  63. };
  64. static struct twl4030_bci_platform_data omap3_bci_pdata = {
  65. .battery_tmp_tbl = omap3_batt_table,
  66. .tblsize = ARRAY_SIZE(omap3_batt_table),
  67. };
  68. static struct twl4030_madc_platform_data omap3_madc_pdata = {
  69. .irq_line = 1,
  70. };
  71. static struct twl4030_codec_data omap3_codec;
  72. static struct twl4030_audio_data omap3_audio_pdata = {
  73. .audio_mclk = 26000000,
  74. .codec = &omap3_codec,
  75. };
  76. static struct regulator_consumer_supply omap3_vdda_dac_supplies[] = {
  77. REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
  78. };
  79. static struct regulator_init_data omap3_vdac_idata = {
  80. .constraints = {
  81. .min_uV = 1800000,
  82. .max_uV = 1800000,
  83. .valid_modes_mask = REGULATOR_MODE_NORMAL
  84. | REGULATOR_MODE_STANDBY,
  85. .valid_ops_mask = REGULATOR_CHANGE_MODE
  86. | REGULATOR_CHANGE_STATUS,
  87. },
  88. .num_consumer_supplies = ARRAY_SIZE(omap3_vdda_dac_supplies),
  89. .consumer_supplies = omap3_vdda_dac_supplies,
  90. };
  91. static struct regulator_consumer_supply omap3_vpll2_supplies[] = {
  92. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  93. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
  94. };
  95. static struct regulator_init_data omap3_vpll2_idata = {
  96. .constraints = {
  97. .min_uV = 1800000,
  98. .max_uV = 1800000,
  99. .valid_modes_mask = REGULATOR_MODE_NORMAL
  100. | REGULATOR_MODE_STANDBY,
  101. .valid_ops_mask = REGULATOR_CHANGE_MODE
  102. | REGULATOR_CHANGE_STATUS,
  103. },
  104. .num_consumer_supplies = ARRAY_SIZE(omap3_vpll2_supplies),
  105. .consumer_supplies = omap3_vpll2_supplies,
  106. };
  107. static struct regulator_init_data omap4_vdac_idata = {
  108. .constraints = {
  109. .min_uV = 1800000,
  110. .max_uV = 1800000,
  111. .valid_modes_mask = REGULATOR_MODE_NORMAL
  112. | REGULATOR_MODE_STANDBY,
  113. .valid_ops_mask = REGULATOR_CHANGE_MODE
  114. | REGULATOR_CHANGE_STATUS,
  115. },
  116. };
  117. static struct regulator_init_data omap4_vaux2_idata = {
  118. .constraints = {
  119. .min_uV = 1200000,
  120. .max_uV = 2800000,
  121. .apply_uV = true,
  122. .valid_modes_mask = REGULATOR_MODE_NORMAL
  123. | REGULATOR_MODE_STANDBY,
  124. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  125. | REGULATOR_CHANGE_MODE
  126. | REGULATOR_CHANGE_STATUS,
  127. },
  128. };
  129. static struct regulator_init_data omap4_vaux3_idata = {
  130. .constraints = {
  131. .min_uV = 1000000,
  132. .max_uV = 3000000,
  133. .apply_uV = true,
  134. .valid_modes_mask = REGULATOR_MODE_NORMAL
  135. | REGULATOR_MODE_STANDBY,
  136. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  137. | REGULATOR_CHANGE_MODE
  138. | REGULATOR_CHANGE_STATUS,
  139. },
  140. };
  141. static struct regulator_consumer_supply omap4_vmmc_supply[] = {
  142. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  143. };
  144. /* VMMC1 for MMC1 card */
  145. static struct regulator_init_data omap4_vmmc_idata = {
  146. .constraints = {
  147. .min_uV = 1200000,
  148. .max_uV = 3000000,
  149. .apply_uV = true,
  150. .valid_modes_mask = REGULATOR_MODE_NORMAL
  151. | REGULATOR_MODE_STANDBY,
  152. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  153. | REGULATOR_CHANGE_MODE
  154. | REGULATOR_CHANGE_STATUS,
  155. },
  156. .num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply),
  157. .consumer_supplies = omap4_vmmc_supply,
  158. };
  159. static struct regulator_init_data omap4_vpp_idata = {
  160. .constraints = {
  161. .min_uV = 1800000,
  162. .max_uV = 2500000,
  163. .apply_uV = true,
  164. .valid_modes_mask = REGULATOR_MODE_NORMAL
  165. | REGULATOR_MODE_STANDBY,
  166. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  167. | REGULATOR_CHANGE_MODE
  168. | REGULATOR_CHANGE_STATUS,
  169. },
  170. };
  171. static struct regulator_init_data omap4_vana_idata = {
  172. .constraints = {
  173. .min_uV = 2100000,
  174. .max_uV = 2100000,
  175. .valid_modes_mask = REGULATOR_MODE_NORMAL
  176. | REGULATOR_MODE_STANDBY,
  177. .valid_ops_mask = REGULATOR_CHANGE_MODE
  178. | REGULATOR_CHANGE_STATUS,
  179. },
  180. };
  181. static struct regulator_init_data omap4_vcxio_idata = {
  182. .constraints = {
  183. .min_uV = 1800000,
  184. .max_uV = 1800000,
  185. .valid_modes_mask = REGULATOR_MODE_NORMAL
  186. | REGULATOR_MODE_STANDBY,
  187. .valid_ops_mask = REGULATOR_CHANGE_MODE
  188. | REGULATOR_CHANGE_STATUS,
  189. },
  190. };
  191. static struct regulator_init_data omap4_vusb_idata = {
  192. .constraints = {
  193. .min_uV = 3300000,
  194. .max_uV = 3300000,
  195. .apply_uV = true,
  196. .valid_modes_mask = REGULATOR_MODE_NORMAL
  197. | REGULATOR_MODE_STANDBY,
  198. .valid_ops_mask = REGULATOR_CHANGE_MODE
  199. | REGULATOR_CHANGE_STATUS,
  200. },
  201. };
  202. static struct regulator_init_data omap4_clk32kg_idata = {
  203. .constraints = {
  204. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  205. },
  206. };
  207. void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
  208. u32 pdata_flags, u32 regulators_flags)
  209. {
  210. if (!pmic_data->irq_base)
  211. pmic_data->irq_base = TWL6030_IRQ_BASE;
  212. if (!pmic_data->irq_end)
  213. pmic_data->irq_end = TWL6030_IRQ_END;
  214. /* Common platform data configurations */
  215. if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
  216. pmic_data->usb = &omap4_usb_pdata;
  217. /* Common regulator configurations */
  218. if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
  219. pmic_data->vdac = &omap4_vdac_idata;
  220. if (regulators_flags & TWL_COMMON_REGULATOR_VAUX2 && !pmic_data->vaux2)
  221. pmic_data->vaux2 = &omap4_vaux2_idata;
  222. if (regulators_flags & TWL_COMMON_REGULATOR_VAUX3 && !pmic_data->vaux3)
  223. pmic_data->vaux3 = &omap4_vaux3_idata;
  224. if (regulators_flags & TWL_COMMON_REGULATOR_VMMC && !pmic_data->vmmc)
  225. pmic_data->vmmc = &omap4_vmmc_idata;
  226. if (regulators_flags & TWL_COMMON_REGULATOR_VPP && !pmic_data->vpp)
  227. pmic_data->vpp = &omap4_vpp_idata;
  228. if (regulators_flags & TWL_COMMON_REGULATOR_VANA && !pmic_data->vana)
  229. pmic_data->vana = &omap4_vana_idata;
  230. if (regulators_flags & TWL_COMMON_REGULATOR_VCXIO && !pmic_data->vcxio)
  231. pmic_data->vcxio = &omap4_vcxio_idata;
  232. if (regulators_flags & TWL_COMMON_REGULATOR_VUSB && !pmic_data->vusb)
  233. pmic_data->vusb = &omap4_vusb_idata;
  234. if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG &&
  235. !pmic_data->clk32kg)
  236. pmic_data->clk32kg = &omap4_clk32kg_idata;
  237. }
  238. void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
  239. u32 pdata_flags, u32 regulators_flags)
  240. {
  241. if (!pmic_data->irq_base)
  242. pmic_data->irq_base = TWL4030_IRQ_BASE;
  243. if (!pmic_data->irq_end)
  244. pmic_data->irq_end = TWL4030_IRQ_END;
  245. /* Common platform data configurations */
  246. if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
  247. pmic_data->usb = &omap3_usb_pdata;
  248. if (pdata_flags & TWL_COMMON_PDATA_BCI && !pmic_data->bci)
  249. pmic_data->bci = &omap3_bci_pdata;
  250. if (pdata_flags & TWL_COMMON_PDATA_MADC && !pmic_data->madc)
  251. pmic_data->madc = &omap3_madc_pdata;
  252. if (pdata_flags & TWL_COMMON_PDATA_AUDIO && !pmic_data->audio)
  253. pmic_data->audio = &omap3_audio_pdata;
  254. /* Common regulator configurations */
  255. if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
  256. pmic_data->vdac = &omap3_vdac_idata;
  257. if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2)
  258. pmic_data->vpll2 = &omap3_vpll2_idata;
  259. }