Skip to contentSkip to conversation

add clk controller driver for Meson-AXG SoC

PATCH Superseded Yixun Lan 5 participants 16 messages Nov 28, 2017 – Dec 6, 2017

Subsystems (5)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Yixun Lan

author
#0 lore raw

v3 cover add clk controller driver for Meson-AXG SoC

Add driver for the clk controller which found in Meson AXG SoC

Note, we deliberately create a seperate source file for the Meson AXG
series, instead of sharing code with previous GXBB/GXL - the file axg.c It would help us maintaining the code more easily.

Changes since v2 [2]:
- drop register offset calculation
- update dt-bindings for new compatible variant

Changes since v1 [1]:
- rework register definion, use '(offset << 2)' to better match the description from data sheet
- drop "#include dt-bindings/clock/gxbb-aoclkc.h" from dts
- rebase code to v4.15-rc1

[2]
http://lists.infradead.org/pipermail/linux-amlogic/2017-November/005468.html
http://lists.infradead.org/pipermail/linux-amlogic/2017-November/005469.html
http://lists.infradead.org/pipermail/linux-amlogic/2017-November/005470.html

[1]
http://lists.infradead.org/pipermail/linux-amlogic/2017-November/005239.html
http://lists.infradead.org/pipermail/linux-amlogic/2017-November/005240.html
http://lists.infradead.org/pipermail/linux-amlogic/2017-November/005241.html

Qiufang Dai (2):
clk: meson-axg: add clock controller drivers
arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

Yixun Lan (1):
dt-bindings: clock: add compatible variant for the Meson-AXG

 .../bindings/clock/amlogic,gxbb-clkc.txt           |   7 +-
 arch/arm64/Kconfig.platforms                       |   1 +
 arch/arm64/boot/dts/amlogic/meson-axg.dtsi         |  15 +
 drivers/clk/meson/Kconfig                          |   8 +
 drivers/clk/meson/Makefile                         |   1 +
 drivers/clk/meson/axg.c                            | 948 +++++++++++++++++++++
 drivers/clk/meson/axg.h                            | 126 +++
 include/dt-bindings/clock/axg-clkc.h               |  72 ++
 8 files changed, 1176 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/meson/axg.c
 create mode 100644 drivers/clk/meson/axg.h
 create mode 100644 include/dt-bindings/clock/axg-clkc.h
Signature · 1 line
2.15.0
author
#1 lore raw

PATCH v3 1/3 dt-bindings: clock: add compatible variant for the Meson-AXG

Update the documentation to support clock driver for the Amlogic's Meson-AXG SoC.

---
 Documentation/devicetree/bindings/clock/amlogic,gxbb-clkc.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/amlogic,gxbb-clkc.txt +5 -2
index 924040769186..e2b377ed6f91 100644
@@ -5,8 +5,11 @@ controllers within the SoC.
 
 Required Properties:
 
-- compatible: should be "amlogic,gxbb-clkc" for GXBB SoC,
-	      or "amlogic,gxl-clkc" for GXL and GXM SoC.
+- compatible: should be:
+		"amlogic,gxbb-clkc" for GXBB SoC,
+		"amlogic,gxl-clkc" for GXL and GXM SoC,
+		"amlogic,axg-clkc" for AXG SoC.
+
 - reg: physical base address of the clock controller and length of memory
        mapped region.
 
Signature · 1 line
2.15.0
author
#3 lore raw

PATCH v3 2/3 clk: meson-axg: add clock controller drivers

In reply to Yixun Lan

From: Qiufang Dai <[email protected]>

Add clock controller drivers for Amlogic Meson-AXG SoC.

---
 arch/arm64/Kconfig.platforms         |   1 +
 drivers/clk/meson/Kconfig            |   8 +
 drivers/clk/meson/Makefile           |   1 +
 drivers/clk/meson/axg.c              | 948 +++++++++++++++++++++++++++++++++++
 drivers/clk/meson/axg.h              | 126 +++++
 include/dt-bindings/clock/axg-clkc.h |  72 +++
 6 files changed, 1156 insertions(+)
 create mode 100644 drivers/clk/meson/axg.c
 create mode 100644 drivers/clk/meson/axg.h
 create mode 100644 include/dt-bindings/clock/axg-clkc.h
arch/arm64/Kconfig.platforms +1 -0
index 2401373565ff..fbedbd8f619a 100644
@@ -105,6 +105,7 @@ config ARCH_MESON
 	select PINCTRL_MESON
 	select COMMON_CLK_AMLOGIC
 	select COMMON_CLK_GXBB
