From patchwork Mon Aug 26 16:45:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 11115071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64F5E174A for ; Mon, 26 Aug 2019 16:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43F262186A for ; Mon, 26 Aug 2019 16:45:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GN6MYYYH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732739AbfHZQpQ (ORCPT ); Mon, 26 Aug 2019 12:45:16 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35697 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732049AbfHZQpQ (ORCPT ); Mon, 26 Aug 2019 12:45:16 -0400 Received: by mail-wm1-f66.google.com with SMTP id l2so195538wmg.0 for ; Mon, 26 Aug 2019 09:45:15 -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=40OiuM1nuJAlvKWfMTtKgR/XOwSSjLB8LuDFl5DKXzY=; b=GN6MYYYHB3XQKR+KiwiVIeeM+2G4bD2QVjJ0i4C+/s4CBPD92zJDGewr9zJsWAgCRN /z45GHS5Uf1w6DWI8hlpFtkeIsMSlftBpG6gJ22S3dI3X7s70ELcZ3mclie1tUmUtfX+ 7pSX+Q9Ic4LZ2i1TtIGatlciKeYIMHfq2cQGn4RqSdKevBITEYAnSgSL0AQOZhdJWE2V K4U7eHqz160iQTcPGp/97QN/v6FHd0Pu3PPD505UezV34nYhvf/t7bezKlDgHDu/HOHj P+1lnPj6hPWhzZ0P3jWvjG75//1tON4d5jP/dlA5EzYpFSW+CUy/Z5vD3LS+Y++h62OC fYyw== 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:mime-version :content-transfer-encoding; bh=40OiuM1nuJAlvKWfMTtKgR/XOwSSjLB8LuDFl5DKXzY=; b=KrejUmv+EOl1/Qar32bZdsnK7ffDscfBY02GrBaUZ4HeRxYufPm6DuTwIOY8wiOPZI nr92YPd4Vw4W12R6AVp968m1iOrYoKTETr/TKBuXNjKekcNVElHAjO0JVfduCctoS4Iu L71U1B7/Ozf8TuucHXsKjrMv4xDA9J/oHCVzGBycDs4yZ4bNtqWFv9rVf+CU0RniZQQ9 OYS9IJI17wS5SH0S6Kc2acuFKl5un/4JXSiqc2SokCh1pgRdZFTXnu2Lj69OdjxtX4vq x+X+4agX7HhwCXBB1Di2hK56xleQZJ18TTTXWeXFU6jwWvElsn/kf7ptsSsa5kx1Wcf1 ZwsA== X-Gm-Message-State: APjAAAWBzf7mtQ6i5x5ukhFqOWPkM9PgWvue/e8+ZtNTYEv6Ip95jpxB hhou6BDqWiWyq6iOtmVcmVknww== X-Google-Smtp-Source: APXvYqz15pvffql6Kf9l8H7kJ6RNaJf4BK1apbLb2u0bWrcxkLHHlUQlchWJBjOeUDMhDxya4m/k1w== X-Received: by 2002:a7b:c4c6:: with SMTP id g6mr23832612wmk.52.1566837914285; Mon, 26 Aug 2019 09:45:14 -0700 (PDT) Received: from localhost.localdomain (124.red-83-36-179.dynamicip.rima-tde.net. [83.36.179.124]) by smtp.gmail.com with ESMTPSA id l62sm77872wml.13.2019.08.26.09.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Aug 2019 09:45:12 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, sboyd@kernel.org, agross@kernel.org, mturquette@baylibre.com Cc: bjorn.andersson@linaro.org, niklas.cassel@linaro.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] clk: qcom: gcc: limit GPLL0_AO_OUT operating frequency Date: Mon, 26 Aug 2019 18:45:06 +0200 Message-Id: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Limit the GPLL0_AO_OUT_MAIN operating frequency as per its hardware specifications. Co-developed-by: Niklas Cassel Signed-off-by: Niklas Cassel Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Bjorn Andersson Acked-by: Stephen Boyd --- drivers/clk/qcom/clk-alpha-pll.c | 8 ++++++++ drivers/clk/qcom/clk-alpha-pll.h | 1 + drivers/clk/qcom/gcc-qcs404.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c index 055318f97991..9228b7b1f56e 100644 --- a/drivers/clk/qcom/clk-alpha-pll.c +++ b/drivers/clk/qcom/clk-alpha-pll.c @@ -878,6 +878,14 @@ static long clk_trion_pll_round_rate(struct clk_hw *hw, unsigned long rate, return clamp(rate, min_freq, max_freq); } +const struct clk_ops clk_alpha_pll_fixed_ops = { + .enable = clk_alpha_pll_enable, + .disable = clk_alpha_pll_disable, + .is_enabled = clk_alpha_pll_is_enabled, + .recalc_rate = clk_alpha_pll_recalc_rate, +}; +EXPORT_SYMBOL_GPL(clk_alpha_pll_fixed_ops); + const struct clk_ops clk_alpha_pll_ops = { .enable = clk_alpha_pll_enable, .disable = clk_alpha_pll_disable, diff --git a/drivers/clk/qcom/clk-alpha-pll.h b/drivers/clk/qcom/clk-alpha-pll.h index 15f27f4b06df..c28eb1a08c0c 100644 --- a/drivers/clk/qcom/clk-alpha-pll.h +++ b/drivers/clk/qcom/clk-alpha-pll.h @@ -109,6 +109,7 @@ struct alpha_pll_config { }; extern const struct clk_ops clk_alpha_pll_ops; +extern const struct clk_ops clk_alpha_pll_fixed_ops; extern const struct clk_ops clk_alpha_pll_hwfsm_ops; extern const struct clk_ops clk_alpha_pll_postdiv_ops; extern const struct clk_ops clk_alpha_pll_huayra_ops; diff --git a/drivers/clk/qcom/gcc-qcs404.c b/drivers/clk/qcom/gcc-qcs404.c index e12c04c09a6a..567140709c7d 100644 --- a/drivers/clk/qcom/gcc-qcs404.c +++ b/drivers/clk/qcom/gcc-qcs404.c @@ -330,7 +330,7 @@ static struct clk_alpha_pll gpll0_ao_out_main = { .parent_names = (const char *[]){ "cxo" }, .num_parents = 1, .flags = CLK_IS_CRITICAL, - .ops = &clk_alpha_pll_ops, + .ops = &clk_alpha_pll_fixed_ops, }, }, }; From patchwork Mon Aug 26 16:45:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 11115073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9100B174A for ; Mon, 26 Aug 2019 16:45:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EEDC206BA for ; Mon, 26 Aug 2019 16:45:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="W+SxFN6U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732610AbfHZQpR (ORCPT ); Mon, 26 Aug 2019 12:45:17 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51372 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732728AbfHZQpR (ORCPT ); Mon, 26 Aug 2019 12:45:17 -0400 Received: by mail-wm1-f67.google.com with SMTP id k1so193780wmi.1 for ; Mon, 26 Aug 2019 09:45:16 -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 :mime-version:content-transfer-encoding; bh=Cw8s/YHZ7PvnoGSE9VFOJmJ7OcBZMxXJRhzFX2CFS/0=; b=W+SxFN6UOnhMQyfKYi//GVhcYoZ3i/nD7OtSMRn5jp7t/KwVidshqc3GGhsEelYCS/ bka02/KN4t8bjYa/TDX+woe/EE53FiG8xCNCJvwzfyJjX7FRDDVKR6IUkcynrIanziVm p76IcKZrk8LC1mr63MLlRIkEqYk4vmRVho6v5i2kRiTuG4yujVFh4wKFmgiQHU0VpxHB 1y0UeMI0pHRjUzyCky6UKE34gzrxy20ZHC+dQpRgSuWOOwN7JLJcHCM6ld6z0ebFr0PK 5tArhVKZkmYvIXu9hIqEzuDAGjRFmo93BnY59OCELg3wfsFC49d839C8QBz689yKzLor XPbg== 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:mime-version:content-transfer-encoding; bh=Cw8s/YHZ7PvnoGSE9VFOJmJ7OcBZMxXJRhzFX2CFS/0=; b=LfMS/8DLb0FHsHsO51wOLSIo8TjA/UFC2fZsN5rDaiVBbyWcFYillTbCRca2aJzbCR ymzGq+5beLUshOMyQrs89MLFTATJ5c3podbLyIV+v2tbGrnuOf2DBgP3HkkHEKA0ZVBO S8vIlm9zmi1/CoMTYPT/iDpF3r1VIp0Kd10Bwsxg8xDqFYLEopHf4FQWfPDdqyA96Zux cMR8U0bwHLuIWh2dCia7XKZgdxEHlyLmjfwQverm2W9zEP2cHsA4ylqxCd0d0bjeOrLN PdhzYrJqVVlaiyDAqq/I+taP9ud8o+QhQFOr7jXAZ9HllF5eKSscuNqFPsjjG7o8I8sg 664Q== X-Gm-Message-State: APjAAAWBBIfQ0CHcX2k2QuyKcDTiqVRTm4r3lZj0uPh8km3uBLluEOa8 5GKwwKIDuOqlmpaqdw6Egzh6xw== X-Google-Smtp-Source: APXvYqypld9ggLNrMKVt7wpQNxzd+rJq3YngYT287XmHw/uezGkbsvjvHScJk81jHJJBt8TnrajMAA== X-Received: by 2002:a1c:494:: with SMTP id 142mr22155343wme.12.1566837915356; Mon, 26 Aug 2019 09:45:15 -0700 (PDT) Received: from localhost.localdomain (124.red-83-36-179.dynamicip.rima-tde.net. [83.36.179.124]) by smtp.gmail.com with ESMTPSA id l62sm77872wml.13.2019.08.26.09.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Aug 2019 09:45:14 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, sboyd@kernel.org, agross@kernel.org, mturquette@baylibre.com Cc: bjorn.andersson@linaro.org, niklas.cassel@linaro.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] clk: qcom: apcs-msm8916: get parent clock names from DT Date: Mon, 26 Aug 2019 18:45:07 +0200 Message-Id: <20190826164510.6425-2-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> References: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Allow accessing the parent clock names required for the driver operation by using the device tree node. This permits extending the driver to other platforms without having to modify its source code. For backwards compatibility leave previous values as default. Co-developed-by: Niklas Cassel Signed-off-by: Niklas Cassel Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Bjorn Andersson --- drivers/clk/qcom/apcs-msm8916.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/clk/qcom/apcs-msm8916.c b/drivers/clk/qcom/apcs-msm8916.c index a6c89a310b18..dd82eb1e5202 100644 --- a/drivers/clk/qcom/apcs-msm8916.c +++ b/drivers/clk/qcom/apcs-msm8916.c @@ -19,7 +19,7 @@ static const u32 gpll0_a53cc_map[] = { 4, 5 }; -static const char * const gpll0_a53cc[] = { +static const char *gpll0_a53cc[] = { "gpll0_vote", "a53pll", }; @@ -50,6 +50,8 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev) struct regmap *regmap; struct clk_init_data init = { }; int ret = -ENODEV; + const char *parents[2]; + int pll_index = 0; regmap = dev_get_regmap(parent, NULL); if (!regmap) { @@ -61,6 +63,16 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev) if (!a53cc) return -ENOMEM; + /* legacy bindings only defined the pll parent clock (index = 0) with no + * name; when both of the parents are specified in the bindings, the + * pll is the second one (index = 1). + */ + if (of_clk_parent_fill(parent->of_node, parents, 2) == 2) { + gpll0_a53cc[0] = parents[0]; + gpll0_a53cc[1] = parents[1]; + pll_index = 1; + } + init.name = "a53mux"; init.parent_names = gpll0_a53cc; init.num_parents = ARRAY_SIZE(gpll0_a53cc); @@ -76,10 +88,11 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev) a53cc->src_shift = 8; a53cc->parent_map = gpll0_a53cc_map; - a53cc->pclk = devm_clk_get(parent, NULL); + a53cc->pclk = of_clk_get(parent->of_node, pll_index); if (IS_ERR(a53cc->pclk)) { ret = PTR_ERR(a53cc->pclk); - dev_err(dev, "failed to get clk: %d\n", ret); + if (ret != -EPROBE_DEFER) + dev_err(dev, "failed to get clk: %d\n", ret); return ret; } @@ -87,6 +100,7 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev) ret = clk_notifier_register(a53cc->pclk, &a53cc->clk_nb); if (ret) { dev_err(dev, "failed to register clock notifier: %d\n", ret); + clk_put(a53cc->pclk); return ret; } @@ -109,6 +123,8 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev) err: clk_notifier_unregister(a53cc->pclk, &a53cc->clk_nb); + clk_put(a53cc->pclk); + return ret; } @@ -117,6 +133,7 @@ static int qcom_apcs_msm8916_clk_remove(struct platform_device *pdev) struct clk_regmap_mux_div *a53cc = platform_get_drvdata(pdev); clk_notifier_unregister(a53cc->pclk, &a53cc->clk_nb); + clk_put(a53cc->pclk); return 0; } From patchwork Mon Aug 26 16:45:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 11115075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCCE718B7 for ; Mon, 26 Aug 2019 16:45:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB61021848 for ; Mon, 26 Aug 2019 16:45:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KabsJLk1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732972AbfHZQpS (ORCPT ); Mon, 26 Aug 2019 12:45:18 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46165 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732816AbfHZQpS (ORCPT ); Mon, 26 Aug 2019 12:45:18 -0400 Received: by mail-wr1-f65.google.com with SMTP id z1so15980481wru.13 for ; Mon, 26 Aug 2019 09:45:17 -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 :mime-version:content-transfer-encoding; bh=BoMlESuV3B6tPWN9XWP2L6fpdT8XV6yqfKxT2xNxK2o=; b=KabsJLk1ZzmKq1DlMZEp/k29ZN2rr4yrR+8FbU+6lJZgjPEJAUiZYYegw4EjL9CI/+ HUracAwaQVCCkTBDakDUb5s4M8ROZsTl3Zz72EdmhuUkE8xP2r+Xrq8kFBZUjwmIxYiF 4SukMlm006PTTDVg8EHnqFDH81vNuIk3jCy+dKF//AF6TRPrgC60ZBONZKv9I4B9NvC+ jEfHHjGd1OlGPoh+dGeRIJnJPHBq+wKiJa6nzTxmailqFW308PmAKHWn5EtbCyIVBFvf 0yMEtDR9P+bt1hi+IWD19RTpVBIovgRJ0hlnV9jz0OLdtnyWZ3nn2SQOrjHtYhg/asOX f5sQ== 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:mime-version:content-transfer-encoding; bh=BoMlESuV3B6tPWN9XWP2L6fpdT8XV6yqfKxT2xNxK2o=; b=tKCOExluzA6twn6NLIL7kUPG/g7PDL/VE+MOpvAr3cxqT+vE3OwvzP1HXCKBgplg+Z W0RJ+f/bXrk0vvb9V2NSiIPmpNAyQctO8MIgAZRXcDnxYbjF44KVZFDPgOL7g9lWRtoA EIHutiTe20dAXSPAgSMSLy2CS6qjHBlR1tIIBY1XVRzLFdkiy7wcVY/R7fCxkzk9DSJS WN5D8z4C+zXUUaamlPjJU9tLQyu1PVrAes103fwdcWi0cR/+EEI38EC/iSVMz9zWKZLB aPufT1PWQtucy9SccJbqFeGel7zW06kR4SeUDZceLtkBCrNv/w2IB3An/G66Gj/4N75R YZSA== X-Gm-Message-State: APjAAAV09A+QyQnRYAchT4KjPnY6Hlw5QpaXNkqSIMh/cbTZ8SHi6ydy XdUNjIxIveRYGO4TI5Qibl+Gml5TbnE= X-Google-Smtp-Source: APXvYqyoNuv9DfnZpQxM6zKbeFAGmBOoB6lJfzBvGkL4tsUO2eT/X3klfLwalxdAz9fxpImq8/nBtg== X-Received: by 2002:a5d:4490:: with SMTP id j16mr23161619wrq.335.1566837916391; Mon, 26 Aug 2019 09:45:16 -0700 (PDT) Received: from localhost.localdomain (124.red-83-36-179.dynamicip.rima-tde.net. [83.36.179.124]) by smtp.gmail.com with ESMTPSA id l62sm77872wml.13.2019.08.26.09.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Aug 2019 09:45:15 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, sboyd@kernel.org, agross@kernel.org, mturquette@baylibre.com Cc: bjorn.andersson@linaro.org, niklas.cassel@linaro.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] clk: qcom: hfpll: get parent clock names from DT Date: Mon, 26 Aug 2019 18:45:08 +0200 Message-Id: <20190826164510.6425-3-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> References: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Allow accessing the parent clock name required for the driver operation using the device tree node. This permits extending the driver to other platforms without having to modify its source code. For backwards compatibility leave the previous value as default. Co-developed-by: Niklas Cassel Signed-off-by: Niklas Cassel Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Bjorn Andersson --- drivers/clk/qcom/hfpll.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/clk/qcom/hfpll.c b/drivers/clk/qcom/hfpll.c index a6de7101430c..87b7f46d27e0 100644 --- a/drivers/clk/qcom/hfpll.c +++ b/drivers/clk/qcom/hfpll.c @@ -52,6 +52,7 @@ static int qcom_hfpll_probe(struct platform_device *pdev) void __iomem *base; struct regmap *regmap; struct clk_hfpll *h; + struct clk *pclk; struct clk_init_data init = { .parent_names = (const char *[]){ "xo" }, .num_parents = 1, @@ -75,6 +76,13 @@ static int qcom_hfpll_probe(struct platform_device *pdev) 0, &init.name)) return -ENODEV; + /* get parent clock from device tree (optional) */ + pclk = devm_clk_get(dev, "xo"); + if (!IS_ERR(pclk)) + init.parent_names = (const char *[]){ __clk_get_name(pclk) }; + else if (PTR_ERR(pclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + h->d = &hdata; h->clkr.hw.init = &init; spin_lock_init(&h->lock); From patchwork Mon Aug 26 16:45:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 11115081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 051551800 for ; Mon, 26 Aug 2019 16:45:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D655221872 for ; Mon, 26 Aug 2019 16:45:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VTzy/+S+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733016AbfHZQp1 (ORCPT ); Mon, 26 Aug 2019 12:45:27 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37253 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732967AbfHZQpT (ORCPT ); Mon, 26 Aug 2019 12:45:19 -0400 Received: by mail-wm1-f67.google.com with SMTP id d16so181886wme.2 for ; Mon, 26 Aug 2019 09:45:18 -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 :mime-version:content-transfer-encoding; bh=onetUiZPcKYw43ltVy2pax5WwMNPrRMe/eAwSVGynt4=; b=VTzy/+S+EG6NglyCNwJnyPj3v2a/38li9pyUxYKXw95aeoqEm9GPssQFRmUG5oI5c6 EibgtBUP8JpXh9l/UOZyVKOalAwVOkPO8s9pNn7XDDPcxuydVS9l5FodOV0SUHXsMs/6 a+ShgY60QQ25TmCk+KweofZi35NxEKp9vY/YYEGj1WvkEMsyEAO9pHrsoCjZkIfjqK7C NDsyahCeF26dySxYSNWqn5Sg+1TpbEPNIBwt+txXub1CsghTQ5+TdX76yEufnG9UVhgI w8Qbj+iA35AgTzxoF9TK2WruT0+7K0jCSVJp/6qNba2MXP71JyvQN8RXct+m5qD4Tufm 2dAw== 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:mime-version:content-transfer-encoding; bh=onetUiZPcKYw43ltVy2pax5WwMNPrRMe/eAwSVGynt4=; b=soF2IqAKRMLyrVqEUAxvlL/wF0IS/hmqVFqRLwygqW50OToAJ58q/kxBL5keAD2GRv mC46QrmvozzB8xxF5N603CqNxfahkRLj1B7bsA3MpeY7X/RGdYvMaXxQBm87pZStuAft OKITUdAWccOwdHGEnPPv2jVzltZ+b0l3+zlmhear+7073kOokfV+uevZm+HkvQk5Z+Yo Phgl7y7fixogQzuMr8pCcnNod+jxLEHlLNuMgs4mJUPjGfAE/QU0v69vJIivuGf3G7sJ D12jjsPM3GwEaGlP4ikpC7ZQM9sk8qSdaC3+/lMAW1HpWLEEqB2nA7f3Pse+MdirLKvb bsAA== X-Gm-Message-State: APjAAAWwOAsg7uughAwuLFJW3X33YmfrtDZxMwLop1expc5gKHqz4frK IEVRZpVBzC1UWkzq+c/EkdSS7Q== X-Google-Smtp-Source: APXvYqz1ti6G8ykQXaSBWITNSJt9no2xf8IMdYAR5XEK+i92tzuI2ROTgl+pfgyiar++tcx9MbRJlQ== X-Received: by 2002:a7b:c947:: with SMTP id i7mr23496677wml.77.1566837917375; Mon, 26 Aug 2019 09:45:17 -0700 (PDT) Received: from localhost.localdomain (124.red-83-36-179.dynamicip.rima-tde.net. [83.36.179.124]) by smtp.gmail.com with ESMTPSA id l62sm77872wml.13.2019.08.26.09.45.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Aug 2019 09:45:16 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, sboyd@kernel.org, agross@kernel.org, mturquette@baylibre.com Cc: bjorn.andersson@linaro.org, niklas.cassel@linaro.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] clk: qcom: hfpll: register as clock provider Date: Mon, 26 Aug 2019 18:45:09 +0200 Message-Id: <20190826164510.6425-4-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> References: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Make the output of the high frequency pll a clock provider. On the QCS404 this PLL controls cpu frequency scaling. Co-developed-by: Niklas Cassel Signed-off-by: Niklas Cassel Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Bjorn Andersson Acked-by: Stephen Boyd --- drivers/clk/qcom/hfpll.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/hfpll.c b/drivers/clk/qcom/hfpll.c index 87b7f46d27e0..0ffed0d41c50 100644 --- a/drivers/clk/qcom/hfpll.c +++ b/drivers/clk/qcom/hfpll.c @@ -53,6 +53,7 @@ static int qcom_hfpll_probe(struct platform_device *pdev) struct regmap *regmap; struct clk_hfpll *h; struct clk *pclk; + int ret; struct clk_init_data init = { .parent_names = (const char *[]){ "xo" }, .num_parents = 1, @@ -87,7 +88,14 @@ static int qcom_hfpll_probe(struct platform_device *pdev) h->clkr.hw.init = &init; spin_lock_init(&h->lock); - return devm_clk_register_regmap(&pdev->dev, &h->clkr); + ret = devm_clk_register_regmap(dev, &h->clkr); + if (ret) { + dev_err(dev, "failed to register regmap clock: %d\n", ret); + return ret; + } + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, + &h->clkr.hw); } static struct platform_driver qcom_hfpll_driver = { From patchwork Mon Aug 26 16:45:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 11115085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D8D0174A for ; Mon, 26 Aug 2019 16:45:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BD9921848 for ; Mon, 26 Aug 2019 16:45:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZIQIzeKY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732728AbfHZQpb (ORCPT ); Mon, 26 Aug 2019 12:45:31 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35862 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732980AbfHZQpT (ORCPT ); Mon, 26 Aug 2019 12:45:19 -0400 Received: by mail-wr1-f67.google.com with SMTP id r3so15996218wrt.3 for ; Mon, 26 Aug 2019 09:45:19 -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 :mime-version:content-transfer-encoding; bh=AduWeROQMDkKls+kl/fLswGL+rHZfEiqcyM0mR/LCMQ=; b=ZIQIzeKYCgaQGA3mvoHdMljzb0wEi7oer9LTbZr5HMpxDFPOgxtKb6VqdW862YV8km 04stCMBB1CU0drEjv/HuwbCLA/Jd1m4jBj2IX5eP5GcLNb5H0y96of/8RLrgkCVmJDiA t6avVK9FSWPEWWBcj4zHGwA+FTc9+7NYbGw2PSPIWtdzIIsiVV33OHd06oRpaEnDWfjN kAPZ/UIGq3FLf5aMXUUhbColc9tbabiobhcFIRuv2HQxs7FFIh+m2bjFJ1v2eRfkr8lt L8NkMZsn9ZC+KG+n8ZrT/975M13k6QJZKo3CsK2SJT13L/Z7K/MRW8HEtqxwztb/2Xk0 6QVg== 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:mime-version:content-transfer-encoding; bh=AduWeROQMDkKls+kl/fLswGL+rHZfEiqcyM0mR/LCMQ=; b=TzUeWsR/x2A9I41jDxIf6397cUO2lofWcw+EvPgHV9KHa2q6dmOU7+4pk1qnmB8RU5 WvmcfJoLcFL9n/8hqBSxUMl2gZEw8JdJ1Le/sOsQlSI36b5aE4VV+coNTnEqsxxtfwvC qpbl1vn41Ov3uz4yD/8g3vLhPa1Zuh1wTtuk0Xvn7mAeH1kmrzg09r4665Iz9dKoC0BH WnoA0js7vWbsx35fOqZ3C7MCs6CU8mOW7pViLP6D7uabb3TbA5y9vlSX4/tQJjgetSjt Q56xSXKMYdUetQKAn9JwqAH5E9nICSQ/BIj+0FJkZdfYZ2cxiqTGUb6CVFz30sdaiZUh lzTQ== X-Gm-Message-State: APjAAAXgETok5KYTs/UXids6sozXLFzPZp7cyrdwg3gO0Is/UOZTT7SM 9rBzTLsYzCwaMe3cPpDNtKnLLg== X-Google-Smtp-Source: APXvYqy0keQA67hzBHSf6JmnEJPjZvrevuThhyTnApH6TfZIBG2gotXVyRWSN+8mPw7MptkOjV1tqw== X-Received: by 2002:a5d:610d:: with SMTP id v13mr24331376wrt.249.1566837918384; Mon, 26 Aug 2019 09:45:18 -0700 (PDT) Received: from localhost.localdomain (124.red-83-36-179.dynamicip.rima-tde.net. [83.36.179.124]) by smtp.gmail.com with ESMTPSA id l62sm77872wml.13.2019.08.26.09.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Aug 2019 09:45:17 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, sboyd@kernel.org, agross@kernel.org, mturquette@baylibre.com Cc: bjorn.andersson@linaro.org, niklas.cassel@linaro.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] clk: qcom: hfpll: CLK_IGNORE_UNUSED Date: Mon, 26 Aug 2019 18:45:10 +0200 Message-Id: <20190826164510.6425-5-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> References: <20190826164510.6425-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org When COMMON_CLK_DISABLED_UNUSED is set, in an effort to save power and to keep the software model of the clock in line with reality, the framework transverses the clock tree and disables those clocks that were enabled by the firmware but have not been enabled by any device driver. If CPUFREQ is enabled, early during the system boot, it might attempt to change the CPU frequency ("set_rate"). If the HFPLL is selected as a provider, it will then change the rate for this clock. As boot continues, clk_disable_unused_subtree will run. Since it wont find a valid counter (enable_count) for a clock that is actually enabled it will attempt to disable it which will cause the CPU to stop. Notice that in this driver, calls to check whether the clock is enabled are routed via the is_enabled callback which queries the hardware. The following commit, rather than marking the clock critical and forcing the clock to be always enabled, addresses the above scenario making sure the clock is not disabled but it continues to rely on the firmware to enable the clock. Co-developed-by: Niklas Cassel Signed-off-by: Niklas Cassel Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Bjorn Andersson --- drivers/clk/qcom/hfpll.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/clk/qcom/hfpll.c b/drivers/clk/qcom/hfpll.c index 0ffed0d41c50..d5fd27938e7b 100644 --- a/drivers/clk/qcom/hfpll.c +++ b/drivers/clk/qcom/hfpll.c @@ -58,6 +58,13 @@ static int qcom_hfpll_probe(struct platform_device *pdev) .parent_names = (const char *[]){ "xo" }, .num_parents = 1, .ops = &clk_ops_hfpll, + /* + * rather than marking the clock critical and forcing the clock + * to be always enabled, we make sure that the clock is not + * disabled: the firmware remains responsible of enabling this + * clock (for more info check the commit log) + */ + .flags = CLK_IGNORE_UNUSED, }; h = devm_kzalloc(dev, sizeof(*h), GFP_KERNEL);