vss.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Au1300 media block power gating (VSS)
  3. *
  4. * This is a stop-gap solution until I have the clock framework integration
  5. * ready. This stuff here really must be handled transparently when clocks
  6. * for various media blocks are enabled/disabled.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/spinlock.h>
  10. #include <asm/mach-au1x00/au1000.h>
  11. #define VSS_GATE 0x00 /* gate wait timers */
  12. #define VSS_CLKRST 0x04 /* clock/block control */
  13. #define VSS_FTR 0x08 /* footers */
  14. #define VSS_ADDR(blk) (KSEG1ADDR(AU1300_VSS_PHYS_ADDR) + (blk * 0x0c))
  15. static DEFINE_SPINLOCK(au1300_vss_lock);
  16. /* enable a block as outlined in the databook */
  17. static inline void __enable_block(int block)
  18. {
  19. void __iomem *base = (void __iomem *)VSS_ADDR(block);
  20. __raw_writel(3, base + VSS_CLKRST); /* enable clock, assert reset */
  21. wmb();
  22. __raw_writel(0x01fffffe, base + VSS_GATE); /* maximum setup time */
  23. wmb();
  24. /* enable footers in sequence */
  25. __raw_writel(0x01, base + VSS_FTR);
  26. wmb();
  27. __raw_writel(0x03, base + VSS_FTR);
  28. wmb();
  29. __raw_writel(0x07, base + VSS_FTR);
  30. wmb();
  31. __raw_writel(0x0f, base + VSS_FTR);
  32. wmb();
  33. __raw_writel(0x01ffffff, base + VSS_GATE); /* start FSM too */
  34. wmb();
  35. __raw_writel(2, base + VSS_CLKRST); /* deassert reset */
  36. wmb();
  37. __raw_writel(0x1f, base + VSS_FTR); /* enable isolation cells */
  38. wmb();
  39. }
  40. /* disable a block as outlined in the databook */
  41. static inline void __disable_block(int block)
  42. {
  43. void __iomem *base = (void __iomem *)VSS_ADDR(block);
  44. __raw_writel(0x0f, base + VSS_FTR); /* disable isolation cells */
  45. wmb();
  46. __raw_writel(0, base + VSS_GATE); /* disable FSM */
  47. wmb();
  48. __raw_writel(3, base + VSS_CLKRST); /* assert reset */
  49. wmb();
  50. __raw_writel(1, base + VSS_CLKRST); /* disable clock */
  51. wmb();
  52. __raw_writel(0, base + VSS_FTR); /* disable all footers */
  53. wmb();
  54. }
  55. void au1300_vss_block_control(int block, int enable)
  56. {
  57. unsigned long flags;
  58. if (alchemy_get_cputype() != ALCHEMY_CPU_AU1300)
  59. return;
  60. /* only one block at a time */
  61. spin_lock_irqsave(&au1300_vss_lock, flags);
  62. if (enable)
  63. __enable_block(block);
  64. else
  65. __disable_block(block);
  66. spin_unlock_irqrestore(&au1300_vss_lock, flags);
  67. }
  68. EXPORT_SYMBOL_GPL(au1300_vss_block_control);