Commit graph

441 commits

Author SHA1 Message Date
Kumar Gala
17f0977fc9 scripts: extract_dts_includes: Fix handing of no binding
There are cases in which we get the parents compat and thus we might
have a binding available for the actual node.  An example is having a
SPI or I2C controller with a child node, but that node doesn't have a
binding associated with it.  We'll end up getting the parent compat, so
return the parent binding in this case.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-11 09:23:21 -06:00
Kumar Gala
471d2f3a0a scripts: extract_dts_includes: Generate device bus info define
For devices on buses like I2C or SPI its possible that a sensor might
support being on either bus type.  In the dts we can tell this by
looking at the parent bus of the device.  Its useful for a driver to
know this so can we build support into the driver accordingly.

For example if the LSM6DSL sensor ("st,lsm6dsl") is in the dts on a spi
bus we now generate:

	#define DT_ST_LPS22HB_PRESS_BUS_SPI	1

Its possible that a system exists in which multiple of the same sensor
exist but on different busses, so drivers should handle that case
accordingly.  For the LSM6DSL example we'd end up with:

	#define DT_ST_LPS22HB_PRESS_BUS_I2C	1
	#define DT_ST_LPS22HB_PRESS_BUS_SPI	1

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-07 09:08:04 -06:00
Kumar Gala
2442382fac scripts: extract_dts_includes: Support same sensor on different bus
There are a number of cases in which we a sensor can be either connected
on I2C or SPI.  We've been treating these cases as different compatiable
properties, but they really should use the same compatiable and just
determine the info based on the parent bus in the device tree.  We can
now support having two different binding files for the same compatiable
to handle the case of a sensor supporting either I2C or SPI as how its
connected.

We put "sensor" nodes in a bus specific dict bus_bindings[bus] that
we can than lookup later based on the DTS and determining the bus type
that the "sensor" node is on.

Fixes #11375

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-07 09:08:04 -06:00
Kumar Gala
2893be57ef scripts: extract_dts_includes: Split out yaml_list info
Have the yaml_list now have 'node', 'bus', and 'compat' information
instead of just the 'node' info.  For now we have all YAML nodes under
yaml_list['node'], however this will change to support sensors that
can be on I2C or SPI, since they will have the same compat, but
different YAML nodes.

This also introduces yaml_list['bus'] which has YAML nodes for any
compatiables on a given 'parent' bus (ie, 'i2c', or 'spi').

Finally, we also have yaml_list['compat'] with all the compatiables
that we parsed and matched to a YAML.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-07 09:08:04 -06:00
Kumar Gala
f34a99532a scripts: extract_dts_includes: Pass node address to get_binding
Change get_binding to take the node address instead of the
compatiable.  This is in prep for having get_binding be able to look
at the parent of the node and determine which bus specific binding to
utilize (for cases like sensors that support both I2C & SPI).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-07 09:08:04 -06:00
Kumar Gala
112b0f5eff scripts: extract_dts_includes: Add accessor function to access binding
Add accessor functions get_binding and get_binding_compats to
encapsulate access to binding database info.  Cleanup all direct access
to binding info and replace with calls to get_binding() and
get_binding_compats()

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-07 09:08:04 -06:00
Kumar Gala
35afcc9c12 scripts: extract_dts_includes: remove passing yaml param to functions
Various functions like add_prop_aliases, extract_single_prop,
extract_single, reg.extract, compatible.extract, default.extract, and
flash.extract don't use the yaml argument that is passed to them.
Remove passing the argument, this is the first step in making access to
the yaml node information go through an accessor function.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-07 09:08:04 -06:00
Kumar Gala
b7f5101e79 scripts: extract_dts_includes: Handle YAML inheritance when we load
Move the handling of 'inherits' in the YAML to right when we load.  This
allows us to remove yaml_collapse function and will allow us to look
into the yaml right after we load it for things like if the yaml is for
a child bus.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-07 09:08:04 -06:00
Jakub Rzeszutko
f8178dcb05 shell: remove Console dependencies
Removed Console dependencies from shell uart backend.
Generated define: CONFIG_UART_SHELL_ON_DEV_NAME for each board.

Fixes #10191

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-07 12:11:11 +01:00
Kumar Gala
459ad673ba scripts: extract_dts_includes: Fix DeprecationWarning
With python3.7 we get the following warning:

	extract_dts_includes.py:496: DeprecationWarning: Using or
	importing the ABCs from 'collections' instead of from
	'collections.abc' is deprecated, and in 3.8 it will stop
	working.

