prm44xx.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * OMAP4 PRM module functions
  3. *
  4. * Copyright (C) 2011 Texas Instruments, Inc.
  5. * Copyright (C) 2010 Nokia Corporation
  6. * Benoît Cousson
  7. * Paul Walmsley
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/delay.h>
  15. #include <linux/errno.h>
  16. #include <linux/err.h>
  17. #include <linux/io.h>
  18. #include "common.h"
  19. #include <plat/cpu.h>
  20. #include <plat/prcm.h>
  21. #include "vp.h"
  22. #include "prm44xx.h"
  23. #include "prm-regbits-44xx.h"
  24. #include "prcm44xx.h"
  25. #include "prminst44xx.h"
  26. /* PRM low-level functions */
  27. /* Read a register in a CM/PRM instance in the PRM module */
  28. u32 omap4_prm_read_inst_reg(s16 inst, u16 reg)
  29. {
  30. return __raw_readl(OMAP44XX_PRM_REGADDR(inst, reg));
  31. }
  32. /* Write into a register in a CM/PRM instance in the PRM module */
  33. void omap4_prm_write_inst_reg(u32 val, s16 inst, u16 reg)
  34. {
  35. __raw_writel(val, OMAP44XX_PRM_REGADDR(inst, reg));
  36. }
  37. /* Read-modify-write a register in a PRM module. Caller must lock */
  38. u32 omap4_prm_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 reg)
  39. {
  40. u32 v;
  41. v = omap4_prm_read_inst_reg(inst, reg);
  42. v &= ~mask;
  43. v |= bits;
  44. omap4_prm_write_inst_reg(v, inst, reg);
  45. return v;
  46. }
  47. /* PRM VP */
  48. /*
  49. * struct omap4_vp - OMAP4 VP register access description.
  50. * @irqstatus_mpu: offset to IRQSTATUS_MPU register for VP
  51. * @tranxdone_status: VP_TRANXDONE_ST bitmask in PRM_IRQSTATUS_MPU reg
  52. */
  53. struct omap4_vp {
  54. u32 irqstatus_mpu;
  55. u32 tranxdone_status;
  56. };
  57. static struct omap4_vp omap4_vp[] = {
  58. [OMAP4_VP_VDD_MPU_ID] = {
  59. .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_2_OFFSET,
  60. .tranxdone_status = OMAP4430_VP_MPU_TRANXDONE_ST_MASK,
  61. },
  62. [OMAP4_VP_VDD_IVA_ID] = {
  63. .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_OFFSET,
  64. .tranxdone_status = OMAP4430_VP_IVA_TRANXDONE_ST_MASK,
  65. },
  66. [OMAP4_VP_VDD_CORE_ID] = {
  67. .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_OFFSET,
  68. .tranxdone_status = OMAP4430_VP_CORE_TRANXDONE_ST_MASK,
  69. },
  70. };
  71. u32 omap4_prm_vp_check_txdone(u8 vp_id)
  72. {
  73. struct omap4_vp *vp = &omap4_vp[vp_id];
  74. u32 irqstatus;
  75. irqstatus = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION,
  76. OMAP4430_PRM_OCP_SOCKET_INST,
  77. vp->irqstatus_mpu);
  78. return irqstatus & vp->tranxdone_status;
  79. }
  80. void omap4_prm_vp_clear_txdone(u8 vp_id)
  81. {
  82. struct omap4_vp *vp = &omap4_vp[vp_id];
  83. omap4_prminst_write_inst_reg(vp->tranxdone_status,
  84. OMAP4430_PRM_PARTITION,
  85. OMAP4430_PRM_OCP_SOCKET_INST,
  86. vp->irqstatus_mpu);
  87. };
  88. u32 omap4_prm_vcvp_read(u8 offset)
  89. {
  90. return omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION,
  91. OMAP4430_PRM_DEVICE_INST, offset);
  92. }
  93. void omap4_prm_vcvp_write(u32 val, u8 offset)
  94. {
  95. omap4_prminst_write_inst_reg(val, OMAP4430_PRM_PARTITION,
  96. OMAP4430_PRM_DEVICE_INST, offset);
  97. }
  98. u32 omap4_prm_vcvp_rmw(u32 mask, u32 bits, u8 offset)
  99. {
  100. return omap4_prminst_rmw_inst_reg_bits(mask, bits,
  101. OMAP4430_PRM_PARTITION,
  102. OMAP4430_PRM_DEVICE_INST,
  103. offset);
  104. }