+	select COMMON_CLK_AXG
 	select MESON_IRQ_GPIO
 	help
 	  This enables support for the Amlogic S905 SoCs.
drivers/clk/meson/Kconfig +8 -0
index d2d0174a6eca..7694302c70a4 100644
@@ -19,3 +19,11 @@ config COMMON_CLK_GXBB
 	help
 	  Support for the clock controller on AmLogic S905 devices, aka gxbb.
 	  Say Y if you want peripherals and CPU frequency scaling to work.
+
+config COMMON_CLK_AXG
+	bool
+	depends on COMMON_CLK_AMLOGIC
+	select RESET_CONTROLLER
+	help
+	  Support for the clock controller on AmLogic A113D devices, aka axg.
+	  Say Y if you want peripherals and CPU frequency scaling to work.
drivers/clk/meson/Makefile +1 -0
index b139d41b25da..3c03ce583798 100644
@@ -5,3 +5,4 @@
 obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o clk-audio-divider.o
 obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
 obj-$(CONFIG_COMMON_CLK_GXBB)	 += gxbb.o gxbb-aoclk.o gxbb-aoclk-regmap.o gxbb-aoclk-32k.o
+obj-$(CONFIG_COMMON_CLK_AXG)	 += axg.o
drivers/clk/meson/axg.c new file +948 -0

948 lines not on this page · raw message

drivers/clk/meson/axg.h new file +126 -0

126 lines not on this page · raw message

include/dt-bindings/clock/axg-clkc.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.15.0
author
#9 lore raw

PATCH v3 3/3 arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

In reply to Yixun Lan

From: Qiufang Dai <[email protected]>

Try to add Hiubus DT info, and also enable clock DT info for the Amlogic's Meson-AXG SoC.

---
 arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +15 -0
index b932a784b02a..36a2e98338a8 100644
@@ -7,6 +7,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/axg-clkc.h>
 
 / {
 	compatible = "amlogic,meson-axg";
@@ -148,6 +149,20 @@
 			#address-cells = <0>;
 		};
 
