1
0

psc.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * File : psc.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2010-11-13 weety first version
  23. */
  24. #include "dm36x.h"
  25. /* ------------------------------------------------------------------------ *
  26. * psc_change_state( id, state ) *
  27. * id = Domain #ID *
  28. * state = ( ENABLE, DISABLE, SYNCRESET, RESET ) *
  29. * ( =3 , =2 , =1 , =0 ) *
  30. * ------------------------------------------------------------------------ */
  31. void psc_change_state(int id, int state)
  32. {
  33. rt_uint32_t mdstat, mdctl;
  34. if (id > DAVINCI_DM365_LPSC_KALEIDO)
  35. return;
  36. mdstat = PSC_MDSTAT_BASE + (id * 4);
  37. mdctl = PSC_MDCTL_BASE + (id * 4);
  38. /*
  39. * Step 0 - Ignore request if the state is already set as is
  40. */
  41. if ((readl(mdstat) & 0x1f) == state)
  42. return;
  43. /*
  44. * Step 1 - Wait for PTSTAT.GOSTAT to clear
  45. */
  46. while (readl(PSC_PTSTAT) & 1) ;
  47. /*
  48. * Step 2 - Set MDCTLx.NEXT to new state
  49. */
  50. writel(readl(mdctl) & (~0x1f), mdctl);
  51. writel(readl(mdctl) | state, mdctl);
  52. /*
  53. * Step 3 - Start power transition ( set PTCMD.GO to 1 )
  54. */
  55. writel(readl(PSC_PTCMD) | 1, PSC_PTCMD);
  56. /*
  57. * Step 4 - Wait for PTSTAT.GOSTAT to clear
  58. */
  59. while (readl(PSC_PTSTAT) & 1) ;
  60. }