prm2xxx_3xxx.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * OMAP2/3 PRM module functions
  3. *
  4. * Copyright (C) 2010 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 <plat/common.h>
  18. #include <plat/cpu.h>
  19. #include <plat/prcm.h>
  20. #include "prm.h"
  21. #include "prm-regbits-24xx.h"
  22. #include "prm-regbits-34xx.h"
  23. /**
  24. * omap2_prm_is_hardreset_asserted - read the HW reset line state of
  25. * submodules contained in the hwmod module
  26. * @prm_mod: PRM submodule base (e.g. CORE_MOD)
  27. * @shift: register bit shift corresponding to the reset line to check
  28. *
  29. * Returns 1 if the (sub)module hardreset line is currently asserted,
  30. * 0 if the (sub)module hardreset line is not currently asserted, or
  31. * -EINVAL if called while running on a non-OMAP2/3 chip.
  32. */
  33. int omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift)
  34. {
  35. if (!(cpu_is_omap24xx() || cpu_is_omap34xx()))
  36. return -EINVAL;
  37. return prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL,
  38. (1 << shift));
  39. }
  40. /**
  41. * omap2_prm_assert_hardreset - assert the HW reset line of a submodule
  42. * @prm_mod: PRM submodule base (e.g. CORE_MOD)
  43. * @shift: register bit shift corresponding to the reset line to assert
  44. *
  45. * Some IPs like dsp or iva contain processors that require an HW
  46. * reset line to be asserted / deasserted in order to fully enable the
  47. * IP. These modules may have multiple hard-reset lines that reset
  48. * different 'submodules' inside the IP block. This function will
  49. * place the submodule into reset. Returns 0 upon success or -EINVAL
  50. * upon an argument error.
  51. */
  52. int omap2_prm_assert_hardreset(s16 prm_mod, u8 shift)
  53. {
  54. u32 mask;
  55. if (!(cpu_is_omap24xx() || cpu_is_omap34xx()))
  56. return -EINVAL;
  57. mask = 1 << shift;
  58. prm_rmw_mod_reg_bits(mask, mask, prm_mod, OMAP2_RM_RSTCTRL);
  59. return 0;
  60. }
  61. /**
  62. * omap2_prm_deassert_hardreset - deassert a submodule hardreset line and wait
  63. * @prm_mod: PRM submodule base (e.g. CORE_MOD)
  64. * @shift: register bit shift corresponding to the reset line to deassert
  65. *
  66. * Some IPs like dsp or iva contain processors that require an HW
  67. * reset line to be asserted / deasserted in order to fully enable the
  68. * IP. These modules may have multiple hard-reset lines that reset
  69. * different 'submodules' inside the IP block. This function will
  70. * take the submodule out of reset and wait until the PRCM indicates
  71. * that the reset has completed before returning. Returns 0 upon success or
  72. * -EINVAL upon an argument error, -EEXIST if the submodule was already out
  73. * of reset, or -EBUSY if the submodule did not exit reset promptly.
  74. */
  75. int omap2_prm_deassert_hardreset(s16 prm_mod, u8 shift)
  76. {
  77. u32 mask;
  78. int c;
  79. if (!(cpu_is_omap24xx() || cpu_is_omap34xx()))
  80. return -EINVAL;
  81. mask = 1 << shift;
  82. /* Check the current status to avoid de-asserting the line twice */
  83. if (prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL, mask) == 0)
  84. return -EEXIST;
  85. /* Clear the reset status by writing 1 to the status bit */
  86. prm_rmw_mod_reg_bits(0xffffffff, mask, prm_mod, OMAP2_RM_RSTST);
  87. /* de-assert the reset control line */
  88. prm_rmw_mod_reg_bits(mask, 0, prm_mod, OMAP2_RM_RSTCTRL);
  89. /* wait the status to be set */
  90. omap_test_timeout(prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTST,
  91. mask),
  92. MAX_MODULE_HARDRESET_WAIT, c);
  93. return (c == MAX_MODULE_HARDRESET_WAIT) ? -EBUSY : 0;
  94. }