twl-common.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 regulator_init_data omap4_vdac_idata = {
  52. .constraints = {
  53. .min_uV = 1800000,
  54. .max_uV = 1800000,
  55. .valid_modes_mask = REGULATOR_MODE_NORMAL
  56. | REGULATOR_MODE_STANDBY,
  57. .valid_ops_mask = REGULATOR_CHANGE_MODE
  58. | REGULATOR_CHANGE_STATUS,
  59. },
  60. };
  61. static struct regulator_init_data omap4_vaux2_idata = {
  62. .constraints = {
  63. .min_uV = 1200000,
  64. .max_uV = 2800000,
  65. .apply_uV = true,
  66. .valid_modes_mask = REGULATOR_MODE_NORMAL
  67. | REGULATOR_MODE_STANDBY,
  68. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  69. | REGULATOR_CHANGE_MODE
  70. | REGULATOR_CHANGE_STATUS,
  71. },
  72. };
  73. static struct regulator_init_data omap4_vaux3_idata = {
  74. .constraints = {
  75. .min_uV = 1000000,
  76. .max_uV = 3000000,
  77. .apply_uV = true,
  78. .valid_modes_mask = REGULATOR_MODE_NORMAL
  79. | REGULATOR_MODE_STANDBY,
  80. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  81. | REGULATOR_CHANGE_MODE
  82. | REGULATOR_CHANGE_STATUS,
  83. },
  84. };
  85. static struct regulator_consumer_supply omap4_vmmc_supply[] = {
  86. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  87. };
  88. /* VMMC1 for MMC1 card */
  89. static struct regulator_init_data omap4_vmmc_idata = {
  90. .constraints = {
  91. .min_uV = 1200000,
  92. .max_uV = 3000000,
  93. .apply_uV = true,
  94. .valid_modes_mask = REGULATOR_MODE_NORMAL
  95. | REGULATOR_MODE_STANDBY,
  96. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  97. | REGULATOR_CHANGE_MODE
  98. | REGULATOR_CHANGE_STATUS,
  99. },
  100. .num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply),
  101. .consumer_supplies = omap4_vmmc_supply,
  102. };
  103. static struct regulator_init_data omap4_vpp_idata = {
  104. .constraints = {
  105. .min_uV = 1800000,
  106. .max_uV = 2500000,
  107. .apply_uV = true,
  108. .valid_modes_mask = REGULATOR_MODE_NORMAL
  109. | REGULATOR_MODE_STANDBY,
  110. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  111. | REGULATOR_CHANGE_MODE
  112. | REGULATOR_CHANGE_STATUS,
  113. },
  114. };
  115. static struct regulator_init_data omap4_vana_idata = {
  116. .constraints = {
  117. .min_uV = 2100000,
  118. .max_uV = 2100000,
  119. .valid_modes_mask = REGULATOR_MODE_NORMAL
  120. | REGULATOR_MODE_STANDBY,
  121. .valid_ops_mask = REGULATOR_CHANGE_MODE
  122. | REGULATOR_CHANGE_STATUS,
  123. },
  124. };
  125. static struct regulator_init_data omap4_vcxio_idata = {
  126. .constraints = {
  127. .min_uV = 1800000,
  128. .max_uV = 1800000,
  129. .valid_modes_mask = REGULATOR_MODE_NORMAL
  130. | REGULATOR_MODE_STANDBY,
  131. .valid_ops_mask = REGULATOR_CHANGE_MODE
  132. | REGULATOR_CHANGE_STATUS,
  133. },
  134. };
  135. static struct regulator_init_data omap4_vusb_idata = {
  136. .constraints = {
  137. .min_uV = 3300000,
  138. .max_uV = 3300000,
  139. .apply_uV = true,
  140. .valid_modes_mask = REGULATOR_MODE_NORMAL
  141. | REGULATOR_MODE_STANDBY,
  142. .valid_ops_mask = REGULATOR_CHANGE_MODE
  143. | REGULATOR_CHANGE_STATUS,
  144. },
  145. };
  146. static struct regulator_init_data omap4_clk32kg_idata = {
  147. .constraints = {
  148. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  149. },
  150. };
  151. void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
  152. u32 pdata_flags, u32 regulators_flags)
  153. {
  154. if (!pmic_data->irq_base)
  155. pmic_data->irq_base = TWL6030_IRQ_BASE;
  156. if (!pmic_data->irq_end)
  157. pmic_data->irq_end = TWL6030_IRQ_END;
  158. /* Common platform data configurations */
  159. if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
  160. pmic_data->usb = &omap4_usb_pdata;
  161. /* Common regulator configurations */
  162. if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
  163. pmic_data->vdac = &omap4_vdac_idata;
  164. if (regulators_flags & TWL_COMMON_REGULATOR_VAUX2 && !pmic_data->vaux2)
  165. pmic_data->vaux2 = &omap4_vaux2_idata;
  166. if (regulators_flags & TWL_COMMON_REGULATOR_VAUX3 && !pmic_data->vaux3)
  167. pmic_data->vaux3 = &omap4_vaux3_idata;
  168. if (regulators_flags & TWL_COMMON_REGULATOR_VMMC && !pmic_data->vmmc)
  169. pmic_data->vmmc = &omap4_vmmc_idata;
  170. if (regulators_flags & TWL_COMMON_REGULATOR_VPP && !pmic_data->vpp)
  171. pmic_data->vpp = &omap4_vpp_idata;
  172. if (regulators_flags & TWL_COMMON_REGULATOR_VANA && !pmic_data->vana)
  173. pmic_data->vana = &omap4_vana_idata;
  174. if (regulators_flags & TWL_COMMON_REGULATOR_VCXIO && !pmic_data->vcxio)
  175. pmic_data->vcxio = &omap4_vcxio_idata;
  176. if (regulators_flags & TWL_COMMON_REGULATOR_VUSB && !pmic_data->vusb)
  177. pmic_data->vusb = &omap4_vusb_idata;
  178. if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG &&
  179. !pmic_data->clk32kg)
  180. pmic_data->clk32kg = &omap4_clk32kg_idata;
  181. }