kconfig: Introduce typed dt kconfig functions
Replace:
dt_chosen_reg_addr
dt_chosen_reg_size
dt_node_reg_addr
dt_node_reg_size
with:
dt_chosen_reg_addr_int
dt_chosen_reg_size_int
dt_chosen_reg_addr_hex
dt_chosen_reg_size_hex
dt_node_reg_addr_int
dt_node_reg_size_int
dt_node_reg_addr_hex
dt_node_reg_size_hex
So that we get the proper formatted string for the type of symbol.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py
index 14345b6..ad3f45b 100644
--- a/scripts/kconfig/kconfigfunctions.py
+++ b/scripts/kconfig/kconfigfunctions.py
@@ -140,31 +140,31 @@
def _node_reg_addr(node, index, unit):
if not node:
- return "0x0"
+ return 0
if not node.regs:
- return "0x0"
+ return 0
if int(index) >= len(node.regs):
- return "0x0"
+ return 0
- return hex(node.regs[int(index)].addr >> _dt_units_to_scale(unit))
+ return node.regs[int(index)].addr >> _dt_units_to_scale(unit)
def _node_reg_size(node, index, unit):
if not node:
- return "0"
+ return 0
if not node.regs:
- return "0"
+ return 0
if int(index) >= len(node.regs):
- return "0"
+ return 0
- return str(node.regs[int(index)].size >> _dt_units_to_scale(unit))
+ return node.regs[int(index)].size >> _dt_units_to_scale(unit)
-def dt_chosen_reg_addr(kconf, _, chosen, index=0, unit=None):
+def _dt_chosen_reg_addr(kconf, chosen, index=0, unit=None):
"""
This function takes a 'chosen' property and treats that property as a path
to an EDT node. If it finds an EDT node, it will look to see if that
@@ -178,14 +178,14 @@
'g' or 'G' divide by 1,073,741,824 (1 << 30)
"""
if doc_mode or edt is None:
- return "0x0"
+ return 0
node = edt.chosen_node(chosen)
return _node_reg_addr(node, index, unit)
-def dt_chosen_reg_size(kconf, _, chosen, index=0, unit=None):
+def _dt_chosen_reg_size(kconf, chosen, index=0, unit=None):
"""
This function takes a 'chosen' property and treats that property as a path
to an EDT node. If it finds an EDT node, it will look to see if that node
@@ -199,14 +199,29 @@
'g' or 'G' divide by 1,073,741,824 (1 << 30)
"""
if doc_mode or edt is None:
- return "0"
+ return 0
node = edt.chosen_node(chosen)
return _node_reg_size(node, index, unit)
-def dt_node_reg_addr(kconf, _, path, index=0, unit=None):
+def dt_chosen_reg(kconf, name, chosen, index=0, unit=None):
+ """
+ This function just routes to the proper function and converts
+ the result to either a string int or string hex value.
+ """
+ if name == "dt_chosen_reg_size_int":
+ return str(_dt_chosen_reg_size(kconf, chosen, index, unit))
+ if name == "dt_chosen_reg_size_hex":
+ return hex(_dt_chosen_reg_size(kconf, chosen, index, unit))
+ if name == "dt_chosen_reg_addr_int":
+ return str(_dt_chosen_reg_addr(kconf, chosen, index, unit))
+ if name == "dt_chosen_reg_addr_hex":
+ return hex(_dt_chosen_reg_addr(kconf, chosen, index, unit))
+
+
+def _dt_node_reg_addr(kconf, path, index=0, unit=None):
"""
This function takes a 'path' and looks for an EDT node at that path. If it
finds an EDT node, it will look to see if that node has a register at the
@@ -219,17 +234,17 @@
'g' or 'G' divide by 1,073,741,824 (1 << 30)
"""
if doc_mode or edt is None:
- return "0"
+ return 0
try:
node = edt.get_node(path)
except edtlib.EDTError:
- return "0"
+ return 0
return _node_reg_addr(node, index, unit)
-def dt_node_reg_size(kconf, _, path, index=0, unit=None):
+def _dt_node_reg_size(kconf, path, index=0, unit=None):
"""
This function takes a 'path' and looks for an EDT node at that path. If it
finds an EDT node, it will look to see if that node has a register at the
@@ -242,16 +257,31 @@
'g' or 'G' divide by 1,073,741,824 (1 << 30)
"""
if doc_mode or edt is None:
- return "0"
+ return 0
try:
node = edt.get_node(path)
except edtlib.EDTError:
- return "0"
+ return 0
return _node_reg_size(node, index, unit)
+def dt_node_reg(kconf, name, path, index=0, unit=None):
+ """
+ This function just routes to the proper function and converts
+ the result to either a string int or string hex value.
+ """
+ if name == "dt_node_reg_size_int":
+ return str(_dt_node_reg_size(kconf, path, index, unit))
+ if name == "dt_node_reg_size_hex":
+ return hex(_dt_node_reg_size(kconf, path, index, unit))
+ if name == "dt_node_reg_addr_int":
+ return str(_dt_node_reg_addr(kconf, path, index, unit))
+ if name == "dt_node_reg_addr_hex":
+ return hex(_dt_node_reg_addr(kconf, path, index, unit))
+
+
def dt_node_has_bool_prop(kconf, _, path, prop):
"""
This function takes a 'path' and looks for an EDT node at that path. If it
@@ -300,9 +330,13 @@
"dt_str_val": (dt_str_val, 1, 1),
"dt_compat_enabled": (dt_compat_enabled, 1, 1),
"dt_chosen_label": (dt_chosen_label, 1, 1),
- "dt_chosen_reg_addr": (dt_chosen_reg_addr, 1, 3),
- "dt_chosen_reg_size": (dt_chosen_reg_size, 1, 3),
- "dt_node_reg_addr": (dt_node_reg_addr, 1, 3),
- "dt_node_reg_size": (dt_node_reg_size, 1, 3),
+ "dt_chosen_reg_addr_int": (dt_chosen_reg, 1, 4),
+ "dt_chosen_reg_addr_hex": (dt_chosen_reg, 1, 4),
+ "dt_chosen_reg_size_int": (dt_chosen_reg, 1, 4),
+ "dt_chosen_reg_size_hex": (dt_chosen_reg, 1, 4),
+ "dt_node_reg_addr_int": (dt_node_reg, 1, 4),
+ "dt_node_reg_addr_hex": (dt_node_reg, 1, 4),
+ "dt_node_reg_size_int": (dt_node_reg, 1, 4),
+ "dt_node_reg_size_hex": (dt_node_reg, 1, 4),
"dt_node_has_bool_prop": (dt_node_has_bool_prop, 2, 2),
}