+		hiubus: hiubus at ff63c000 {
+			compatible = "simple-bus";
+			reg = <0x0 0xff63c000 0x0 0x1c00>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xff63c000 0x0 0x1c00>;
+
+			clkc: clock-controller at 0 {
+				compatible = "amlogic,axg-clkc";
+				#clock-cells = <1>;
+				reg = <0x0 0x0 0x0 0x320>;
+			};
+		};
+
 		mailbox: mailbox at ff63dc00 {
 			compatible = "amlogic,meson-gx-mhu", "amlogic,meson-gxbb-mhu";
 			reg = <0 0xff63dc00 0 0x400>;
Signature · 1 line
2.15.0
maintainer Acked-by on v3 2/3
#4 lore raw

Re: [PATCH v3 2/3] clk: meson-axg: add clock controller drivers

In reply to Yixun Lan
Quoted 6 lines · Yixun Lan

From: Qiufang Dai <[email protected]>

Add clock controller drivers for Amlogic Meson-AXG SoC.

Quoted 8 lines
---
 arch/arm64/Kconfig.platforms         |   1 +
 drivers/clk/meson/Kconfig            |   8 +
 drivers/clk/meson/Makefile           |   1 +
 drivers/clk/meson/axg.c              | 948 +++++++++++++++++++++++++++++++++++
 drivers/clk/meson/axg.h              | 126 +++++
 include/dt-bindings/clock/axg-clkc.h |  72 +++

This belongs in the binding patch.

Otherwise,

Quoted 4 lines
 6 files changed, 1156 insertions(+)
 create mode 100644 drivers/clk/meson/axg.c
 create mode 100644 drivers/clk/meson/axg.h
 create mode 100644 include/dt-bindings/clock/axg-clkc.h
author
#5 lore raw

Re: [PATCH v3 2/3] clk: meson-axg: add clock controller drivers

HI Rob

Quoted 14 lines · Rob Herring
Quoted 12 lines · Yixun Lan

From: Qiufang Dai <[email protected]>

Add clock controller drivers for Amlogic Meson-AXG SoC.

---
 arch/arm64/Kconfig.platforms         |   1 +
 drivers/clk/meson/Kconfig            |   8 +
 drivers/clk/meson/Makefile           |   1 +
 drivers/clk/meson/axg.c              | 948 +++++++++++++++++++++++++++++++++++
 drivers/clk/meson/axg.h              | 126 +++++
Quoted 4 lines
Quoted 1 line
 include/dt-bindings/clock/axg-clkc.h |  72 +++

This belongs in the binding patch.

is it Ok to keep it in this patch?
the initial idea to do this is to keep the commit bisectable..

Quoted 12 lines

Otherwise,

Quoted 4 lines
 6 files changed, 1156 insertions(+)
 create mode 100644 drivers/clk/meson/axg.c
 create mode 100644 drivers/clk/meson/axg.h
 create mode 100644 include/dt-bindings/clock/axg-clkc.h

.

#6 lore raw

Re: [PATCH v3 2/3] clk: meson-axg: add clock controller drivers

In reply to Yixun Lan
Quoted 19 lines · Yixun Lan
drivers/clk/meson/axg.c new file +13 -0
new file mode 100644
index 000000000000..51c5b4062715
@@ -0,0 +1,948 @@
+/*
+ * AmLogic Meson-AXG Clock Controller Driver
+ *
+ * Copyright (c) 2016 Baylibre SAS.
+ * Author: Michael Turquette <[email protected]>
+ *
+ * Copyright (c) 2017 Amlogic, inc.
+ * Author: Qiufang Dai <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <linux/clk.h>

drivers/clk/meson/axg.c line 23

Quoted 10 lines
drivers/clk/meson/axg.c new file +10 -0
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/init.h>
+
+#include "clkc.h"
+#include "axg.h"
+
+static DEFINE_SPINLOCK(clk_lock);

meson_axg_clk_lock?

Quoted 12 lines
drivers/clk/meson/axg.c new file +12 -0
+
+static const struct pll_rate_table sys_pll_rate_table[] = {
+	PLL_RATE(24000000, 56, 1, 2),
+	PLL_RATE(48000000, 64, 1, 2),
+	PLL_RATE(72000000, 72, 1, 2),
+	PLL_RATE(96000000, 64, 1, 2),
+	PLL_RATE(120000000, 80, 1, 2),
+	PLL_RATE(144000000, 96, 1, 2),
+	PLL_RATE(168000000, 56, 1, 1),
+	PLL_RATE(192000000, 64, 1, 1),
+	PLL_RATE(216000000, 72, 1, 1),
+	PLL_RATE(240000000, 80, 1, 1),

[...]

Quoted 8 lines
drivers/clk/meson/axg.c new file +8 -0
+
+static const struct clkc_data axg_clkc_data = {
+	.clk_gates = axg_clk_gates,
+	.clk_gates_count = ARRAY_SIZE(axg_clk_gates),
+	.clk_mplls = axg_clk_mplls,
+	.clk_mplls_count = ARRAY_SIZE(axg_clk_mplls),
+	.clk_plls = axg_clk_plls,
+	.clk_plls_count = ARRAY_SIZE(axg_clk_plls),

drivers/clk/meson/axg.c line 874

Quoted 10 lines
drivers/clk/meson/axg.c new file +10 -0
+	.clk_muxes = axg_clk_muxes,
+	.clk_muxes_count = ARRAY_SIZE(axg_clk_muxes),
+	.clk_dividers = axg_clk_dividers,
+	.clk_dividers_count = ARRAY_SIZE(axg_clk_dividers),
+	.hw_onecell_data = &axg_hw_onecell_data,
+};
+
+static const struct of_device_id clkc_match_table[] = {
+	{ .compatible = "amlogic,axg-clkc", .data = &axg_clkc_data },
+	{},

Nitpick: Drop the comma. Nothing comes after this.

Quoted 5 lines
drivers/clk/meson/axg.c new file +5 -0
+};
+
+static int axg_clkc_probe(struct platform_device *pdev)
+{
+	const struct clkc_data *clkc_data;

drivers/clk/meson/axg.c line 889

Quoted 10 lines
drivers/clk/meson/axg.c new file +10 -0
+	void __iomem *clk_base;
+	int ret, clkid, i;
+	struct device *dev = &pdev->dev;
+
+	clkc_data = of_device_get_match_data(&pdev->dev);
+	if (!clkc_data)
+		return -EINVAL;
+
+	/*  Generic clocks and PLLs */
+	clk_base = of_iomap(dev->of_node, 0);

Use platform device APIs for ioremapping?

Quoted 21 lines
drivers/clk/meson/axg.c new file +21 -0
+	if (!clk_base) {
+		pr_err("%s: Unable to map clk base\n", __func__);
+		return -ENXIO;
+	}
+
+	/* Populate base address for PLLs */
+	for (i = 0; i < clkc_data->clk_plls_count; i++)
+		clkc_data->clk_plls[i]->base = clk_base;
+
+	/* Populate base address for MPLLs */
+	for (i = 0; i < clkc_data->clk_mplls_count; i++)
+		clkc_data->clk_mplls[i]->base = clk_base;
+
+	/* Populate base address for gates */
+	for (i = 0; i < clkc_data->clk_gates_count; i++)
+		clkc_data->clk_gates[i]->reg = clk_base +
+			(u64)clkc_data->clk_gates[i]->reg;
+
+	/* Populate base address for muxes */
+	for (i = 0; i < clkc_data->clk_muxes_count; i++)
+		clkc_data->clk_muxes[i]->reg = clk_base +

drivers/clk/meson/axg.c line 920

Quoted 10 lines
drivers/clk/meson/axg.c new file +10 -0
+			(u64)clkc_data->clk_muxes[i]->reg;
+
+	/* Populate base address for dividers */
+	for (i = 0; i < clkc_data->clk_dividers_count; i++)
+		clkc_data->clk_dividers[i]->reg = clk_base +
+			(u64)clkc_data->clk_dividers[i]->reg;
+
+	/*
+	 * register all clks
+	 */

Yes, that's obvious..

Quoted 34 lines
drivers/clk/meson/axg.c new file +28 -0
+	for (clkid = 0; clkid < clkc_data->hw_onecell_data->num; clkid++) {
+		/* array might be sparse */
+		if (!clkc_data->hw_onecell_data->hws[clkid])
+			continue;
+
+		ret = devm_clk_hw_register(dev,
+					clkc_data->hw_onecell_data->hws[clkid]);
+		if (ret)
+			goto iounmap;
+	}
+
+	return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
+			clkc_data->hw_onecell_data);
+
+iounmap:
+	iounmap(clk_base);
+	return ret;
+}
+
+static struct platform_driver axg_driver = {
+	.probe		= axg_clkc_probe,
+	.driver		= {
+		.name	= "axg-clkc",
+		.of_match_table = clkc_match_table,
+	},
+};
+
+builtin_platform_driver(axg_driver);
include/dt-bindings/clock/axg-clkc.h new file +0 -0
new file mode 100644
index 000000000000..d2c0f49ba0df

