From: Jie Luo <quic_luoj@quicinc.com>
To: Stephen Boyd <sboyd@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Conor Dooley <conor+dt@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Rob Herring <robh@kernel.org>, Will Deacon <will@kernel.org>
Cc: <linux-arm-msm@vger.kernel.org>, <linux-clk@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<quic_kkumarcs@quicinc.com>, <quic_suruchia@quicinc.com>,
<quic_pavir@quicinc.com>, <quic_linchen@quicinc.com>,
<quic_leiwei@quicinc.com>, <bartosz.golaszewski@linaro.org>,
<srinivas.kandagatla@linaro.org>
Subject: Re: [PATCH v4 2/4] clk: qcom: Add CMN PLL clock controller driver for IPQ SoC
Date: Thu, 17 Oct 2024 23:35:43 +0800 [thread overview]
Message-ID: <daa8998b-a008-42cf-a941-00218683cce2@quicinc.com> (raw)
In-Reply-To: <77ad972276c165acc3d0e9d72df1a021.sboyd@kernel.org>
On 10/17/2024 5:37 AM, Stephen Boyd wrote:
> Quoting Luo Jie (2024-10-15 07:16:52)
>> diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
>> index 30eb8236c9d8..3def659fc5cb 100644
>> --- a/drivers/clk/qcom/Kconfig
>> +++ b/drivers/clk/qcom/Kconfig
>> @@ -190,6 +190,16 @@ config IPQ_APSS_6018
>> Say Y if you want to support CPU frequency scaling on
>> ipq based devices.
>>
>> +config IPQ_CMN_PLL
>> + tristate "IPQ CMN PLL Clock Controller"
>> + depends on IPQ_GCC_9574
>
> What is the build dependency?
Will remove this dependency. There is no build dependency on
IPQ_GCC_9574, but only a functional dependency on the SoC's GCC block
since the CMNPLL consumes AHB/SYS clocks from the GCC.
>
>> + help
>> + Support for CMN PLL clock controller on IPQ platform. The
>> + CMN PLL feeds the reference clocks to the Ethernet devices
>> + based on IPQ SoC.
>> + Say Y or M if you want to support CMN PLL clock on the IPQ
>> + based devices.
>> +
>> config IPQ_GCC_4019
>> tristate "IPQ4019 Global Clock Controller"
>> help
>> diff --git a/drivers/clk/qcom/ipq-cmn-pll.c b/drivers/clk/qcom/ipq-cmn-pll.c
>> new file mode 100644
>> index 000000000000..f5ebc7d93ed8
>> --- /dev/null
>> +++ b/drivers/clk/qcom/ipq-cmn-pll.c
>> @@ -0,0 +1,411 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>> + */
>> +
>> +/*
>> + * CMN PLL block expects the reference clock from on-board Wi-Fi block,
>> + * and supplies fixed rate clocks as output to the networking hardware
>> + * blocks and to GCC. The networking related blocks include PPE (packet
>> + * process engine), the externally connected PHY or switch devices, and
>> + * the PCS.
>> + *
>> + * On the IPQ9574 SoC, there are three clocks with 50 MHZ and one clock
>> + * with 25 MHZ which are output from the CMN PLL to Ethernet PHY (or switch),
>> + * and one clock with 353 MHZ to PPE. The other fixed rate output clocks
>> + * are supplied to GCC (24 MHZ as XO and 32 KHZ as sleep clock), and to PCS
>> + * with 31.25 MHZ.
>> + *
>> + * +---------+
>> + * | GCC |
>> + * +--+---+--+
>> + * AHB CLK| |SYS CLK
>> + * V V
>> + * +-------+---+------+
>> + * | +-------------> eth0-50mhz
>> + * REF CLK | IPQ9574 |
>> + * -------->+ +-------------> eth1-50mhz
>> + * | CMN PLL block |
>> + * | +-------------> eth2-50mhz
>> + * | |
>> + * +----+----+----+---+-------------> eth-25mhz
>> + * | | |
>> + * V V V
>> + * GCC PCS NSS/PPE
>> + */
>> +
>> +#include <linux/bitfield.h>
>> +#include <linux/clk-provider.h>
>> +#include <linux/clk.h>
>> +#include <linux/delay.h>
>> +#include <linux/err.h>
>> +#include <linux/io.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_address.h>
>
> What is of_address.h for? Did you mean mod_devicetable.h?
I will replace of_address.h with mod_devicetable.h for 'of_device_id'
structure usage.
>
>> +#include <linux/platform_device.h>
>> +#include <linux/pm_clock.h>
>> +#include <linux/pm_runtime.h>
>> +#include <linux/regmap.h>
>> +
>> +#include <dt-bindings/clock/qcom,ipq-cmn-pll.h>
>> +
>> +#define CMN_PLL_REFCLK_SRC_SELECTION 0x28
>> +#define CMN_PLL_REFCLK_SRC_DIV GENMASK(9, 8)
>> +
>> +#define CMN_PLL_LOCKED 0x64
>> +#define CMN_PLL_CLKS_LOCKED BIT(8)
>> +
>> +#define CMN_PLL_POWER_ON_AND_RESET 0x780
>> +#define CMN_ANA_EN_SW_RSTN BIT(6)
>> +
>> +#define CMN_PLL_REFCLK_CONFIG 0x784
>> +#define CMN_PLL_REFCLK_EXTERNAL BIT(9)
>> +#define CMN_PLL_REFCLK_DIV GENMASK(8, 4)
> [...]
>> +
>> +/*
>> + * This function is used to initialize the CMN PLL to enable the fixed
>> + * rate output clocks. It is expected to be configured once.
>> + */
>> +static int clk_cmn_pll_determine_rate(struct clk_hw *hw,
>> + struct clk_rate_request *req)
>> +{
>> + struct clk_cmn_pll *cmn_pll = to_clk_cmn_pll(hw);
>> + u32 val;
>> + int ret;
>> +
>> + /*
>> + * Configure the reference input clock selection as per the given
>> + * parent clock. The output clock rates are always of fixed value.
>> + */
>> + switch (req->best_parent_rate) {
>> + case 25000000:
>> + val = 3;
>> + break;
>> + case 31250000:
>> + val = 4;
>> + break;
>> + case 40000000:
>> + val = 6;
>> + break;
>> + case 50000000:
>> + val = 8;
>> + break;
>> + case 48000000:
>> + case 96000000:
>> + /*
>> + * Parent clock rate 48 MHZ and 96 MHZ take the same value
>> + * of reference clock index. 96 MHZ needs the source clock
>> + * divider to be programmed as 2.
>> + */
>> + val = 7;
>> + break;
>> + default:
>> + return -EINVAL;
>> + }
>> +
>> + ret = regmap_update_bits(cmn_pll->regmap, CMN_PLL_REFCLK_CONFIG,
>> + CMN_PLL_REFCLK_INDEX,
>> + FIELD_PREP(CMN_PLL_REFCLK_INDEX, val));
>
> The determine_rate() function shouldn't modify the hardware. This should
> be done in the set_rate() callback. Likely you'll need to use
> assigned-clock-rates to do that.
OK. I will move the hardware configuration code into clk_ops::set_rate().
We are using the DT property assigned-clock-rates-u64 to configure the
clock rate of CMN PLL to 12 GHZ since 64 bits are required.
next prev parent reply other threads:[~2024-10-17 15:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 14:16 [PATCH v4 0/4] Add CMN PLL clock controller driver for IPQ9574 Luo Jie
2024-10-15 14:16 ` [PATCH v4 1/4] dt-bindings: clock: qcom: Add CMN PLL clock controller for IPQ SoC Luo Jie
2024-10-15 14:16 ` [PATCH v4 2/4] clk: qcom: Add CMN PLL clock controller driver " Luo Jie
2024-10-16 21:37 ` Stephen Boyd
2024-10-17 15:35 ` Jie Luo [this message]
2024-10-17 17:40 ` Stephen Boyd
2024-10-18 6:49 ` Jie Luo
2024-10-15 14:16 ` [PATCH v4 3/4] arm64: defconfig: Enable Qualcomm IPQ CMN PLL clock controller Luo Jie
2024-10-15 14:16 ` [PATCH v4 4/4] arm64: dts: qcom: Add CMN PLL node for IPQ9574 SoC Luo Jie
2024-10-17 22:32 ` Dmitry Baryshkov
2024-10-18 6:54 ` Jie Luo
2024-10-18 8:11 ` Dmitry Baryshkov
2024-10-18 14:03 ` Jie Luo
2024-10-18 15:38 ` Dmitry Baryshkov
2024-10-23 13:05 ` Jie Luo
2024-10-25 14:05 ` Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=daa8998b-a008-42cf-a941-00218683cce2@quicinc.com \
--to=quic_luoj@quicinc.com \
--cc=andersson@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=quic_kkumarcs@quicinc.com \
--cc=quic_leiwei@quicinc.com \
--cc=quic_linchen@quicinc.com \
--cc=quic_pavir@quicinc.com \
--cc=quic_suruchia@quicinc.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox