From patchwork Wed Aug 29 23:15:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 145478 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp148393ljw; Wed, 29 Aug 2018 16:13:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYqLAjucAsUtErjPlxZwYpZoLu8X3eicBHvyG2utdvRGp0C40YWgPqDsb+o7gwdpt+XNJ2R X-Received: by 2002:a65:520d:: with SMTP id o13-v6mr7484815pgp.282.1535584412358; Wed, 29 Aug 2018 16:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535584412; cv=none; d=google.com; s=arc-20160816; b=duz2tGG6woDiQlTzNQc4pqrkGXAV3CIEhlXnc+zqB6xBIjV9lLIMoBPitjeObb8O2U 1HFnCqbC+DS9rTW/2vd4ZQX+pwhd/PkejC/9OcQ6zXPOJs3nOnX1U68c5G4QIrqfTbgH zAqrOh17HF41RgvkoO8RqZGz8LSgtWp6F/cRxDSe8Vai43mU86acg/4qV0aoQ2Unlpxk XuEu7W0gEL4K6P5V0WjWGv9ePIwslIfaBa/jO7uBXDwsJ/+N5WeGv4jbTGcy1MK0/7Ie KcYe95J2vqVsycxDqu0eURKjuTbP7qcLoTxV1LHQq9KcizrTnvVsTqvxTwhEl3GULEQp livQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=HX4F/rdiOP0kU6rBurqBeHoRoGC1++7SAIga+ZKr2rE=; b=la6LPoEocgixI9SzK2TsIFFwxFGJAbgqcMLYjzQWQnvSWYsQBjH4z7WqVcqhCac3xV wOIjQ9qmr+DAw3Wb1rDy7ODJ7UMNEGyftJ6iX4H1gVuCCNo8Jadb3cdMydRov0Zj9ok0 gG5djVILFfqFMvYdtSuq9/2UQa7hYF8PZI4/QwLEOEuAfNTvAd+tEDMKGONjeZVTKwQh PQAWD36KjnoQDv7QkgqdT7mX5KGmBPuQfA/lzF705Nbsjpj0VlLBT8m7/NnD7h8XrjVq ks5/OwgT6HmjVWKqzn3nN7YF00r7WKRQucDw+qY9Ip70xSJz1ezB8RyIEQDZM14ROmHo k+ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wwb0cd9n; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8-v6si4627050pfo.128.2018.08.29.16.13.31; Wed, 29 Aug 2018 16:13:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 header.s=google header.b=Wwb0cd9n; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbeH3DMn (ORCPT + 6 others); Wed, 29 Aug 2018 23:12:43 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43831 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727643AbeH3DMm (ORCPT ); Wed, 29 Aug 2018 23:12:42 -0400 Received: by mail-pf1-f196.google.com with SMTP id j26-v6so2946335pfi.10 for ; Wed, 29 Aug 2018 16:13:29 -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:in-reply-to:references; bh=HX4F/rdiOP0kU6rBurqBeHoRoGC1++7SAIga+ZKr2rE=; b=Wwb0cd9nxM6/lBhhSkAx8Cs01gZ12pfgPMg9+/CqlkeVS1DgWjbcKvRXzuK5WYE0NA SHReuJkQY8HZu1n2eHl8eQF0T0OTTlCXexoaowP9+06h1Hyp47337jImfMfR2roIfsez 1PnJQ0/S5KiW0YwkR/vORlw8sMFu3QdkUHzs4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HX4F/rdiOP0kU6rBurqBeHoRoGC1++7SAIga+ZKr2rE=; b=oyWIq+103/wIStPXc1Gtv9/3W7aRB0kdmJlUA9FW4pg865y2wYypgHZJnYwQqolCb0 lPWn/EcKwF2se2/jICyjAWD2HzcijthJjKwzrxvV4CzJtHaUMdqxUhxk2Ltz3iTAo77q LTHKcV5egXh1dQqE1fCZyx5yT7n9lB0wV2g5HP6mBjgKMGeQOh2//++JyoanpcQ+xCD/ +0dI0Mdj0Bg3kTxDb5Hj8mWYLkgnz1K3BILF6ygxFAzm7fsVx0NdlsFinjo9VhNkxZA+ SCBRxtukC0M7k4DcNPonhbbbiSCrUdzFD0UKInzS+fsnTWDcyii96ZYLP97kQfFrp1I6 tuug== X-Gm-Message-State: APzg51ARhtH8j4tijv8DEjh+KrGI9004aC1i8BhSh/LIGHnmHs8nQb02 qq6Od4ssZb4bmtWp7D9sQ2wKzQ== X-Received: by 2002:a63:6745:: with SMTP id b66-v6mr7627496pgc.248.1535584408381; Wed, 29 Aug 2018 16:13:28 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id w69-v6sm14035404pgd.37.2018.08.29.16.13.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 16:13:27 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Stephen Boyd Cc: Sricharan R , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Craig Tatlor Subject: [PATCH 2/3] firmware: qcom: scm: Refactor clock handling Date: Wed, 29 Aug 2018 16:15:04 -0700 Message-Id: <20180829231505.22660-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180829231505.22660-1-bjorn.andersson@linaro.org> References: <20180829231505.22660-1-bjorn.andersson@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org At one point in time all "future" platforms required three clocks, so the binding and driver was written to treat this as the default case. But new platforms has no clock requirements, which currently makes them all a special case, causing the need for a patch in the binding and driver for each new platform added. This patch reworks the driver logic so that it will attempt to acquire all three clocks and fail based on the given compatible. This allow us to drop the clock requirement from "qcom,scm", in a way that will remain backwards compatible with existing DT files. Specific compatibles are added for apq8084, msm8916 and msm8974 to match the updated binding and although equivalent to qcom,scm both ipq4019 and msm8996 are kept as these have been used without fallback to qcom,scm. The result of this patch is that new platforms, that require no clocks, can be use the fallback compatible of "qcom,scm". Signed-off-by: Bjorn Andersson --- drivers/firmware/qcom_scm.c | 74 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 32 deletions(-) -- 2.18.0 Reviewed-by: Stephen Boyd diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index e778af766fae..af4eee86919d 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -525,34 +525,44 @@ static int qcom_scm_probe(struct platform_device *pdev) return ret; clks = (unsigned long)of_device_get_match_data(&pdev->dev); - if (clks & SCM_HAS_CORE_CLK) { - scm->core_clk = devm_clk_get(&pdev->dev, "core"); - if (IS_ERR(scm->core_clk)) { - if (PTR_ERR(scm->core_clk) != -EPROBE_DEFER) - dev_err(&pdev->dev, - "failed to acquire core clk\n"); + + scm->core_clk = devm_clk_get(&pdev->dev, "core"); + if (IS_ERR(scm->core_clk)) { + if (PTR_ERR(scm->core_clk) == -EPROBE_DEFER) + return PTR_ERR(scm->core_clk); + + if (clks & SCM_HAS_CORE_CLK) { + dev_err(&pdev->dev, "failed to acquire core clk\n"); return PTR_ERR(scm->core_clk); } + + scm->core_clk = NULL; } - if (clks & SCM_HAS_IFACE_CLK) { - scm->iface_clk = devm_clk_get(&pdev->dev, "iface"); - if (IS_ERR(scm->iface_clk)) { - if (PTR_ERR(scm->iface_clk) != -EPROBE_DEFER) - dev_err(&pdev->dev, - "failed to acquire iface clk\n"); + scm->iface_clk = devm_clk_get(&pdev->dev, "iface"); + if (IS_ERR(scm->iface_clk)) { + if (PTR_ERR(scm->iface_clk) == -EPROBE_DEFER) + return PTR_ERR(scm->iface_clk); + + if (clks & SCM_HAS_IFACE_CLK) { + dev_err(&pdev->dev, "failed to acquire iface clk\n"); return PTR_ERR(scm->iface_clk); } + + scm->iface_clk = NULL; } - if (clks & SCM_HAS_BUS_CLK) { - scm->bus_clk = devm_clk_get(&pdev->dev, "bus"); - if (IS_ERR(scm->bus_clk)) { - if (PTR_ERR(scm->bus_clk) != -EPROBE_DEFER) - dev_err(&pdev->dev, - "failed to acquire bus clk\n"); + scm->bus_clk = devm_clk_get(&pdev->dev, "bus"); + if (IS_ERR(scm->bus_clk)) { + if (PTR_ERR(scm->bus_clk) == -EPROBE_DEFER) + return PTR_ERR(scm->bus_clk); + + if (clks & SCM_HAS_BUS_CLK) { + dev_err(&pdev->dev, "failed to acquire bus clk\n"); return PTR_ERR(scm->bus_clk); } + + scm->bus_clk = NULL; } scm->reset.ops = &qcom_scm_pas_reset_ops; @@ -594,23 +604,23 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm-apq8064", /* FIXME: This should have .data = (void *) SCM_HAS_CORE_CLK */ }, - { .compatible = "qcom,scm-msm8660", - .data = (void *) SCM_HAS_CORE_CLK, - }, - { .compatible = "qcom,scm-msm8960", - .data = (void *) SCM_HAS_CORE_CLK, - }, - { .compatible = "qcom,scm-msm8996", - .data = NULL, /* no clocks */ + { .compatible = "qcom,scm-apq8084", .data = (void *)(SCM_HAS_CORE_CLK | + SCM_HAS_IFACE_CLK | + SCM_HAS_BUS_CLK) }, - { .compatible = "qcom,scm-ipq4019", - .data = NULL, /* no clocks */ + { .compatible = "qcom,scm-ipq4019" }, + { .compatible = "qcom,scm-msm8660", .data = (void *) SCM_HAS_CORE_CLK }, + { .compatible = "qcom,scm-msm8960", .data = (void *) SCM_HAS_CORE_CLK }, + { .compatible = "qcom,scm-msm8916", .data = (void *)(SCM_HAS_CORE_CLK | + SCM_HAS_IFACE_CLK | + SCM_HAS_BUS_CLK) }, - { .compatible = "qcom,scm", - .data = (void *)(SCM_HAS_CORE_CLK - | SCM_HAS_IFACE_CLK - | SCM_HAS_BUS_CLK), + { .compatible = "qcom,scm-msm8974", .data = (void *)(SCM_HAS_CORE_CLK | + SCM_HAS_IFACE_CLK | + SCM_HAS_BUS_CLK) }, + { .compatible = "qcom,scm-msm8996" }, + { .compatible = "qcom,scm" }, {} };