include/dt-bindings/clock/axg-clkc.h line 6

Quoted 6 lines
include/dt-bindings/clock/axg-clkc.h new file +6 -0
@@ -0,0 +1,72 @@
+/*
+ * Meson-AXG clock tree IDs
+ *
+ * Copyright (c) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: (GPL-2.0+ OR MIT)

There's a standard way to add these it seems. They should be the first line in the file and look like

/* SPDX-License-Identifier: */

for header files and

// SPDX-License-Identifier:

for C files.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#10 lore raw

Re: [PATCH v3 3/3] arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

In reply to Yixun Lan
Quoted 13 lines · Yixun Lan
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
index b932a784b02a..36a2e98338a8 100644
@@ -7,6 +7,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/axg-clkc.h>
 
 / {
 	compatible = "amlogic,meson-axg";

arch/arm64/boot/dts/amlogic/meson-axg.dtsi line 152

Quoted 4 lines
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
@@ -148,6 +149,20 @@
 			#address-cells = <0>;
 		};
 
+		hiubus: hiubus at ff63c000 {

Maybe just call the node "bus at ff63c000"?

Quoted 19 lines
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +13 -0
+			compatible = "simple-bus";
+			reg = <0x0 0xff63c000 0x0 0x1c00>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xff63c000 0x0 0x1c00>;
+
+			clkc: clock-controller at 0 {
+				compatible = "amlogic,axg-clkc";
+				#clock-cells = <1>;
+				reg = <0x0 0x0 0x0 0x320>;
+			};
+		};
+
 		mailbox: mailbox at ff63dc00 {
 			compatible = "amlogic,meson-gx-mhu", "amlogic,meson-gxbb-mhu";
 			reg = <0 0xff63dc00 0 0x400>;
Signature · 1 line
2.15.0
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#7 lore raw

Re: [PATCH v3 2/3] clk: meson-axg: add clock controller drivers

In reply to Stephen Boyd

Hi Stephen

Quoted 24 lines · Stephen Boyd
Quoted 23 lines · Yixun Lan
drivers/clk/meson/axg.c new file +17 -0
new file mode 100644
index 000000000000..51c5b4062715
@@ -0,0 +1,948 @@
+/*
+ * AmLogic Meson-AXG Clock Controller Driver
+ *
+ * Copyright (c) 2016 Baylibre SAS.
+ * Author: Michael Turquette <[email protected]>
+ *
+ * Copyright (c) 2017 Amlogic, inc.
+ * Author: Qiufang Dai <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
Quoted 9 lines

drivers/clk/meson/axg.c line 23

Quoted 6 lines
drivers/clk/meson/axg.c new file +6 -0
+#include <linux/init.h>
+
+#include "clkc.h"
+#include "axg.h"
+
+static DEFINE_SPINLOCK(clk_lock);

meson_axg_clk_lock?

em... I'd leave it unchanged

because the spinlock will be used at macro MESON_GATE() [1] which defined at drivers/clk/meson/clkc.h, and it assume using the generic name 'clk_lock', change name will break the code..

and besides it's already defined as static, so I see no problem here

[1]

#define MESON_GATE(_name, _reg, _bit)                                   \
struct clk_gate _name = {                                               \
        .reg = (void __iomem *) _reg,                                   \
        .bit_idx = (_bit),                                              \
        .lock = &clk_lock,

[2]
drivers/clk/meson/gxbb.c
drivers/clk/meson/meson8b.c

Quoted 25 lines
Quoted 12 lines
drivers/clk/meson/axg.c new file +12 -0
+
+static const struct pll_rate_table sys_pll_rate_table[] = {
+	PLL_RATE(24000000, 56, 1, 2),
+	PLL_RATE(48000000, 64, 1, 2),
+	PLL_RATE(72000000, 72, 1, 2),
+	PLL_RATE(96000000, 64, 1, 2),
+	PLL_RATE(120000000, 80, 1, 2),
+	PLL_RATE(144000000, 96, 1, 2),
+	PLL_RATE(168000000, 56, 1, 1),
+	PLL_RATE(192000000, 64, 1, 1),
+	PLL_RATE(216000000, 72, 1, 1),
+	PLL_RATE(240000000, 80, 1, 1),

[...]

Quoted 12 lines
drivers/clk/meson/axg.c new file +12 -0
+
+static const struct clkc_data axg_clkc_data = {
+	.clk_gates = axg_clk_gates,
+	.clk_gates_count = ARRAY_SIZE(axg_clk_gates),
+	.clk_mplls = axg_clk_mplls,
+	.clk_mplls_count = ARRAY_SIZE(axg_clk_mplls),
+	.clk_plls = axg_clk_plls,
+	.clk_plls_count = ARRAY_SIZE(axg_clk_plls),
+	.clk_muxes = axg_clk_muxes,
+	.clk_muxes_count = ARRAY_SIZE(axg_clk_muxes),
+	.clk_dividers = axg_clk_dividers,
+	.clk_dividers_count = ARRAY_SIZE(axg_clk_dividers),
Quoted 9 lines

drivers/clk/meson/axg.c line 874

Quoted 6 lines
drivers/clk/meson/axg.c new file +6 -0
+	.hw_onecell_data = &axg_hw_onecell_data,
+};
+
+static const struct of_device_id clkc_match_table[] = {
+	{ .compatible = "amlogic,axg-clkc", .data = &axg_clkc_data },
+	{},

Nitpick: Drop the comma. Nothing comes after this.

sure, can do

Quoted 9 lines
Quoted 9 lines
drivers/clk/meson/axg.c new file +9 -0
+};
+
+static int axg_clkc_probe(struct platform_device *pdev)
+{
+	const struct clkc_data *clkc_data;
+	void __iomem *clk_base;
+	int ret, clkid, i;
+	struct device *dev = &pdev->dev;
+
Quoted 9 lines

drivers/clk/meson/axg.c line 889

Quoted 6 lines
drivers/clk/meson/axg.c new file +6 -0
+	clkc_data = of_device_get_match_data(&pdev->dev);
+	if (!clkc_data)
+		return -EINVAL;
+
+	/*  Generic clocks and PLLs */
+	clk_base = of_iomap(dev->of_node, 0);

Use platform device APIs for ioremapping?

I assume you are referring to 'platform_get_resource + devm_ioremap_resource' ?

the idea sounds good to me.

Quoted 25 lines
Quoted 25 lines
drivers/clk/meson/axg.c new file +25 -0
+	if (!clk_base) {
+		pr_err("%s: Unable to map clk base\n", __func__);
+		return -ENXIO;
+	}
+
+	/* Populate base address for PLLs */
+	for (i = 0; i < clkc_data->clk_plls_count; i++)
+		clkc_data->clk_plls[i]->base = clk_base;
+
+	/* Populate base address for MPLLs */
+	for (i = 0; i < clkc_data->clk_mplls_count; i++)
+		clkc_data->clk_mplls[i]->base = clk_base;
+
+	/* Populate base address for gates */
+	for (i = 0; i < clkc_data->clk_gates_count; i++)
+		clkc_data->clk_gates[i]->reg = clk_base +
+			(u64)clkc_data->clk_gates[i]->reg;
+
+	/* Populate base address for muxes */
+	for (i = 0; i < clkc_data->clk_muxes_count; i++)
+		clkc_data->clk_muxes[i]->reg = clk_base +
+			(u64)clkc_data->clk_muxes[i]->reg;
+
+	/* Populate base address for dividers */
+	for (i = 0; i < clkc_data->clk_dividers_count; i++)
Quoted 9 lines

drivers/clk/meson/axg.c line 920

Quoted 6 lines
drivers/clk/meson/axg.c new file +6 -0
+		clkc_data->clk_dividers[i]->reg = clk_base +
+			(u64)clkc_data->clk_dividers[i]->reg;
+
+	/*
+	 * register all clks
+	 */

Yes, that's obvious..

will drop at next version

Quoted 8 lines
Quoted 8 lines
drivers/clk/meson/axg.c new file +8 -0
+	for (clkid = 0; clkid < clkc_data->hw_onecell_data->num; clkid++) {
+		/* array might be sparse */
+		if (!clkc_data->hw_onecell_data->hws[clkid])
+			continue;
+
+		ret = devm_clk_hw_register(dev,
+					clkc_data->hw_onecell_data->hws[clkid]);
+		if (ret)
Quoted 8 lines

drivers/clk/meson/axg.c line 936

Quoted 8 lines
drivers/clk/meson/axg.c new file +8 -0
+			goto iounmap;
+	}
+
+	return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
+			clkc_data->hw_onecell_data);
+
+iounmap:
+	iounmap(clk_base);

