psc.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. /*
  28. * The PSC manages three inputs to a "module" which may be a peripheral or
  29. * CPU. Those inputs are the module's: clock; reset signal; and sometimes
  30. * its power domain. For our purposes, we only care whether clock and power
  31. * are active, and the module is out of reset.
  32. *
  33. * DaVinci chips may include two separate power domains: "Always On" and "DSP".
  34. * Chips without a DSP generally have only one domain.
  35. *
  36. * The "Always On" power domain is always on when the chip is on, and is
  37. * powered by the VDD pins (on DM644X). The majority of DaVinci modules
  38. * lie within the "Always On" power domain.
  39. *
  40. * A separate domain called the "DSP" domain houses the C64x+ and other video
  41. * hardware such as VICP. In some chips, the "DSP" domain is not always on.
  42. * The "DSP" power domain is powered by the CVDDDSP pins (on DM644X).
  43. */
  44. /* Works on Always On power domain only (no PD argument) */
  45. void lpsc_on(unsigned int id)
  46. {
  47. dv_reg_p mdstat, mdctl;
  48. if (id >= DAVINCI_LPSC_GEM)
  49. return; /* Don't work on DSP Power Domain */
  50. mdstat = REG_P(PSC_MDSTAT_BASE + (id * 4));
  51. mdctl = REG_P(PSC_MDCTL_BASE + (id * 4));
  52. while (REG(PSC_PTSTAT) & 0x01)
  53. continue;
  54. if ((*mdstat & 0x1f) == 0x03)
  55. return; /* Already on and enabled */
  56. *mdctl |= 0x03;
  57. switch (id) {
  58. #ifdef CONFIG_SOC_DM644X
  59. /* Special treatment for some modules as for sprue14 p.7.4.2 */
  60. case DAVINCI_LPSC_VPSSSLV:
  61. case DAVINCI_LPSC_EMAC:
  62. case DAVINCI_LPSC_EMAC_WRAPPER:
  63. case DAVINCI_LPSC_MDIO:
  64. case DAVINCI_LPSC_USB:
  65. case DAVINCI_LPSC_ATA:
  66. case DAVINCI_LPSC_VLYNQ:
  67. case DAVINCI_LPSC_UHPI:
  68. case DAVINCI_LPSC_DDR_EMIF:
  69. case DAVINCI_LPSC_AEMIF:
  70. case DAVINCI_LPSC_MMC_SD:
  71. case DAVINCI_LPSC_MEMSTICK:
  72. case DAVINCI_LPSC_McBSP:
  73. case DAVINCI_LPSC_GPIO:
  74. *mdctl |= 0x200;
  75. break;
  76. #endif
  77. }
  78. REG(PSC_PTCMD) = 0x01;
  79. while (REG(PSC_PTSTAT) & 0x03)
  80. continue;
  81. while ((*mdstat & 0x1f) != 0x03) /* Probably an overkill... */
  82. continue;
  83. }
  84. /* Not all DaVinci chips have a DSP power domain. */
  85. #ifdef CONFIG_SOC_DM644X
  86. /* If DSPLINK is used, we don't want U-Boot to power on the DSP. */
  87. #if !defined(CONFIG_SYS_USE_DSPLINK)
  88. void dsp_on(void)
  89. {
  90. int i;
  91. if (REG(PSC_PDSTAT1) & 0x1f)
  92. return; /* Already on */
  93. REG(PSC_GBLCTL) |= 0x01;
  94. REG(PSC_PDCTL1) |= 0x01;
  95. REG(PSC_PDCTL1) &= ~0x100;
  96. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_GEM * 4)) |= 0x03;
  97. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_GEM * 4)) &= 0xfffffeff;
  98. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_IMCOP * 4)) |= 0x03;
  99. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_IMCOP * 4)) &= 0xfffffeff;
  100. REG(PSC_PTCMD) = 0x02;
  101. for (i = 0; i < 100; i++) {
  102. if (REG(PSC_EPCPR) & 0x02)
  103. break;
  104. }
  105. REG(PSC_CHP_SHRTSW) = 0x01;
  106. REG(PSC_PDCTL1) |= 0x100;
  107. REG(PSC_EPCCR) = 0x02;
  108. for (i = 0; i < 100; i++) {
  109. if (!(REG(PSC_PTSTAT) & 0x02))
  110. break;
  111. }
  112. REG(PSC_GBLCTL) &= ~0x1f;
  113. }
  114. #endif /* CONFIG_SYS_USE_DSPLINK */
  115. #endif /* have a DSP */