prm2xxx_3xxx.c 3.4 KB

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