Commit b75acfb4 authored by Markus Mayer's avatar Markus Mayer Committed by Viresh Kumar

cpufreq: brcmstb-avs-cpufreq: more flexible interface for __issue_avs_command()

We are changing how parameters are passed to __issue_avs_command(), so we
can pass input *and* output arguments with the same command, rather than
just one or the other.
Signed-off-by: default avatarMarkus Mayer <mmayer@broadcom.com>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent afdb219b
...@@ -195,7 +195,8 @@ static void __iomem *__map_region(const char *name) ...@@ -195,7 +195,8 @@ static void __iomem *__map_region(const char *name)
return ptr; return ptr;
} }
static int __issue_avs_command(struct private_data *priv, int cmd, bool is_send, static int __issue_avs_command(struct private_data *priv, unsigned int cmd,
unsigned int num_in, unsigned int num_out,
u32 args[]) u32 args[])
{ {
unsigned long time_left = msecs_to_jiffies(AVS_TIMEOUT); unsigned long time_left = msecs_to_jiffies(AVS_TIMEOUT);
...@@ -225,11 +226,9 @@ static int __issue_avs_command(struct private_data *priv, int cmd, bool is_send, ...@@ -225,11 +226,9 @@ static int __issue_avs_command(struct private_data *priv, int cmd, bool is_send,
/* Clear status before we begin. */ /* Clear status before we begin. */
writel(AVS_STATUS_CLEAR, base + AVS_MBOX_STATUS); writel(AVS_STATUS_CLEAR, base + AVS_MBOX_STATUS);
/* We need to send arguments for this command. */ /* Provide input parameters */
if (args && is_send) { for (i = 0; i < num_in; i++)
for (i = 0; i < AVS_MAX_CMD_ARGS; i++)
writel(args[i], base + AVS_MBOX_PARAM(i)); writel(args[i], base + AVS_MBOX_PARAM(i));
}
/* Protect from spurious interrupts. */ /* Protect from spurious interrupts. */
reinit_completion(&priv->done); reinit_completion(&priv->done);
...@@ -256,11 +255,9 @@ static int __issue_avs_command(struct private_data *priv, int cmd, bool is_send, ...@@ -256,11 +255,9 @@ static int __issue_avs_command(struct private_data *priv, int cmd, bool is_send,
goto out; goto out;
} }
/* This command returned arguments, so we read them back. */ /* Process returned values */
if (args && !is_send) { for (i = 0; i < num_out; i++)
for (i = 0; i < AVS_MAX_CMD_ARGS; i++)
args[i] = readl(base + AVS_MBOX_PARAM(i)); args[i] = readl(base + AVS_MBOX_PARAM(i));
}
/* Clear status to tell AVS co-processor we are done. */ /* Clear status to tell AVS co-processor we are done. */
writel(AVS_STATUS_CLEAR, base + AVS_MBOX_STATUS); writel(AVS_STATUS_CLEAR, base + AVS_MBOX_STATUS);
...@@ -338,7 +335,7 @@ static int brcm_avs_get_pmap(struct private_data *priv, struct pmap *pmap) ...@@ -338,7 +335,7 @@ static int brcm_avs_get_pmap(struct private_data *priv, struct pmap *pmap)
u32 args[AVS_MAX_CMD_ARGS]; u32 args[AVS_MAX_CMD_ARGS];
int ret; int ret;
ret = __issue_avs_command(priv, AVS_CMD_GET_PMAP, false, args); ret = __issue_avs_command(priv, AVS_CMD_GET_PMAP, 0, 4, args);
if (ret || !pmap) if (ret || !pmap)
return ret; return ret;
...@@ -359,7 +356,7 @@ static int brcm_avs_set_pmap(struct private_data *priv, struct pmap *pmap) ...@@ -359,7 +356,7 @@ static int brcm_avs_set_pmap(struct private_data *priv, struct pmap *pmap)
args[2] = pmap->p2; args[2] = pmap->p2;
args[3] = pmap->state; args[3] = pmap->state;
return __issue_avs_command(priv, AVS_CMD_SET_PMAP, true, args); return __issue_avs_command(priv, AVS_CMD_SET_PMAP, 4, 0, args);
} }
static int brcm_avs_get_pstate(struct private_data *priv, unsigned int *pstate) static int brcm_avs_get_pstate(struct private_data *priv, unsigned int *pstate)
...@@ -367,7 +364,7 @@ static int brcm_avs_get_pstate(struct private_data *priv, unsigned int *pstate) ...@@ -367,7 +364,7 @@ static int brcm_avs_get_pstate(struct private_data *priv, unsigned int *pstate)
u32 args[AVS_MAX_CMD_ARGS]; u32 args[AVS_MAX_CMD_ARGS];
int ret; int ret;
ret = __issue_avs_command(priv, AVS_CMD_GET_PSTATE, false, args); ret = __issue_avs_command(priv, AVS_CMD_GET_PSTATE, 0, 1, args);
if (ret) if (ret)
return ret; return ret;
*pstate = args[0]; *pstate = args[0];
...@@ -381,7 +378,8 @@ static int brcm_avs_set_pstate(struct private_data *priv, unsigned int pstate) ...@@ -381,7 +378,8 @@ static int brcm_avs_set_pstate(struct private_data *priv, unsigned int pstate)
args[0] = pstate; args[0] = pstate;
return __issue_avs_command(priv, AVS_CMD_SET_PSTATE, true, args); return __issue_avs_command(priv, AVS_CMD_SET_PSTATE, 1, 0, args);
} }
static u32 brcm_avs_get_voltage(void __iomem *base) static u32 brcm_avs_get_voltage(void __iomem *base)
...@@ -593,7 +591,7 @@ static int brcm_avs_cpufreq_init(struct cpufreq_policy *policy) ...@@ -593,7 +591,7 @@ static int brcm_avs_cpufreq_init(struct cpufreq_policy *policy)
/* All cores share the same clock and thus the same policy. */ /* All cores share the same clock and thus the same policy. */
cpumask_setall(policy->cpus); cpumask_setall(policy->cpus);
ret = __issue_avs_command(priv, AVS_CMD_ENABLE, false, NULL); ret = __issue_avs_command(priv, AVS_CMD_ENABLE, 0, 0, NULL);
if (!ret) { if (!ret) {
unsigned int pstate; unsigned int pstate;
......
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