From patchwork Thu Aug 18 18:40: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: 74207 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp74204qga; Thu, 18 Aug 2016 18:31:12 -0700 (PDT) X-Received: by 10.66.74.103 with SMTP id s7mr8842993pav.1.1471570272199; Thu, 18 Aug 2016 18:31:12 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gp10si5306844pac.79.2016.08.18.18.31.11; Thu, 18 Aug 2016 18:31:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755319AbcHSBaz (ORCPT + 27 others); Thu, 18 Aug 2016 21:30:55 -0400 Received: from mail-lf0-f51.google.com ([209.85.215.51]:35384 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754635AbcHSB3N (ORCPT ); Thu, 18 Aug 2016 21:29:13 -0400 Received: by mail-lf0-f51.google.com with SMTP id f93so23062793lfi.2 for ; Thu, 18 Aug 2016 18:27:20 -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=NLPTpwBRUyRYyarlMWv+7tQ3Rv8KD74foA0U5YX45jY=; b=IgWE4dyUUV6UsWeOw+PRqunjQtc8920yIJalV0VD3RXyclhTLULCx6Wvd7Gnfcp4te Wa0VU8e5gziRoOKgJVmfWiW7J9234RIa1+D20L4GZJ08hqC+iQoXsLsS2AJQqsUgN4fL igbjQpgi01XvBdka5izU1giV8vN5n+dadIIDk= 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=NLPTpwBRUyRYyarlMWv+7tQ3Rv8KD74foA0U5YX45jY=; b=gcyv2LdFmvA8euFpRuvAAmZW2iKkPbsfywzkOaRrJdXA3u30B/bWMJeelpe57CRoqZ XUuSEMdSrl4AAwHxoaJJQ7eiZfg5bC62efNAavMvvgienAVM+AsYou4TAw6hwBPT99xy /4y4GD0dLyUhRM2fDYDy/ogiQwsOAmdUf4UiY01cngkY736Xj66qYB0NnTM5edy/gjjl 4fuYN0Buqy1kpNV39QzvnkMCx+Dus4vE9t/XlLbgSBmDiVtzH0MXo1gIkUt/GCDUORJv DnNKE3lcwyOt+TFS9zu0SuZw/0Vk/lZ17DRW988kWgxYhex/cd4e7iYXMbEl/Zfvh1sA WsYQ== X-Gm-Message-State: AEkoout3nns03ZAhZD767xGMGTAzHni/LedyXbQIDFvWUhz9DqigTI7rtbR6HKWQ8vjI7RJN X-Received: by 10.25.213.20 with SMTP id m20mr1154969lfg.61.1471545651530; Thu, 18 Aug 2016 11:40:51 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-357171d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.113.53]) by smtp.gmail.com with ESMTPSA id z78sm532201lfd.2.2016.08.18.11.40.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Aug 2016 11:40:50 -0700 (PDT) From: Linus Walleij To: lee.jones@linaro.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , =?UTF-8?q?Bj=C3=B6rn=20Andersson?= Subject: [PATCH v2] mfd: qcom_rpm: handle message RAM clock Date: Thu, 18 Aug 2016 20:40:45 +0200 Message-Id: <1471545645-11437-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The MSM8660, APQ8060, IPQ806x and MSM8960 have a GCC clock to the message RAM used by the RPM. This needs to be enabled for messages to pass through. This is a crude solution that simply prepare/enable at probe() and disable/unprepare at remove(). More elaborate PM is probably possible to add later. The construction uses IS_ERR() to gracefully handle the platforms that do not provide a message RAM clock. It will bail out of probe only if the clock is hitting a probe deferral situation. Of course this requires the proper device tree set-up: rpm: rpm@104000 { compatible = "qcom,rpm-msm8660"; clocks = <&gcc RPM_MSG_RAM_H_CLK>; clock-names = "ram"; ... }; I have provided this in the MSM8660 device tree, and will provide patches for the other targets. Cc: Björn Andersson Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Exploit that a clk can be NULL and handled transparently by the clock framework, simplifying the code - Move clock disablement after the OF depopulation call --- drivers/mfd/qcom_rpm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.7.4 diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c index 2e44323455dd..315da71bde49 100644 --- a/drivers/mfd/qcom_rpm.c +++ b/drivers/mfd/qcom_rpm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -48,6 +49,7 @@ struct qcom_rpm { struct regmap *ipc_regmap; unsigned ipc_offset; unsigned ipc_bit; + struct clk *ramclk; struct completion ack; struct mutex lock; @@ -501,6 +503,20 @@ static int qcom_rpm_probe(struct platform_device *pdev) mutex_init(&rpm->lock); init_completion(&rpm->ack); + /* Enable message RAM clock */ + rpm->ramclk = devm_clk_get(&pdev->dev, "ram"); + if (IS_ERR(rpm->ramclk)) { + ret = PTR_ERR(rpm->ramclk); + if (ret == -EPROBE_DEFER) + return ret; + /* + * Fall through in all other cases, as the clock is + * optional. (Does not exist on all platforms.) + */ + rpm->ramclk = NULL; + } + clk_prepare_enable(rpm->ramclk); /* Accepts NULL */ + irq_ack = platform_get_irq_byname(pdev, "ack"); if (irq_ack < 0) { dev_err(&pdev->dev, "required ack interrupt missing\n"); @@ -620,7 +636,11 @@ static int qcom_rpm_probe(struct platform_device *pdev) static int qcom_rpm_remove(struct platform_device *pdev) { + struct qcom_rpm *rpm = dev_get_drvdata(&pdev->dev); + of_platform_depopulate(&pdev->dev); + clk_disable_unprepare(rpm->ramclk); + return 0; }