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