[PATCH 15/31] clk: ti: am335x: add clock manager driver
Dario Binacchi
dariobin at libero.it
Tue Aug 25 11:21:08 CEST 2020
The implementation of this driver was needed to bind the sub-nodes of
the 'clocks' node. In fact, the lack of the compatible property in
the 'clocks' node does not allow the generic 'simple-bus' driver to bind
the 'clocks' node and in turn its sub-nodes.
The 'prcm at 200000' node is therefore the node closest to the 'clocks'
node whose driver can bind all the 'clocks' sub-nodes.
prcm: prcm at 200000 {
compatible = "ti,am3-prcm", "simple-bus";
reg = <0x200000 0x4000>;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x200000 0x4000>;
prcm_clocks: clocks {
#address-cells = <1>;
#size-cells = <0>;
};
prcm_clockdomains: clockdomains {
};
};
&prcm_clocks {
...
dpll_core_ck: dpll_core_ck at 490 {
#clock-cells = <0>;
compatible = "ti,am3-dpll-core-clock";
clocks = <&sys_clkin_ck>, <&sys_clkin_ck>;
reg = <0x0490>, <0x045c>, <0x0468>;
};
...
};
Signed-off-by: Dario Binacchi <dariobin at libero.it>
---
drivers/clk/ti/Makefile | 8 ++++-
drivers/clk/ti/am3-prcm.c | 73 +++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 1 deletion(-)
create mode 100644 drivers/clk/ti/am3-prcm.c
diff --git a/drivers/clk/ti/Makefile b/drivers/clk/ti/Makefile
index 0b7e61cdf7..3d6e0cd79d 100644
--- a/drivers/clk/ti/Makefile
+++ b/drivers/clk/ti/Makefile
@@ -3,7 +3,13 @@
# Copyright (C) 2020 Dario Binacchi <dariobin at libero.it>
#
-obj-$(CONFIG_ARCH_OMAP2PLUS) += clk.o omap4-cm.o
+ifeq ($(CONFIG_ARCH_OMAP2PLUS), y)
+
+obj-y += clk.o omap4-cm.o
+obj-$(CONFIG_AM33XX) += am3-prcm.o
+
+endif # CONFIG_ARCH_OMAP2PLUS
+
obj-$(CONFIG_CLK_TI_AM3_DPLL) += clk-am3-dpll.o clk-am3-dpll-x2.o
obj-$(CONFIG_CLK_TI_CTRL) += clk-ctrl.o
obj-$(CONFIG_CLK_TI_DIVIDER) += clk-divider.o
diff --git a/drivers/clk/ti/am3-prcm.c b/drivers/clk/ti/am3-prcm.c
new file mode 100644
index 0000000000..8461de6077
--- /dev/null
+++ b/drivers/clk/ti/am3-prcm.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * AM335x power reset and clock manager (prcm)
+ *
+ * Copyright (C) 2020 Dario Binacchi <dariobin at libero.it>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/lists.h>
+#include <linux/err.h>
+
+static int ti_am3_prcm_bind(struct udevice *dev)
+{
+ ofnode clocks_node;
+ int err;
+
+ err = dm_scan_fdt_dev(dev);
+ if (err) {
+ dev_err(dev, "%s: dm_scan_fdt, err=%d\n", __func__, err);
+ return err;
+ }
+
+ clocks_node = ofnode_find_subnode(dev_ofnode(dev), "clocks");
+ if (!ofnode_valid(clocks_node)) {
+ dev_err(dev, "%s: failed to get clocks sub-node\n", __func__);
+ return -ENODEV;
+ }
+
+ err = device_bind_driver_to_node(dev, "ti_am3_prcm_clocks",
+ "prcm_clocks", clocks_node, NULL);
+ if (err) {
+ dev_err(dev, "%s: failed to bind prcm_clocks\n", __func__);
+ return err;
+ }
+
+ return 0;
+}
+
+static const struct udevice_id ti_am3_prcm_ids[] = {
+ {.compatible = "ti,am3-prcm"},
+ {}
+};
+
+U_BOOT_DRIVER(ti_am3_prcm) = {
+ .name = "ti_am3_prcm",
+ .id = UCLASS_SIMPLE_BUS,
+ .of_match = ti_am3_prcm_ids,
+ .bind = ti_am3_prcm_bind,
+};
+
+static int ti_am3_prcm_clocks_bind(struct udevice *dev)
+{
+ ofnode node;
+ int err;
+
+ ofnode_for_each_subnode(node, dev_ofnode(dev)) {
+ err = lists_bind_fdt(dev, node, NULL, false);
+ if (err) {
+ dev_err(dev, "%s: lists_bind_fdt, err=%d\n",
+ __func__, err);
+ return err;
+ }
+ }
+
+ return 0;
+}
+
+U_BOOT_DRIVER(ti_am3_prcm_clocks) = {
+ .name = "ti_am3_prcm_clocks",
+ .id = UCLASS_SIMPLE_BUS,
+ .bind = ti_am3_prcm_clocks_bind,
+};
--
2.17.1
More information about the U-Boot
mailing list