devfreq: devfreq_spdm: Scale parameters to and from TZ driver

Send all the frequency performance levels in KHz units to TZ driver and
convert all the bandwidth recommendations to Bytes/s from Kbytes/s to
accomodate change in the syscall interface calls to TZ SPDM driver.

Change-Id: I209ea0583fdd43f78f51793d7818ea5afd5959c7
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
This commit is contained in:
Dilip Kota 2015-05-21 17:49:36 +05:30
parent 2c722f1086
commit d4c3883ced
3 changed files with 24 additions and 3 deletions

View File

@ -70,7 +70,7 @@ static int change_bw(struct device *dev, unsigned long *freq, u32 flags)
update_thresholds:
desc.arg[0] = SPDM_CMD_ENABLE;
desc.arg[1] = data->spdm_client;
desc.arg[2] = clk_get_rate(data->cci_clk);
desc.arg[2] = (clk_get_rate(data->cci_clk)) / 1000;
ext_status = spdm_ext_call(&desc, 3);
if (ext_status)
pr_err("External command %u failed with error %u",
@ -298,6 +298,8 @@ static int probe(struct platform_device *pdev)
{
struct spdm_data *data = 0;
int ret = -EINVAL;
struct spdm_args desc = { { 0 } };
int ext_status = 0;
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
@ -311,6 +313,20 @@ static int probe(struct platform_device *pdev)
if (ret)
goto bad_of;
desc.arg[0] = SPDM_CMD_GET_VERSION;
ext_status = spdm_ext_call(&desc, 1);
if (ext_status) {
pr_err("%s:External command %u failed with error %u\n",
__func__, (int)desc.arg[0], ext_status);
goto bad_of;
}
if (desc.ret[0] < SPDM_TZ_VERSION) {
pr_err("%s: Version mismatch expected 0x%x got 0x%x", __func__,
SPDM_TZ_VERSION, (int)desc.arg[0]);
goto bad_of;
}
data->bus_scale_client_id = msm_bus_scale_register_client(data->pdata);
if (!data->bus_scale_client_id) {
ret = -EINVAL;

View File

@ -89,7 +89,9 @@ extern void spdm_remove_debugfs(struct spdm_data *data);
#define SPDM_HYP_FNID 5
#define SPDM_SCM_SVC_ID 0x9
#define SPDM_SCM_CMD_ID 0x4
#define SPDM_TZ_VERSION 0x20000 /* TZ SPDM driver version */
/* SPDM CMD ID's for hypervisor/SCM */
#define SPDM_CMD_GET_VERSION 0
#define SPDM_CMD_GET_BW_ALL 1
#define SPDM_CMD_GET_BW_SPECIFIC 2
#define SPDM_CMD_ENABLE 3

View File

@ -88,7 +88,8 @@ static irqreturn_t threaded_isr(int irq, void *dev_id)
devfreq_monitor_suspend(data->devfreq);
mutex_lock(&data->devfreq->lock);
data->action = SPDM_UP;
data->new_bw = desc.ret[1] >> 6;
data->new_bw =
(desc.ret[1] * 1000) >> 6;
update_devfreq(data->devfreq);
data->action = SPDM_DOWN;
mutex_unlock(&data->devfreq->lock);
@ -113,6 +114,7 @@ static int gov_spdm_hyp_target_bw(struct devfreq *devfreq, unsigned long *freq,
int usage;
struct spdm_args desc = { { 0 } };
int ext_status = 0;
u64 bw_ret;
if (!devfreq || !devfreq->profile || !devfreq->profile->get_dev_status)
return ret;
@ -134,7 +136,8 @@ static int gov_spdm_hyp_target_bw(struct devfreq *devfreq, unsigned long *freq,
if (ext_status)
pr_err("External command %u failed with error %u",
(int)desc.arg[0], ext_status);
*freq = desc.ret[0] >> 6;
bw_ret = desc.ret[0] * 1000;
*freq = bw_ret >> 6;
}
return 0;