twl4030.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2009 Wind River Systems, Inc.
  3. * Tom Rix <Tom.Rix at windriver.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. *
  7. * twl4030_power_reset_init is derived from code on omapzoom,
  8. * git://git.omapzoom.com/repo/u-boot.git
  9. *
  10. * Copyright (C) 2007-2009 Texas Instruments, Inc.
  11. *
  12. * twl4030_power_init is from cpu/omap3/common.c, power_init_r
  13. *
  14. * (C) Copyright 2004-2008
  15. * Texas Instruments, <www.ti.com>
  16. *
  17. * Author :
  18. * Sunil Kumar <sunilsaini05 at gmail.com>
  19. * Shashi Ranjan <shashiranjanmca05 at gmail.com>
  20. *
  21. * Derived from Beagle Board and 3430 SDP code by
  22. * Richard Woodruff <r-woodruff2 at ti.com>
  23. * Syed Mohammed Khasim <khasim at ti.com>
  24. */
  25. #include <twl4030.h>
  26. /*
  27. * Power Reset
  28. */
  29. void twl4030_power_reset_init(void)
  30. {
  31. u8 val = 0;
  32. if (twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
  33. TWL4030_PM_MASTER_P1_SW_EVENTS, &val)) {
  34. printf("Error:TWL4030: failed to read the power register\n");
  35. printf("Could not initialize hardware reset\n");
  36. } else {
  37. val |= TWL4030_PM_MASTER_SW_EVENTS_STOPON_PWRON;
  38. if (twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
  39. TWL4030_PM_MASTER_P1_SW_EVENTS, val)) {
  40. printf("Error:TWL4030: failed to write the power register\n");
  41. printf("Could not initialize hardware reset\n");
  42. }
  43. }
  44. }
  45. /*
  46. * Set Device Group and Voltage
  47. */
  48. void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
  49. u8 dev_grp, u8 dev_grp_sel)
  50. {
  51. int ret;
  52. /* Select the Voltage */
  53. ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_reg,
  54. vsel_val);
  55. if (ret != 0) {
  56. printf("Could not write vsel to reg %02x (%d)\n",
  57. vsel_reg, ret);
  58. return;
  59. }
  60. /* Select the Device Group (enable the supply if dev_grp_sel != 0) */
  61. ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp,
  62. dev_grp_sel);
  63. if (ret != 0)
  64. printf("Could not write grp_sel to reg %02x (%d)\n",
  65. dev_grp, ret);
  66. }
  67. void twl4030_power_init(void)
  68. {
  69. /* set VAUX3 to 2.8V */
  70. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX3_DEDICATED,
  71. TWL4030_PM_RECEIVER_VAUX3_VSEL_28,
  72. TWL4030_PM_RECEIVER_VAUX3_DEV_GRP,
  73. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  74. /* set VPLL2 to 1.8V */
  75. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VPLL2_DEDICATED,
  76. TWL4030_PM_RECEIVER_VPLL2_VSEL_18,
  77. TWL4030_PM_RECEIVER_VPLL2_DEV_GRP,
  78. TWL4030_PM_RECEIVER_DEV_GRP_ALL);
  79. /* set VDAC to 1.8V */
  80. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VDAC_DEDICATED,
  81. TWL4030_PM_RECEIVER_VDAC_VSEL_18,
  82. TWL4030_PM_RECEIVER_VDAC_DEV_GRP,
  83. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  84. }
  85. void twl4030_power_mmc_init(int dev_index)
  86. {
  87. if (dev_index == 0) {
  88. /* Set VMMC1 to 3.15 Volts */
  89. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VMMC1_DEDICATED,
  90. TWL4030_PM_RECEIVER_VMMC1_VSEL_32,
  91. TWL4030_PM_RECEIVER_VMMC1_DEV_GRP,
  92. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  93. mdelay(100); /* ramp-up delay from Linux code */
  94. } else if (dev_index == 1) {
  95. /* Set VMMC2 to 3.15 Volts */
  96. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VMMC2_DEDICATED,
  97. TWL4030_PM_RECEIVER_VMMC2_VSEL_32,
  98. TWL4030_PM_RECEIVER_VMMC2_DEV_GRP,
  99. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  100. mdelay(100); /* ramp-up delay from Linux code */
  101. }
  102. }