can also drop this once convert to devm_ API

Quoted 28 lines
Quoted 18 lines
drivers/clk/meson/axg.c new file +12 -0
+	return ret;
+}
+
+static struct platform_driver axg_driver = {
+	.probe		= axg_clkc_probe,
+	.driver		= {
+		.name	= "axg-clkc",
+		.of_match_table = clkc_match_table,
+	},
+};
+
+builtin_platform_driver(axg_driver);
include/dt-bindings/clock/axg-clkc.h new file +0 -0
new file mode 100644
index 000000000000..d2c0f49ba0df

include/dt-bindings/clock/axg-clkc.h line 6

Quoted 6 lines
include/dt-bindings/clock/axg-clkc.h new file +6 -0
@@ -0,0 +1,72 @@
+/*
+ * Meson-AXG clock tree IDs
+ *
+ * Copyright (c) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: (GPL-2.0+ OR MIT)

There's a standard way to add these it seems. They should be the first line in the file and look like

Quoted 8 lines

/* SPDX-License-Identifier: */

for header files and

// SPDX-License-Identifier:

for C files.

thanks for the suggestion, will update at next version

author
#11 lore raw

Re: [PATCH v3 3/3] arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

In reply to Stephen Boyd

Hi Stephen

Quoted 17 lines · Stephen Boyd
Quoted 16 lines · Yixun Lan
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
index b932a784b02a..36a2e98338a8 100644
@@ -7,6 +7,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/axg-clkc.h>
 
 / {
 	compatible = "amlogic,meson-axg";
@@ -148,6 +149,20 @@
 			#address-cells = <0>;
 		};
 
