mt_spm_sspm_notifier.c 846 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2021, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stddef.h>
  7. #include <lib/mmio.h>
  8. #include <mt_spm_notifier.h>
  9. #include <mt_spm_sspm_intc.h>
  10. #define MT_SPM_SSPM_MBOX_OFF(x) (SSPM_MBOX_BASE + x)
  11. #define MT_SPM_MBOX(slot) MT_SPM_SSPM_MBOX_OFF((slot << 2UL))
  12. #define SSPM_MBOX_SPM_LP_LOOKUP1 MT_SPM_MBOX(0)
  13. #define SSPM_MBOX_SPM_LP_LOOKUP2 MT_SPM_MBOX(1)
  14. #define SSPM_MBOX_SPM_LP1 MT_SPM_MBOX(2)
  15. #define SSPM_MBOX_SPM_LP2 MT_SPM_MBOX(3)
  16. int mt_spm_sspm_notify(int type, unsigned int lp_mode)
  17. {
  18. switch (type) {
  19. case MT_SPM_NOTIFY_LP_ENTER:
  20. mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode);
  21. DO_SPM_SSPM_LP_SUSPEND();
  22. break;
  23. case MT_SPM_NOTIFY_LP_LEAVE:
  24. mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode);
  25. DO_SPM_SSPM_LP_RESUME();
  26. break;
  27. default:
  28. break;
  29. }
  30. return 0;
  31. }