Skip to contentSkip to conversation

fdt: add new fdt address parsing functions

PATCH New Stephen Warren 3 participants 8 messages Aug 6, 2015 – Sep 15, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

From: Stephen Warren <[email protected]>

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

dev_get_addr() is updated to use the new functions.

Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.

Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".

Cc Thierry Reding <[email protected]>
Cc Simon Glass <[email protected]>
Cc Michal Suchanek <[email protected]>

---
For patch context, this patch relies on Thierry's "fdt: Fix fdtdec_get_addr_size() for 64-bit" having been reverted.

---
 drivers/core/device.c |   5 ++-
 include/fdtdec.h      | 111 +++++++++++++++++++++++++++++++++++++++++++----
 lib/fdtdec.c          | 116 +++++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 202 insertions(+), 30 deletions(-)
drivers/core/device.c +4 -1
index 51b1b44e5b0a..917dd85551d3 100644
@@ -555,7 +555,10 @@ const char *dev_get_uclass_name(struct udevice *dev)
 #ifdef CONFIG_OF_CONTROL
 fdt_addr_t dev_get_addr(struct udevice *dev)
 {
-	return fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+	return fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
+						dev->parent->of_offset,
+						dev->of_offset, "reg",
+						0, NULL);
 }
 #else
 fdt_addr_t dev_get_addr(struct udevice *dev)
include/fdtdec.h +103 -8

127 lines not on this page · raw message

lib/fdtdec.c +95 -21

130 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

Quoted 18 lines · Stephen Warren

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

lib/fdtdec.c +0 -0
index 95b59b586ff0..3afec045e9bd 100644

lib/fdtdec.c line 3

Quoted 3 lines
lib/fdtdec.c +2 -0
@@ -1,3 +1,5 @@
+#define DEBUG
+
  /*

Uggh. That part will of course have to be dropped, but I'll hold off resending in case there are any other comments.

#2 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

In reply to Stephen Warren

Hi Stephen,

Quoted 31 lines · Stephen Warren

From: Stephen Warren <[email protected]>

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

dev_get_addr() is updated to use the new functions.

Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.

Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".

Cc Thierry Reding <[email protected]>
Cc Simon Glass <[email protected]>
Cc Michal Suchanek <[email protected]>
Quoted 8 lines

---
For patch context, this patch relies on Thierry's "fdt: Fix fdtdec_get_addr_size() for 64-bit" having been reverted.

---
 drivers/core/device.c |   5 ++-
 include/fdtdec.h      | 111 +++++++++++++++++++++++++++++++++++++++++++----
 lib/fdtdec.c          | 116 +++++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 202 insertions(+), 30 deletions(-)

This looks perfect to me, and covers all cases. Thank you for resolving this.

Re SPL I'll be getting back to that before long and taking another look at code size. If anything needs tweaking in dev_get_addr() I'll send a patch then.

I'll wait to see if there are other comments and apply this to the fdt tree early next week.

Regards,
Simon

#3 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

In reply to Stephen Warren
Quoted 17 lines · Stephen Warren

From: Stephen Warren <[email protected]>

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

dev_get_addr() is updated to use the new functions.

Quoted 8 lines

Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.

Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".

Tested this patch for cpsw ethernet dt migration to getting cpsw address space. Also dropped *#define DEBUG* in lib/fdtdev.c file.

Regards
Mugunthan V N

#4 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

Hi,

Quoted 28 lines · Mugunthan V N
Quoted 17 lines · Stephen Warren

From: Stephen Warren <[email protected]>

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

dev_get_addr() is updated to use the new functions.

Quoted 8 lines

Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.

Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".

Quoted 5 lines

Tested this patch for cpsw ethernet dt migration to getting cpsw address space. Also dropped *#define DEBUG* in lib/fdtdev.c file.

Thanks for testing this. I would like to apply this - are there any other comments?

Regards,
Simon

#5 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

Quoted 31 lines · Simon Glass

Hi,

Quoted 28 lines · Mugunthan V N
Quoted 25 lines · Stephen Warren

From: Stephen Warren <[email protected]>

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

dev_get_addr() is updated to use the new functions.

Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.

Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".

Quoted 8 lines
Quoted 5 lines

Tested this patch for cpsw ethernet dt migration to getting cpsw address space. Also dropped *#define DEBUG* in lib/fdtdev.c file.

Thanks for testing this. I would like to apply this - are there any other comments?

There is no other comments apart from removing #define DEBUG

Regards
Mugunthan V N

#6 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

Quoted 35 lines · Mugunthan V N
Quoted 34 lines · Simon Glass

Hi,

Quoted 31 lines · Mugunthan V N
Quoted 17 lines · Stephen Warren

From: Stephen Warren <[email protected]>

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

dev_get_addr() is updated to use the new functions.

Quoted 8 lines

Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.

Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".

Tested this patch for cpsw ethernet dt migration to getting cpsw address space. Also dropped *#define DEBUG* in lib/fdtdev.c file.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thanks for testing this. I would like to apply this - are there any other comments?

There is no other comments apart from removing #define DEBUG

Simon

Are you applying this patch?

Regards
Mugunthan V N

#7 lore raw

PATCH 1/1 fdt: add new fdt address parsing functions

Quoted 42 lines · Mugunthan V N
Quoted 41 lines · Mugunthan V N
Quoted 39 lines · Simon Glass

Hi,

Quoted 28 lines · Mugunthan V N
Quoted 17 lines · Stephen Warren

From: Stephen Warren <[email protected]>

fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.

This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.

dev_get_addr() is updated to use the new functions.

Quoted 8 lines

Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.

Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".

Quoted 5 lines

Tested this patch for cpsw ethernet dt migration to getting cpsw address space. Also dropped *#define DEBUG* in lib/fdtdev.c file.

Thanks for testing this. I would like to apply this - are there any other comments?

Quoted 6 lines
Quoted 2 lines

There is no other comments apart from removing #define DEBUG

Simon

Are you applying this patch?

Applied to u-boot-fdt.