diff mbox series

[U-Boot,v3,1/2] dm: core: add clocks node scan

Message ID 1504529757-10843-2-git-send-email-patrice.chotard@st.com
State Accepted
Commit e81c98649b7a67d43c5baae407430a242d3b26b9
Delegated to: Simon Glass
Headers show
Series dm: core: add clocks node scan | expand

Commit Message

Patrice CHOTARD Sept. 4, 2017, 12:55 p.m. UTC
From: Patrice Chotard <patrice.chotard@st.com>

Currently, all fixed-clock declared in "clocks" node in device tree
can be binded by clk_fixed_rate.c driver only if each of them have
the "simple-bus" compatible string.
This constraint has been invoked here [1].

This patch offers a solution to avoid adding "simple-bus" compatible
string to nodes that are not busses.

[1] https://patchwork.ozlabs.org/patch/558837/

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

v3:	_ rename dm_extended_scan_dt() to dm_extended_scan_fdt() to insure 
	  function naming consistency
	_ update dm_extended_scan_fdt() description

 drivers/core/root.c | 34 ++++++++++++++++++++++++++++++++--
 include/dm/root.h   | 14 ++++++++++++++
 2 files changed, 46 insertions(+), 2 deletions(-)

Comments

Simon Glass Sept. 9, 2017, 4:55 a.m. UTC | #1
On 4 September 2017 at 06:55,  <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> Currently, all fixed-clock declared in "clocks" node in device tree
> can be binded by clk_fixed_rate.c driver only if each of them have
> the "simple-bus" compatible string.
> This constraint has been invoked here [1].
>
> This patch offers a solution to avoid adding "simple-bus" compatible
> string to nodes that are not busses.
>
> [1] https://patchwork.ozlabs.org/patch/558837/
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
>
> v3:     _ rename dm_extended_scan_dt() to dm_extended_scan_fdt() to insure
>           function naming consistency
>         _ update dm_extended_scan_fdt() description
>
>  drivers/core/root.c | 34 ++++++++++++++++++++++++++++++++--
>  include/dm/root.h   | 14 ++++++++++++++
>  2 files changed, 46 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Sept. 12, 2017, 10:52 a.m. UTC | #2
On 4 September 2017 at 06:55,  <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> Currently, all fixed-clock declared in "clocks" node in device tree
> can be binded by clk_fixed_rate.c driver only if each of them have
> the "simple-bus" compatible string.
> This constraint has been invoked here [1].
>
> This patch offers a solution to avoid adding "simple-bus" compatible
> string to nodes that are not busses.
>
> [1] https://patchwork.ozlabs.org/patch/558837/
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
>
> v3:     _ rename dm_extended_scan_dt() to dm_extended_scan_fdt() to insure
>           function naming consistency
>         _ update dm_extended_scan_fdt() description
>
>  drivers/core/root.c | 34 ++++++++++++++++++++++++++++++++--
>  include/dm/root.h   | 14 ++++++++++++++
>  2 files changed, 46 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/core/root.c b/drivers/core/root.c
index d691d6f..757d109 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -312,8 +312,38 @@  int dm_scan_fdt(const void *blob, bool pre_reloc_only)
 #endif
 	return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only);
 }
+#else
+static int dm_scan_fdt_node(struct udevice *parent, const void *blob,
+			    int offset, bool pre_reloc_only)
+{
+	return 0;
+}
 #endif
 
+int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only)
+{
+	int node, ret;
+
+	ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
+	if (ret) {
+		debug("dm_scan_fdt() failed: %d\n", ret);
+		return ret;
+	}
+
+	/* bind fixed-clock */
+	node = ofnode_to_offset(ofnode_path("/clocks"));
+	/* if no DT "clocks" node, no need to go further */
+	if (node < 0)
+		return ret;
+
+	ret = dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, node,
+			       pre_reloc_only);
+	if (ret)
+		debug("dm_scan_fdt_node() failed: %d\n", ret);
+
+	return ret;
+}
+
 __weak int dm_scan_other(bool pre_reloc_only)
 {
 	return 0;
@@ -335,9 +365,9 @@  int dm_init_and_scan(bool pre_reloc_only)
 	}
 
 	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
-		ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
+		ret = dm_extended_scan_fdt(gd->fdt_blob, pre_reloc_only);
 		if (ret) {
-			debug("dm_scan_fdt() failed: %d\n", ret);
+			debug("dm_extended_scan_dt() failed: %d\n", ret);
 			return ret;
 		}
 	}
diff --git a/include/dm/root.h b/include/dm/root.h
index 50a6011..b075eef 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -56,6 +56,20 @@  int dm_scan_platdata(bool pre_reloc_only);
 int dm_scan_fdt(const void *blob, bool pre_reloc_only);
 
 /**
+ * dm_extended_scan_fdt() - Scan the device tree and bind drivers
+ *
+ * This calls dm_scna_dft() which scans the device tree and creates a driver
+ * for each node. the top-level subnodes are examined and also all sub-nodes
+ * of "clocks" node.
+ *
+ * @blob: Pointer to device tree blob
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
+ * flag. If false bind all drivers.
+ * @return 0 if OK, -ve on error
+ */
+int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only);
+
+/**
  * dm_scan_other() - Scan for other devices
  *
  * Some devices may not be visible to Driver Model. This weak function can