Quoted 4 lines

arch/arm64/boot/dts/amlogic/meson-axg.dtsi line 152

Quoted 1 line
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
+		hiubus: hiubus at ff63c000 {

Maybe just call the node "bus at ff63c000"?

isn't this just a name? what's the benefits to change? personally, I tend to keep it this way, because it's better map to the data sheet

we also has 'aobus', 'cbus' scattered there..

Quoted 20 lines
Quoted 19 lines
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +13 -0
+			compatible = "simple-bus";
+			reg = <0x0 0xff63c000 0x0 0x1c00>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xff63c000 0x0 0x1c00>;
+
+			clkc: clock-controller at 0 {
+				compatible = "amlogic,axg-clkc";
+				#clock-cells = <1>;
+				reg = <0x0 0x0 0x0 0x320>;
+			};
+		};
+
 		mailbox: mailbox at ff63dc00 {
 			compatible = "amlogic,meson-gx-mhu", "amlogic,meson-gxbb-mhu";
 			reg = <0 0xff63dc00 0 0x400>;
Signature · 1 line
2.15.0
#12 lore raw

Re: [PATCH v3 3/3] arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

Quoted 24 lines · Yixun Lan

Hi Stephen

Quoted 17 lines · Stephen Boyd
Quoted 16 lines · Yixun Lan
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
index b932a784b02a..36a2e98338a8 100644
@@ -7,6 +7,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/axg-clkc.h>
 
 / {
 	compatible = "amlogic,meson-axg";
@@ -148,6 +149,20 @@
 			#address-cells = <0>;
 		};
 
Quoted 4 lines

arch/arm64/boot/dts/amlogic/meson-axg.dtsi line 152

Quoted 1 line
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
+		hiubus: hiubus at ff63c000 {

Maybe just call the node "bus at ff63c000"?

Quoted 5 lines

isn't this just a name? what's the benefits to change? personally, I tend to keep it this way, because it's better map to the data sheet

we also has 'aobus', 'cbus' scattered there..

Per the ePAPR node names are supposed to be generic, like disk, cpu, display-controller, gpu, etc. I've never heard of a hiubus, so probably it's some vendor specific thing? We have the phandle anyway so it's not like we're losing much information here.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#8 lore raw

Re: [PATCH v3 2/3] clk: meson-axg: add clock controller drivers

In reply to Yixun Lan
Quoted 36 lines · Yixun Lan

Hi Stephen

Quoted 24 lines · Stephen Boyd
Quoted 23 lines · Yixun Lan
drivers/clk/meson/axg.c new file +17 -0
new file mode 100644
index 000000000000..51c5b4062715
@@ -0,0 +1,948 @@
+/*
+ * AmLogic Meson-AXG Clock Controller Driver
+ *
+ * Copyright (c) 2016 Baylibre SAS.
+ * Author: Michael Turquette <[email protected]>
+ *
+ * Copyright (c) 2017 Amlogic, inc.
+ * Author: Qiufang Dai <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
Quoted 9 lines

drivers/clk/meson/axg.c line 23

Quoted 6 lines
drivers/clk/meson/axg.c new file +6 -0
+#include <linux/init.h>
+
+#include "clkc.h"
+#include "axg.h"
+
+static DEFINE_SPINLOCK(clk_lock);

meson_axg_clk_lock?

Quoted 7 lines

em... I'd leave it unchanged

because the spinlock will be used at macro MESON_GATE() [1] which defined at drivers/clk/meson/clkc.h, and it assume using the generic name 'clk_lock', change name will break the code..

and besides it's already defined as static, so I see no problem here

The problem is lockdep debugging and ctags/grep on the source code. clk_lock is very generic when it should be more specific so we can find this lock later on from a lockdep report with a simple search of the code.

Maybe make another patch to rename it to meson_clk_lock so the macro doesn't have to change too much, and we get it slightly more unique. Looks like v4l2 also has a clk_lock.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/clk/meson/axg.c new file +9 -0
+};
+
+static int axg_clkc_probe(struct platform_device *pdev)
+{
+	const struct clkc_data *clkc_data;
+	void __iomem *clk_base;
+	int ret, clkid, i;
+	struct device *dev = &pdev->dev;
+
Quoted 9 lines

drivers/clk/meson/axg.c line 889

Quoted 6 lines
drivers/clk/meson/axg.c new file +6 -0
+	clkc_data = of_device_get_match_data(&pdev->dev);
+	if (!clkc_data)
+		return -EINVAL;
+
+	/*  Generic clocks and PLLs */
+	clk_base = of_iomap(dev->of_node, 0);

Use platform device APIs for ioremapping?

Quoted 4 lines

I assume you are referring to 'platform_get_resource + devm_ioremap_resource' ?

the idea sounds good to me.

Yes.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#13 lore raw

Re: [PATCH v3 3/3] arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

In reply to Stephen Boyd
Quoted 31 lines · Stephen Boyd
Quoted 30 lines · Yixun Lan

Hi Stephen

Quoted 18 lines · Stephen Boyd
Quoted 17 lines · Yixun Lan
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
index b932a784b02a..36a2e98338a8 100644
@@ -7,6 +7,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/axg-clkc.h>
 
 / {
 	compatible = "amlogic,meson-axg";
@@ -148,6 +149,20 @@
 			#address-cells = <0>;
 		};
 
Quoted 4 lines

arch/arm64/boot/dts/amlogic/meson-axg.dtsi line 152

Quoted 1 line
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +1 -0
+		hiubus: hiubus at ff63c000 {

Maybe just call the node "bus at ff63c000"?

isn't this just a name? what's the benefits to change? personally, I tend to keep it this way, because it's better map to the data sheet

Quoted 6 lines
Quoted 1 line

we also has 'aobus', 'cbus' scattered there..

Per the ePAPR node names are supposed to be generic, like disk, cpu, display-controller, gpu, etc. I've never heard of a hiubus, so probably it's some vendor specific thing? We have the phandle anyway so it's not like we're losing much information here.

Stephen, there is a lot of busses on platform. We can't just call them all 'bus'.
I don't get the problem with this name.
We are re-using the name from the datasheet here, no fancy invention. It seems to be quite common.

Quoted 1 line
#14 lore raw

Re: [PATCH v3 3/3] arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

Quoted 20 lines · Jerome Brunet
Quoted 12 lines · Stephen Boyd
Quoted 11 lines · Yixun Lan

Hi Stephen

Quoted 3 lines · Stephen Boyd

Maybe just call the node "bus at ff63c000"?

isn't this just a name? what's the benefits to change? personally, I tend to keep it this way, because it's better map to the data sheet

Quoted 6 lines
Quoted 1 line

we also has 'aobus', 'cbus' scattered there..

Per the ePAPR node names are supposed to be generic, like disk, cpu, display-controller, gpu, etc. I've never heard of a hiubus, so probably it's some vendor specific thing? We have the phandle anyway so it's not like we're losing much information here.

Quoted 6 lines

Stephen, there is a lot of busses on platform. We can't just call them all 'bus'.
I don't get the problem with this name.
We are re-using the name from the datasheet here, no fancy invention. It seems to be quite common.

Ok. I'm not the maintainer of the DTS so no worries from me. I'm just pointing out that the ePAPR says that node names should be generic, and 'hiubus' doesn't sound generic to me. If it matches some datasheet then I suppose that's good, but probably that sort of distinction should have gone into the compatible string instead of the node name.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#15 lore raw

Re: [PATCH v3 3/3] arm64: dts: meson-axg: add clock DT info for Meson AXG SoC

Quoted 28 lines · Stephen Boyd
Quoted 20 lines · Jerome Brunet
Quoted 12 lines · Stephen Boyd
Quoted 11 lines · Yixun Lan

Hi Stephen

Quoted 3 lines · Stephen Boyd

Maybe just call the node "bus at ff63c000"?

isn't this just a name? what's the benefits to change? personally, I tend to keep it this way, because it's better map to the data sheet

Quoted 6 lines
Quoted 1 line

we also has 'aobus', 'cbus' scattered there..

Per the ePAPR node names are supposed to be generic, like disk, cpu, display-controller, gpu, etc. I've never heard of a hiubus, so probably it's some vendor specific thing? We have the phandle anyway so it's not like we're losing much information here.

Quoted 6 lines

Stephen, there is a lot of busses on platform. We can't just call them all 'bus'.
I don't get the problem with this name.
We are re-using the name from the datasheet here, no fancy invention. It seems to be quite common.

Quoted 6 lines

Ok. I'm not the maintainer of the DTS so no worries from me. I'm just pointing out that the ePAPR says that node names should be generic, and 'hiubus' doesn't sound generic to me. If it matches some datasheet then I suppose that's good, but probably that sort of distinction should have gone into the compatible string instead of the node name.

Stephen is right, the node-name should be generic (e.g. "bus") but the label can (should) be more SoC-specific, so it should look like:

		hiubus: bus at ff63c000 {

Note that we weren't strict about this for all the rest of the amlogic SoCs (mostly because I didn't notice ) but we should start doing it correctly now. I'll also clean up the existing DTs.

Kevin