Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam: gmac: replace deprecated dt_int_val in Kconfig #24057

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/ethernet/Kconfig.sam_gmac
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if ETH_SAM_GMAC
config ETH_SAM_GMAC_QUEUES
int "Number of active hardware TX and RX queues"
default 1
range 1 $(dt_int_val,DT_INST_0_ATMEL_SAM_GMAC_NUM_QUEUES)
range 1 $(dt_node_int_prop_int,/soc/ethernet@40050088,num-queues)
stephanosio marked this conversation as resolved.
Show resolved Hide resolved
help
Select the number of hardware queues used by the driver. Packets will be
routed to appropriate queues based on their priority.
Expand Down
38 changes: 38 additions & 0 deletions scripts/kconfig/kconfigfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,19 @@ def _node_reg_size(node, index, unit):
return node.regs[int(index)].size >> _dt_units_to_scale(unit)


def _node_int_prop(node, prop):
if not node:
return 0

if prop not in node.props:
return 0

if node.props[prop].type != "int":
return 0

return node.props[prop].val


def _dt_chosen_reg_addr(kconf, chosen, index=0, unit=None):
"""
This function takes a 'chosen' property and treats that property as a path
Expand Down Expand Up @@ -340,6 +353,29 @@ def dt_node_has_bool_prop(kconf, _, path, prop):
return "n"


def dt_node_int_prop(kconf, name, path, prop):
"""
This function takes a 'path' and property name ('prop') looks for an EDT
node at that path. If it finds an EDT node, it will look to see if that
node has a property called 'prop' and if that 'prop' is an integer type
will return the value of the property 'prop' as either a string int or
string hex value, if not we return 0.
"""

if doc_mode or edt is None:
return "0"

try:
node = edt.get_node(path)
except edtlib.EDTError:
return "0"

if name == "dt_node_int_prop_int":
return str(_node_int_prop(node, prop))
if name == "dt_node_int_prop_hex":
return hex(_node_int_prop(node, prop))


def dt_compat_enabled(kconf, _, compat):
"""
This function takes a 'compat' and returns "y" if we find an "enabled"
Expand Down Expand Up @@ -402,6 +438,8 @@ def shields_list_contains(kconf, _, shield):
"dt_node_reg_size_int": (dt_node_reg, 1, 3),
"dt_node_reg_size_hex": (dt_node_reg, 1, 3),
"dt_node_has_bool_prop": (dt_node_has_bool_prop, 2, 2),
"dt_node_int_prop_int": (dt_node_int_prop, 2, 2),
"dt_node_int_prop_hex": (dt_node_int_prop, 2, 2),
"dt_nodelabel_has_compat": (dt_nodelabel_has_compat, 2, 2),
"shields_list_contains": (shields_list_contains, 1, 1),
}