psc.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 DM6446 includes two separate power domains: "Always On" and "DSP". The
  29. * "Always On" power domain is always on when the chip is on. The "Always On"
  30. * domain is powered by the VDD pins of the DM6446. The majority of the
  31. * DM6446's modules lie within the "Always On" power domain. A separate
  32. * domain called the "DSP" domain houses the C64x+ and VICP. The "DSP" domain
  33. * is not always on. The "DSP" power domain is powered by the CVDDDSP pins of
  34. * the DM6446.
  35. */
  36. /* Works on Always On power domain only (no PD argument) */
  37. void lpsc_on(unsigned int id)
  38. {
  39. dv_reg_p mdstat, mdctl;
  40. if (id >= DAVINCI_LPSC_GEM)
  41. return; /* Don't work on DSP Power Domain */
  42. mdstat = REG_P(PSC_MDSTAT_BASE + (id * 4));
  43. mdctl = REG_P(PSC_MDCTL_BASE + (id * 4));
  44. while (REG(PSC_PTSTAT) & 0x01);
  45. if ((*mdstat & 0x1f) == 0x03)
  46. return; /* Already on and enabled */
  47. *mdctl |= 0x03;
  48. /* Special treatment for some modules as for sprue14 p.7.4.2 */
  49. switch (id) {
  50. case DAVINCI_LPSC_VPSSSLV:
  51. case DAVINCI_LPSC_EMAC:
  52. case DAVINCI_LPSC_EMAC_WRAPPER:
  53. case DAVINCI_LPSC_MDIO:
  54. case DAVINCI_LPSC_USB:
  55. case DAVINCI_LPSC_ATA:
  56. case DAVINCI_LPSC_VLYNQ:
  57. case DAVINCI_LPSC_UHPI:
  58. case DAVINCI_LPSC_DDR_EMIF:
  59. case DAVINCI_LPSC_AEMIF:
  60. case DAVINCI_LPSC_MMC_SD:
  61. case DAVINCI_LPSC_MEMSTICK:
  62. case DAVINCI_LPSC_McBSP:
  63. case DAVINCI_LPSC_GPIO:
  64. *mdctl |= 0x200;
  65. break;
  66. }
  67. REG(PSC_PTCMD) = 0x01;
  68. while (REG(PSC_PTSTAT) & 0x03);
  69. while ((*mdstat & 0x1f) != 0x03); /* Probably an overkill... */
  70. }
  71. /* If DSPLINK is used, we don't want U-Boot to power on the DSP. */
  72. #if !defined(CONFIG_SYS_USE_DSPLINK)
  73. void dsp_on(void)
  74. {
  75. int i;
  76. if (REG(PSC_PDSTAT1) & 0x1f)
  77. return; /* Already on */
  78. REG(PSC_GBLCTL) |= 0x01;
  79. REG(PSC_PDCTL1) |= 0x01;
  80. REG(PSC_PDCTL1) &= ~0x100;
  81. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_GEM * 4)) |= 0x03;
  82. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_GEM * 4)) &= 0xfffffeff;
  83. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_IMCOP * 4)) |= 0x03;
  84. REG(PSC_MDCTL_BASE + (DAVINCI_LPSC_IMCOP * 4)) &= 0xfffffeff;
  85. REG(PSC_PTCMD) = 0x02;
  86. for (i = 0; i < 100; i++) {
  87. if (REG(PSC_EPCPR) & 0x02)
  88. break;
  89. }
  90. REG(PSC_CHP_SHRTSW) = 0x01;
  91. REG(PSC_PDCTL1) |= 0x100;
  92. REG(PSC_EPCCR) = 0x02;
  93. for (i = 0; i < 100; i++) {
  94. if (!(REG(PSC_PTSTAT) & 0x02))
  95. break;
  96. }
  97. REG(PSC_GBLCTL) &= ~0x1f;
  98. }
  99. #endif /* CONFIG_SYS_USE_DSPLINK */