Commit ea17a0f1 authored by Pali Rohár's avatar Pali Rohár Committed by Lorenzo Pieralisi

phy: marvell: comphy: Convert internal SMCC firmware return codes to errno

Driver ->power_on and ->power_off callbacks leaks internal SMCC firmware
return codes to phy caller. This patch converts SMCC error codes to
standard linux errno codes. Include file linux/arm-smccc.h already provides
defines for SMCC error codes, so use them instead of custom driver defines.
Note that return value is signed 32bit, but stored in unsigned long type
with zero padding.
Tested-by: default avatarTomasz Maciej Nowak <tmn505@gmail.com>
Link: https://lore.kernel.org/r/20200902144344.16684-2-pali@kernel.orgSigned-off-by: default avatarPali Rohár <pali@kernel.org>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: default avatarRob Herring <robh@kernel.org>
parent d0c6a347
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#define COMPHY_SIP_POWER_ON 0x82000001 #define COMPHY_SIP_POWER_ON 0x82000001
#define COMPHY_SIP_POWER_OFF 0x82000002 #define COMPHY_SIP_POWER_OFF 0x82000002
#define COMPHY_SIP_PLL_LOCK 0x82000003 #define COMPHY_SIP_PLL_LOCK 0x82000003
#define COMPHY_FW_NOT_SUPPORTED (-1)
#define COMPHY_FW_MODE_SATA 0x1 #define COMPHY_FW_MODE_SATA 0x1
#define COMPHY_FW_MODE_SGMII 0x2 #define COMPHY_FW_MODE_SGMII 0x2
...@@ -112,10 +111,19 @@ static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane, ...@@ -112,10 +111,19 @@ static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane,
unsigned long mode) unsigned long mode)
{ {
struct arm_smccc_res res; struct arm_smccc_res res;
s32 ret;
arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res); arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res);
ret = res.a0;
return res.a0; switch (ret) {
case SMCCC_RET_SUCCESS:
return 0;
case SMCCC_RET_NOT_SUPPORTED:
return -EOPNOTSUPP;
default:
return -EINVAL;
}
} }
static int mvebu_a3700_comphy_get_fw_mode(int lane, int port, static int mvebu_a3700_comphy_get_fw_mode(int lane, int port,
...@@ -220,7 +228,7 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy) ...@@ -220,7 +228,7 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy)
} }
ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param); ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param);
if (ret == COMPHY_FW_NOT_SUPPORTED) if (ret == -EOPNOTSUPP)
dev_err(lane->dev, dev_err(lane->dev,
"unsupported SMC call, try updating your firmware\n"); "unsupported SMC call, try updating your firmware\n");
......
...@@ -123,7 +123,6 @@ ...@@ -123,7 +123,6 @@
#define COMPHY_SIP_POWER_ON 0x82000001 #define COMPHY_SIP_POWER_ON 0x82000001
#define COMPHY_SIP_POWER_OFF 0x82000002 #define COMPHY_SIP_POWER_OFF 0x82000002
#define COMPHY_FW_NOT_SUPPORTED (-1)
/* /*
* A lane is described by the following bitfields: * A lane is described by the following bitfields:
...@@ -273,10 +272,19 @@ static int mvebu_comphy_smc(unsigned long function, unsigned long phys, ...@@ -273,10 +272,19 @@ static int mvebu_comphy_smc(unsigned long function, unsigned long phys,
unsigned long lane, unsigned long mode) unsigned long lane, unsigned long mode)
{ {
struct arm_smccc_res res; struct arm_smccc_res res;
s32 ret;
arm_smccc_smc(function, phys, lane, mode, 0, 0, 0, 0, &res); arm_smccc_smc(function, phys, lane, mode, 0, 0, 0, 0, &res);
ret = res.a0;
return res.a0; switch (ret) {
case SMCCC_RET_SUCCESS:
return 0;
case SMCCC_RET_NOT_SUPPORTED:
return -EOPNOTSUPP;
default:
return -EINVAL;
}
} }
static int mvebu_comphy_get_mode(bool fw_mode, int lane, int port, static int mvebu_comphy_get_mode(bool fw_mode, int lane, int port,
...@@ -819,7 +827,7 @@ static int mvebu_comphy_power_on(struct phy *phy) ...@@ -819,7 +827,7 @@ static int mvebu_comphy_power_on(struct phy *phy)
if (!ret) if (!ret)
return ret; return ret;
if (ret == COMPHY_FW_NOT_SUPPORTED) if (ret == -EOPNOTSUPP)
dev_err(priv->dev, dev_err(priv->dev,
"unsupported SMC call, try updating your firmware\n"); "unsupported SMC call, try updating your firmware\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment