Commit f37be01e authored by Linus Walleij's avatar Linus Walleij Committed by Lee Jones

mfd: qcom_rpm: Parametrize also ack selector size

The RPM has two sets of selectors (IPC bit fields): request and
acknowledge. Apparently, some models use 4*32 bit words for select
and some use 7*32 bit words for request, but all use 7*32 words
for acknowledge bits.

So apparently you can on the models with requests of 4*32 select
bits send 4*32 messages and get 7*32 different replies, so on ACK
interrupt, 7*32 bit words need to be read. This is how the vendor
code apparently works.

Cc: stable@vger.kernel.org
Reported-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 0a58da1e
...@@ -39,7 +39,8 @@ struct qcom_rpm_data { ...@@ -39,7 +39,8 @@ struct qcom_rpm_data {
unsigned int req_sel_off; unsigned int req_sel_off;
unsigned int ack_ctx_off; unsigned int ack_ctx_off;
unsigned int ack_sel_off; unsigned int ack_sel_off;
unsigned int sel_size; unsigned int req_sel_size;
unsigned int ack_sel_size;
}; };
struct qcom_rpm { struct qcom_rpm {
...@@ -160,7 +161,8 @@ static const struct qcom_rpm_data apq8064_template = { ...@@ -160,7 +161,8 @@ static const struct qcom_rpm_data apq8064_template = {
.req_sel_off = 11, .req_sel_off = 11,
.ack_ctx_off = 15, .ack_ctx_off = 15,
.ack_sel_off = 23, .ack_sel_off = 23,
.sel_size = 4, .req_sel_size = 4,
.ack_sel_size = 7,
}; };
static const struct qcom_rpm_resource msm8660_rpm_resource_table[] = { static const struct qcom_rpm_resource msm8660_rpm_resource_table[] = {
...@@ -248,7 +250,8 @@ static const struct qcom_rpm_data msm8660_template = { ...@@ -248,7 +250,8 @@ static const struct qcom_rpm_data msm8660_template = {
.req_sel_off = 11, .req_sel_off = 11,
.ack_ctx_off = 19, .ack_ctx_off = 19,
.ack_sel_off = 27, .ack_sel_off = 27,
.sel_size = 7, .req_sel_size = 7,
.ack_sel_size = 7,
}; };
static const struct qcom_rpm_resource msm8960_rpm_resource_table[] = { static const struct qcom_rpm_resource msm8960_rpm_resource_table[] = {
...@@ -335,7 +338,8 @@ static const struct qcom_rpm_data msm8960_template = { ...@@ -335,7 +338,8 @@ static const struct qcom_rpm_data msm8960_template = {
.req_sel_off = 11, .req_sel_off = 11,
.ack_ctx_off = 15, .ack_ctx_off = 15,
.ack_sel_off = 23, .ack_sel_off = 23,
.sel_size = 4, .req_sel_size = 4,
.ack_sel_size = 7,
}; };
static const struct qcom_rpm_resource ipq806x_rpm_resource_table[] = { static const struct qcom_rpm_resource ipq806x_rpm_resource_table[] = {
...@@ -380,7 +384,8 @@ static const struct qcom_rpm_data ipq806x_template = { ...@@ -380,7 +384,8 @@ static const struct qcom_rpm_data ipq806x_template = {
.req_sel_off = 11, .req_sel_off = 11,
.ack_ctx_off = 15, .ack_ctx_off = 15,
.ack_sel_off = 23, .ack_sel_off = 23,
.sel_size = 4, .req_sel_size = 4,
.ack_sel_size = 7,
}; };
static const struct of_device_id qcom_rpm_of_match[] = { static const struct of_device_id qcom_rpm_of_match[] = {
...@@ -417,7 +422,7 @@ int qcom_rpm_write(struct qcom_rpm *rpm, ...@@ -417,7 +422,7 @@ int qcom_rpm_write(struct qcom_rpm *rpm,
writel_relaxed(buf[i], RPM_REQ_REG(rpm, res->target_id + i)); writel_relaxed(buf[i], RPM_REQ_REG(rpm, res->target_id + i));
bitmap_set((unsigned long *)sel_mask, res->select_id, 1); bitmap_set((unsigned long *)sel_mask, res->select_id, 1);
for (i = 0; i < rpm->data->sel_size; i++) { for (i = 0; i < rpm->data->req_sel_size; i++) {
writel_relaxed(sel_mask[i], writel_relaxed(sel_mask[i],
RPM_CTRL_REG(rpm, rpm->data->req_sel_off + i)); RPM_CTRL_REG(rpm, rpm->data->req_sel_off + i));
} }
...@@ -446,7 +451,7 @@ static irqreturn_t qcom_rpm_ack_interrupt(int irq, void *dev) ...@@ -446,7 +451,7 @@ static irqreturn_t qcom_rpm_ack_interrupt(int irq, void *dev)
int i; int i;
ack = readl_relaxed(RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); ack = readl_relaxed(RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off));
for (i = 0; i < rpm->data->sel_size; i++) for (i = 0; i < rpm->data->ack_sel_size; i++)
writel_relaxed(0, writel_relaxed(0,
RPM_CTRL_REG(rpm, rpm->data->ack_sel_off + i)); RPM_CTRL_REG(rpm, rpm->data->ack_sel_off + i));
writel(0, RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); writel(0, RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off));
......
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