From patchwork Tue Jun 14 09:48:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 69974 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1956502qgf; Tue, 14 Jun 2016 02:49:07 -0700 (PDT) X-Received: by 10.98.47.129 with SMTP id v123mr1983203pfv.71.1465897747689; Tue, 14 Jun 2016 02:49:07 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uq9si3882853pac.211.2016.06.14.02.49.07; Tue, 14 Jun 2016 02:49:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751778AbcFNJtF (ORCPT + 3 others); Tue, 14 Jun 2016 05:49:05 -0400 Received: from mail-lf0-f46.google.com ([209.85.215.46]:35107 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752203AbcFNJtE (ORCPT ); Tue, 14 Jun 2016 05:49:04 -0400 Received: by mail-lf0-f46.google.com with SMTP id u74so100799236lff.2 for ; Tue, 14 Jun 2016 02:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CHXYWHRB4Pe15KvOfiRUKZlzRuwVY61Qahic0lPP4sk=; b=HMdkoFAnJRDHC8CqnfiCE34k0AfeUlns5r9AC8bb/lByU8076wJ4genbVdIJlR9nRl zu1ABcapX3eRZL9bIRE+LmhDSP2K+Gh6t83h3ReKiWn1C6gToEZ9eMmO/YfmjkYPY/3m NOEii+Ssu/nXW/H2zUJLP9dCPlFFwJ7A5WvDc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CHXYWHRB4Pe15KvOfiRUKZlzRuwVY61Qahic0lPP4sk=; b=Ug2r83KHonYWQ3naGRBwJftA1P/TyW9QszAVZapIGYwaywW6JS90c4TcZmKMcMS/3J UG/qPO5xBPtNW2ER0zwyamZbnzfrtS1sHPs7yNnUUTWwzPyIEWAXTsSxWcTP2Mk4A+e3 5b/mp4e3WFAghH5gCm7391W7jIkOMs4E5ZWovRERySmflz0JnNgMuSaYjA5DdKd8Tdkk QgIx29wH3Ghh3oaezlCWTiRDHoaa3f6S4QC/FLlHZ5VSmA+zFN1aiAjAR8Wiy59ZTVdA ZtfjWxwbdovSyWXssrN7lhCR5rHAjreKu7ZMCkz1MH7RUCpxjAICdQH4gLBGl6I7Dl/z yY6Q== X-Gm-Message-State: ALyK8tL8AUv6BFPt6YE4r6sXAsjBoLeTnpuoZcE4IyWwH3ZWsLQ2P2LRXKYjUKPIS8mwmu+6 X-Received: by 10.46.9.215 with SMTP id 206mr4999057ljj.63.1465897737312; Tue, 14 Jun 2016 02:48:57 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-cc7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.204]) by smtp.gmail.com with ESMTPSA id g10sm3347875lbf.26.2016.06.14.02.48.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 02:48:55 -0700 (PDT) From: Linus Walleij To: , linux-kernel@vger.kernel.org, Bjorn Andersson , Stephen Boyd Cc: Linus Walleij , stable@vger.kernel.org Subject: [PATCH] mfd: qcom_rpm: fix offset error for msm8660 Date: Tue, 14 Jun 2016 11:48:45 +0200 Message-Id: <1465897725-16213-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The RPM in MSM8660/APQ8060 has different offsets to the selector ACK and request context ACK registers. Make all these register offsets part of the per-SoC data and assign the right values. The bug was found by verifying backwards to the vendor tree in the out-of-tree files : all were using offsets 3,11,15,23 except the MSM8660/APQ8060 which was using offsets 3,11,19,27. Cc: stable@vger.kernel.org Fixes: 58e214382bdd ("mfd: qcom-rpm: Driver for the Qualcomm RPM") Cc: Björn Andersson Cc: Stephen Boyd Signed-off-by: Linus Walleij --- drivers/mfd/qcom_rpm.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Bjorn Andersson diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c index 4f589cf75549..82cc7986e1ca 100644 --- a/drivers/mfd/qcom_rpm.c +++ b/drivers/mfd/qcom_rpm.c @@ -34,7 +34,11 @@ struct qcom_rpm_resource { struct qcom_rpm_data { u32 version; const struct qcom_rpm_resource *resource_table; - unsigned n_resources; + unsigned int n_resources; + unsigned int req_ctx_off; + unsigned int req_sel_off; + unsigned int ack_ctx_off; + unsigned int ack_sel_off; }; struct qcom_rpm { @@ -61,10 +65,6 @@ struct qcom_rpm { #define RPM_REQUEST_TIMEOUT (5 * HZ) -#define RPM_REQUEST_CONTEXT 3 -#define RPM_REQ_SELECT 11 -#define RPM_ACK_CONTEXT 15 -#define RPM_ACK_SELECTOR 23 #define RPM_SELECT_SIZE 7 #define RPM_NOTIFICATION BIT(30) @@ -155,6 +155,10 @@ static const struct qcom_rpm_data apq8064_template = { .version = 3, .resource_table = apq8064_rpm_resource_table, .n_resources = ARRAY_SIZE(apq8064_rpm_resource_table), + .req_ctx_off = 3, + .req_sel_off = 11, + .ack_ctx_off = 15, + .ack_sel_off = 23, }; static const struct qcom_rpm_resource msm8660_rpm_resource_table[] = { @@ -238,6 +242,10 @@ static const struct qcom_rpm_data msm8660_template = { .version = 2, .resource_table = msm8660_rpm_resource_table, .n_resources = ARRAY_SIZE(msm8660_rpm_resource_table), + .req_ctx_off = 3, + .req_sel_off = 11, + .ack_ctx_off = 19, + .ack_sel_off = 27, }; static const struct qcom_rpm_resource msm8960_rpm_resource_table[] = { @@ -320,6 +328,10 @@ static const struct qcom_rpm_data msm8960_template = { .version = 3, .resource_table = msm8960_rpm_resource_table, .n_resources = ARRAY_SIZE(msm8960_rpm_resource_table), + .req_ctx_off = 3, + .req_sel_off = 11, + .ack_ctx_off = 15, + .ack_sel_off = 23, }; static const struct qcom_rpm_resource ipq806x_rpm_resource_table[] = { @@ -360,6 +372,10 @@ static const struct qcom_rpm_data ipq806x_template = { .version = 3, .resource_table = ipq806x_rpm_resource_table, .n_resources = ARRAY_SIZE(ipq806x_rpm_resource_table), + .req_ctx_off = 3, + .req_sel_off = 11, + .ack_ctx_off = 15, + .ack_sel_off = 23, }; static const struct of_device_id qcom_rpm_of_match[] = { @@ -398,10 +414,10 @@ int qcom_rpm_write(struct qcom_rpm *rpm, bitmap_set((unsigned long *)sel_mask, res->select_id, 1); for (i = 0; i < ARRAY_SIZE(sel_mask); i++) { writel_relaxed(sel_mask[i], - RPM_CTRL_REG(rpm, RPM_REQ_SELECT + i)); + RPM_CTRL_REG(rpm, rpm->data->req_sel_off + i)); } - writel_relaxed(BIT(state), RPM_CTRL_REG(rpm, RPM_REQUEST_CONTEXT)); + writel_relaxed(BIT(state), RPM_CTRL_REG(rpm, rpm->data->req_ctx_off)); reinit_completion(&rpm->ack); regmap_write(rpm->ipc_regmap, rpm->ipc_offset, BIT(rpm->ipc_bit)); @@ -424,10 +440,11 @@ static irqreturn_t qcom_rpm_ack_interrupt(int irq, void *dev) u32 ack; int i; - ack = readl_relaxed(RPM_CTRL_REG(rpm, RPM_ACK_CONTEXT)); + ack = readl_relaxed(RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); for (i = 0; i < RPM_SELECT_SIZE; i++) - writel_relaxed(0, RPM_CTRL_REG(rpm, RPM_ACK_SELECTOR + i)); - writel(0, RPM_CTRL_REG(rpm, RPM_ACK_CONTEXT)); + writel_relaxed(0, + RPM_CTRL_REG(rpm, rpm->data->ack_sel_off + i)); + writel(0, RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); if (ack & RPM_NOTIFICATION) { dev_warn(rpm->dev, "ignoring notification!\n");