soc_reset.c 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2019 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file peripheral reset interface for Actions SoC
  8. */
  9. #include <kernel.h>
  10. #include <soc.h>
  11. static void acts_reset_peripheral_control(int reset_id, int assert)
  12. {
  13. unsigned int key;
  14. if (reset_id > RESET_ID_MAX_ID)
  15. return;
  16. key = irq_lock();
  17. if (assert) {
  18. if (reset_id < 32) {
  19. sys_clear_bit(RMU_MRCR0, reset_id);
  20. } else {
  21. sys_clear_bit(RMU_MRCR1, reset_id - 32);
  22. }
  23. } else {
  24. if (reset_id < 32) {
  25. sys_set_bit(RMU_MRCR0, reset_id);
  26. } else {
  27. sys_set_bit(RMU_MRCR1, reset_id - 32);
  28. }
  29. }
  30. irq_unlock(key);
  31. }
  32. void acts_reset_peripheral_assert(int reset_id)
  33. {
  34. acts_reset_peripheral_control(reset_id, 1);
  35. }
  36. void acts_reset_peripheral_deassert(int reset_id)
  37. {
  38. acts_reset_peripheral_control(reset_id, 0);
  39. }
  40. void acts_reset_peripheral(int reset_id)
  41. {
  42. acts_reset_peripheral_assert(reset_id);
  43. acts_reset_peripheral_deassert(reset_id);
  44. }