Enable I2C in SPL, support runtime detection of add-on board
Subsystems (3)
cover Enable I2C in SPL, support runtime detection of add-on board
From: Suniel Mahesh <[email protected]>
This patch series adds runtime detection of add-on board(ROC-RK3399-PC Mezzanine) by enabling I2C in SPL.
This add on board hosts a CW2015 chip which is connected as slave to I2C2. In order to dynamically detect this add-on board at runtime, I2C2 is probed in SPL. If probe is successfull then a corresponding dtb is loaded, else regular dtb is loaded for the u-boot proper.
Patch #1 moves board initialiation code after rk3399 init is done. Patch #2 enables I2C in SPL for any add-on board detection at run time. Patch #3 adds support for add-on board run-time detection. Patch #4 drops ROC-RK3399-PC Mezzanine board as this is an add-on board, it will be detected at runtime. Patch #5 enables PCIe/M.2 and NVMe, as this add-on board has a PCIe/M.2.
Jagan Teki (1):
rockchip: spl: Move board_early_init_f after cpu timer
Suniel Mahesh (4):
roc-pc-rk3399: Enable I2C in SPL for add-on board detection
roc-pc-rk3399: Add support for add-on board run-time detection
rk3399: drop ROC-RK3399-PC Mezzanine board
roc-pc-rk3399: Enable PCIe/M.2, NVMe
arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 13 +++++ arch/arm/mach-rockchip/spl.c | 5 +- board/firefly/roc-pc-rk3399/MAINTAINERS | 2 - board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 56 ++++++++++++++++++++++ configs/roc-pc-mezzanine-rk3399_defconfig | 74 ----------------------------- configs/roc-pc-rk3399_defconfig | 10 +++- 6 files changed, 81 insertions(+), 79 deletions(-) delete mode 100644 configs/roc-pc-mezzanine-rk3399_defconfig
Signature · 1 line
2.7.4
PATCH 1/5 rockchip: spl: Move board_early_init_f after cpu timer
From: Jagan Teki <[email protected]>
Custom board_early_init_f not only deal with simple gpio configuration but also have a possibility to access clocks to process any clock related operations like checking reset cause state and etc.
So, call it once the rockchip timer initialization done instead of calling first place of board_init_f which doesn't have any rockchip init code before.
This specific concern was tested with checking reset reason via board_early_init_f, which indeed require a clk probe.
--- arch/arm/mach-rockchip/spl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/spl.c +3 -2
@@ -124,8 +124,6 @@ void board_init_f(ulong dummy)debug ("\nspl:debug uart enabled in %s\n" , __func__);#endif -board_early_init_f (); - ret =spl_early_init ();if (ret) {printf ("spl_early_init() failed: %d\n" , ret);
@@ -139,6 +137,9 @@ void board_init_f(ulong dummy)/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ timer_init ();#endif + +board_early_init_f (); +#if !defined(CONFIG_TPL ) || defined(CONFIG_SPL_OS_BOOT )debug ("\nspl:init dram\n" ); ret =uclass_get_device (UCLASS_RAM ,0 , &dev);
Signature · 1 line
2.7.4
PATCH 2/5 roc-pc-rk3399: Enable I2C in SPL for add-on board detection
In reply to sunil at amarulasolutions.comFrom: Suniel Mahesh <[email protected]>
This patch enables I2C in SPL for any add-on board detection at run time.
--- arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 13 +++++++++++++ configs/roc-pc-rk3399_defconfig | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-)
arch/arm/dts/rk3399-roc-pc-u-boot.dtsi +13 -0
@@ -56,3 +56,16 @@ &vcc_sdio { regulator-always-on; }; + +&pcfg_pull_none_12ma { + u-boot,dm-pre-reloc; +}; + +&i2c2 { + u-boot,dm-pre-reloc; + status= "okay"; +}; + +&i2c2_xfer { + u-boot,dm-pre-reloc; +};
configs/roc-pc-rk3399_defconfig +4 -1
@@ -13,19 +13,22 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 +CONFIG_SPL_I2C_SUPPORT=y CONFIG_TPL=y CONFIG_TPL_GPIO_SUPPORT=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y +CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc" -CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" +CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y
Signature · 1 line
2.7.4
PATCH 3/5 roc-pc-rk3399: Add support for add-on board run-time detection
In reply to sunil at amarulasolutions.comFrom: Suniel Mahesh <[email protected]>
roc-pc-rk3399 target has an add-on board, this add-on board hosts a CW2015 chip which is connected as slave to I2C2. In order to dynamically detect this add-on board at runtime, I2C2 is probed in SPL. If probe is successfull then a corresponding dtb is loaded, else regular dtb is loaded for the u-boot proper.
--- board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 56 +++++++++++++++++++++++++++++ configs/roc-pc-rk3399_defconfig | 2 ++ 2 files changed, 58 insertions(+)
board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +56 -0
@@ -32,6 +32,62 @@ out: }#endif +#if !defined(CONFIG_TPL_BUILD ) && defined(CONFIG_SPL_BUILD ) + +#include <i2c.h> + +#define BUS_NUM 2 +#define ROC_RK3399_MEZZ_BAT_ADDR 0x62 + +enum roc_rk3399_pc_board_type { +ROC_RK3399_PC ,/* roc-rk3399-pc base board */ +ROC_RK3399_MEZZ_M2_POE ,/* roc-rk3399-Mezz M.2 PoE */ +}; + +int board_early_init_f (void ) +{ +struct udevice *bus, *dev; +int ret; + +/* default board type */ + gd->board_type =ROC_RK3399_PC ; + + ret =uclass_get_device_by_seq (UCLASS_I2C ,BUS_NUM , &bus); +if (ret) { +debug ("failed to get i2c bus 2\n" ); +return ret; + } + + ret =dm_i2c_probe (bus,ROC_RK3399_MEZZ_BAT_ADDR ,0 , &dev); +if (ret) { +debug ("failed to probe i2c2 battery controller IC\n" ); +return ret; + } + + gd->board_type =ROC_RK3399_MEZZ_M2_POE ; + +return 0 ; +} + +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match (const char *name) +{ +if (gd->board_type ==ROC_RK3399_PC ) { +if (!strcmp (name,"rk3399-roc-pc.dtb" )) +return 0 ; + } + +if (gd->board_type ==ROC_RK3399_MEZZ_M2_POE ) { +if (!strcmp (name,"rk3399-roc-pc-mezzanine.dtb" )) +return 0 ; + } + +return -EINVAL ; +} +#endif + +#endif /* CONFIG_SPL_BUILD */ +#if defined(CONFIG_TPL_BUILD )#define GPIO0_BASE 0xff720000
configs/roc-pc-rk3399_defconfig +2 -0
@@ -10,6 +10,7 @@ CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART=y CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc.dtb" CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_BOARD_TYPES=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
@@ -25,6 +26,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_TIME=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc" +CONFIG_OF_LIST="rk3399-roc-pc rk3399-roc-pc-mezzanine" CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y
Signature · 1 line
2.7.4
PATCH 4/5 rk3399: drop ROC-RK3399-PC Mezzanine board
In reply to sunil at amarulasolutions.comFrom: Suniel Mahesh <[email protected]>
As we have added runtime detection support for ROC-RK3399-PC Mezzanine board, which is an add-on board and as indicated in earlier commit, we are dropping separate defconfig file and support.
see commit f417d71ea78b ("rk3399: Add ROC-RK3399-PC Mezzanine board")
--- board/firefly/roc-pc-rk3399/MAINTAINERS | 2 - configs/roc-pc-mezzanine-rk3399_defconfig | 74 ------------------------------- 2 files changed, 76 deletions(-) delete mode 100644 configs/roc-pc-mezzanine-rk3399_defconfig
board/firefly/roc-pc-rk3399/MAINTAINERS +0 -2
@@ -1,8 +1,6 @@ ROC-RK3399-PC M: Levin Du <[email protected]> -M: Suniel Mahesh <[email protected]> S: Maintained F: board/firefly/roc-pc-rk3399 F: include/configs/roc-pc-rk3399.h F: configs/roc-pc-rk3399_defconfig -F: configs/roc-pc-mezzanine-rk3399_defconfig
configs/roc-pc-mezzanine-rk3399_defconfig deleted +0 -74
74 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 4/5 rk3399: drop ROC-RK3399-PC Mezzanine board
Quoted 8 lines · On Fri, May 22, 2020 at 11:34 PM <[email protected]> wrote:
From: Suniel Mahesh <[email protected]>
As we have added runtime detection support for ROC-RK3399-PC Mezzanine board, which is an add-on board and as indicated in earlier commit, we are dropping separate defconfig file and support.
see commit
f417d71ea78b("rk3399: Add ROC-RK3399-PC Mezzanine board")
The commit head can be "rk3399: Drop roc-pc-mezzanine-rk3399 defconfig"
Jagan.
PATCH 5/5 roc-pc-rk3399: Enable PCIe/M.2, NVMe
In reply to sunil at amarulasolutions.comFrom: Suniel Mahesh <[email protected]>
ROC-RK3399-PC Mezzanine is an add-on board for roc-pc-rk3399 target and it hosts a PCIe/M.2 interface. As we have added runtime detection support for this add-on board, this patch enables PCIe/M.2, NVMe so that SSD's which have a PCIe/M.2 interface can be detected.
=> nvme scan
=> nvme device
IDE device 0: Vendor: 0x144d Rev: 2B2QEXM7 Prod: S4EUNG0N104275H
Type: Hard Disk
Capacity: 238475.1 MB = 232.8 GB (488397168 x 512)
--- configs/roc-pc-rk3399_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/roc-pc-rk3399_defconfig +3 -0
@@ -22,6 +22,7 @@ CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_PCI=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_SPL_OF_CONTROL=y
@@ -42,6 +43,8 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y +CONFIG_NVME=y +CONFIG_PCI=y CONFIG_PHY_ROCKCHIP_INNO_USB2=y CONFIG_PHY_ROCKCHIP_TYPEC=y CONFIG_PMIC_RK8XX=y
Signature · 1 line
2.7.4
PATCH 5/5 roc-pc-rk3399: Enable PCIe/M.2, NVMe
Quoted 15 lines · On Fri, May 22, 2020 at 11:34 PM <[email protected]> wrote:
From: Suniel Mahesh <[email protected]>
ROC-RK3399-PC Mezzanine is an add-on board for roc-pc-rk3399 target and it hosts a PCIe/M.2 interface. As we have added runtime detection support for this add-on board, this patch enables PCIe/M.2, NVMe so that SSD's which have a PCIe/M.2 interface can be detected.
=> nvme scan
=> nvme deviceIDE device 0: Vendor:
0x144dRev: 2B2QEXM7 Prod: S4EUNG0N104275H
Type: Hard Disk
Capacity: 238475.1 MB = 232.8 GB (488397168 x 512)
Quoted 5 lines
Signed-off-by Suniel Mahesh <[email protected]>Signed-off-by Jagan Teki <[email protected]>--- configs/roc-pc-rk3399_defconfig | 3 +++ 1 file changed, 3 insertions(+)
We need to squash to 4/5 not be a separate patch since this support already added.
Jagan.
cover Enable I2C in SPL, support runtime detection of add-on board
In reply to sunil at amarulasolutions.comHi,
Quoted 25 lines · On Sat, May 23, 2020 at 2:04 AM <[email protected]> wrote:
From: Suniel Mahesh <[email protected]>
This patch series adds runtime detection of add-on board(ROC-RK3399-PC Mezzanine) by enabling I2C in SPL.
This add on board hosts a CW2015 chip which is connected as slave to I2C2. In order to dynamically detect this add-on board at runtime, I2C2 is probed in SPL. If probe is successfull then a corresponding dtb is loaded, else regular dtb is loaded for the u-boot proper.Patch #1 moves board initialiation code after rk3399 init is done. Patch #2 enables I2C in SPL for any add-on board detection at run time. Patch #3 adds support for add-on board run-time detection. Patch #4 drops ROC-RK3399-PC Mezzanine board as this is an add-on board, it will be detected at runtime. Patch #5 enables PCIe/M.2 and NVMe, as this add-on board has a PCIe/M.2.
Jagan Teki (1):
rockchip: spl: Moveboard_early_init_fafter cpu timerSuniel Mahesh (4):
roc-pc-rk3399: Enable I2C in SPL for add-on board detection
roc-pc-rk3399: Add support for add-on board run-time detection
rk3399: drop ROC-RK3399-PC Mezzanine board
roc-pc-rk3399: Enable PCIe/M.2, NVMe
Quoted 5 lines
arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 13 +++++ arch/arm/mach-rockchip/spl.c | 5 +- board/firefly/roc-pc-rk3399/MAINTAINERS | 2 - board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 56 ++++++++++++++++++++++ configs/roc-pc-mezzanine-rk3399_defconfig | 74 -----------------------------
FYI this is going to be problematic for people that have the non-POE version of the
mezzanine board and still want to access NVMe from U-boot. Maybe worth keeping a target for these people to use.
ChenYu
Quoted 7 lines
configs/roc-pc-rk3399_defconfig | 10 +++- 6 files changed, 81 insertions(+), 79 deletions(-) delete mode 100644 configs/roc-pc-mezzanine-rk3399_defconfig--
2.7.4
cover Enable I2C in SPL, support runtime detection of add-on board
Hi Suniel,
??? Any idea bout ChenYu's comment?
Thanks,
- Kever
Quoted 48 lines · Chen-Yu Tsai
Hi,
Quoted 24 lines · On Sat, May 23, 2020 at 2:04 AM <[email protected]> wrote:
From: Suniel Mahesh <[email protected]>
This patch series adds runtime detection of add-on board(ROC-RK3399-PC Mezzanine) by enabling I2C in SPL.
This add on board hosts a CW2015 chip which is connected as slave to I2C2. In order to dynamically detect this add-on board at runtime, I2C2 is probed in SPL. If probe is successfull then a corresponding dtb is loaded, else regular dtb is loaded for the u-boot proper.Patch #1 moves board initialiation code after rk3399 init is done. Patch #2 enables I2C in SPL for any add-on board detection at run time. Patch #3 adds support for add-on board run-time detection. Patch #4 drops ROC-RK3399-PC Mezzanine board as this is an add-on board, it will be detected at runtime. Patch #5 enables PCIe/M.2 and NVMe, as this add-on board has a PCIe/M.2.
Jagan Teki (1):
rockchip: spl: Moveboard_early_init_fafter cpu timerSuniel Mahesh (4):
roc-pc-rk3399: Enable I2C in SPL for add-on board detection
roc-pc-rk3399: Add support for add-on board run-time detection
rk3399: drop ROC-RK3399-PC Mezzanine board
roc-pc-rk3399: Enable PCIe/M.2, NVMeQuoted 5 lines
arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 13 +++++ arch/arm/mach-rockchip/spl.c | 5 +- board/firefly/roc-pc-rk3399/MAINTAINERS | 2 - board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 56 ++++++++++++++++++++++ configs/roc-pc-mezzanine-rk3399_defconfig | 74 -----------------------------FYI this is going to be problematic for people that have the non-POE version of the
mezzanine board and still want to access NVMe from U-boot. Maybe worth keeping a target for these people to use.ChenYu
Quoted 7 lines
configs/roc-pc-rk3399_defconfig | 10 +++- 6 files changed, 81 insertions(+), 79 deletions(-)delete mode 100644 configs/roc-pc-mezzanine-rk3399_defconfig
--
2.7.4
cover Enable I2C in SPL, support runtime detection of add-on board
Hi Kever,
Quoted 4 lines · Kever Yang
Hi Suniel,
Any idea bout ChenYu's comment?
Yes, ChenYu's point is valid, right now we are in communication with Libretech about the I/O differences to differentiate baseboard vs expansion. We will come back with proper solutions.
Jagan.