Esempio n. 1
0
def generate_node_defines(node_path):
    # Generates #defines (and .conf file values) from the device
    # tree node at 'node_path'

    if get_compat(node_path) not in get_binding_compats():
        return

    # We extract a few different #defines for a flash partition, so it's easier
    # to handle it in one step
    if 'partition@' in node_path:
        flash.extract_partition(node_path)
        return

    generate_bus_defines(node_path)

    # Generate per-property ('foo = <1 2 3>', etc.) #defines
    for yaml_prop, yaml_val in get_binding(node_path)['properties'].items():
        if 'generation' not in yaml_val:
            continue

        match = False

        # Handle each property individually, this ends up handling common
        # patterns for things like reg, interrupts, etc that we don't need
        # any special case handling at a node level
        for prop in reduced[node_path]['props']:
            if re.fullmatch(yaml_prop, prop):
                match = True
                generate_prop_defines(node_path, prop)

        # Handle the case that we have a boolean property, but its not
        # in the dts
        if not match and yaml_val['type'] == 'boolean':
            generate_prop_defines(node_path, yaml_prop)
Esempio n. 2
0
def generate_node_defines(node_path):
    node = reduced[node_path]
    node_compat = get_compat(node_path)

    if node_compat not in get_binding_compats():
        return

    for k, v in get_binding(node_path)['properties'].items():
        if 'generation' not in v:
            continue

        # Handle any per node extraction first.  For example we
        # extract a few different defines for a flash partition so its
        # easier to handle the partition node in one step
        if 'partition@' in node_path:
            flash.extract_partition(node_path)
            continue

        match = False

        # Handle each property individually, this ends up handling common
        # patterns for things like reg, interrupts, etc that we don't need
        # any special case handling at a node level
        for c in node['props']:
            if c in {
                    'interrupt-names', 'reg-names', 'phandle', 'linux,phandle'
            }:
                continue

            if re.fullmatch(k, c):
                match = True

                if 'pinctrl-' in c:
                    names = deepcopy(node['props'].get('pinctrl-names', []))
                elif not c.endswith('-names'):
                    names = deepcopy(node['props'].get(c[:-1] + '-names', []))
                    if not names:
                        names = deepcopy(node['props'].get(c + '-names', []))

                if not isinstance(names, list):
                    names = [names]

                extract_property(node_compat, node_path, c, v, names)

        # Handle the case that we have a boolean property, but its not
        # in the dts
        if not match and v['type'] == 'boolean':
            extract_property(node_compat, node_path, k, v, None)
def extract_node_include_info(reduced, root_node_address, sub_node_address,
                              y_sub):

    filter_list = ['interrupt-names', 'reg-names', 'phandle', 'linux,phandle']
    node = reduced[sub_node_address]
    node_compat = get_compat(root_node_address)

    if node_compat not in get_binding_compats():
        return {}, {}

    if y_sub is None:
        y_node = get_binding(root_node_address)
    else:
        y_node = y_sub

    # check to see if we need to process the properties
    for k, v in y_node['properties'].items():
        if 'properties' in v:
            for c in reduced:
                if root_node_address + '/' in c:
                    extract_node_include_info(reduced, root_node_address, c, v)
        if 'generation' in v:

            match = False

            # Handle any per node extraction first.  For example we
            # extract a few different defines for a flash partition so its
            # easier to handle the partition node in one step
            if 'partition@' in sub_node_address:
                flash.extract_partition(sub_node_address)
                continue

            # Handle each property individually, this ends up handling common
            # patterns for things like reg, interrupts, etc that we don't need
            # any special case handling at a node level
            for c in node['props'].keys():
                # if prop is in filter list - ignore it
                if c in filter_list:
                    continue

                if re.match(k + '$', c):

                    if 'pinctrl-' in c:
                        names = deepcopy(node['props'].get(
                            'pinctrl-names', []))
                    else:
                        if not c.endswith("-names"):
                            names = deepcopy(node['props'].get(
                                c[:-1] + '-names', []))
                            if not names:
                                names = deepcopy(node['props'].get(
                                    c + '-names', []))
                    if not isinstance(names, list):
                        names = [names]

                    extract_property(node_compat, sub_node_address, c, v,
                                     names)
                    match = True

            # Handle the case that we have a boolean property, but its not
            # in the dts
            if not match:
                if v['type'] == "boolean":
                    extract_property(node_compat, sub_node_address, k, v, None)