Received: by 10.223.176.46 with SMTP id f43csp1306637wra; Fri, 26 Jan 2018 15:57:31 -0800 (PST) X-Google-Smtp-Source: AH8x224QazdNKdPJtyHEoFJ7J9rwtK9nFJ+G+0/vofoKl4zSjdnsNI1oTPlT445vHHWGxH2S2OKh X-Received: by 10.99.95.193 with SMTP id t184mr16724429pgb.189.1517011051444; Fri, 26 Jan 2018 15:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517011051; cv=none; d=google.com; s=arc-20160816; b=R/kmUgGZqqQ47lur3TB6HxqiE3Wu1DvNbpIMSHahTp8/MBJtVHk7AQjdMe3cZioMSL jT2Xuonhrtm0gNdL9p361i+POiMES/VKGYY78UzPTVEAZMyUFDEuOBEm1FWPI2vKn7Zu HfGfVABG2aOtYGegh2CPNbs07NzeVfkMNH/M3is4WJRBzlyyi2DyzNHI0PK9M/pJLJwB GtMPZeJTo2vcjQl3RHOkI/3RQjZIggfcHSQl0nUepCLqrWDazt3afLWZQd2drGbshHl2 c3tM8+oO7/vqwcWpiXrmPztnOoiqaWhJvnHhTrpo0Awj6y+z98Rr8ZEFqCunPTaO/f5u BYyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=9MpDcCeyizl6AMVwnT6tdHc6cPk40/m188n+YxYLVR0=; b=N9x1j5Y6QIA4QtODNlOov1Kg9XxYx3RPMtAi2a5gbmWfLMMLDMxAaNdNjzut5ucZIL iMqwmBbBgWxh5TMiNSVcacLXGWJ33xj4u/m0PDXqBNRLqEkbZ4Xd3IFRdL4W61BQkNgo ZhYe+anOtjVBKO7drWwWY+JpXAC3MIi8wVLPE0o+78trg0cKumg1z7sB1GaSPNjVX8wS sss9Q6DnVP3PnwLMWyqBL7wbeiCurKfviqwiU9GmOGKLkIkBkVJKyfiyAojLuxhYHus/ Ow0E2l5Hj7myKBI35JRB14oxm3FuMlqOZEvI/26uE/XAAptkbogrM7m72eJyZldhq7so APPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=e0scWTPO; dkim=pass header.i=@codeaurora.org header.s=default header.b=IaBkTG5r; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8-v6si4429614pls.595.2018.01.26.15.57.16; Fri, 26 Jan 2018 15:57:31 -0800 (PST) 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=@codeaurora.org header.s=default header.b=e0scWTPO; dkim=pass header.i=@codeaurora.org header.s=default header.b=IaBkTG5r; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751598AbeAZX4y (ORCPT + 99 others); Fri, 26 Jan 2018 18:56:54 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:51786 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751297AbeAZX4w (ORCPT ); Fri, 26 Jan 2018 18:56:52 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7F4F4600C1; Fri, 26 Jan 2018 23:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517011011; bh=4l1j/H1nKKF/SBwV/57Iw5KYdNhhEoiibfgfnWrtnk8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=e0scWTPO+2Qd8bS5bjpAVz0QeUcsBJAekvD8pStmXn+LC1WIoKFobFCn8Vv0RCp2+ +r4jNG5hHZCRaNyWyO4lidTbyYHQSefEwcCBVbtTdNk1K7M1DTDw8yjNqT0bW3FVvj Ezo+rijb1OouPKom6DjBvpnRWQ45WyUAkIYZA844= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3FD39600C1; Fri, 26 Jan 2018 23:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517011010; bh=4l1j/H1nKKF/SBwV/57Iw5KYdNhhEoiibfgfnWrtnk8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IaBkTG5rsld0piDsCuElVO6Pig9z7wsHvBNPRcDQL1gcKJfftM4866kSnoX1K/HR8 0kfrR68m2PCoWMT1bQm2wDTDz2PaTbOayU7wSe9SjVi53+F9AXZqgTEr8+o5OLj7oY Vi7UTVVkpvyW8HAeiGrrvdbVDqv92eeX6nK1tEDk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3FD39600C1 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sboyd@codeaurora.org Date: Fri, 26 Jan 2018 15:56:49 -0800 From: Stephen Boyd To: Amit Nischal Cc: Michael Turquette , Andy Gross , David Brown , Rajendra Nayak , Odelu Kukatla , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Taniya Das Subject: Re: [PATCH v2] clk: qcom: Add Global Clock controller (GCC) driver for SDM845 Message-ID: <20180126235649.GF28313@codeaurora.org> References: <1516610736-17088-1-git-send-email-anischal@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516610736-17088-1-git-send-email-anischal@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/22, Amit Nischal wrote: > Add support for the global clock controller found on SDM845 > based devices. This should allow most non-multimedia device > drivers to probe and control their clocks. > > Signed-off-by: Taniya Das Is Taniya the author? Should be a From: line then. > Signed-off-by: Amit Nischal > --- > > This patch is dependent on below changes: > 1. https://patchwork.kernel.org/patch/10139991/ > 2. https://patchwork.kernel.org/patch/10139987/ > 3. https://patchwork.kernel.org/patch/10144621/ Ok. Next time you can send them all again in a series to make it easier for me. > > diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig > index fbf4532..91e4557 100644 > --- a/drivers/clk/qcom/Kconfig > +++ b/drivers/clk/qcom/Kconfig > @@ -226,3 +226,12 @@ config SPMI_PMIC_CLKDIV > Technologies, Inc. SPMI PMIC. It configures the frequency of > clkdiv outputs of the PMIC. These clocks are typically wired > through alternate functions on GPIO pins. > + > +config SDM_GCC_845 > + tristate "SDM845 Global Clock Controller" > + depends on COMMON_CLK_QCOM > + help > + Support for the global clock controller on Qualcomm Technologies, Inc > + sdm845 devices. > + Say Y if you want to use peripheral devices such as UART, SPI, > + i2c, USB, UFS, SD/eMMC, PCIe, etc. Put this in sorted order in the Kconfig? Or at least try to. I should go back and sort the rest later. > diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile > index 230332c..1aa23b3 100644 > --- a/drivers/clk/qcom/Makefile > +++ b/drivers/clk/qcom/Makefile > @@ -29,6 +29,7 @@ obj-$(CONFIG_MSM_GCC_8960) += gcc-msm8960.o > obj-$(CONFIG_MSM_GCC_8974) += gcc-msm8974.o > obj-$(CONFIG_MSM_GCC_8994) += gcc-msm8994.o > obj-$(CONFIG_MSM_GCC_8996) += gcc-msm8996.o > +obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o This should be sorted too. > obj-$(CONFIG_MSM_LCC_8960) += lcc-msm8960.o > obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o > obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o > diff --git a/drivers/clk/qcom/gcc-sdm845.c b/drivers/clk/qcom/gcc-sdm845.c > new file mode 100644 > index 0000000..fe62d87 > --- /dev/null > +++ b/drivers/clk/qcom/gcc-sdm845.c > @@ -0,0 +1,3633 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2018, The Linux Foundation. All rights reserved. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include "common.h" > +#include "clk-regmap.h" > +#include "clk-pll.h" > +#include "clk-rcg.h" > +#include "clk-branch.h" > +#include "clk-alpha-pll.h" > +#include "gdsc.h" > +#include "reset.h" > + > +#define GCC_MMSS_MISC 0x09FFC Please drop the onetime defines. > +#define GCC_GPU_MISC 0x71028 > + > +#define CXO_FREQUENCY 19200000 > + > +#define F(f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) } > + > +static struct freq_tbl cxo_safe_src_f = { const? > + .freq = CXO_FREQUENCY, > + .src = 0, > + .pre_div = 1, > + .m = 0, > + .n = 0, > +}; All those = 0 are useless. But CXO may not always be 19.2 MHz so that's a non-starter. Try and figure out how to get rid of this? > + > +enum { > + P_BI_TCXO, > + P_AUD_REF_CLK, > + P_CORE_BI_PLL_TEST_SE, > + P_GPLL0_OUT_EVEN, > + P_GPLL0_OUT_MAIN, > + P_GPLL4_OUT_MAIN, > + P_SLEEP_CLK, > +}; > + > +static const struct parent_map gcc_parent_map_0[] = { > + { P_BI_TCXO, 0 }, > + { P_GPLL0_OUT_MAIN, 1 }, > + { P_GPLL0_OUT_EVEN, 6 }, > + { P_CORE_BI_PLL_TEST_SE, 7 }, [...] > + > +static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = { > + F(400000, P_BI_TCXO, 12, 1, 4), > + F(9600000, P_BI_TCXO, 2, 0, 0), > + F(19200000, P_BI_TCXO, 1, 0, 0), > + F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0), > + F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0), > + F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0), > + F(201500000, P_GPLL4_OUT_MAIN, 4, 0, 0), > + { } > +}; > + > +static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { > + .cmd_rcgr = 0x1400c, > + .mnd_width = 8, > + .hid_width = 5, > + .parent_map = gcc_parent_map_10, > + .freq_tbl = ftbl_gcc_sdcc2_apps_clk_src, > + .safe_src_freq_tbl = &cxo_safe_src_f, > + .clkr.hw.init = &(struct clk_init_data){ > + .name = "gcc_sdcc2_apps_clk_src", > + .parent_names = gcc_parent_names_10, > + .num_parents = 5, > + .flags = CLK_SET_RATE_PARENT, > + .ops = &clk_rcg2_shared_ops, > + }, > +}; > + > +static const struct freq_tbl ftbl_gcc_sdcc4_apps_clk_src[] = { > + F(400000, P_BI_TCXO, 12, 1, 4), > + F(9600000, P_BI_TCXO, 2, 0, 0), > + F(19200000, P_BI_TCXO, 1, 0, 0), > + F(25000000, P_GPLL0_OUT_MAIN, 12, 1, 2), > + F(50000000, P_GPLL0_OUT_MAIN, 12, 0, 0), > + F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0), > + { } > +}; > + > +static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { > + .cmd_rcgr = 0x1600c, > + .mnd_width = 8, > + .hid_width = 5, > + .parent_map = gcc_parent_map_0, > + .freq_tbl = ftbl_gcc_sdcc4_apps_clk_src, > + .safe_src_freq_tbl = &cxo_safe_src_f, Honestly, why do we need this other structure? Can't we point to the entry in the frequency table for this clk and use that? Or know that these are an RCG, and 99% of the time the "safe frequency" is going to be source 0 and div 1? > + .clkr.hw.init = &(struct clk_init_data){ > + .name = "gcc_sdcc4_apps_clk_src", > + .parent_names = gcc_parent_names_0, > + .num_parents = 4, > + .flags = CLK_SET_RATE_PARENT, > + .ops = &clk_rcg2_shared_ops, [...] > + > +static const struct regmap_config gcc_sdm845_regmap_config = { > + .reg_bits = 32, > + .reg_stride = 4, > + .val_bits = 32, > + .max_register = 0x182090, > + .fast_io = true, > +}; > + > +static const struct qcom_cc_desc gcc_sdm845_desc = { > + .config = &gcc_sdm845_regmap_config, > + .clks = gcc_sdm845_clocks, > + .num_clks = ARRAY_SIZE(gcc_sdm845_clocks), > + .resets = gcc_sdm845_resets, > + .num_resets = ARRAY_SIZE(gcc_sdm845_resets), > + .gdscs = gcc_sdm845_gdscs, > + .num_gdscs = ARRAY_SIZE(gcc_sdm845_gdscs), > +}; > + > +static const struct of_device_id gcc_sdm845_match_table[] = { > + { .compatible = "qcom,gcc-sdm845" }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, gcc_sdm845_match_table); > + > +static int gcc_sdm845_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct regmap *regmap; > + int i, ret = 0; Don't assign things and then reassign them without testing it first. > + > + regmap = qcom_cc_map(pdev, &gcc_sdm845_desc); > + if (IS_ERR(regmap)) > + return PTR_ERR(regmap); > + > + for (i = 0; i < ARRAY_SIZE(gcc_sdm845_hws); i++) { > + ret = devm_clk_hw_register(dev, gcc_sdm845_hws[i]); > + if (ret) > + return ret; > + } > + > + ret = qcom_cc_really_probe(pdev, &gcc_sdm845_desc, regmap); > + if (ret) { > + dev_err(&pdev->dev, "Failed to register GCC clocks\n"); Drop this error message. > + return ret; > + } > + > + /* Disable the GPLL0 active input to MMSS and GPU via MISC registers */ > + regmap_update_bits(regmap, GCC_MMSS_MISC, 0x3, 0x3); > + regmap_update_bits(regmap, GCC_GPU_MISC, 0x3, 0x3); Can bootloaders do this? Or this can be a branch clk that we expose in the tree as the "gpll0" source entry for the multimedia clock controls? Do we ever turn these back on? > + > + dev_info(&pdev->dev, "Registered GCC clocks\n"); Drop. > + > + return ret; > +} > + -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project