kconfig: Add new functions to kconfigfunctions to use EDT

Add a new set of functions that utilize EDT so we can move away from the
generated .conf file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2019-08-28 09:30:23 -05:00 committed by Kumar Gala
commit 5735397b9b
4 changed files with 234 additions and 38 deletions

View file

@ -815,62 +815,52 @@ from the device tree.
Device Tree Related Functions
=============================
See the Python docstrings in ``scripts/kconfig/kconfigfunctions.py`` for more
details on the functions.
.. code-block:: none
dt_int_val(kconf, _, name, unit):
This function looks up 'name' in the DTS generated "conf" style database
(generated_dts_board.conf in <build_dir>/zephyr/include/generated/)
and if it's found it will return the value as an decimal integer. The
function will divide the value based on 'unit':
None No division
'k' or 'K' divide by 1024 (1 << 10)
'm' or 'M' divide by 1,048,576 (1 << 20)
'g' or 'G' divide by 1,073,741,824 (1 << 30)
dt_hex_val(kconf, _, name, unit):
This function looks up 'name' in the DTS generated "conf" style database
(generated_dts_board.conf in <build_dir>/zephyr/include/generated/)
and if it's found it will return the value as an hex integer. The
function will divide the value based on 'unit':
None No division
'k' or 'K' divide by 1024 (1 << 10)
'm' or 'M' divide by 1,048,576 (1 << 20)
'g' or 'G' divide by 1,073,741,824 (1 << 30)
dt_str_val(kconf, _, name):
This function looks up 'name' in the DTS generated "conf" style database
(generated_dts_board.conf in <build_dir>/zephyr/include/generated/)
and if it's found it will return the value as string. if it's not found we
return an empty string.
dt_chosen_reg_addr(kconf, _, chosen, index=0, unit=None):
dt_chosen_reg_size(kconf, _, chosen, index=0, unit=None):
dt_node_reg_addr(kconf, _, path, index=0, unit=None):
dt_node_reg_size(kconf, _, path, index=0, unit=None):
dt_compat_enabled(kconf, _, compat):
dt_node_has_bool_prop(kconf, _, path, prop):
Example Usage
=============
-------------
The following example shows the usage of the ``dt_int_val`` function:
The following example shows the usage of the ``dt_node_reg_addr`` function.
This function will take a path to a device tree node and register the register
address of that node:
.. code-block:: none
boards/arm/mimxrt1020_evk/Kconfig.defconfig
boards/riscv/hifive1_revb/Kconfig.defconfig
config FLASH_SIZE
default $(dt_int_val,DT_NXP_IMX_FLEXSPI_402A8000_SIZE_1,K)
config FLASH_BASE_ADDRESS
default $(dt_node_reg_addr,/soc/spi@10014000,1)
In this example if we examine the generated generated_dts_board.conf file
as part of the Zephyr build we'd find the following entry:
In this example if we examine the dts file for the board:
.. code-block:: none
DT_NXP_IMX_FLEXSPI_402A8000_SIZE_1=8388608
spi0: spi@10014000 {
compatible = "sifive,spi0";
reg = <0x10014000 0x1000 0x20010000 0x3c0900>;
reg-names = "control", "mem";
...
};
The ``dt_int_val`` will search the generated_dts_board.conf that is derived from
the dts for the board and match the ``DT_NXP_IMX_FLEXSPI_402A8000_SIZE_1`` entry.
The function than will than scale the value by ``1024``. This effective causes
The ``dt_node_reg_addr`` will search the dts file for a node at the path
``/soc/spi@10014000``. The function than will extract the register address
at the index 1. This effective gets the value of ``0x20010000`` and causes
the above to look like:
.. code-block:: none
config FLASH_SIZE
default 8192
config FLASH_BASE_ADDRESS
default 0x20010000
Other resources