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>
This commit is contained in:
Kumar Gala 2018-12-07 07:50:21 -06:00 committed by Kumar Gala
commit 471d2f3a0a

View file

@ -30,6 +30,7 @@ class DTCompatible(DTDirective):
def extract(self, node_address, prop, def_label):
# compatible definition
binding = get_binding(node_address)
compatible = reduced[node_address]['props'][prop]
if not isinstance(compatible, list):
compatible = [compatible, ]
@ -42,6 +43,17 @@ class DTCompatible(DTDirective):
compat_defs: "1",
}
insert_defs(node_address, load_defs, {})
# Generate #define for BUS a "sensor" might be on
# for example:
# #define DT_ST_LPS22HB_PRESS_BUS_SPI 1
if 'parent' in binding:
bus = binding['parent']['bus']
compat_defs = 'DT_' + compat_label + '_BUS_' + bus.upper()
load_defs = {
compat_defs: "1",
}
insert_defs(node_address, load_defs, {})
##
# @brief Management information for compatible.