psc.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Power and Sleep Controller (PSC) functions.
  3. *
  4. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  5. * Copyright (C) 2008 Lyrtech <www.lyrtech.com>
  6. * Copyright (C) 2004 Texas Instruments.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <common.h>
  26. #include <asm/arch/hardware.h>
  27. #define PINMUX0_EMACEN (1 << 31)
  28. #define PINMUX0_AECS5 (1 << 11)
  29. #define PINMUX0_AECS4 (1 << 10)
  30. #define PINMUX1_I2C (1 << 7)
  31. #define PINMUX1_UART1 (1 << 1)
  32. #define PINMUX1_UART0 (1 << 0)
  33. /*
  34. * The DM6446 includes two separate power domains: "Always On" and "DSP". The
  35. * "Always On" power domain is always on when the chip is on. The "Always On"
  36. * domain is powered by the VDD pins of the DM6446. The majority of the
  37. * DM6446's modules lie within the "Always On" power domain. A separate
  38. * domain called the "DSP" domain houses the C64x+ and VICP. The "DSP" domain
  39. * is not always on. The "DSP" power domain is powered by the CVDDDSP pins of
  40. * the DM6446.
  41. */
  42. /* Works on Always On power domain only (no PD argument) */
  43. void lpsc_on(unsigned int id)
  44. {
  45. dv_reg_p mdstat, mdctl;
  46. if (id >= DAVINCI_LPSC_GEM)
  47. return; /* Don't work on DSP Power Domain */
  48. mdstat = REG_P(PSC_MDSTAT_BASE + (id * 4));
  49. mdctl = REG_P(PSC_MDCTL_BASE + (id * 4));
  50. while (REG(PSC_PTSTAT) & 0x01);
  51. if ((*mdstat & 0x1f) == 0x03)
  52. return; /* Already on and enabled */
  53. *mdctl |= 0x03;
  54. /* Special treatment for some modules as for sprue14 p.7.4.2 */
  55. switch (id) {
  56. case DAVINCI_LPSC_VPSSSLV:
  57. case DAVINCI_LPSC_EMAC:
  58. case DAVINCI_LPSC_EMAC_WRAPPER:
  59. case DAVINCI_LPSC_MDIO:
  60. case DAVINCI_LPSC_USB:
  61. case DAVINCI_LPSC_ATA:
  62. case DAVINCI_LPSC_VLYNQ:
  63. case DAVINCI_LPSC_UHPI:
  64. case DAVINCI_LPSC_DDR_EMIF:
  65. case DAVINCI_LPSC_AEMIF:
  66. case DAVINCI_LPSC_MMC_SD:
  67. case DAVINCI_LPSC_MEMSTICK:
  68. case DAVINCI_LPSC_McBSP:
  69. case DAVINCI_LPSC_GPIO:
  70. *mdctl |= 0x200;
  71. break;
  72. }
  73. REG(PSC_PTCMD) = 0x01;
  74. while (REG(PSC_PTSTAT) & 0x03);
  75. while ((*mdstat & 0x1f) != 0x03); /* Probably an overkill... */
  76. }
  77. /* If DSPLINK is used, we don't want U-Boot to power on the DSP. */
  78. #if !defined(CONFIG_SYS_USE_DSPLINK)
  79. void dsp_on(void)
  80. {
  81. int i;
  82. if (REG(PSC_PDSTAT1) & 0x1f)
  83. return; /* Already on */
  84. REG(PSC_GBLCTL) |= 0x01;
  85. REG(PSC_PDCTL1) |= 0x01;
  86. REG(PSC_PDCTL1) &= ~0x100;
  87. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_GEM * 4)) |= 0x03;
  88. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_GEM * 4)) &= 0xfffffeff;
  89. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_IMCOP * 4)) |= 0x03;
  90. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_IMCOP * 4)) &= 0xfffffeff;
  91. REG(PSC_PTCMD) = 0x02;
  92. for (i = 0; i < 100; i++) {
  93. if (REG(PSC_EPCPR) & 0x02)
  94. break;
  95. }
  96. REG(PSC_CHP_SHRTSW) = 0x01;
  97. REG(PSC_PDCTL1) |= 0x100;
  98. REG(PSC_EPCCR) = 0x02;
  99. for (i = 0; i < 100; i++) {
  100. if (!(REG(PSC_PTSTAT) & 0x02))
  101. break;
  102. }
  103. REG(PSC_GBLCTL) &= ~0x1f;
  104. }
  105. #endif /* CONFIG_SYS_USE_DSPLINK */
  106. void davinci_enable_uart0(void)
  107. {
  108. lpsc_on(DAVINCI_LPSC_UART0);
  109. /* Bringup UART0 out of reset */
  110. REG(UART0_PWREMU_MGMT) = 0x0000e003;
  111. /* Enable UART0 MUX lines */
  112. REG(PINMUX1) |= PINMUX1_UART0;
  113. }
  114. #ifdef CONFIG_DRIVER_TI_EMAC
  115. void davinci_enable_emac(void)
  116. {
  117. lpsc_on(DAVINCI_LPSC_EMAC);
  118. lpsc_on(DAVINCI_LPSC_EMAC_WRAPPER);
  119. lpsc_on(DAVINCI_LPSC_MDIO);
  120. /* Enable GIO3.3V cells used for EMAC */
  121. REG(VDD3P3V_PWDN) = 0;
  122. /* Enable EMAC. */
  123. REG(PINMUX0) |= PINMUX0_EMACEN;
  124. }
  125. #endif
  126. void davinci_enable_i2c(void)
  127. {
  128. lpsc_on(DAVINCI_LPSC_I2C);
  129. /* Enable I2C pin Mux */
  130. REG(PINMUX1) |= PINMUX1_I2C;
  131. }
  132. void davinci_errata_workarounds(void)
  133. {
  134. /*
  135. * Workaround for TMS320DM6446 errata 1.3.22:
  136. * PSC: PTSTAT Register Does Not Clear After Warm/Maximum Reset
  137. * Revision(s) Affected: 1.3 and earlier
  138. */
  139. REG(PSC_SILVER_BULLET) = 0;
  140. /*
  141. * Set the PR_OLD_COUNT bits in the Bus Burst Priority Register (PBBPR)
  142. * as suggested in TMS320DM6446 errata 2.1.2:
  143. *
  144. * On DM6446 Silicon Revision 2.1 and earlier, under certain conditions
  145. * low priority modules can occupy the bus and prevent high priority
  146. * modules like the VPSS from getting the required DDR2 throughput.
  147. * A hex value of 0x20 should provide a good ARM (cache enabled)
  148. * performance and still allow good utilization by the VPSS or other
  149. * modules.
  150. */
  151. REG(VBPR) = 0x20;
  152. }