Add a function that given a node address we get a list of compats back
instead of just the first. This is in prep for eDTS support.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Before dtc 1.4.7 we'd get something like the following for an reg
property:
reg = <1 2 3 4>;
After dtc 1.4.7 we get:
reg = <1 2>, <3 4>;
We should handle both cases in the extract reg handling code. So if
we see a list of lists, we flatten it to a single list to normalize
the property.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Python's open() by default using "system character encoding", which
may vary from system to system (e.g. LOCALE=C aka "ascii" on bare-OS
systems, something on Windows, etc.). But Zephyr files are utf-8, so
read them as such, by explicitly specifying encoding.
This is similar to changes earlier done to another script in 94620bd.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
The 'id' field was never used and tended to just have the compat of the
node. Lets remove it and removed some code in extract_dts_includes.py
related to it. Added a warning if 'id' is set in a yaml so we can
remove it going forward.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
For now we've used range properties as a pass through. However range
properties can translate from one address space to another. This is
typically used one address spaces translate from one physical bus to
another (For example going from PCI address space to internal SoC memory
map). However, we can also use this for cases where we want to reduce
duplication (For example with ARMv8-M for secure v non-secure MMIO
registers).
'ranges' takes either the form of:
ranges; /* pass through translation */
or:
ranges = <child-bus-address parent-bus-address length>;
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
We use to walk to the full tree in search of addr/size cells. We should
only have to look at the parent of the node for these properties.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Given the path address to a node return the address/size cells. In
theory this should just be looking up the #{address,size}-cells in
the parent node, we'll make that cleanup next.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
In case of having more than one reg, aliases would not generate
properly. Number of register at the end of define was missing.
Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
When the code partition is not at the beginning of the flash, the load
offset is wrongly computed. The address in the device tree is already
relative to the beginning of the parent node, ie the beginning of the
flash memory space. There is therefore no need to subtract it.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
The node name parsing for the _LABEL #define does not parse the unique
node portion in the same fashion between @<unit_address> and _<number>.
This change normalizes the two modes.
Signed-off-by: David Leach <david.leach@nxp.com>
If size or address cells happened to be 2 we'd get the wrong value since
we where shift the least significant 32-bit's up. Adjust the math based
on the value of the cell amount to fix things.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Rename address / size cell variable to clarify that its the number
of address / size cells.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
reg class is updated to take into account whole use cases
of reg extraction so extract_reg_prop could be removed.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Parameter 'names' is provided as argument of several property
extract functions. Thought it is actually used only once.
Remove when not needed.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.
With have *many* violations on Zephyr's code, this commit is tackling
only the violations caused by headers guards. It also takes the
opportunity to normalize them using the filename in uppercase and
replacing dot with underscore. e.g file.h -> FILE_H
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Generate CONFIG_DT_COMPAT flags using available nodes
'compatible' property.
Store them in a bogus node_address key of defs dict so
duplicates could be removed.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Before dtc 1.4.7 we'd get something like the following for an interrupt
property in which #interrupt-cells is 2.
interrupts = <1 2 3 4>;
After dtc 1.4.7 we get:
interrupts = <1 2>, <3 4>;
We should handle both cases in the extract interrupt handling code. So
if we see a list of lists, we flatten it to a single list to normalize
the property.
Fixes: #9558
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
A node alias name should be applied to the all property names.
Before this patch, the alias name is applied erroneously
just for CLOCK_CONTROLLER, skipping the CLOCK_BITS and CLOCK_BUS
property names.
Signed-off-by: Istvan Bisz <istvan.bisz@t-online.hu>
In addtion to zephyr/dts/bindings als scan the dts/bindings
directory within the application source directory for bindings.
Allows to have application specific bindings and drivers.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
When a DTS node has no 'compatible' property and its parent node has a
list for its compatible property, return only the first element of the
parent's compatible list.
Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
Variables 'names' is copying value from 'reduced' dict and gives
illusion that any computation could be done on copied data.
Problem is that later computation on 'names' will modify data in
'reduced'.
Use deepcopy in order to avoid erasing thing in reduced.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
'defs' variable is used and passed as a parameter in the vast
majority of the functions of extract_dts_includes script.
Set this variable global
Do the same with 'struct' variable for upcoming change.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Treat new generated dtc element 'alt-name' as usual aliases.
Aim is not to duplicate generation of node elements but provide
pointers using generic alternate names.
For instance, defining following overriding node:
arduino_i2c : i2c1 {};
Will generate following definition:
#define ARDUINO_I2C_LABEL ST_STM32_I2C_V1_40005400_LABEL
Then 'ARDUINO_I2C_LABEL' could be use a generic binding.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Allow use of new element of dtc grammar called overriding nodes:
i2cexp: &i2c2 {};
It allows a node to assign an alternate label to a node that
could be generic and used for adapter boards.
This commit is a derivative of a dtc commit from dtc v1.4.2 [1]
[1] https://bit.ly/2GFLLOa
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Do not provide info message if node type, title, version,
node description is overwritten.
This is the expected behaviour.
Fixes#8360
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
In some cases, node label could be generated with "/" character
in name string, which prevents compilation
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Commit 93d3a42776 changed the interface
of extract_controller() but did not change the recursive call within.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Correctly process multiple include files given to the
!include command of the YAML loader.
The fix only targets the sequential definition of include files.
Fixes#7067
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
'cell_string' yaml attribute has been introduced in order to
help enforcement of specific string during defines generation.
This adds complexity in understanding script behavior as a black
box and create additional dependency which is not strictly required.
For node specific generation functions (pinctrl and interrupts),
this could be replaced directly by an hardcoded version
(as everyone used the same 'cell_string' anyway).
For extract_cells functions, string could be replaced by extracted
property name. As a consequence, we're now able to generate defines
for properties refering to these controllers via phandle.
For instance, in following node
spbtle-rf@0 {
compatible = "st,spbtle-rf";
reg = <0>;
reset-gpios = <&gpioa 8 0>;
};
We'll be able to generate:
#define ST_STM32_SPI_...LE_RF_0_RESET_GPIOS_CONTROLLER "GPIOA"
#define ST_STM32_SPI_...PBTLE_RF_0_RESET_GPIOS_FLAGS_0 0
#define ST_STM32_SPI_..._SPBTLE_RF_0_RESET_GPIOS_PIN_0 8
Only impact for this whole change is for NXP clocks which were the
only ones using 'cell_string' attribute with a value different than
the default one.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
extract_controller only handle the first phandle in a cell property.
However we could easily have something like this where the phandles
vary:
gpios = <&gpiod 13 GPIO_INT_ACTIVE_LOW
&gpioc 14 GPIO_INT_ACTIVE_LOW>;
So we need to walk the property list for each phandle and produce a
define associated with it.
Also, if alias to the node is defined, indexed alias define
is generated for every indexed controller define:
#define GPIO_LEDS_0_GPIO_CONTROLLER_0 "GPIOA"
#define GPIO_LEDS_0_GPIO_CONTROLLER_1 "GPIOB"
#define LED1_GPIO_CONTROLLER_0 GPIO_LEDS_0_GPIO_CONTROLLER_0
#define LED1_GPIO_CONTROLLER_1 GPIO_LEDS_0_GPIO_CONTROLLER_1
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
If we had something like:
gpios = <&gpiod 13 GPIO_INT_ACTIVE_LOW
&gpiod 14 GPIO_INT_ACTIVE_LOW>;
The script blows up in extract_cells. While extract_cells attempted to
handle more than a single item in such a list, it didn't manipulate the
prop list for the recursive calls properly.
Since we pop off items from the prop list as we use them we can easily
pass the prop list to the rescurive call to fix things.
Besides, if alias is defined for the node, indexed aliases defines are
generated:
#define GPIO_LEDS_0_GPIO_FLAGS_0 4
#define GPIO_LEDS_0_GPIO_FLAGS_1 0
#define GPIO_LEDS_0_GPIO_PIN_0 5
#define GPIO_LEDS_0_GPIO_PIN_1 6
#define LED1_GPIO_FLAGS_0 GPIO_LEDS_0_GPIO_FLAGS_0
#define LED1_GPIO_FLAGS_1 GPIO_LEDS_0_GPIO_FLAGS_1
#define LED1_GPIO_PIN_0 GPIO_LEDS_0_GPIO_PIN_0
#define LED1_GPIO_PIN_1 GPIO_LEDS_0_GPIO_PIN_1
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Indexed defines were systematically generated even when there
was only one element to generate.
So we ended up generated a lot of _0 defines.
Then we needed to generate aliases to these _0 indexed defines,
in order to get useful defines.
For instance:
#define GPIO_LEDS_0_GPIO_FLAGS_0 4
#define GPIO_LEDS_0_GPIO_PIN_0 5
#define GPIO_LEDS_0_GPIO_FLAGS GPIO_LEDS_0_GPIO_FLAGS_0
#define GPIO_LEDS_0_GPIO_PIN GPIO_LEDS_0_GPIO_PIN_0
This commit allows to generate _0 indexed define only if a
property has more than one elements to define.
Aliases generation to _0 indexed defines are also removed.
Note: IRQ are left untouched since this is frequent to handle
multiple IRQs in a driver
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Some functions were using y_key and y_val as argument. This was not
quite easy to read. Rename argument into more informative versions.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
When a node is referencing to a parent node and this node is
reported as controller, generate a #define to declare this controller.
Value is controller property 'label'
For instance, if following gpio controller is referenced in board dts:
green_led_1: led@1 {
gpios = <&gpioa 5 GPIO_INT_ACTIVE_HIGH>;
label = "User LD1";
};
Following will be generated:
\#define GPIO_LEDS_1_GPIO_CONTROLLER "GPIOA"
Besides, if defined, alias label will be generated as well for this
controller:
aliases {
led0 = &green_led_1;
};
will trigger generation of:
\#define LED0_GPIO_CONTROLLER GPIO_LEDS_1_GPIO_CONTROLLER
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Modify get_compat function to look for 'compatible' property
in parent nodes if not available at node level.
Since this operation is quite common, this allows some code
factorization. As a consequence, get_compat takes 'node_address'
as argument instead of 'node'.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Apply extract_cells function also when property name
contains "gpio" (could be cs-gpio, rst-gpio, gpio-irq, ..)
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
In order to generate defs for references in aliases dts node,
add some treatment in extract_xxx functions to generate
aliases #define's
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
During yaml collapse step, convert inherited 'id' key to 'node_type'.
With this new 'node_type', it's is more easy to apply common treatment
to all bindings that include the same base yaml file but might not
have similar bindings/constraint naming convention.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Prepare to split extract_dts_includes in modules.
extract_dts_includes design is based on globals. Every module must be
able to use (import) them.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Moving logical parts into dedicated functions for clarity.
Factorizing a bit the code for potential future changes (more
'zephyr,xxxx' directives related to CONFIG_ option).
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Thus no need to parse twice the .dtsi, .dts and .yaml files.
Simplify provided arguments relevancy, letting argparse generating usage
message by itself.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Mandated by Python PEP-8.
(And normalize the way we write python in dts scripts also)
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
We should be able to run the script without requiring a zephyr,flash
property in the choosen node. Qualify insert based on having the
choosen property.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
When building in Windows, extract_dts_includes.py failed with an
exception on boards that have dts sensor bindings. This was caused by
path handling to search for i2c-device.yaml that worked in Linux, but
not in Windows.
Affected boards were disco_l475_iot1, frdm_k64f, frdm_kw41z, and
hexiwear_k64.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>