From patchwork Thu Aug 18 13:00:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 74162 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp335305qga; Thu, 18 Aug 2016 06:00:52 -0700 (PDT) X-Received: by 10.98.196.138 with SMTP id h10mr3887149pfk.60.1471525251815; Thu, 18 Aug 2016 06:00:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si2464126pav.105.2016.08.18.06.00.50; Thu, 18 Aug 2016 06:00:51 -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 S1947256AbcHRNAg (ORCPT + 27 others); Thu, 18 Aug 2016 09:00:36 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:32995 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1947224AbcHRNAc (ORCPT ); Thu, 18 Aug 2016 09:00:32 -0400 Received: by mail-lf0-f50.google.com with SMTP id b199so11238480lfe.0 for ; Thu, 18 Aug 2016 06:00:31 -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=GPAEDJUanvtGAfWOQ/ABesKW8tYatw0t124AAy1YuhU=; b=S1wQLQmLboQLZgTPqt3tM9XTNinvNLy3J4sEjtXJz/mAxo7U+QAS3rW0FAa0DdU09j Eui++7cxQntJXIN8K+4lmoBgAO4CJE7KimT1m3Nte2KCGkb1jHqQOTMFgMpK19OBoJ9f RYsBg7rupw6BLOZ3t9n6aJlhXUF5KN98QHrzE= 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=GPAEDJUanvtGAfWOQ/ABesKW8tYatw0t124AAy1YuhU=; b=hR/+wCk9chSwAVZeugOFC5mu4YQDRrkUfhyvqYXqMnS4FUO0RR4GKvsAst3vsGUPpu 0fV8/AvTJhtHCy4y4PX0QgoR4oLvv36RE5y0IiFJPNBwL6G7mT031tWh9yxUYEij5bMZ zfeL365ondlnk9rWU+CJ8X+mZLuQxP+2n1qzoSoTkf9HbzAMNLmfGIRwCaNKp8h42d6k bcDNDhOwlEwm92kuKzppj1LEZ9zXY1SqPuOis0mT/444KoqIWe795leXfBqcMUsX73AK xuiqjhlJ0zbAkRFGxC3hVBro+mslH22wsWg9cFwwjjbYAzAe6c0jYjI7gtRegzP/kNP8 9gDw== X-Gm-Message-State: AEkoouutn7GUZrFrG6DO+BKl/vMgwUkIoRd8SwmfFs6KcN7pekL5GmiLT938jRqhmzVAuX/v X-Received: by 10.25.214.40 with SMTP id n40mr678593lfg.105.1471525229960; Thu, 18 Aug 2016 06:00:29 -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 i5sm312553lfe.40.2016.08.18.06.00.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Aug 2016 06:00:28 -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] mfd: qcom_rpm: handle message RAM clock Date: Thu, 18 Aug 2016 15:00:19 +0200 Message-Id: <1471525219-647-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 --- 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..58d0617d9a0a 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.) + */ + } else { + clk_prepare_enable(rpm->ramclk); + } + irq_ack = platform_get_irq_byname(pdev, "ack"); if (irq_ack < 0) { dev_err(&pdev->dev, "required ack interrupt missing\n"); @@ -620,6 +636,10 @@ 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); + + if (!IS_ERR(rpm->ramclk)) + clk_disable_unprepare(rpm->ramclk); of_platform_depopulate(&pdev->dev); return 0; }