Fix this by using 'from collections.abc import Mapping' instead of
'import collections'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-04 22:54:46 -05:00
Bobby Noelte
1bf1d6a267 scripts: extract_dts_includes: fix cell name readout from yaml
Default for a unavailable cell name was an empty list, whereas a
given name is a string. Leads to a runtime error if the name is given.
Make the default an empty string.

Names for cells are taken from the yaml binding. The key used is
"#cells" which clashes if there are different cell based properties
for a device. Readout names from the more specific "#xxx-cells" if
given and fall back to "#cells" if not given.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2018-11-19 08:35:10 -06:00
Andrzej Głąbek
a7c430f36f scripts: dts: Use DT_ prefix in generated labels
Almost all labels generated by the extracting script are now prefixed
with DT_. The only exceptions are:
- stuff with 'base_label' specified in yaml bindings
- items specified by 'regs_config' and 'name_config' dictionaries
  in globals.py module
- FLASH related labels generated by flash.extract() called separately
  from generate_node_definitions(), e.g. FLASH_WRITE_BLOCK_SIZE -
  these are used directly, not through fixups, from existing code
  so I didn't want to touch them now

Labels generated for aliases are additionally prefixed with information
from the 'compatible' property, e.g. DT_GPIO_LEDS_LED0_* is generated
instead of LED0_*. To provide backward compatibility for code that uses
LEDx_* and SWx_* labels in their previous forms, a command line option
named 'old-alias-names' is added to the extraction script. This option
causes that the labels for aliases are generated in both old and new
forms. Currently this option is always enabled in dts.cmake.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Erwan Gouriou
eaac6d3cf9 scripts/dts: extract_dts_includes: fix multi-compat bus parent
Case when bus parent has more than one compatible was not treated
correctly. Use get_compat() method which returns first compat
in case several compats are available

Fixes #11121

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-11-10 11:45:53 -06:00
Kumar Gala
7c2a8a4678 dts/extract_dts_includes.py: Expose flash partition extract function
Allow directly calling the flash partition extraction function and
remove passing any arguments that the function doesn't actually use.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-06 07:42:39 -06:00
Kumar Gala
6fd3fbbd22 dts/extract_dts_includes.py: Rework flash partition extraction
Reworked flash partition extraction so we call it when we see a
node that is 'partiton@' instead of per property.  We also handle the
'read-only' property in the flash partition extraction function which
lets us remove 'use-property-label' handling.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-06 07:42:39 -06:00
Kumar Gala
577df2dbe3 dts/extract_dts_includes.py: remove use of 'use-property-label' in regs
We don't have any cases that need 'use-property-label' related to
handling of reg extraction so lets remove it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-06 07:42:39 -06:00
Kumar Gala
30960e61bf scripts/dts: extract_dts_includes: Add support for client pwms
Add support to the extract script to handle 'pwms' client properties.
This is pretty much identical to how we hand 'gpios'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-05 14:01:21 -06:00
Kumar Gala
a834c53e91 scripts: dts: extract: Fix handling of prop being a list of lists
Before dtc 1.4.7 we'd get something like the following for an gpios
property:

reg = <1 2 3 4>;

After dtc 1.4.7 we get:

cs-gpios = <0x05 0x0d 0x00>, < 0x06 0x00 0x00>;

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>
2018-11-02 23:11:33 -04:00
Erwan Gouriou
94d3b6a211 scripts/dts: extract: fix 'compatbible' property typo
Replace "Compatibles" with "compatibles".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-10-25 08:02:33 +01:00
Erwan Gouriou
ba79b2f43f scripts/dts: extract: Provide a value to generated compat #define
Compat define is generated without value. This should not harm,
but since generated flag is a "Kconfig like" define, we migth need it
to hold a value.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-10-25 08:02:33 +01:00
Erwan Gouriou
a6716aef15 scripts/dts: extract_dts_includes: fix alias creation for subnodes
Heuristic for populating an alias string for a subnode
of an alias node was wrong as there was no check if
alias already existed and string created was not in line
with device tree specfication (allowed chars: [0-9],[a-z], '-').

