dataOperationOfSprayterminal.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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 "soc.h"
  28. #include "twl-common.h"
  29. #include "pm.h"
  30. #include "voltage.h"
  31. #include "mux.h"
  32. static struct i2c_board_info __initdata pmic_i2c_board_info = {
  33. .addr = 0x48,
  34. .flags = I2C_CLIENT_WAKE,
  35. };
  36. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  37. static int twl_set_voltage(void *data, int target_uV)
  38. {
  39. struct voltagedomain *voltdm = (struct voltagedomain *)data;
  40. return voltdm_scale(voltdm, target_uV);
  41. }
  42. static int twl_get_voltage(void *data)
  43. {
  44. struct voltagedomain *voltdm = (struct voltagedomain *)data;
  45. return voltdm_get_voltage(voltdm);
  46. }
  47. #endif
  48. void __init omap_pmic_init(int bus, u32 clkrate,
  49. const char *pmic_type, int pmic_irq,
  50. struct twl4030_platform_data *pmic_data)
  51. {
  52. omap_mux_init_signal("sys_nirq", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
  53. strncpy(pmic_i2c_board_info.type, pmic_type,
  54. sizeof(pmic_i2c_board_info.type));
  55. pmic_i2c_board_info.irq = pmic_irq;
  56. pmic_i2c_board_info.platform_data = pmic_data;
  57. omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
  58. }
  59. void __init omap4_pmic_init(const char *pmic_type,
  60. struct twl4030_platform_data *pmic_data,
  61. struct i2c_board_info *devices, int nr_devices)
  62. {
  63. /* PMIC part*/
  64. omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
  65. omap_mux_init_signal("fref_clk0_out.sys_drm_msecure", OMAP_PIN_OUTPUT);
  66. omap_pmic_init(1, 400, pmic_type, 7 + OMAP44XX_IRQ_GIC_START, pmic_data);
  67. /* Register additional devices on i2c1 bus if needed */
  68. if (devices)
  69. i2c_register_board_info(1, devices, nr_devices);
  70. }
  71. void __init omap_pmic_late_init(void)
  72. {
  73. /* Init the OMAP TWL parameters (if PMIC has been registerd) */
  74. if (!pmic_i2c_board_info.irq)
  75. return;
  76. omap3_twl_init();
  77. omap4_twl_init();
  78. }
  79. #if defined(CONFIG_ARCH_OMAP3)
  80. static struct twl4030_usb_data omap3_usb_pdata = {
  81. .usb_mode = T2_USB_MODE_ULPI,
  82. };
  83. static int omap3_batt_table[] = {
  84. /* 0 C */
  85. 30800, 29500, 28300, 27100,
  86. 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
  87. 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
  88. 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
  89. 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
  90. 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
  91. 4040, 3910, 3790, 3670, 3550
  92. };
  93. static struct twl4030_bci_platform_data omap3_bci_pdata = {
  94. .battery_tmp_tbl = omap3_batt_table,
  95. .tblsize = ARRAY_SIZE(omap3_batt_table),
  96. };
  97. static struct twl4030_madc_platform_data omap3_madc_pdata = {
  98. .irq_line = 1,
  99. };
  100. static struct twl4030_codec_data omap3_codec;
  101. static struct twl4030_audio_data omap3_audio_pdata = {
  102. .audio_mclk = 26000000,
  103. .codec = &omap3_codec,
  104. };
  105. static struct regulator_consumer_supply omap3_vdda_dac_supplies[] = {
  106. REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
  107. };
  108. static struct regulator_init_data omap3_vdac_idata = {
  109. .constraints = {
  110. .min_uV = 1800000,
  111. .max_uV = 1800000,
  112. .valid_modes_mask = REGULATOR_MODE_NORMAL
  113. | REGULATOR_MODE_STANDBY,
  114. .valid_ops_mask = REGULATOR_CHANGE_MODE
  115. | REGULATOR_CHANGE_STATUS,
  116. },
  117. .num_consumer_supplies = ARRAY_SIZE(omap3_vdda_dac_supplies),
  118. .consumer_supplies = omap3_vdda_dac_supplies,
  119. };
  120. static struct regulator_consumer_supply omap3_vpll2_supplies[] = {
  121. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  122. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
  123. };
  124. static struct regulator_init_data omap3_vpll2_idata = {
  125. .constraints = {
  126. .min_uV = 1800000,
  127. .max_uV = 1800000,
  128. .valid_modes_mask = REGULATOR_MODE_NORMAL
  129. | REGULATOR_MODE_STANDBY,
  130. .valid_ops_mask = REGULATOR_CHANGE_MODE
  131. | REGULATOR_CHANGE_STATUS,
  132. },
  133. .num_consumer_supplies = ARRAY_SIZE(omap3_vpll2_supplies),
  134. .consumer_supplies = omap3_vpll2_supplies,
  135. };
  136. static struct regulator_consumer_supply omap3_vdd1_supply[] = {
  137. REGULATOR_SUPPLY("vcc", "cpu0"),
  138. };
  139. static struct regulator_consumer_supply omap3_vdd2_supply[] = {
  140. REGULATOR_SUPPLY("vcc", "l3_main.0"),
  141. };
  142. static struct regulator_init_data omap3_vdd1 = {
  143. .constraints = {
  144. .name = "vdd_mpu_iva",
  145. .min_uV = 600000,
  146. .max_uV = 1450000,
  147. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  148. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  149. },
  150. .num_consumer_supplies = ARRAY_SIZE(omap3_vdd1_supply),
  151. .consumer_supplies = omap3_vdd1_supply,
  152. };
  153. static struct regulator_init_data omap3_vdd2 = {
  154. .constraints = {
  155. .name = "vdd_core",
  156. .min_uV = 600000,
  157. .max_uV = 1450000,
  158. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  159. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  160. },
  161. .num_consumer_supplies = ARRAY_SIZE(omap3_vdd2_supply),
  162. .consumer_supplies = omap3_vdd2_supply,
  163. };
  164. static struct twl_regulator_driver_data omap3_vdd1_drvdata = {
  165. .get_voltage = twl_get_voltage,
  166. .set_voltage = twl_set_voltage,
  167. };
  168. static struct twl_regulator_driver_data omap3_vdd2_drvdata = {
  169. .get_voltage = twl_get_voltage,
  170. .set_voltage = twl_set_voltage,
  171. };
  172. void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
  173. u32 pdata_flags, u32 regulators_flags)
  174. {
  175. if (!pmic_data->vdd1) {
  176. omap3_vdd1.driver_data = &omap3_vdd1_drvdata;
  177. omap3_vdd1_drvdata.data = voltdm_lookup("mpu_iva");
  178. pmic_data->vdd1 = &omap3_vdd1;
  179. }
  180. if (!pmic_data->vdd2) {
  181. omap3_vdd2.driver_data = &omap3_vdd2_drvdata;
  182. omap3_vdd2_drvdata.data = voltdm_lookup("core");
  183. pmic_data->vdd2 = &omap3_vdd2;
  184. }
  185. /* Common platform data configurations */
  186. if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
  187. pmic_data->usb = &omap3_usb_pdata;
  188. if (pdata_flags & TWL_COMMON_PDATA_BCI && !pmic_data->bci)
  189. pmic_data->bci = &omap3_bci_pdata;
  190. if (pdata_flags & TWL_COMMON_PDATA_MADC && !pmic_data->madc)
  191. pmic_data->madc = &omap3_madc_pdata;
  192. if (pdata_flags & TWL_COMMON_PDATA_AUDIO && !pmic_data->audio)
  193. pmic_data->audio = &omap3_audio_pdata;
  194. /* Common regulator configurations */
  195. if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
  196. pmic_data->vdac = &omap3_vdac_idata;
  197. if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2)
  198. pmic_data->vpll2 = &omap3_vpll2_idata;
  199. }
  200. #endif /* CONFIG_ARCH_OMAP3 */
  201. #if defined(CONFIG_ARCH_OMAP4)
  202. static struct twl4030_usb_data omap4_usb_pdata = {
  203. };
  204. static struct regulator_consumer_supply omap4_vdda_hdmi_dac_supplies[] = {
  205. REGULATOR_SUPPLY("vdda_hdmi_dac", "omapdss_hdmi"),
  206. };
  207. static struct regulator_init_data omap4_vdac_idata = {
  208. .constraints = {
  209. .min_uV = 1800000,
  210. .max_uV = 1800000,
  211. .valid_modes_mask = REGULATOR_MODE_NORMAL
  212. | REGULATOR_MODE_STANDBY,
  213. .valid_ops_mask = REGULATOR_CHANGE_MODE
  214. | REGULATOR_CHANGE_STATUS,
  215. },
  216. .num_consumer_supplies = ARRAY_SIZE(omap4_vdda_hdmi_dac_supplies),
  217. .consumer_supplies = omap4_vdda_hdmi_dac_supplies,
  218. .supply_regulator = "V2V1",
  219. };
  220. static struct regulator_init_data omap4_vaux2_idata = {
  221. .constraints = {
  222. .min_uV = 1200000,
  223. .max_uV = 2800000,
  224. .apply_uV = true,
  225. .valid_modes_mask = REGULATOR_MODE_NORMAL
  226. | REGULATOR_MODE_STANDBY,
  227. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  228. | REGULATOR_CHANGE_MODE
  229. | REGULATOR_CHANGE_STATUS,
  230. },
  231. };
  232. static struct regulator_init_data omap4_vaux3_idata = {
  233. .constraints = {
  234. .min_uV = 1000000,
  235. .max_uV = 3000000,
  236. .apply_uV = true,
  237. .valid_modes_mask = REGULATOR_MODE_NORMAL
  238. | REGULATOR_MODE_STANDBY,
  239. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  240. | REGULATOR_CHANGE_MODE
  241. | REGULATOR_CHANGE_STATUS,
  242. },
  243. };
  244. static struct regulator_consumer_supply omap4_vmmc_supply[] = {
  245. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  246. };
  247. /* VMMC1 for MMC1 card */
  248. static struct regulator_init_data omap4_vmmc_idata = {
  249. .constraints = {
  250. .min_uV = 1200000,
  251. .max_uV = 3000000,
  252. .apply_uV = true,
  253. .valid_modes_mask = REGULATOR_MODE_NORMAL
  254. | REGULATOR_MODE_STANDBY,
  255. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  256. | REGULATOR_CHANGE_MODE
  257. | REGULATOR_CHANGE_STATUS,
  258. },
  259. .num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply),
  260. .consumer_supplies = omap4_vmmc_supply,
  261. };
  262. static struct regulator_init_data omap4_vpp_idata = {
  263. .constraints = {
  264. .min_uV = 1800000,
  265. .max_uV = 2500000,
  266. .apply_uV = true,
  267. .valid_modes_mask = REGULATOR_MODE_NORMAL
  268. | REGULATOR_MODE_STANDBY,
  269. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  270. | REGULATOR_CHANGE_MODE
  271. | REGULATOR_CHANGE_STATUS,
  272. },
  273. };
  274. static struct regulator_init_data omap4_vana_idata = {
  275. .constraints = {
  276. .min_uV = 2100000,
  277. .max_uV = 2100000,
  278. .valid_modes_mask = REGULATOR_MODE_NORMAL
  279. | REGULATOR_MODE_STANDBY,
  280. .valid_ops_mask = REGULATOR_CHANGE_MODE
  281. | REGULATOR_CHANGE_STATUS,
  282. },
  283. };
  284. static struct regulator_consumer_supply omap4_vcxio_supply[] = {
  285. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dss"),
  286. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
  287. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.1"),
  288. };
  289. static struct regulator_init_data omap4_vcxio_idata = {
  290. .constraints = {
  291. .min_uV = 1800000,
  292. .max_uV = 1800000,
  293. .valid_modes_mask = REGULATOR_MODE_NORMAL
  294. | REGULATOR_MODE_STANDBY,
  295. .valid_ops_mask = REGULATOR_CHANGE_MODE
  296. | REGULATOR_CHANGE_STATUS,
  297. .always_on = true,
  298. },
  299. .num_consumer_supplies = ARRAY_SIZE(omap4_vcxio_supply),
  300. .consumer_supplies = omap4_vcxio_supply,
  301. .supply_regulator = "V2V1",
  302. };
  303. static struct regulator_init_data omap4_vusb_idata = {
  304. .constraints = {
  305. .min_uV = 3300000,
  306. .max_uV = 3300000,
  307. .valid_modes_mask = REGULATOR_MODE_NORMAL
  308. | REGULATOR_MODE_STANDBY,
  309. .valid_ops_mask = REGULATOR_CHANGE_MODE
  310. | REGULATOR_CHANGE_STATUS,
  311. },
  312. };
  313. static struct regulator_init_data omap4_clk32kg_idata = {
  314. .constraints = {
  315. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  316. },
  317. };
  318. static struct regulator_consumer_supply omap4_vdd1_supply[] = {
  319. REGULATOR_SUPPLY("vcc", "cpu0"),
  320. };
  321. static struct regulator_consumer_supply omap4_vdd2_supply[] = {
  322. REGULATOR_SUPPLY("vcc", "iva.0"),
  323. };
  324. static struct regulator_consumer_supply omap4_vdd3_supply[] = {
  325. REGULATOR_SUPPLY("vcc", "l3_main.0"),
  326. };
  327. static struct regulator_init_data omap4_vdd1 = {
  328. .constraints = {
  329. .name = "vdd_mpu",
  330. .min_uV = 500000,
  331. .max_uV = 1500000,
  332. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  333. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  334. },
  335. .num_consumer_supplies = ARRAY_SIZE(omap4_vdd1_supply),
  336. .consumer_supplies = omap4_vdd1_supply,
  337. };
  338. static struct regulator_init_data omap4_vdd2 = {
  339. .constraints = {