mt_spm_sspm_notifier.c 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2022, 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. #include <sspm_reg.h>
  11. #define MT_SPM_SSPM_MBOX_OFF(x) (SSPM_MBOX_BASE + x)
  12. #define MT_SPM_MBOX(slot) MT_SPM_SSPM_MBOX_OFF((slot << 2UL))
  13. #define SSPM_MBOX_SPM_LP_LOOKUP1 MT_SPM_MBOX(0)
  14. #define SSPM_MBOX_SPM_LP_LOOKUP2 MT_SPM_MBOX(1)
  15. #define SSPM_MBOX_SPM_LP1 MT_SPM_MBOX(2)
  16. #define SSPM_MBOX_SPM_LP2 MT_SPM_MBOX(3)
  17. int mt_spm_sspm_notify(int type, unsigned int lp_mode)
  18. {
  19. switch (type) {
  20. case MT_SPM_NOTIFY_LP_ENTER:
  21. mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode);
  22. DO_SPM_SSPM_LP_SUSPEND();
  23. break;
  24. case MT_SPM_NOTIFY_LP_LEAVE:
  25. mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode);
  26. DO_SPM_SSPM_LP_RESUME();
  27. break;
  28. case MT_SPM_NOTIFY_SUSPEND_VCORE_VOLTAGE:
  29. mmio_write_32(SSPM_MBOX_SPM_LP2, lp_mode);
  30. break;
  31. default:
  32. break;
  33. }
  34. return 0;
  35. }