diff mbox series

[RFC,5/6] dtoc: update dtb_platdata to support cd-gpios

Message ID 20200513201345.26769-6-walter.lozano@collabora.com
State Superseded
Headers show
Series improve OF_PLATDATA support | expand

Commit Message

Walter Lozano May 13, 2020, 8:13 p.m. UTC
Currently dtoc does not support the property cd-gpios used to declare
the gpios for card detect in mmc.

This patch adds support to cd-gpios property.

Signed-off-by: Walter Lozano <walter.lozano at collabora.com>
---
 tools/dtoc/dtb_platdata.py | 13 ++++++++-----
 tools/dtoc/test_dtoc.py    |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

Comments

Simon Glass May 20, 2020, 3:07 a.m. UTC | #1
On Wed, 13 May 2020 at 14:14, Walter Lozano <walter.lozano at collabora.com> wrote:
>
> Currently dtoc does not support the property cd-gpios used to declare
> the gpios for card detect in mmc.
>
> This patch adds support to cd-gpios property.
>
> Signed-off-by: Walter Lozano <walter.lozano at collabora.com>
> ---
>  tools/dtoc/dtb_platdata.py | 13 ++++++++-----
>  tools/dtoc/test_dtoc.py    |  2 +-
>  2 files changed, 9 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>
diff mbox series

Patch

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index d30e2af2ec..71a734b408 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -228,7 +228,7 @@  class DtbPlatdata(object):
         Return:
             Number of argument cells is this is a phandle, else None
         """
-        if prop.name in ['clocks']:
+        if prop.name in ['clocks', 'cd-gpios']:
             if not isinstance(prop.value, list):
                 prop.value = [prop.value]
             val = prop.value
@@ -248,11 +248,14 @@  class DtbPlatdata(object):
                 if not target:
                     raise ValueError("Cannot parse '%s' in node '%s'" %
                                      (prop.name, node_name))
-                prop_name = '#clock-cells'
-                cells = target.props.get(prop_name)
+                cells = None
+                for prop_name in ['#clock-cells', '#gpio-cells']:
+                    cells = target.props.get(prop_name)
+                    if cells:
+                        break
                 if not cells:
-                    raise ValueError("Node '%s' has no '%s' property" %
-                            (target.name, prop_name))
+                    raise ValueError("Node '%s' has no cells property" %
+                            (target.name))
                 num_args = fdt_util.fdt32_to_cpu(cells.value)
                 max_args = max(max_args, num_args)
                 args.append(num_args)
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 7e8947d4af..814988c374 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -426,7 +426,7 @@  void populate_phandle_data(void) {
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
             dtb_platdata.run_steps(['struct'], dtb_file, False, output)
-        self.assertIn("Node 'phandle-target' has no '#clock-cells' property",
+        self.assertIn("Node 'phandle-target' has no cells property",
                       str(e.exception))
 
     def test_aliases(self):