mbox series

[v4,00/10] Add support for extension boards detection and DT overlays application

Message ID 20210420082541.28757-1-kory.maincent@bootlin.com
Headers show
Series Add support for extension boards detection and DT overlays application | expand

Message

Köry Maincent April 20, 2021, 8:25 a.m. UTC
This series of patches aims at proposing a generic U-Boot mechanism to
detect extension boards connected to the HW platform, and apply the
appropriate Device Tree overlays depending on the detected extension
boards.

Indeed, numerous popular platforms, such as the BeagleBone or the
RaspberryPi, feature some kind of extension board mechanism. These
extension boards are often discoverable through some kind of EEPROM
(connected on I2C, 1-wire, etc.) and require Device Tree overlays to be
applied at the U-Boot level to provide a complete HW description to the
Linux kernel. However, currently this logic is usually implemented
ad-hoc in downstream forks of U-Boot.

This series proposes to bring a HW-agnostic and generic solution to
this problem to upstream U-Boot. The series shows that it is generic
enough by implementing its usage for 2 different families of HW
platforms and expansion boards:

 - The BeagleBone Black and BeagleBone AI, that use extension boards
   where the EEPROM describing the extension boards is connected over
   I2C.

 - The CHIP, that uses extension boards where the EEPROM describing the
   extension boards is connected over 1-wire.

The patch series implements a new command called "extension", with two
sub-commands:

 - "extension scan" to detect available extension boards

 - "extension list" will simply list the detected extension boards

 - "extension apply" will allow to apply the Device Tree overlays
   corresponding to one extension board or to all expansion boards

Note that the name "extension" has been chosen to not refer to any
particular board-specific terminology for extension boards ("cape" for
BeagleBone, "DIP" for CHIP, "hat" for RaspberryPi, etc.). However, we
welcome suggestions of other names and are definitely willing to use a
different naming.

The "extension apply" command requires two environment variables to be
defined so that it knows how to apply DT overlays. This is described
in more details in PATCH 1.

This generic code requires board-specific code for the detection and
enumeration of extension boards. This is simply implemented in the form
of a board-specific extension_board_scan() function, which fills in a
list of detected extension boards.

In detail:

 - PATCH 1 move fdt_valid function to fdt_support file
 - PATCH 2 implements the generic command and logic
 - PATCH 3 implements the python test for the "extension" command
 - PATCH 4 implements the board-specific code for the BeagleBone platforms
 - PATCH 5 enables the mechanism for the BeagleBone AI
 - PATCH 6 review the detection mechanism of one-wire devices
 - PATCH 7 and 8 enable the mechanism for the CHIP
 - PATCH 9 and 10 enable the mechanism for the BeagleBone Black

Thanks in advance for your review and feedback

Change since v1:
- remove the one wire devicetree description of the CHIP board
- rewrite the detection of w1 to makes it automatic and not devicetree
  dependent
- replace Kconfig CHIP board target by Kconfig CHIP_DIP_SCAN simple option
- rewrite doc to rST syntax
- make few syntax update

Change since v2:
- review the detection of w1 to makes it compatible with automatic
  detection alongside the devicetree description detection
- update the patch separation between the mechanism for the CHIP and the
  configuration activation

Change since v3:
- Update commit messages on the extension command patch
- Remove a test on CMD_EXTENSION in the chip.c file.