Fix these two points.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-10-24 18:17:09 +01:00
Kumar Gala
f6a30ff070 dts/extract_dts_includes.py: refactor get_node_label_string
We can replace the method get_node_label_string in DTDirective with the
global function get_node_label.  This way we have a single place that
labels for defines are being generated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-24 10:41:25 +01:00
Kumar Gala
193ad8ef9f dts/extract_dts_includes.py: refactor get_node_label
Don't based the compat to get_node_label, we can just figure out based
on the node address we are passed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-24 10:41:25 +01:00
Kumar Gala
168c2dec95 dts/extract_dts_includes.py: Move label override handling
Refactor the handling of 'use-property-label' into extract_prop since
its the only place its needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-24 10:41:25 +01:00
Kumar Gala
25ec17683f scripts/dts/extract: Change compat define prefix
Drop CONFIG_ and just use DT_ prefix for compatiable generated defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-24 10:40:46 +01:00
Kumar Gala
b61b0cc631 dts/extract_dts_includes.py: Filter out standard properties
Standard device tree properties like 'reg-names', 'interrupt-names', and
'phandle' should be handled by other extract mechanisms or ignored.  So
filter them out before we even call extract_property

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-19 10:01:51 -05:00
Kumar Gala
fc5e23365e dts: Add proper handling for boolean properties
We've never handled boolean properties well, if we had a boolean that
existed we'd generate a define of 'True' and if the boolean didn't exist
than nothing would be generated.  So there was no easy way to tell that
the boolean wasn't defined.

Now if we mark a property as boolean in the yaml, we will generate a
define for it regardless if it exists or not.  If it exists we'll
set the value to 1, and if it doesn't to 0.

