public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Dario Binacchi <dariobin@libero.it>
To: u-boot@lists.denx.de
Subject: [PATCH v3 18/27] misc: am33xx: add control module driver
Date: Sun, 11 Oct 2020 14:13:31 +0200	[thread overview]
Message-ID: <20201011121340.21660-19-dariobin@libero.it> (raw)
In-Reply-To: <20201011121340.21660-1-dariobin@libero.it>

The implementation of this driver was needed to bind the device tree
sub-nodes of the 'clocks' node. In fact, the lack of the compatible
property in the 'clocks' node does not allow the generic 'syscon' or
'simple-bus' drivers linked to the 'scm_conf at 0' node to bind the
'clocks' node and in turn its sub-nodes.
The 'scm at 210000' node is therefore the node closest to the 'clocks' node
whose driver can bind all the 'clocks' sub-nodes. In this way, the
address translation functions are able to walk along the device tree
towards the upper nodes until the address composition is completed.

scm: scm at 210000 {
	compatible = "ti,am3-scm", "simple-bus";
	...

	scm_conf: scm_conf at 0 {
		compatible = "syscon", "simple-bus";
		#address-cells = <1>;
		#size-cells = <1>;
		ranges = <0 0 0x800>;

		scm_clocks: clocks {
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};
};

For DT binding details see Linux doc:
- Documentation/devicetree/bindings/arm/omap/ctrl.txt

Signed-off-by: Dario Binacchi <dariobin@libero.it>


---

Changes in v3:
- Remove doc/device-tree-bindings/arm/omap,ctrl.txt.
- Remove doc/device-tree-bindings/pinctrl/pinctrl-single.txt.
- Add to commit message the references to linux kernel dt binding
  documentation.

Changes in v2:
- Remove the 'ti_am3_scm_clocks' driver. Handle 'scm_clocks' node in
  the 'ti_am3_scm' driver.
- Update the commit message.

 drivers/misc/Kconfig      |  7 ++++
 drivers/misc/Makefile     |  1 +
 drivers/misc/ti-am3-scm.c | 81 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 drivers/misc/ti-am3-scm.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b67e906a76..9e8b676637 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -500,4 +500,11 @@ config ESM_PMIC
 	  Support ESM (Error Signal Monitor) on PMIC devices. ESM is used
 	  typically to reboot the board in error condition.
 
+config TI_AM3_SCM
+	bool "AM33XX specific control module support (SCM)"
+	depends on ARCH_OMAP2PLUS
+	help
+	 The control module includes status and control logic not addressed
+	 within the peripherals or the rest of the device infrastructure.
+
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 947bd3a647..056fb3b522 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -75,3 +75,4 @@ obj-$(CONFIG_MICROCHIP_FLEXCOM) += microchip_flexcom.o
 obj-$(CONFIG_K3_AVS0) += k3_avs.o
 obj-$(CONFIG_ESM_K3) += k3_esm.o
 obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
+obj-$(CONFIG_TI_AM3_SCM) += ti-am3-scm.o
diff --git a/drivers/misc/ti-am3-scm.c b/drivers/misc/ti-am3-scm.c
new file mode 100644
index 0000000000..9a57c783c3
--- /dev/null
+++ b/drivers/misc/ti-am3-scm.c
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * AM335x specific control module (scm)
+ *
+ * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/lists.h>
+#include <linux/err.h>
+
+static int ti_am3_scm_bind(struct udevice *dev)
+{
+	ofnode clocks_node, conf_node, node;
+	struct udevice *conf_dev;
+	int err;
+
+	if (!strcmp("clocks", ofnode_get_name(dev_ofnode(dev)))) {
+		ofnode_for_each_subnode(node, dev_ofnode(dev)) {
+			dev_dbg(dev, "%s: node=%s\n", __func__,
+				ofnode_get_name(node));
+			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;
+	}
+
+	err = dm_scan_fdt_dev(dev);
+	if (err) {
+		dev_err(dev, "%s: dm_scan_fdt, err=%d\n", __func__, err);
+		return err;
+	}
+
+	conf_node = dev_read_subnode(dev, "scm_conf at 0");
+	if (!ofnode_valid(conf_node)) {
+		dev_err(dev, "%s: failed to get conf sub-node\n", __func__);
+		return -ENODEV;
+	}
+
+	if (uclass_get_device_by_ofnode(UCLASS_SYSCON, conf_node, &conf_dev)) {
+		if (uclass_get_device_by_ofnode(UCLASS_SIMPLE_BUS, conf_node,
+						&conf_dev)) {
+			dev_err(dev, "%s: failed to get conf device\n",
+				__func__);
+			return -ENODEV;
+		}
+	}
+
+	clocks_node = dev_read_subnode(conf_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(conf_dev, "ti_am3_scm", "scm_clocks",
+					 clocks_node, NULL);
+	if (err) {
+		dev_err(dev, "%s: failed to bind scm_clocks\n", __func__);
+		return err;
+	}
+
+	return 0;
+}
+
+static const struct udevice_id ti_am3_scm_ids[] = {
+	{.compatible = "ti,am3-scm"},
+	{}
+};
+
+U_BOOT_DRIVER(ti_am3_scm) = {
+	.name = "ti_am3_scm",
+	.id = UCLASS_SIMPLE_BUS,
+	.of_match = ti_am3_scm_ids,
+	.bind = ti_am3_scm_bind,
+};
-- 
2.17.1

  parent reply	other threads:[~2020-10-11 12:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11 12:13 [PATCH v3 00/27] Add DM support for omap PWM backlight Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 01/27] clk: export generic routines Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 02/27] dt-bindings: bus: ti-sysc: resync with Linux 5.9-rc7 Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 03/27] bus: ti: add minimal sysc interconnect target driver Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 04/27] arm: dts: sync am33xx with Linux 5.9-rc7 Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 05/27] clk: add clk_round_rate() Dario Binacchi
2020-10-11 12:26   ` Sean Anderson
2020-10-11 12:13 ` [PATCH v3 06/27] clk: ti: add mux clock driver Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 07/27] arm: ti: am33xx: add DPLL_EN_FAST_RELOCK_BYPASS macro Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 08/27] clk: ti: am33xx: add DPLL clock drivers Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 09/27] clk: ti: add divider clock driver Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 10/27] clk: ti: add gate " Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 11/27] ti: am33xx: fix do_enable_clocks() to accept NULL parameters Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 12/27] clk: ti: add support for clkctrl clocks Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 13/27] clk: ti: move drivers to 'ti' directory Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 14/27] clk: ti: omap4: add clock manager driver Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 15/27] clk: ti: am335x: " Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 16/27] fdt: translate address if #size-cells = <0> Dario Binacchi
2020-10-11 12:13 ` [PATCH v3 17/27] omap: timer: fix the rate setting Dario Binacchi
2020-10-11 12:13 ` Dario Binacchi [this message]
2020-10-14  8:22 ` [PATCH v3 00/27] Add DM support for omap PWM backlight Felix Brack
2020-10-14 21:22   ` Dario Binacchi
2020-10-15  8:53     ` Felix Brack
2020-10-15 18:56       ` Dario Binacchi
2020-10-16  8:41         ` Felix Brack
2020-10-16 20:31           ` Dario Binacchi

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=20201011121340.21660-19-dariobin@libero.it \
    --to=dariobin@libero.it \
    --cc=u-boot@lists.denx.de \
    /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