devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leonard Crestez <leonard.crestez@nxp.com>
To: Anson Huang <anson.huang@nxp.com>
Cc: dl-linux-imx <linux-imx@nxp.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"festevam@gmail.com" <festevam@gmail.com>,
	"mturquette@baylibre.com" <mturquette@baylibre.com>,
	"sboyd@kernel.org" <sboyd@kernel.org>,
	Aisheng Dong <aisheng.dong@nxp.com>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-clk@vger.kernel.org"
	<linux-clk@vger.kernel.org>"viresh.kumar@linaro.org" <vi>
Subject: Re: [PATCH V2 2/2] clk: imx: scu: add cpu frequency scaling support
Date: Wed, 13 Feb 2019 13:53:04 +0000	[thread overview]
Message-ID: <59b181b77605f516b0e3a896ddce0224b4504b30.camel@nxp.com> (raw)
In-Reply-To: <1550064410-28417-2-git-send-email-Anson.Huang@nxp.com>

On Wed, 2019-02-13 at 13:32 +0000, Anson Huang wrote:
> On NXP's i.MX SoCs with system controller inside, CPU frequency
> scaling can ONLY be done by system controller firmware, and it
> can ONLY be requested from secure mode, so Linux kernel has to
> call ARM SMC to trap to ARM-Trusted-Firmware to request system
> controller firmware to do CPU frequency scaling.

> +#ifdef CONFIG_CPUFREQ_DT
> +#define IMX_SIP_CPUFREQ			0xC2000001
> +#define IMX_SIP_SET_CPUFREQ		0x00
> +
>  static struct imx_sc_ipc *ccm_ipc_handle;

Without CONFIG_CPUFREQ_DT the ccm_ipc_handle won't be defined and build
will break.

But is there a good reason for ifdef? In general clock function are
compiled even if no driver is calling them.

> +#ifdef CONFIG_CPUFREQ_DT
> +	/* CPU clock can ONLY be done by TF-A */
> +	if (clk->clk_type == IMX_SC_PM_CLK_CPU) {
> +		struct arm_smccc_res res;
> +		unsigned int cluster_id;
> +		int i;
> +
> +		for (i = 0; i < ARRAY_SIZE(imx_sc_cpufreq_data); i++) {
> +			if (!strcmp(clk_hw_get_name(hw),
> +				imx_sc_cpufreq_data[i].clk_name)) {
> +				cluster_id = imx_sc_cpufreq_data[i].cluster_id;
> +				break;
> +			}
> +		}
> +
> +		/*
> +		 * As some other clock types have same value as
> +		 * IMX_SC_PM_CLK_CPU, so we need to double check
> +		 * the clock being scaled is indeed CPU clock which
> +		 * matches the table we define.
> +		 */
> +		if (i < ARRAY_SIZE(imx_sc_cpufreq_data)) {
> +			arm_smccc_smc(IMX_SIP_CPUFREQ, IMX_SIP_SET_CPUFREQ,
> +				cluster_id, rate, 0, 0, 0, 0, &res);
> +			return 0;
> +		}
> +	}
> +#endif

The code inside the ifdef would look better in a separate
imx_clk_atf_set_rate function. Maybe even separate clk_ops?


  reply	other threads:[~2019-02-13 13:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 13:32 [PATCH V2 1/2] arm64: dts: freescale: imx8qxp: add cpu opp table Anson Huang
2019-02-13 13:32 ` [PATCH V2 2/2] clk: imx: scu: add cpu frequency scaling support Anson Huang
2019-02-13 13:53   ` Leonard Crestez [this message]
2019-02-13 14:02     ` Anson Huang

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=59b181b77605f516b0e3a896ddce0224b4504b30.camel@nxp.com \
    --to=leonard.crestez@nxp.com \
    --cc=aisheng.dong@nxp.com \
    --cc=anson.huang@nxp.com \
    --cc=daniel.baluta@nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@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;
as well as URLs for NNTP newsgroup(s).