prminst44xx.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * OMAP4 PRM instance functions
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Paul Walmsley
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/errno.h>
  14. #include <linux/err.h>
  15. #include <linux/io.h>
  16. #include <plat/common.h>
  17. #include "prm44xx.h"
  18. #include "prminst44xx.h"
  19. #include "prm-regbits-44xx.h"
  20. #include "prcm44xx.h"
  21. #include "prcm_mpu44xx.h"
  22. static u32 _prm_bases[OMAP4_MAX_PRCM_PARTITIONS] = {
  23. [OMAP4430_INVALID_PRCM_PARTITION] = 0,
  24. [OMAP4430_PRM_PARTITION] = OMAP4430_PRM_BASE,
  25. [OMAP4430_CM1_PARTITION] = 0,
  26. [OMAP4430_CM2_PARTITION] = 0,
  27. [OMAP4430_SCRM_PARTITION] = 0,
  28. [OMAP4430_PRCM_MPU_PARTITION] = OMAP4430_PRCM_MPU_BASE,
  29. };
  30. /* Read a register in a PRM instance */
  31. u32 omap4_prminst_read_inst_reg(u8 part, s16 inst, u16 idx)
  32. {
  33. BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
  34. part == OMAP4430_INVALID_PRCM_PARTITION ||
  35. !_prm_bases[part]);
  36. return __raw_readl(OMAP2_L4_IO_ADDRESS(_prm_bases[part] + inst +
  37. idx));
  38. }
  39. /* Write into a register in a PRM instance */
  40. void omap4_prminst_write_inst_reg(u32 val, u8 part, s16 inst, u16 idx)
  41. {
  42. BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
  43. part == OMAP4430_INVALID_PRCM_PARTITION ||
  44. !_prm_bases[part]);
  45. __raw_writel(val, OMAP2_L4_IO_ADDRESS(_prm_bases[part] + inst + idx));
  46. }
  47. /* Read-modify-write a register in PRM. Caller must lock */
  48. u32 omap4_prminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part, s16 inst,
  49. s16 idx)
  50. {
  51. u32 v;
  52. v = omap4_prminst_read_inst_reg(part, inst, idx);
  53. v &= ~mask;
  54. v |= bits;
  55. omap4_prminst_write_inst_reg(v, part, inst, idx);
  56. return v;
  57. }