a3700_sip_svc.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. #include <common/debug.h>
  8. #include <common/runtime_svc.h>
  9. #include <lib/smccc.h>
  10. #include <marvell_plat_priv.h>
  11. #include <plat_marvell.h>
  12. #include "comphy/phy-comphy-3700.h"
  13. /* Comphy related FID's */
  14. #define MV_SIP_COMPHY_POWER_ON 0x82000001
  15. #define MV_SIP_COMPHY_POWER_OFF 0x82000002
  16. #define MV_SIP_COMPHY_PLL_LOCK 0x82000003
  17. /* Miscellaneous FID's' */
  18. #define MV_SIP_DRAM_SIZE 0x82000010
  19. /* This macro is used to identify COMPHY related calls from SMC function ID */
  20. #define is_comphy_fid(fid) \
  21. ((fid) >= MV_SIP_COMPHY_POWER_ON && (fid) <= MV_SIP_COMPHY_PLL_LOCK)
  22. uintptr_t mrvl_sip_smc_handler(uint32_t smc_fid,
  23. u_register_t x1,
  24. u_register_t x2,
  25. u_register_t x3,
  26. u_register_t x4,
  27. void *cookie,
  28. void *handle,
  29. u_register_t flags)
  30. {
  31. u_register_t ret;
  32. VERBOSE("%s: got SMC (0x%x) x1 0x%lx, x2 0x%lx\n",
  33. __func__, smc_fid, x1, x2);
  34. if (is_comphy_fid(smc_fid)) {
  35. if (x1 >= MAX_LANE_NR) {
  36. ERROR("%s: Wrong smc (0x%x) lane nr: %lx\n",
  37. __func__, smc_fid, x2);
  38. SMC_RET1(handle, SMC_UNK);
  39. }
  40. }
  41. switch (smc_fid) {
  42. /* Comphy related FID's */
  43. case MV_SIP_COMPHY_POWER_ON:
  44. /* x1: comphy_index, x2: comphy_mode */
  45. ret = mvebu_3700_comphy_power_on(x1, x2);
  46. SMC_RET1(handle, ret);
  47. case MV_SIP_COMPHY_POWER_OFF:
  48. /* x1: comphy_index, x2: comphy_mode */
  49. ret = mvebu_3700_comphy_power_off(x1, x2);
  50. SMC_RET1(handle, ret);
  51. case MV_SIP_COMPHY_PLL_LOCK:
  52. /* x1: comphy_index, x2: comphy_mode */
  53. ret = mvebu_3700_comphy_is_pll_locked(x1, x2);
  54. SMC_RET1(handle, ret);
  55. /* Miscellaneous FID's' */
  56. case MV_SIP_DRAM_SIZE:
  57. /* x1: ap_base_addr */
  58. ret = mvebu_get_dram_size(MVEBU_REGS_BASE);
  59. SMC_RET1(handle, ret);
  60. default:
  61. ERROR("%s: unhandled SMC (0x%x)\n", __func__, smc_fid);
  62. SMC_RET1(handle, SMC_UNK);
  63. }
  64. }
  65. /* Define a runtime service descriptor for fast SMC calls */
  66. DECLARE_RT_SVC(
  67. marvell_sip_svc,
  68. OEN_SIP_START,
  69. OEN_SIP_END,
  70. SMC_TYPE_FAST,
  71. NULL,
  72. mrvl_sip_smc_handler
  73. );