Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: use codegen for device instantiation #10888

Closed
wants to merge 13 commits into from

Commits on Nov 27, 2018

  1. scripts: cogeno: add inline code generation

    Cogeno is a file generation tool. It uses pieces of Python or
    Jinja2 script code in the source file as generators to
    generate whatever text is needed.
    
    Cogeno is based on Cog. All files taken from Cog are modified.
    The files are marked by the Cog author's copyright:
    
    Copyright 2004-2016, Ned Batchelder.
              http://nedbatchelder.com/code/cog
    SPDX-License-Identifier: MIT
    
    Origin: https://pypi.python.org/pypi/cogapp
    Status:  2.5.1
    Description: A code generator for executing Python snippets in source
                 files.
    Dependencies: python
    URL: https://pypi.python.org/pypi/cogapp
    commit: 2.5.1
    Maintained-by: External
    License: MIT
    License Link:
        URL: https://pypi.python.org/pypi/cogapp
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    0dd210c View commit details
    Browse the repository at this point in the history
  2. scripts: cogeno: edts: add extended DTS database module

    The Extended Device Tree Specification database collates
    device tree (dts) information with information taken from
    the device tree bindings.
    
    The EDTS database may be loaded from a json file, stored
    to a json file or extracted from the DTS files and the
    bindings yaml files.
    
    The database is integrated into cogeno as a module.
    
    The commit integrates database development done in zephyrproject-rtos#9876
    which was based on zephyrproject-rtos#6762.
    
    Major differences/ improvements to zephyrproject-rtos#9876 are:
    - the database now has an own extraction function that
      can be used instead of e.g. extract_dts_includes.
      The extraction function follows the design of
      the extract_dts_includes script and the additions that
      were done in zephyrproject-rtos#9876. It is restructured and several globals
      are now classes and objects. All functionality of
      extract_dts_includes related to the generation of defines
      is not part of the database extract function. It's sole
      purpose is to fill the database directly from the compiled
      DTS file.
    - the database got itś own directory 'edtsdb' to structure
      all files related to the database.
    - The EDTSDevice class from zephyrproject-rtos#9876 was enhanced to allow
      devices to access the database they are taken from.
    
    Mayor compatibility issues to zephyrproject-rtos#9876.
    - The consumer, provider API and the internal structure
      of the database is copied from zephyrproject-rtos#9876.
      - API should be fully compatible.
      - Extraction of children was replaced as it broke the
        concept of the devices struct as a list of devices.
        The functions device.get_children() and
        device.get_parent() may be used to acess the
        parent<->child relation.
    - The EDTSDevice class is copied from zephyrproject-rtos#9876.
      - The device API should be compatible except for
        - the constructor which now needs the EDTS database and
        - the unique id feature. To ge an unique id the
          device.get_name() function can be used instead.
    
    Signed off from zephyrproject-rtos#9876 added to attribute for the changes done
    there and copied.
    
    Signed-off-by: Erwan Gouriou <[email protected]>
    Signed-off-by: Kumar Gala <[email protected]>
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    bd05cb5 View commit details
    Browse the repository at this point in the history
  3. scripts: cogeno: edts: add generic bindings for EDTS extraction

    These are generic bindings that the extraction function of
    the EDTS database can work with. The bindings can be overriden by
    providing a same named file to cogeno within a directory
    that is given in the --bindings option.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    6d7e50f View commit details
    Browse the repository at this point in the history
  4. templates: add Zephyr device declaration for code generation

    Modules and templates for Zephyr device declaration using
    code generation by cogeno.
    
    devicedeclare.py: a python module to support codegen python
                      templates and cogeno inline templates
    devicedeclare.jinja2: a jinja2 template to support cogeno
                          jinja2 templates and codegen inline
                          templates
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    b6d36f4 View commit details
    Browse the repository at this point in the history
  5. scripts: integrate code generation into Zephyr build system

    Integrate code generation by cogeno into Zephyr build system.
    
    If a source file is added by  zephyr_sources_codegen(..) or
    zephyr_sources_codegen_ifdef(..) cogeno will be executed and
    the generated file stored to the build directory. Compilation
    will run on the generated file only.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    0f9247d View commit details
    Browse the repository at this point in the history
  6. drivers: i2c: stm32: use code generation for driver instantiation

    Replace device instances code by codegen solution.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    fee96d1 View commit details
    Browse the repository at this point in the history
  7. drivers: spi: stm32: use code generation for driver instantiation

    Replace device instances code by code generation solution.
    
    For testing purposes all different ways of code generation
    are done for this driver:
    - inline template  - cogeno and Jinja2 snippets
                       - generates a source file
    - Jinja2 template  - generates a header file
    - codegen template - generates a header file
    
    Compilation is done for the unmodified source file including
    the codegen generated header file.
    
    Additionally the following adaptations are done:
    - Extend bindings to allow DTS extract for device info.
    - Correct DTS to be used in SPI driver.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    320a8f2 View commit details
    Browse the repository at this point in the history
  8. drivers: serial: stm32: use code generation for driver instantiation

    Replace device instances code by code generation solution.
    
    Extend binding to allow DTS extraction for device info.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    14efbdc View commit details
    Browse the repository at this point in the history
  9. drivers: can: stm32: use code generation for driver instantiation

    Replace device instances code by code generation solution.
    
    Extend binding to allow DTS extract for device info.
    
    Correct DTS to be used in CAN driver.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    67ad920 View commit details
    Browse the repository at this point in the history
  10. drivers: pwm: stm32: use code generation for driver instantiation

    Replace device instances code by code generation solution.
    
    Extend binding to allow DTS extraction for device info.
    
    Adapt samples.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    08fb2e9 View commit details
    Browse the repository at this point in the history
  11. drivers: interrupt: stm32: use code generation for driver instantiation

    Replace device instances code by code generation solution.
    
    Add binding to allow DTS extract for device info.
    
    Add DTS to be used in EXTI driver.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    3cebfd3 View commit details
    Browse the repository at this point in the history
  12. tests: drivers: spi: support NUCLEO F0x boards

    The NUCLEO FO91RC, F070RB, F030R8 boards use SPI_1
    for loopback test.
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    be75e68 View commit details
    Browse the repository at this point in the history
  13. spi: sam: fix function and config naming

    Incorrect naming prevents compilation.
    Change names:
      - CONFIG_xx_NAME -> DT_xx_NAME
      - spi_sam0_xx -> spi_sam_xx
    
    Signed-off-by: Bobby Noelte <[email protected]>
    b0661 committed Nov 27, 2018
    Configuration menu
    Copy the full SHA
    6350298 View commit details
    Browse the repository at this point in the history