Fixes #8376

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-19 07:55:34 -05:00
Kumar Gala
527a69ce62 dts/extract/globals.py: Add function to get list of compats
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>
2018-10-18 12:57:32 -05:00
Kumar Gala
3c14bbe884 scripts: dts: extract: Fix handling of reg prop being a list of lists
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>
2018-10-18 06:59:13 -05:00
Paul Sokolovsky
b9248a17ac scripts: extract_dts_includes: Read files as utf-8
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>
2018-10-17 13:56:25 +02:00
Kumar Gala
011b93011e dts: yaml: remove unused id field
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>
2018-10-11 08:03:44 -05:00
Kumar Gala
c922788d0a scripts/dts/extract: Add support for translating range properties
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>
2018-10-05 13:19:39 -05:00
Kumar Gala
31340d8cdd scripts/dts/extract: Re-implement get_addr_size_cells
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>
2018-10-05 09:59:07 -05:00
Kumar Gala
6a8d5952d0 scripts/dts: Add help function to get address/size cells for a node
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>
2018-10-05 09:59:07 -05:00
Kumar Gala
bf0001242c scripts/dts/extract: Add get_parent_address helper function
We have a few places that we want the path to the parent, so lets add a
helper function for that.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-05 09:59:07 -05:00
Mieszko Mierunski
316f8604b7 script: dts: Fix alias generation for reg property.
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>
2018-10-04 07:54:48 -05:00
Aurelien Jarno
872719e9a6 scripts/dts/extract/flash.py: fix load offset
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>
2018-10-02 10:00:04 -07:00
David Leach
dc2acd6b94 scripts: extract: globals.py: Fix node name parsing
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>
2018-10-02 09:45:39 -05:00
Kumar Gala
c57f3a09bc scripts/dts/extract: Fix handling of value extraction based on cells
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>
2018-09-21 07:23:49 -07:00
Bobby Noelte
14ced2f021 scripts/dts/extract: Cleanup reg extraction
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>
2018-09-21 07:23:49 -07:00
Erwan Gouriou
cc054c8044 scripts/dts/extract: factorize 'reg' prop extraction
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>
2018-09-21 07:23:49 -07:00
Erwan Gouriou
8245b0c1a2 scripts/dts: extract_dts_includes: remove unused 'names' argument
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>
2018-09-21 07:23:49 -07:00
Flavio Ceolin
a7fffa9e00 headers: Fix headers guards
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>
2018-09-17 15:49:26 -04:00
Erwan Gouriou
c5ada39411 scripts: extract_dts_includes.py: generate 'compatible' CONFIG flags
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>
2018-09-14 08:02:53 -05:00
Kumar Gala
5824b81176 scripts: dts: extract: Fix handling of irq prop being a list of lists
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>
2018-09-06 09:46:03 -05:00
Istvan Bisz
1642c45717 scripts: dts: extract: clock.py fix node alias name
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>
2018-09-03 12:46:44 -04:00
Bobby Noelte
5a16b9020f dts: bindings: scan application dir for bindings
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>
2018-08-27 12:50:13 -04:00
Nathaniel Graff
0b60f3839d dts: Fix get_compat when parent compat is a list
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>
2018-08-16 06:22:39 -07:00
Erwan Gouriou
69a211fe00 scripts: extract_dts_includes: use deepcopcy when accessing reduced
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>
2018-08-06 09:44:21 -05:00
Erwan Gouriou
8e7403504a scripts/dts: extract_dts_includes: makes 'defs' and 'structs' global
'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>
2018-08-06 09:44:21 -05:00
Erwan Gouriou
deb0941cd5 scripts/extract/globals: treat node alternate names as 'aliases'
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>
2018-07-05 11:28:53 -05:00
Erwan Gouriou
fa5d6ec363 scripts: devicetree.py: get alternate labels from dt
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>
2018-07-05 11:28:53 -05:00
Bobby Noelte
ca7fc2adbc scripts: extract_dts_includes.py: fix false info message
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>
2018-07-04 08:28:45 -04:00
Bobby Noelte
08216f5ef4 scripts: extract_dts_includes.py: refactor for better maintenance
Refactor for better maintenance and to ease future enhancements.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2018-07-03 12:48:19 -05:00
Erwan Gouriou
ad29ec69dd scripts: extract: globals.py: fix node name when it includes "@"
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>
2018-06-12 03:54:26 -04:00
Bobby Noelte
1d27ee0b09 scripts: extract_dts_includes: fix recursion in extract_controller
Commit 93d3a42776 changed the interface
of extract_controller() but did not change the recursive call within.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2018-05-28 16:49:34 -04:00
Bobby Noelte
58967c7d3c scripts: extract_dts_includes.py: fix multiple include in bindings
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>
2018-05-25 10:59:12 -05:00
Erwan Gouriou
93d3a42776 scripts: extract_includes_dts: Remove usage of cell_string yaml attribute
'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>
2018-05-10 10:38:23 -05:00
Erwan Gouriou
9272a3e5ac scripts: extract_dts_includes: remove prefix argument
prefix was given as argument in several functions but not used
as property is never defined.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-05-10 10:38:23 -05:00
Kumar Gala
ded17a910d scripts: extract_dts_includes: Fix extract_controller for a list
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>
2018-05-10 10:38:23 -05:00
Kumar Gala
97a1ea22fc scripts: extract_dts_includes: Fix extract_cells for a list
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>
2018-05-10 10:38:23 -05:00
Erwan Gouriou
081c9c3bec scripts: extract_dts_includes: Generate'_0' defines only when needed
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>
2018-05-10 10:38:23 -05:00
Erwan Gouriou
e099f3813e scripts: extract_dts_includes: rename arguments for easier reading
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>
2018-05-10 10:38:23 -05:00
Erwan Gouriou
69beec87b1 scripts: extract_dts_includes: generate controller #define's
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>
2018-04-19 09:32:39 -05:00
Erwan Gouriou
f3caef8eac scripts: extract_dts_inlcudes: look up compatible field in parents
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>
2018-04-19 09:32:39 -05:00
Erwan Gouriou
3b529ca3ee scripts: extract_dts_inlcudes: generate cells for gpio
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>
2018-04-13 13:36:45 -05:00
Erwan Gouriou
074c90c5c4 scripts: dts_extract_include: generate aliases defs
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>
2018-04-10 13:01:02 -05:00
Erwan Gouriou
ba2ce2e9f0 script/extract_dts_includes: factorize call to upper()
Factorize call to 'upper()' into convert_string_to_label function

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-04-10 13:01:02 -05:00
Erwan Gouriou
1ee8eeaccc scripts: extract_dts_include: convert inherited 'id' to 'node_type'
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>
2018-03-26 14:48:49 -04:00
Bobby Noelte
b6005bfb2a scripts: extract_dts_includes.py: factorize globals for module usage
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>
2018-03-26 14:48:49 -04:00
Tomasz Bursztyka
dfd92b0602 script/dts: Remove unnecessary empty return on functions
No need to use return at the end of a function when it's not returning
anything.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-26 14:48:49 -04:00
Tomasz Bursztyka
7ef3ddee0b scripts/dts: De-clutter main function in extract_dts_includes
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>
2018-03-26 14:48:49 -04:00
Tomasz Bursztyka
1134393ac1 scripts/dts: Make extract_dts_includes generating both files by itself
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>
2018-03-26 14:48:49 -04:00
Tomasz Bursztyka
b34d156693 scripts/dts: Use 4-spaces tabs instead of 2-space tabs in devicetree.py
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>
2018-03-26 14:48:49 -04:00
Tomasz Bursztyka
6a9ebdcd18 scripts/dts: Fix Copyright headers
One was missing it and the other was not the new format.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-26 14:48:49 -04:00
Kumar Gala
767785825e scripts: extract_dts_inculdes: Fix issue if no zephyr,flash prop
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>
2018-03-15 08:14:00 -05:00
Maureen Helm
66d6b58176 scripts: extract_dts_includes: Fix path handling in Windows
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>
2018-03-12 09:44:36 -05:00
Kumar Gala
451fc36824 scripts: extract_dts_inculdes: Fix reg prop size/addr cell calculation
When we determine the address and size cells to determine how to parse a
reg property, we need to stop at the parent of the node, not at the node
itself.  If we have #address-cells or #size-cells in a node its meant
for the children of that node and not the node itself.

