From: Stephen Boyd <sboyd@kernel.org>
To: Jesse Taube <mr.bossman075@gmail.com>, linux-imx@nxp.com
Cc: robh+dt@kernel.org, mturquette@baylibre.com, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, aisheng.dong@nxp.com, stefan@agner.ch,
linus.walleij@linaro.org, daniel.lezcano@linaro.org,
tglx@linutronix.de, arnd@arndb.de, olof@lixom.net,
soc@kernel.org, linux@armlinux.org.uk, abel.vesa@nxp.com,
dev@lynxeye.de, marcel.ziswiler@toradex.com,
tharvey@gateworks.com, leoyang.li@nxp.com,
sebastian.reichel@collabora.com, cniedermaier@dh-electronics.com,
Mr.Bossman075@gmail.com, clin@suse.com,
giulio.benetti@benettiengineering.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH v1 08/12] clk: imx: Add initial support for i.MXRT1170 clock driver
Date: Fri, 22 Apr 2022 20:03:29 -0700 [thread overview]
Message-ID: <20220423030331.0E85CC385A0@smtp.kernel.org> (raw)
In-Reply-To: <20220326144313.673549-9-Mr.Bossman075@gmail.com>
Quoting Jesse Taube (2022-03-26 07:43:09)
> diff --git a/drivers/clk/imx/clk-imxrt1170.c b/drivers/clk/imx/clk-imxrt1170.c
> new file mode 100644
> index 000000000000..041aea3d4b02
> --- /dev/null
> +++ b/drivers/clk/imx/clk-imxrt1170.c
> @@ -0,0 +1,391 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
> +/*
> + * Copyright (C) 2022
> + * Author(s):
> + * Jesse Taube <Mr.Bossman075@gmail.com>
> + */
> +#include <linux/clk.h>
> +#include <linux/of_address.h>
Is this include used?
> +#include <linux/of_irq.h>
Is this include used?
> +#include <linux/platform_device.h>
Need to include clk-provider.h
> +#include <dt-bindings/clock/imxrt1170-clock.h>
> +
> +#include "clk.h"
> +
> +#define CLOCK_MUX_DEFAULT "rcosc48M_div2", "osc", "rcosc400M", "rcosc16M"
> +
> +#define LPCG_GATE(gate) (0x6000 + (gate * 0x20))
> +
> +#define DEF_CLOCK(flags, macro, name) \
> +do { \
> + hws[macro##_SEL] = imx_clk_hw_mux(#name"_sel", ccm_base + (name * 0x80), \
> + 8, 3, root_clocks[name], 8); \
> + hws[macro##_GATE] = imx_clk_hw_gate_dis_flags(#name"_gate", #name"_sel", \
> + ccm_base + (name * 0x80), 24, flags); \
> + hws[macro] = imx_clk_hw_divider(#name, #name"_gate", ccm_base + (name * 0x80), 0, 8); \
> +} while (0)
> +
> +enum root_clock_names {
> + m7, /* root clock m7. */
Is the comment adding any value? It has the enum name after "root clock"
and the enum is "root_clock_names" so it looks very obvious.
> + m4, /* root clock m4. */
> + bus, /* root clock bus. */
> + bus_lpsr, /* root clock bus lpsr. */
[...]
> + end, /* root clock end. */
> +};
> +
> +static const char * const root_clocks[79][8] = {
> + {CLOCK_MUX_DEFAULT, "pll_arm", "pll1_sys", "pll3_sys", "pll_video"},
Space after { and before }
> + {CLOCK_MUX_DEFAULT, "pll3_pfd3", "pll3_sys", "pll2_sys", "pll1_div5"},
> + {CLOCK_MUX_DEFAULT, "pll3_sys", "pll1_div5", "pll2_sys", "pll2_pfd3"},
[...]
> + {CLOCK_MUX_DEFAULT, "pll2_pfd3", "rcosc48M", "pll3_pfd1", "pll_audio"}
> +};
> +
> +static const char * const pll_arm_mux[] = {"pll_arm_pre", "osc"};
> +static const char * const pll3_mux[] = {"pll3_pre", "osc"};
> +static const char * const pll2_mux[] = {"pll2_pre", "osc"};
> +
> +static const struct clk_div_table post_div_table[] = {
> + { .val = 3, .div = 1, },
> + { .val = 2, .div = 8, },
> + { .val = 1, .div = 4, },
> + { .val = 0, .div = 2, },
> + { }
> +};
> +
> +static struct clk_hw **hws;
> +static struct clk_hw_onecell_data *clk_hw_data;
Do either of these need to be static global variables? They could be
local function pointers allocated on the heap (like they already are).
> +
> +static int imxrt1170_clocks_probe(struct platform_device *pdev)
> +{
[...]
> + hws[IMXRT1170_CLK_PLL2_PFD3] = imx_clk_hw_pfd("pll2_pfd3", "pll2_sys", pll_base + 0x270, 3);
> +
> + /* CCM clocks */
> + ccm_base = devm_platform_ioremap_resource(pdev, 0);
> + if (WARN_ON(IS_ERR(ccm_base)))
> + return PTR_ERR(ccm_base);
> +
> + DEF_CLOCK(CLK_IS_CRITICAL, IMXRT1170_CLK_M7, m7);
Don't have macros do things to variables that are in global scope. It
makes things very non-obvious. Instead, pass hw to the macro, or better
yet make a static inline function and let the compiler decide to inline
it or not.
> + DEF_CLOCK(CLK_IS_CRITICAL, IMXRT1170_CLK_M4, m4);
[...]
> + DEF_CLOCK(0, IMXRT1170_CLK_CSI2_UI, csi2_ui);
> + DEF_CLOCK(0, IMXRT1170_CLK_CSI, csi);
> + DEF_CLOCK(0, IMXRT1170_CLK_CKO1, cko1);
> + DEF_CLOCK(0, IMXRT1170_CLK_CKO2, cko2);
> +
> + hws[IMXRT1170_CLK_USB] = imx_clk_hw_gate("usb", "bus", ccm_base + LPCG_GATE(115), 0);
> +
> + clk_set_rate(hws[IMXRT1170_CLK_PLL_ARM]->clk, 90000000);
Use assigned-clock-rates?
> +
> + imx_check_clk_hws(hws, IMXRT1170_CLK_END);
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-04-23 3:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-26 14:43 [PATCH v1 00/12] Add support for the i.MXRT1170-evk Jesse Taube
2022-03-26 14:43 ` [PATCH v1 01/12] dt-bindings: arm: imx: Add i.MXRT compatible Documentation Jesse Taube
2022-03-27 19:04 ` Krzysztof Kozlowski
2022-03-26 14:43 ` [PATCH v1 02/12] dt-bindings: timer: gpt: " Jesse Taube
2022-03-27 19:06 ` Krzysztof Kozlowski
2022-03-26 14:43 ` [PATCH v1 03/12] dt-bindings: pinctrl: add i.MXRT1170 pinctrl Documentation Jesse Taube
2022-03-27 19:08 ` Krzysztof Kozlowski
2022-03-27 19:14 ` Jesse Taube
2022-03-27 19:30 ` Krzysztof Kozlowski
2022-03-26 14:43 ` [PATCH v1 04/12] dt-bindings: clock: imx: Add documentation for i.MXRT1170 clock Jesse Taube
2022-03-27 19:12 ` Krzysztof Kozlowski
2022-03-26 14:43 ` [PATCH v1 05/12] ARM: mach-imx: Add support for i.MXRT1170 Jesse Taube
2022-03-26 14:43 ` [PATCH v1 06/12] ARM: clk: imx: Update pllv3 to support i.MXRT1170 Jesse Taube
2022-04-10 8:10 ` Shawn Guo
2022-03-26 14:43 ` [PATCH v1 07/12] dt-bindings: imx: Add clock binding for i.MXRT1170 Jesse Taube
2022-03-27 19:13 ` Krzysztof Kozlowski
2022-03-26 14:43 ` [PATCH v1 08/12] clk: imx: Add initial support for i.MXRT1170 clock driver Jesse Taube
2022-04-23 3:03 ` Stephen Boyd [this message]
2022-04-23 16:11 ` Jesse Taube
2022-04-24 3:53 ` Jesse Taube
2022-04-23 17:46 ` Abel Vesa
2022-03-26 14:43 ` [PATCH v1 09/12] pinctrl: freescale: Add i.MXRT1170 pinctrl driver support Jesse Taube
2022-03-26 14:43 ` [PATCH v1 10/12] ARM: dts: imxrt1170-pinfunc: Add pinctrl binding header Jesse Taube
2022-03-26 14:43 ` [PATCH v1 11/12] ARM: dts: imx: Add i.MXRT1170-EVK support Jesse Taube
2022-03-27 19:17 ` Krzysztof Kozlowski
2022-03-26 14:43 ` [PATCH v1 12/12] ARM: imxrt_defconfig: Add i.MXRT1170 Jesse Taube
2022-03-27 19:23 ` Krzysztof Kozlowski
2022-03-27 19:37 ` Jesse Taube
2022-04-10 2:39 ` [PATCH v1 00/12] Add support for the i.MXRT1170-evk Jesse Taube
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=20220423030331.0E85CC385A0@smtp.kernel.org \
--to=sboyd@kernel.org \
--cc=abel.vesa@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=arnd@arndb.de \
--cc=clin@suse.com \
--cc=cniedermaier@dh-electronics.com \
--cc=daniel.lezcano@linaro.org \
--cc=dev@lynxeye.de \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=giulio.benetti@benettiengineering.com \
--cc=kernel@pengutronix.de \
--cc=leoyang.li@nxp.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=marcel.ziswiler@toradex.com \
--cc=mr.bossman075@gmail.com \
--cc=mturquette@baylibre.com \
--cc=olof@lixom.net \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sebastian.reichel@collabora.com \
--cc=shawnguo@kernel.org \
--cc=soc@kernel.org \
--cc=stefan@agner.ch \
--cc=tglx@linutronix.de \
--cc=tharvey@gateworks.com \
/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).