* [U-Boot] [PATCH v2 0/2] dm: core: add clocks node scan
@ 2017-08-08 12:34 patrice.chotard at st.com
2017-08-08 12:34 ` [U-Boot] [PATCH v2 1/2] " patrice.chotard at st.com
2017-08-08 12:34 ` [U-Boot] [PATCH v2 2/2] dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_test patrice.chotard at st.com
0 siblings, 2 replies; 6+ messages in thread
From: patrice.chotard at st.com @ 2017-08-08 12:34 UTC (permalink / raw)
To: u-boot
From: Patrice Chotard <patrice.chotard@st.com>
v2: _ implement this feature in dm_extended_scan_dt() which can be called
from test/dm/test-main.c to insure that test scan DT clocks
sub-nodes
_ replace fdt_path_offset() by ofnode_path()
_ update sandbox dedicated test
Patrice Chotard (2):
dm: core: add clocks node scan
dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in
dm_do_test
arch/sandbox/dts/test.dts | 10 ++++++----
drivers/core/root.c | 34 ++++++++++++++++++++++++++++++++--
include/dm/root.h | 14 ++++++++++++++
test/dm/test-main.c | 2 +-
4 files changed, 53 insertions(+), 7 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 1/2] dm: core: add clocks node scan
2017-08-08 12:34 [U-Boot] [PATCH v2 0/2] dm: core: add clocks node scan patrice.chotard at st.com
@ 2017-08-08 12:34 ` patrice.chotard at st.com
2017-08-13 21:35 ` Simon Glass
2017-08-08 12:34 ` [U-Boot] [PATCH v2 2/2] dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_test patrice.chotard at st.com
1 sibling, 1 reply; 6+ messages in thread
From: patrice.chotard at st.com @ 2017-08-08 12:34 UTC (permalink / raw)
To: u-boot
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>
---
v2: _ implement this feature in dm_extended_scan_dt() which can be called
from test/dm/test-main.c to insure that test scan DT clocks
sub-nodes
_ replace fdt_path_offset() by ofnode_path()
drivers/core/root.c | 34 ++++++++++++++++++++++++++++++++--
include/dm/root.h | 14 ++++++++++++++
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/drivers/core/root.c b/drivers/core/root.c
index d691d6f..748ef9c 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_dt(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_dt(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..3426830 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_dt() - Scan the device tree and bind drivers
+ *
+ * This 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_dt(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
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 2/2] dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_test
2017-08-08 12:34 [U-Boot] [PATCH v2 0/2] dm: core: add clocks node scan patrice.chotard at st.com
2017-08-08 12:34 ` [U-Boot] [PATCH v2 1/2] " patrice.chotard at st.com
@ 2017-08-08 12:34 ` patrice.chotard at st.com
2017-08-13 21:35 ` Simon Glass
1 sibling, 1 reply; 6+ messages in thread
From: patrice.chotard at st.com @ 2017-08-08 12:34 UTC (permalink / raw)
To: u-boot
From: Patrice Chotard <patrice.chotard@st.com>
This allows to scan the DT including all "clocks" node's sub-nodes
in which fixed-clock are defined.
All fixed-clock should be defined inside a clocks node which collect all
external oscillators. Until now, all clocks sub-nodes can't be binded except
if the "simple-bus" compatible string is added which is a hack.
Update test.dts by moving clk_fixed node inside clocks.
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
v2: _ none
arch/sandbox/dts/test.dts | 10 ++++++----
test/dm/test-main.c | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 65b2f8e..e67d428 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -127,10 +127,12 @@
compatible = "denx,u-boot-fdt-test";
};
- clk_fixed: clk-fixed {
- compatible = "fixed-clock";
- #clock-cells = <0>;
- clock-frequency = <1234>;
+ clocks {
+ clk_fixed: clk-fixed {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <1234>;
+ };
};
clk_sandbox: clk-sbox {
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 9d88d31..ab3e35b 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -92,7 +92,7 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
if (test->flags & DM_TESTF_PROBE_TEST)
ut_assertok(do_autoprobe(uts));
if (test->flags & DM_TESTF_SCAN_FDT)
- ut_assertok(dm_scan_fdt(gd->fdt_blob, false));
+ ut_assertok(dm_extended_scan_dt(gd->fdt_blob, false));
/*
* Silence the console and rely on console reocrding to get
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 1/2] dm: core: add clocks node scan
2017-08-08 12:34 ` [U-Boot] [PATCH v2 1/2] " patrice.chotard at st.com
@ 2017-08-13 21:35 ` Simon Glass
2017-09-04 12:37 ` Patrice CHOTARD
0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2017-08-13 21:35 UTC (permalink / raw)
To: u-boot
+Rob Clark who is doing a similar thing with the /chosen node
Hi Patrice,
On 8 August 2017 at 06:34, <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>
> ---
>
> v2: _ implement this feature in dm_extended_scan_dt() which can be called
> from test/dm/test-main.c to insure that test scan DT clocks
> sub-nodes
> _ replace fdt_path_offset() by ofnode_path()
>
> drivers/core/root.c | 34 ++++++++++++++++++++++++++++++++--
> include/dm/root.h | 14 ++++++++++++++
> 2 files changed, 46 insertions(+), 2 deletions(-)
This looks good but please add a sandbox test to test/dm/clk.c
>
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index d691d6f..748ef9c 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_dt(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_dt(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..3426830 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_dt() - Scan the device tree and bind drivers
For consistency dm_extended_scan_fdt()
> + *
> + * This 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
Should mention that this calls dm_scan_fdt()
> + *
> + * @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_dt(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
> --
> 1.9.1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 2/2] dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_test
2017-08-08 12:34 ` [U-Boot] [PATCH v2 2/2] dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_test patrice.chotard at st.com
@ 2017-08-13 21:35 ` Simon Glass
0 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2017-08-13 21:35 UTC (permalink / raw)
To: u-boot
On 8 August 2017 at 06:34, <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> This allows to scan the DT including all "clocks" node's sub-nodes
> in which fixed-clock are defined.
> All fixed-clock should be defined inside a clocks node which collect all
> external oscillators. Until now, all clocks sub-nodes can't be binded except
> if the "simple-bus" compatible string is added which is a hack.
>
> Update test.dts by moving clk_fixed node inside clocks.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
>
> v2: _ none
>
> arch/sandbox/dts/test.dts | 10 ++++++----
> test/dm/test-main.c | 2 +-
> 2 files changed, 7 insertions(+), 5 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 1/2] dm: core: add clocks node scan
2017-08-13 21:35 ` Simon Glass
@ 2017-09-04 12:37 ` Patrice CHOTARD
0 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2017-09-04 12:37 UTC (permalink / raw)
To: u-boot
Hi Simon
On 08/13/2017 11:35 PM, Simon Glass wrote:
> +Rob Clark who is doing a similar thing with the /chosen node
>
> Hi Patrice,
>
> On 8 August 2017 at 06:34, <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>
>> ---
>>
>> v2: _ implement this feature in dm_extended_scan_dt() which can be called
>> from test/dm/test-main.c to insure that test scan DT clocks
>> sub-nodes
>> _ replace fdt_path_offset() by ofnode_path()
>>
>> drivers/core/root.c | 34 ++++++++++++++++++++++++++++++++--
>> include/dm/root.h | 14 ++++++++++++++
>> 2 files changed, 46 insertions(+), 2 deletions(-)
>
> This looks good but please add a sandbox test to test/dm/clk.c
There is already a dedicated clk test for fixed-clock in test/dm/clk.c.
To check that fixed-clock is correctly binded with this patch i simply
updates the arch/sandbox/dts/test.dts by adding clk_fixed node inside
clocks {
...
};
See patch 2.
>
>>
>> diff --git a/drivers/core/root.c b/drivers/core/root.c
>> index d691d6f..748ef9c 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_dt(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_dt(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..3426830 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_dt() - Scan the device tree and bind drivers
>
> For consistency dm_extended_scan_fdt()
ok
>
>> + *
>> + * This 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
>
> Should mention that this calls dm_scan_fdt()
ok i will add it.
>
>> + *
>> + * @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_dt(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
>> --
>> 1.9.1
>>
>
> Regards,
> Simon
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-04 12:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-08 12:34 [U-Boot] [PATCH v2 0/2] dm: core: add clocks node scan patrice.chotard at st.com
2017-08-08 12:34 ` [U-Boot] [PATCH v2 1/2] " patrice.chotard at st.com
2017-08-13 21:35 ` Simon Glass
2017-09-04 12:37 ` Patrice CHOTARD
2017-08-08 12:34 ` [U-Boot] [PATCH v2 2/2] dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_test patrice.chotard at st.com
2017-08-13 21:35 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.