Fixes #4568

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-21 06:48:42 -06:00
Christopher Collins
14735116d1 subsys: mgmt: UART transport for SMP (mcumgr).
Add a UART driver dedicated to transporting mcumgr SMP requests and
responses.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-20 22:07:52 +01:00
Erwin Rol
e4890181b4 scripts/dts/extract_dts_includes.py: add ccm support
Add support for generating CONFIG_CCM_BASE_ADDRESS and CONFIG_CCM_SIZE
from the dts files.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Kumar Gala
8a6381d8e8 dts: flash: Add support for flash labels
Added a label for soc-nv-flash nodes.  Made some updates to the
generation to maintain creating defines for properties like
erase-block-size and write-block-size so they we get both
FLASH_ERASE_BLOCK_SIZE and FLASH_${LABEL}_ERASE_BLOCK_SIZE (same for
WRITE_BLOCK_SIZE).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-07 11:28:28 -06:00
Kumar Gala
bc6aae8d73 scripts: extract_dts_includes: Sanitize interrupt names
Its possible we have dashes in interrupt names that we need to convert
to underscores when we generate defines.  Make sure we do that otherwise
things aren't going to build.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-29 11:10:43 -06:00
Marti Bolivar
607a817a4a scripts: extract_dts_includes: fix potential undefined read
Only read 'status' when it has been assigned in compress_nodes().

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Erwan Gouriou
fa47748ca3 scripts: extract_dts_inculdes: treat 'parent: bus' attribute
When node has 'bus' as 'parent' attribute, change base label to
include parent address in label prefix.

Besides, generates a "_BUS_NAME" define which equals parent label.

Signed-Off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-12-14 11:30:44 -06:00
Erwan Gouriou
568fc9d91f scripts: extract_dts_include: update to match new bindings path
Following move of dts bindings from common/yaml to bindings,
update yaml file search routine.

Signed-Off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-12-14 11:30:44 -06:00
Erwan Gouriou
318436589c script: extract_dts_includes: fix recursive inclusion
extract_dts_includes script was not handling correctly
recusrsive inclusions. Fix it.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-12-12 12:52:04 -06:00
Erwan Gouriou
104553d93f yaml: fix properties syntax to 'mapping' instead of 'series'
According to yaml syntaxic rules, 'properties' described in dts
bindings yaml files could be seen as 'mapping'(key/value couple),
instead of 'series' (list of single elements).
yaml 'mappings' will then be converted by yaml python library as
python 'dict' which will ease treatment (instead of current list
as were before this commit).
Same treatment is applied to 'inherits'.

script extract_dts_inlcude is updated to take change of yaml_list
structre into account. This allows some code simplification. Largest
impact is yaml_collapse function which works now allow complete
overload method on all the attributes of a yaml nodes.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-11-28 11:42:59 -06:00
Kumar Gala
03fb9ff5f9 scripts/dts/extract_dts_includes.py: Cleanup yaml file finding
Cleanup how we find the yaml files for device tree bindings.  Move to a
recursive dir search of the dts/ dir.  This will be useful for
supporting re-organizing of the yaml files to match binding dir
structure.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-10-23 15:02:00 +02:00
Kumar Gala
aed577a853 scripts/dts/extract_dts_includes.py: allow multiple fixup files
Allow the script to take multiple -f (fixup) file options.  We output
the fixup files in order that the -f options are passed.  This will
allow us to have a common soc fixup and board fixup if we desire.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-09-17 17:34:38 -04:00
Aska Wu
729a7b1e84 scripts/dts/extract_dts_includes.py: Fix tab calculation
If there's any key in the alias which length is larger than other keys
in the node, the include file will be incorrect, there will be no tab
between the key and value.

We need to take into account the max length of alias keys.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-09-17 16:51:16 -04:00
Anas Nashif
3461c8cf59 scripts: move dts related scripts to scripts/dts/
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 08:53:56 -07:00