From patchwork Tue Mar 2 09:58:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 1445925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DqXdV3lRgz9s1l for ; Tue, 2 Mar 2021 20:58:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD0D581C7C; Tue, 2 Mar 2021 10:58:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 971C2819F3; Tue, 2 Mar 2021 10:58:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8B1258002F for ; Tue, 2 Mar 2021 10:58:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kory.maincent@bootlin.com X-Originating-IP: 78.113.208.92 Received: from localhost.localdomain (92.208.113.78.rev.sfr.net [78.113.208.92]) (Authenticated sender: kory.maincent@bootlin.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 85EAFE000A; Tue, 2 Mar 2021 09:58:14 +0000 (UTC) From: Kory Maincent To: u-boot@lists.denx.de Cc: thomas.petazzoni@bootlin.com, jkridner@beagleboard.org, drew@beagleboard.org, robertcnelson@gmail.com, maxime@cerno.tech, trini@konsulko.com, andre.przywara@arm.com Subject: [PATCH v2 00/12] Add support for extension boards detection and DT overlays application Date: Tue, 2 Mar 2021 10:58:01 +0100 Message-Id: <20210302095813.3273-1-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean 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 to 8 review the detection mechanism of one-wire devices - PATCH 9 an 10 enable the mechanism for the CHIP - PATCH 10 and 11 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 dependant - replace Kconfig CHIP board target by Kconfig CHIP_DIP_SCAN simple option - rewrite doc to rST syntax - make few syntax update Kory Maincent (12): 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 w1-eeprom: remove sandbox eeprom driver sandbox: remove w1-eeprom declaration and document arm: mach-sunxi: add configuration for the CHIP to enable w1 sun5i: add support for DIP detection to CHIP board 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 + arch/sandbox/dts/sandbox.dtsi | 18 -- board/sandbox/sandbox.c | 23 +++ board/sunxi/Makefile | 1 + board/sunxi/chip.c | 104 +++++++++++ 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 + .../w1-eeprom/eep_sandbox.txt | 34 ---- doc/usage/extension.rst | 111 ++++++++++++ drivers/w1-eeprom/Makefile | 2 - drivers/w1-eeprom/ds24xxx.c | 20 +-- drivers/w1-eeprom/ds2502.c | 18 +- drivers/w1-eeprom/eep_sandbox.c | 61 ------- drivers/w1-eeprom/w1-eeprom-uclass.c | 45 +++-- drivers/w1/w1-uclass.c | 2 +- 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 ++++++ 39 files changed, 785 insertions(+), 218 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 delete mode 100644 doc/device-tree-bindings/w1-eeprom/eep_sandbox.txt create mode 100644 doc/usage/extension.rst delete mode 100644 drivers/w1-eeprom/eep_sandbox.c create mode 100644 include/extension_board.h create mode 100644 test/py/tests/test_extension.py