Kory Maincent (10):
  fdt_support: move fdt_valid from cmd_fdt.c to fdt_support.c
  cmd: add support for a new "extension" command
  pytest: add sandbox test for "extension" command
  ti/common: add support for extension_scan_board function
  am57xx: add support for cape detect functionality
  w1: replace dt detection by automatic detection
  arm: sunxi: add support for DIP detection to CHIP board
  configs: CHIP: add support for DIP detect functionality
  arm: am335x: add support for i2c2 bus
  am335x: add support for cape detect functionality

 arch/Kconfig                              |   2 +
 arch/arm/mach-omap2/am33xx/Kconfig        |   1 +
 arch/arm/mach-omap2/am33xx/clock_am33xx.c |   1 +
 arch/arm/mach-omap2/omap5/Kconfig         |   1 +
 arch/arm/mach-sunxi/Kconfig               |   9 ++
 arch/sandbox/dts/Makefile                 |   1 +
 arch/sandbox/dts/overlay0.dts             |   9 ++
 arch/sandbox/dts/overlay1.dts             |   9 ++
 board/sandbox/sandbox.c                   |  23 +++
 board/sunxi/Makefile                      |   1 +
 board/sunxi/chip.c                        | 100 +++++++++++++
 board/ti/am335x/board.c                   |   3 +
 board/ti/am335x/board.h                   |   1 +
 board/ti/am335x/mux.c                     |  15 ++
 board/ti/am57xx/board.c                   |   1 +
 board/ti/common/Kconfig                   |   6 +
 board/ti/common/Makefile                  |   1 +
 board/ti/common/cape_detect.c             |  96 +++++++++++++
 board/ti/common/cape_detect.h             |  28 ++++
 cmd/Kconfig                               |  12 ++
 cmd/Makefile                              |   1 +
 cmd/extension_board.c                     | 167 ++++++++++++++++++++++
 cmd/fdt.c                                 |  49 -------
 common/fdt_support.c                      |  46 ++++++
 configs/CHIP_defconfig                    |   1 +
 doc/usage/extension.rst                   | 111 ++++++++++++++
 drivers/w1-eeprom/ds24xxx.c               |   7 +
 drivers/w1-eeprom/ds2502.c                |   6 +
 drivers/w1-eeprom/w1-eeprom-uclass.c      |  31 ----
 drivers/w1/w1-uclass.c                    |  76 +++++++++-
 include/extension_board.h                 |  31 ++++
 include/fdt_support.h                     |   2 +
 include/w1-eeprom.h                       |   2 -
 include/w1.h                              |  17 +++
 test/py/tests/test_extension.py           |  52 +++++++
 35 files changed, 835 insertions(+), 84 deletions(-)
 create mode 100644 arch/sandbox/dts/overlay0.dts
 create mode 100644 arch/sandbox/dts/overlay1.dts
 create mode 100644 board/sunxi/chip.c
 create mode 100644 board/ti/common/cape_detect.c
 create mode 100644 board/ti/common/cape_detect.h
 create mode 100644 cmd/extension_board.c
 create mode 100644 doc/usage/extension.rst
 create mode 100644 include/extension_board.h
 create mode 100644 test/py/tests/test_extension.py

Comments

Tom Rini May 4, 2021, 11:57 a.m. UTC | #1
On Tue, Apr 20, 2021 at 10:25:31AM +0200, Kory Maincent wrote:

> This series of patches aims at proposing a generic U-Boot mechanism to
> detect extension boards connected to the HW platform, and apply the
> appropriate Device Tree overlays depending on the detected extension
> boards.
> 
> Indeed, numerous popular platforms, such as the BeagleBone or the
> RaspberryPi, feature some kind of extension board mechanism. These
> extension boards are often discoverable through some kind of EEPROM
> (connected on I2C, 1-wire, etc.) and require Device Tree overlays to be
> applied at the U-Boot level to provide a complete HW description to the
> Linux kernel. However, currently this logic is usually implemented
> ad-hoc in downstream forks of U-Boot.
> 
> This series proposes to bring a HW-agnostic and generic solution to
> this problem to upstream U-Boot. The series shows that it is generic
> enough by implementing its usage for 2 different families of HW
> platforms and expansion boards:
> 
>  - The BeagleBone Black and BeagleBone AI, that use extension boards
>    where the EEPROM describing the extension boards is connected over
>    I2C.
> 
>  - The CHIP, that uses extension boards where the EEPROM describing the
>    extension boards is connected over 1-wire.
> 
> The patch series implements a new command called "extension", with two
> sub-commands:
> 
>  - "extension scan" to detect available extension boards
> 
>  - "extension list" will simply list the detected extension boards
> 
>  - "extension apply" will allow to apply the Device Tree overlays
>    corresponding to one extension board or to all expansion boards
> 
> Note that the name "extension" has been chosen to not refer to any
> particular board-specific terminology for extension boards ("cape" for
> BeagleBone, "DIP" for CHIP, "hat" for RaspberryPi, etc.). However, we
> welcome suggestions of other names and are definitely willing to use a
> different naming.
> 
> The "extension apply" command requires two environment variables to be
> defined so that it knows how to apply DT overlays. This is described
> in more details in PATCH 1.
> 
> This generic code requires board-specific code for the detection and
> enumeration of extension boards. This is simply implemented in the form
> of a board-specific extension_board_scan() function, which fills in a
> list of detected extension boards.
> 
> In detail:
> 
>  - PATCH 1 move fdt_valid function to fdt_support file
>  - PATCH 2 implements the generic command and logic
>  - PATCH 3 implements the python test for the "extension" command
>  - PATCH 4 implements the board-specific code for the BeagleBone platforms
>  - PATCH 5 enables the mechanism for the BeagleBone AI
>  - PATCH 6 review the detection mechanism of one-wire devices
>  - PATCH 7 and 8 enable the mechanism for the CHIP
>  - PATCH 9 and 10 enable the mechanism for the BeagleBone Black
> 
> Thanks in advance for your review and feedback

Can you please rebase this on current master?  Thanks.