[PATCH] power: regulator: tps6287x: Add driver for TPS6287x step down convertors
Add driver for TPS6287x step down convertors Data sheet: https://www.ti.com/lit/ds/slvsgc5a/slvsgc5a.pdf Signed-off-by: Keerthy --- drivers/power/regulator/Kconfig | 18 ++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/tps6287x_regulator.c | 172 +++ 3 files changed, 191 insertions(+) create mode 100644 drivers/power/regulator/tps6287x_regulator.c diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 102ec7bc5f..db4b40c35e 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -375,6 +375,15 @@ config DM_REGULATOR_TPS80031 features for TPS80031/TPS80032 PMICs. The driver implements get/set api for: value and enable. +config DM_REGULATOR_TPS6287X + bool "Enable driver for TPS6287x Power Regulator" + depends on DM_REGULATOR + help + The TPS6287X is a step down converter with a fast transient + response. This driver supports all four variants of the chip + (TPS62870, TPS62871, TPS62872, TPS62873). It implements the + get/set api for value only, as the power line is always on. + config DM_REGULATOR_STPMIC1 bool "Enable driver for STPMIC1 regulators" depends on DM_REGULATOR && PMIC_STPMIC1 @@ -394,6 +403,15 @@ config DM_REGULATOR_ANATOP regulators. It is recommended that this option be enabled on i.MX6 platform. +config SPL_DM_REGULATOR_TPS6287X + bool "Enable driver for TPS6287x Power Regulator" + depends on SPL_DM_REGULATOR + help + The TPS6287X is a step down converter with a fast transient + response. This driver supports all four variants of the chip + (TPS62870, TPS62871, TPS62872, TPS62873). It implements the + get/set api for value only, as the power line is always on. + config SPL_DM_REGULATOR_STPMIC1 bool "Enable driver for STPMIC1 regulators in SPL" depends on SPL_DM_REGULATOR && PMIC_STPMIC1 diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index f79932d833..6335e5566d 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o obj-$(CONFIG_DM_REGULATOR_TPS65910) += tps65910_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_TPS65911) += tps65911_regulator.o obj-$(CONFIG_DM_REGULATOR_TPS62360) += tps62360_regulator.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_TPS6287X) += tps6287x_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_TPS80031) += tps80031_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_STPMIC1) += stpmic1.o obj-$(CONFIG_DM_REGULATOR_TPS65941) += tps65941_regulator.o diff --git a/drivers/power/regulator/tps6287x_regulator.c b/drivers/power/regulator/tps6287x_regulator.c new file mode 100644 index 00..6d18571919 --- /dev/null +++ b/drivers/power/regulator/tps6287x_regulator.c @@ -0,0 +1,172 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com/ + * Keerthy + */ + +#include +#include +#include +#include + +#define TPS6287X_REG_VSET 0x0 +#define TPS6287X_REG_CONTROL1 0x1 +#define TPS6287X_REG_CONTROL2 0x2 +#define TPS6287X_REG_CONTROL3 0x3 +#define TPS6287X_REG_STATUS0x4 +#define TPS6287X_REG_VSET_VSET_MASK0xff +#define TPS6287X_REG_CONTROL2_VRANGE_MASK 0xc + +struct tps6287x_regulator_config { + u32 vmin; + u32 vmax; +}; + +struct tps6287x_regulator_pdata { + u8 vsel_offset; + struct udevice *i2c; + struct tps6287x_regulator_config *config; +}; + +static struct tps6287x_regulator_config tps6287x_data = { + .vmin = 40, + .vmax = 335, +}; + +static int tps6287x_regulator_set_value(struct udevice *dev, int uV) +{ + struct tps6287x_regulator_pdata *pdata = dev_get_plat(dev); + u8 regval, vset; + int ret; + + if (uV < pdata->config->vmin || uV > pdata->config->vmax) + return -EINVAL; + /* +* Based on the value of VRANGE bit field of CONTROL2 reg the range +* varies. +*/ + ret = dm_i2c_read(pdata->i2c, TPS6287X_REG_CONTROL2, ®val, 1); + if (ret) { + dev_err(dev, "CTRL2 reg read failed: %d\n", ret); + return ret; + } + + regval &= TPS6287X_REG_CONTROL2_VRANGE_MASK; + regval >>= ffs(TPS6287X_REG_CONTROL2_VRANGE_MASK) - 1; + + /* +* VRANGE = 0. Increment step 1250 uV starting with 0 --> 40 uV +* VRANGE = 1. Increment step 2500 uV starting with 0 --> 40 uV +* VRANGE = 2. Increment step 5000 uV starting with 0 --> 40 uV +* VRANGE = 3. Increment step 1 uV starting with 0 -->
Re: [PATCH] board: ti: j721e: Add support for both esm probe
On 4/17/2024 10:06 AM, Udit Kumar wrote: At present only MCU domain ESM is probed, this means errors occurred in mcu domain will be propagate to MCU_SAFETY_ERRORn. MCU ESM accepts SOC_SAFETY_ERRORn signal as Error event and propagate to MCU_SAFETY_ERRORn.[0] Therefore adding support to probe both main domain and mcu domain ESM. Reviewed-by: Keerthy [0]: https://www.ti.com/lit/zip/spruil1 spruil1c.pdf from zip Figure 12-1244. ESM Modules Overview Signed-off-by: Udit Kumar --- board/ti/j721e/evm.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c index 9dc3ed6dff..539eaf4718 100644 --- a/board/ti/j721e/evm.c +++ b/board/ti/j721e/evm.c @@ -465,10 +465,13 @@ void spl_board_init(void) } if (IS_ENABLED(CONFIG_ESM_K3)) { - ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_DRIVER_GET(k3_esm), &dev); + ret = uclass_get_device_by_name(UCLASS_MISC, "esm@70", &dev); + if (ret) + printf("MISC init for esm@70 failed: %d\n", ret); + + ret = uclass_get_device_by_name(UCLASS_MISC, "esm@4080", &dev); if (ret) - printf("ESM init failed: %d\n", ret); + printf("MISC init for esm@4080 failed: %d\n", ret); } if (IS_ENABLED(CONFIG_ESM_PMIC)) {
[PATCH RFC 10/10] board: ti: j721e: Enable ESM initialization for J7200
Enable ESM initialization for J7200 Signed-off-by: Keerthy --- board/ti/j721e/evm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c index 42fa94b7a5..070b28326f 100644 --- a/board/ti/j721e/evm.c +++ b/board/ti/j721e/evm.c @@ -543,7 +543,8 @@ void spl_board_init(void) } #ifdef CONFIG_ESM_K3 - if (board_ti_k3_is("J721EX-PM2-SOM")) { + if ((board_ti_k3_is("J721EX-PM2-SOM")) || + IS_ENABLED(CONFIG_TARGET_J7200_R5_EVM)) { ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(k3_esm), &dev); if (ret) @@ -557,7 +558,8 @@ void spl_board_init(void) #endif #ifdef CONFIG_ESM_PMIC - if (board_ti_k3_is("J721EX-PM2-SOM")) { + if ((board_ti_k3_is("J721EX-PM2-SOM")) || + IS_ENABLED(CONFIG_TARGET_J7200_R5_EVM)) { ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(pmic_esm), &dev); -- 2.17.1
[PATCH RFC 09/10] configs: j7200_evm_r5_defconfig: Enable the ESM configs
Enable the ESM configs. Signed-off-by: Keerthy --- configs/j7200_evm_r5_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/j7200_evm_r5_defconfig b/configs/j7200_evm_r5_defconfig index c4dd33627b..7adc230fc1 100644 --- a/configs/j7200_evm_r5_defconfig +++ b/configs/j7200_evm_r5_defconfig @@ -101,6 +101,8 @@ CONFIG_DM_MAILBOX=y CONFIG_K3_SEC_PROXY=y CONFIG_FS_LOADER=y CONFIG_SPL_FS_LOADER=y +CONFIG_ESM_K3=y +CONFIG_ESM_PMIC=y CONFIG_K3_AVS0=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_SPL_MMC_HS400_SUPPORT=y -- 2.17.1
[PATCH RFC 08/10] arm: dts: k3-j7200-r5-common-proc-board: Add PMIC ESM node
Enable the TPS659413 has the ESM PMIC. Signed-off-by: Keerthy --- arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts index e62f9218e8..4e5e4a08f8 100644 --- a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts @@ -271,6 +271,20 @@ }; }; + tps659413: tps659413@48 { + compatible = "ti,tps659413"; + reg = <0x48>; + bootph-pre-ram; + + regulators_a: regulators { + bootph-pre-ram; + }; + + esm: esm { + compatible = "ti,tps659413-esm"; + bootph-pre-ram; + }; + }; }; &wkup_vtm0 { -- 2.17.1
[PATCH RFC 07/10] configs: j721s2_evm_r5_defconfig: Enable ESM & PMIC ESM configs
Enable ESM & PMIC ESM configs Signed-off-by: Keerthy --- configs/j721s2_evm_r5_defconfig | 7 +++ 1 file changed, 7 insertions(+) diff --git a/configs/j721s2_evm_r5_defconfig b/configs/j721s2_evm_r5_defconfig index 1e66ac23d0..b9ac56f34d 100644 --- a/configs/j721s2_evm_r5_defconfig +++ b/configs/j721s2_evm_r5_defconfig @@ -112,6 +112,8 @@ CONFIG_DM_MAILBOX=y CONFIG_K3_SEC_PROXY=y CONFIG_FS_LOADER=y CONFIG_SPL_FS_LOADER=y +CONFIG_ESM_K3=y +CONFIG_ESM_PMIC=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_SPL_MMC_HS400_SUPPORT=y CONFIG_MMC_SDHCI=y @@ -142,6 +144,11 @@ CONFIG_PINCTRL_SINGLE=y CONFIG_POWER_DOMAIN=y CONFIG_TI_POWER_DOMAIN=y CONFIG_K3_SYSTEM_CONTROLLER=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_TPS65941=y +CONFIG_DM_REGULATOR=y +CONFIG_SPL_DM_REGULATOR=y +CONFIG_DM_REGULATOR_TPS65941=y CONFIG_REMOTEPROC_TI_K3_ARM64=y CONFIG_RESET_TI_SCI=y CONFIG_DM_SERIAL=y -- 2.17.1
[PATCH RFC 06/10] board: ti: j721s2: Initialize the ESM & PMIC ESM
Initialize the ESM & PMIC ESM Signed-off-by: Keerthy --- board/ti/j721s2/evm.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index 7795300abc..effa52ff5a 100644 --- a/board/ti/j721s2/evm.c +++ b/board/ti/j721s2/evm.c @@ -319,4 +319,31 @@ int board_late_init(void) void spl_board_init(void) { + struct udevice *dev; + int ret; + + if (IS_ENABLED(CONFIG_ESM_K3)) { + ret = uclass_get_device_by_name(UCLASS_MISC, "esm@70", + &dev); + if (ret) + printf("MISC init for esm@70 failed: %d\n", ret); + + ret = uclass_get_device_by_name(UCLASS_MISC, "esm@4080", + &dev); + if (ret) + printf("MISC init for esm@4080 failed: %d\n", ret); + + ret = uclass_get_device_by_name(UCLASS_MISC, "esm@4208", + &dev); + if (ret) + printf("MISC init for esm@4208 failed: %d\n", ret); + } + + if (IS_ENABLED(CONFIG_ESM_PMIC)) { + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(pmic_esm), + &dev); + if (ret) + printf("ESM PMIC init failed: %d\n", ret); + } } -- 2.17.1
[PATCH RFC 05/10] board: ti: j721e: Initialize MCU ESM
Initialize MCU ESM. This is needed to propagate MAIN domain events to the PMIC. Signed-off-by: Keerthy --- board/ti/j721e/evm.c | 5 + 1 file changed, 5 insertions(+) diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c index 38fe447d8f..42fa94b7a5 100644 --- a/board/ti/j721e/evm.c +++ b/board/ti/j721e/evm.c @@ -548,7 +548,12 @@ void spl_board_init(void) DM_DRIVER_GET(k3_esm), &dev); if (ret) printf("ESM init failed: %d\n", ret); + + ret = uclass_get_device_by_name(UCLASS_MISC, "esm@4080", &dev); + if (ret) + printf("MISC init for esm@4080 failed: %d\n", ret); } + #endif #ifdef CONFIG_ESM_PMIC -- 2.17.1
[PATCH RFC 04/10] arm64: dts: ti: k3-j721e: Add MCU domain ESM instance
Patch adds the ESM instance for MCU domian of j721e. Signed-off-by: Keerthy --- arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi index 22166c7942..66fdd6443f 100644 --- a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi @@ -408,4 +408,11 @@ ti,loczrama = <1>; }; }; + + mcu_esm: esm@4080 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x4080 0x00 0x1000>; + ti,esm-pins = <95>; + bootph-pre-ram; + }; }; -- 2.17.1
[PATCH RFC 03/10] arm: dts: k3-j721s2-r5-common-proc-board: Add ESM PMIC and dependent nodes
PMIC ESM is part of tps6594x PMIC and connected to WKUP_I2C instance. Signed-off-by: Keerthy --- .../dts/k3-j721s2-r5-common-proc-board.dts| 39 +++ 1 file changed, 39 insertions(+) diff --git a/arch/arm/dts/k3-j721s2-r5-common-proc-board.dts b/arch/arm/dts/k3-j721s2-r5-common-proc-board.dts index c74e8e58ae..629706aaf1 100644 --- a/arch/arm/dts/k3-j721s2-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721s2-r5-common-proc-board.dts @@ -142,6 +142,14 @@ J721S2_WKUP_IOPAD(0x0b4, PIN_OUTPUT, 0) /* (D27) WKUP_UART0_TXD */ >; }; + + wkup_i2c0_pins_default: wkup-i2c0-pins-default { + bootph-pre-ram; + pinctrl-single,pins = < + J721S2_WKUP_IOPAD(0x100, PIN_INPUT, 0) /* (H24) WKUP_I2C0_SCL */ + J721S2_WKUP_IOPAD(0x104, PIN_INPUT, 0) /* (H27) WKUP_I2C0_SDA */ + >; + }; }; &sms { @@ -197,4 +205,35 @@ ti,sci = <&dm_tifs>; }; +&wkup_i2c0 { + bootph-pre-ram; + pinctrl-names = "default"; + pinctrl-0 = <&wkup_i2c0_pins_default>; + clock-frequency = <40>; + + tps659413: tps659413@48 { + compatible = "ti,tps659413"; + reg = <0x48>; + bootph-pre-ram; + + regulators: regulators { + bootph-pre-ram; + buck1234_reg: buck1234 { + /*VDD_CPU_AVS*/ + regulator-name = "buck1234"; + regulator-min-microvolt = <60>; + regulator-max-microvolt = <90>; + regulator-always-on; + regulator-boot-on; + bootph-pre-ram; + }; + }; + + esm: esm { + compatible = "ti,tps659413-esm"; + bootph-pre-ram; + }; + }; +}; + #include "k3-j721s2-common-proc-board-u-boot.dtsi" -- 2.17.1
[PATCH RFC 02/10] arm64: dts: ti: k3-j7200: Add MCU domain ESM instance
Patch adds the ESM instance for MCU domian of j7200. Signed-off-by: Keerthy --- arch/arm/dts/k3-j7200-mcu-wakeup.dtsi | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi b/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi index 1044ec6c4b..2b185fa350 100644 --- a/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi @@ -375,4 +375,11 @@ ti,loczrama = <1>; }; }; + + mcu_esm: esm@4080 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x4080 0x00 0x1000>; + ti,esm-pins = <95>; + bootph-pre-ram; + }; }; -- 2.17.1
[PATCH RFC 01/10] arm64: dts: ti: k3-j721s2: Add ESM instances
Patch adds the ESM instances for j721s2. It has 3 instances. One in the main domain and two in the mcu-wakeup domian. Signed-off-by: Keerthy --- arch/arm/dts/k3-j721s2-main.dtsi | 7 +++ arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi | 14 ++ 2 files changed, 21 insertions(+) diff --git a/arch/arm/dts/k3-j721s2-main.dtsi b/arch/arm/dts/k3-j721s2-main.dtsi index 976ba1e95a..859b5124ae 100644 --- a/arch/arm/dts/k3-j721s2-main.dtsi +++ b/arch/arm/dts/k3-j721s2-main.dtsi @@ -934,4 +934,11 @@ interrupt-names = "int0", "int1"; bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; }; + + main_esm: esm@70 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x70 0x00 0x1000>; + ti,esm-pins = <688>, <689>; + bootph-pre-ram; + }; }; diff --git a/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi b/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi index 7521963719..f28cf7df50 100644 --- a/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi @@ -299,4 +299,18 @@ ti,cpts-periodic-outputs = <2>; }; }; + + mcu_esm: esm@4080 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x4080 0x00 0x1000>; + ti,esm-pins = <95>; + bootph-pre-ram; + }; + + wkup_esm: esm@4208 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x4208 0x00 0x1000>; + ti,esm-pins = <63>; + bootph-pre-ram; + }; }; -- 2.17.1
[PATCH RFC 00/10] arm: dts: j7200/j721s2: Enable the ESM and PMIC ESM
This patch series is RFC. This is enabling ESM/PMIC_ESM modules needed for watchdog functionality. Keerthy (10): arm64: dts: ti: k3-j721s2: Add ESM instances arm64: dts: ti: k3-j7200: Add MCU domain ESM instance arm: dts: k3-j721s2-r5-common-proc-board: Add ESM PMIC and dependent nodes arm64: dts: ti: k3-j721e: Add MCU domain ESM instance board: ti: j721e: Initialize MCU ESM board: ti: j721s2: Initialize the ESM & PMIC ESM configs: j721s2_evm_r5_defconfig: Enable ESM & PMIC ESM configs arm: dts: k3-j7200-r5-common-proc-board: Add PMIC ESM node configs: j7200_evm_r5_defconfig: Enable the ESM configs board: ti: j721e: Enable ESM initialization for J7200 arch/arm/dts/k3-j7200-mcu-wakeup.dtsi | 7 .../arm/dts/k3-j7200-r5-common-proc-board.dts | 14 +++ arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 7 arch/arm/dts/k3-j721s2-main.dtsi | 7 arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi| 14 +++ .../dts/k3-j721s2-r5-common-proc-board.dts| 39 +++ board/ti/j721e/evm.c | 11 +- board/ti/j721s2/evm.c | 27 + configs/j7200_evm_r5_defconfig| 2 + configs/j721s2_evm_r5_defconfig | 7 10 files changed, 133 insertions(+), 2 deletions(-) -- 2.17.1
[PATCH 2/2] arm64: dts: ti: k3-j7200: Add MCU domain ESM instance
Patch adds the ESM instance for MCU domian of j7200. Signed-off-by: Keerthy --- arch/arm/dts/k3-j7200-mcu-wakeup.dtsi | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi b/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi index 1044ec6c4b..2b185fa350 100644 --- a/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j7200-mcu-wakeup.dtsi @@ -375,4 +375,11 @@ ti,loczrama = <1>; }; }; + + mcu_esm: esm@4080 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x4080 0x00 0x1000>; + ti,esm-pins = <95>; + bootph-pre-ram; + }; }; -- 2.17.1
[PATCH 1/2] arm64: dts: ti: k3-j721s2: Add ESM instances
Patch adds the ESM instances for j721s2. It has 3 instances. One in the main domain and two in the mcu-wakeup domian. Signed-off-by: Keerthy --- arch/arm/dts/k3-j721s2-main.dtsi | 7 +++ arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi | 14 ++ 2 files changed, 21 insertions(+) diff --git a/arch/arm/dts/k3-j721s2-main.dtsi b/arch/arm/dts/k3-j721s2-main.dtsi index 976ba1e95a..859b5124ae 100644 --- a/arch/arm/dts/k3-j721s2-main.dtsi +++ b/arch/arm/dts/k3-j721s2-main.dtsi @@ -934,4 +934,11 @@ interrupt-names = "int0", "int1"; bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; }; + + main_esm: esm@70 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x70 0x00 0x1000>; + ti,esm-pins = <688>, <689>; + bootph-pre-ram; + }; }; diff --git a/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi b/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi index 7521963719..f28cf7df50 100644 --- a/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi @@ -299,4 +299,18 @@ ti,cpts-periodic-outputs = <2>; }; }; + + mcu_esm: esm@4080 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x4080 0x00 0x1000>; + ti,esm-pins = <95>; + bootph-pre-ram; + }; + + wkup_esm: esm@4208 { + compatible = "ti,j721e-esm"; + reg = <0x00 0x4208 0x00 0x1000>; + ti,esm-pins = <63>; + bootph-pre-ram; + }; }; -- 2.17.1
[PATCH 0/2] arm64: ti: k3-j7: Add the ESM nodes
Hi Tom, https://lore.kernel.org/linux-arm-kernel/5187c590-ee9a-4c46-b326-655f4c371...@linaro.org/T/#me178708007a6b3b9695ae0ff84475fa4f49f283c I have posted the ESM patches to the linux kernel device tree mailing list. These are neeeded in R5 SPL to enable watchdog support. Keerthy (2): arm64: dts: ti: k3-j721s2: Add ESM instances arm64: dts: ti: k3-j7200: Add MCU domain ESM instance arch/arm/dts/k3-j7200-mcu-wakeup.dtsi | 7 +++ arch/arm/dts/k3-j721s2-main.dtsi | 7 +++ arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi | 14 ++ 3 files changed, 28 insertions(+) -- 2.17.1
[PATCH] arm: dts: k3-j721e-r5-common-proc-board: tps659413: Correct the min/max voltages of VDD_CPU
Correct the min/max voltages of VDD_CPU. As per data sheet the VDD_CPU minimum voltage is .6V & maximum voltage is .9V. Correct the same. While at it fix the comment to reflect VDD_CPU instead of VDD_MPU. Data Sheet Link: https://www.ti.com/lit/gpn/dra829v Signed-off-by: Keerthy --- arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 5362c52870..1507109892 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -259,10 +259,10 @@ regulators: regulators { u-boot,dm-spl; buck12_reg: buck12 { - /*VDD_MPU*/ + /*VDD_CPU*/ regulator-name = "buck12"; - regulator-min-microvolt = <80>; - regulator-max-microvolt = <125>; + regulator-min-microvolt = <60>; + regulator-max-microvolt = <90>; regulator-always-on; regulator-boot-on; u-boot,dm-spl; -- 2.17.1
Re: [PATCH v2 0/3] arm: dts: k3-j721e: Enable OSPI1/QSPI
On 04/03/20 10:10 am, Lokesh Vutla wrote: On 04/03/20 10:09 AM, Keerthy wrote: The patch series enables he OSPI1 aka QSPI node. This is a precursor for enabling QSPI boot on j721e. How did you test this using R5 defconig? #define CONFIG_SF_DEFAULT_BUS 1 So as to force SPI boot to OSPI1/QSPI. Booted using OSPI boot probed sf probe 1:0 & burnt all the boot images on to QSPI. Then booted from QSPI. - Keerthy Thanks and regards, Lokesh
[PATCH v2 3/3] arm: dts: k3-j721e-r5-common-proc-board: Add ospi1 flash node
Add ospi1 flash node required for QSPI boot. Signed-off-by: Keerthy --- .../arm/dts/k3-j721e-r5-common-proc-board.dts | 25 +++ 1 file changed, 25 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 44da8eabc2..84bfb1025e 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -320,4 +320,29 @@ }; }; +&ospi1 { + pinctrl-names = "default"; + pinctrl-0 = <&mcu_fss0_ospi1_pins_default>; + u-boot,dm-spl; + + reg = <0x0 0x4705 0x0 0x100>, + <0x0 0x5800 0x0 0x800>; + + flash@0{ + compatible = "jedec,spi-nor"; + reg = <0x0>; + spi-tx-bus-width = <1>; + spi-rx-bus-width = <4>; + spi-max-frequency = <4000>; + cdns,tshsl-ns = <60>; + cdns,tsd2d-ns = <60>; + cdns,tchsh-ns = <60>; + cdns,tslch-ns = <60>; + cdns,read-delay = <2>; + #address-cells = <1>; + #size-cells = <1>; + u-boot,dm-spl; + }; +}; + #include "k3-j721e-common-proc-board-u-boot.dtsi" -- 2.17.1
[PATCH v2 1/3] arm: dts: k3-j721e: Enable ospi1/qspi
Enable the ospi1/qspi for both r5 and a72 configurations. Signed-off-by: Keerthy --- Changes in v2: * Moved the pin definitions out of u-boot.dtsi to r5 and a72 based dts files. .../arm/dts/k3-j721e-common-proc-board-u-boot.dtsi | 12 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 14 ++ 2 files changed, 26 insertions(+) diff --git a/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi index d422100d42..7b01e4204f 100644 --- a/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi +++ b/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi @@ -365,3 +365,15 @@ u-boot,dm-spl; }; }; + +&ospi1 { + u-boot,dm-spl; + + flash@0 { + u-boot,dm-spl; + }; +}; + +&mcu_fss0_ospi1_pins_default { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index ebea9efa58..44da8eabc2 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -134,6 +134,20 @@ J721E_WKUP_IOPAD(0x002c, PIN_OUTPUT, 0) /* MCU_OSPI0_CSn0 */ >; }; + + mcu_fss0_ospi1_pins_default: mcu-fss0-ospi1-pins-default { + u-boot,dm-spl; + pinctrl-single,pins = < + J721E_WKUP_IOPAD(0x34, PIN_OUTPUT, 0) /* (F22) MCU_OSPI1_CLK */ + J721E_WKUP_IOPAD(0x50, PIN_OUTPUT, 0) /* (C22) MCU_OSPI1_CSn0 */ + J721E_WKUP_IOPAD(0x40, PIN_INPUT, 0) /* (D22) MCU_OSPI1_D0 */ + J721E_WKUP_IOPAD(0x44, PIN_INPUT, 0) /* (G22) MCU_OSPI1_D1 */ + J721E_WKUP_IOPAD(0x48, PIN_INPUT, 0) /* (D23) MCU_OSPI1_D2 */ + J721E_WKUP_IOPAD(0x4c, PIN_INPUT, 0) /* (C23) MCU_OSPI1_D3 */ + J721E_WKUP_IOPAD(0x3c, PIN_INPUT, 0) /* (B23) MCU_OSPI1_DQS */ + J721E_WKUP_IOPAD(0x38, PIN_INPUT, 0) /* (A23) MCU_OSPI1_LBCLKO */ + >; + }; }; &main_pmx0 { -- 2.17.1
[PATCH v2 2/3] arm: dts: k3-j721e-mcu-wakeup: Add assigned-clocks/rates properties for ospi1/qspi
Add assigned-clocks/rates properties for ospi1/qspi. This is the expected rate as per ROM configuration. Signed-off-by: Keerthy --- arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi index a9e97f219b..2eed50aa5a 100644 --- a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi @@ -170,6 +170,8 @@ cdns,fifo-width = <4>; cdns,trigger-address = <0x0>; clocks = <&k3_clks 104 0>; + assigned-clocks = <&k3_clks 104 0>; + assigned-clock-rates = <1>; power-domains = <&k3_pds 104 TI_SCI_PD_EXCLUSIVE>; #address-cells = <1>; #size-cells = <0>; -- 2.17.1
[PATCH v2 0/3] arm: dts: k3-j721e: Enable OSPI1/QSPI
The patch series enables he OSPI1 aka QSPI node. This is a precursor for enabling QSPI boot on j721e. Changes in v2: * Moved the pin definitions out of u-boot.dtsi to r5 and a72 based dts files. Keerthy (3): arm: dts: k3-j721e: Enable ospi1/qspi arm: dts: k3-j721e-mcu-wakeup: Add assigned-clocks/rates properties for ospi1/qspi arm: dts: k3-j721e-r5-common-proc-board: Add ospi1 flash node .../k3-j721e-common-proc-board-u-boot.dtsi| 12 ++ arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 2 + .../arm/dts/k3-j721e-r5-common-proc-board.dts | 39 +++ 3 files changed, 53 insertions(+) -- 2.17.1
[PATCH 2/3] arm: dts: k3-j721e-mcu-wakeup: Add assigned-clocks/rates properties for ospi1/qspi
Add assigned-clocks/rates properties for ospi1/qspi. This is the expected rate as per ROM configuration. Signed-off-by: Keerthy --- arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi index a9e97f219b..2eed50aa5a 100644 --- a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi @@ -170,6 +170,8 @@ cdns,fifo-width = <4>; cdns,trigger-address = <0x0>; clocks = <&k3_clks 104 0>; + assigned-clocks = <&k3_clks 104 0>; + assigned-clock-rates = <1>; power-domains = <&k3_pds 104 TI_SCI_PD_EXCLUSIVE>; #address-cells = <1>; #size-cells = <0>; -- 2.17.1
[PATCH 3/3] arm: dts: k3-j721e-r5-common-proc-board: Add ospi1 flash node
Add ospi1 flash node required for QSPI boot. Signed-off-by: Keerthy --- .../arm/dts/k3-j721e-r5-common-proc-board.dts | 25 +++ 1 file changed, 25 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index ebea9efa58..cb98e4ba33 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -306,4 +306,29 @@ }; }; +&ospi1 { + pinctrl-names = "default"; + pinctrl-0 = <&mcu_fss0_ospi1_pins_default>; + u-boot,dm-spl; + + reg = <0x0 0x4705 0x0 0x100>, + <0x0 0x5800 0x0 0x800>; + + flash@0{ + compatible = "jedec,spi-nor"; + reg = <0x0>; + spi-tx-bus-width = <1>; + spi-rx-bus-width = <4>; + spi-max-frequency = <4000>; + cdns,tshsl-ns = <60>; + cdns,tsd2d-ns = <60>; + cdns,tchsh-ns = <60>; + cdns,tslch-ns = <60>; + cdns,read-delay = <2>; + #address-cells = <1>; + #size-cells = <1>; + u-boot,dm-spl; + }; +}; + #include "k3-j721e-common-proc-board-u-boot.dtsi" -- 2.17.1
[PATCH 1/3] arm: dts: k3-j721e-common-proc-board-u-boot: Enable ospi1/qspi
Enable the ospi1/qspi module while at it move the corresponding pins to common u-boot.dtsi file. Signed-off-by: Keerthy --- .../k3-j721e-common-proc-board-u-boot.dtsi| 23 +++ arch/arm/dts/k3-j721e-common-proc-board.dts | 13 --- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi index d422100d42..d15b5181f4 100644 --- a/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi +++ b/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi @@ -260,6 +260,20 @@ J721E_WKUP_IOPAD(0x0088, PIN_INPUT, 0) /* (L4) MCU_MDIO0_MDIO */ >; }; + + mcu_fss0_ospi1_pins_default: mcu-fss0-ospi1-pins-default { + pinctrl-single,pins = < + J721E_WKUP_IOPAD(0x34, PIN_OUTPUT, 0) /* (F22) MCU_OSPI1_CLK */ + J721E_WKUP_IOPAD(0x50, PIN_OUTPUT, 0) /* (C22) MCU_OSPI1_CSn0 */ + J721E_WKUP_IOPAD(0x40, PIN_INPUT, 0) /* (D22) MCU_OSPI1_D0 */ + J721E_WKUP_IOPAD(0x44, PIN_INPUT, 0) /* (G22) MCU_OSPI1_D1 */ + J721E_WKUP_IOPAD(0x48, PIN_INPUT, 0) /* (D23) MCU_OSPI1_D2 */ + J721E_WKUP_IOPAD(0x4c, PIN_INPUT, 0) /* (C23) MCU_OSPI1_D3 */ + J721E_WKUP_IOPAD(0x3c, PIN_INPUT, 0) /* (B23) MCU_OSPI1_DQS */ + J721E_WKUP_IOPAD(0x38, PIN_INPUT, 0) /* (A23) MCU_OSPI1_LBCLKO */ + >; + u-boot,dm-spl; + }; }; &main_pmx0 { @@ -365,3 +379,12 @@ u-boot,dm-spl; }; }; + +&ospi1 { + status = "okay"; + u-boot,dm-spl; + + flash@0 { + u-boot,dm-spl; + }; +}; diff --git a/arch/arm/dts/k3-j721e-common-proc-board.dts b/arch/arm/dts/k3-j721e-common-proc-board.dts index 496a15e1d1..d02422ed25 100644 --- a/arch/arm/dts/k3-j721e-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-common-proc-board.dts @@ -123,19 +123,6 @@ J721E_WKUP_IOPAD(0xfc, PIN_INPUT_PULLUP, 0) /* (H24) WKUP_I2C0_SDA */ >; }; - - mcu_fss0_ospi1_pins_default: mcu-fss0-ospi1-pins-default { - pinctrl-single,pins = < - J721E_WKUP_IOPAD(0x34, PIN_OUTPUT, 0) /* (F22) MCU_OSPI1_CLK */ - J721E_WKUP_IOPAD(0x50, PIN_OUTPUT, 0) /* (C22) MCU_OSPI1_CSn0 */ - J721E_WKUP_IOPAD(0x40, PIN_INPUT, 0) /* (D22) MCU_OSPI1_D0 */ - J721E_WKUP_IOPAD(0x44, PIN_INPUT, 0) /* (G22) MCU_OSPI1_D1 */ - J721E_WKUP_IOPAD(0x48, PIN_INPUT, 0) /* (D23) MCU_OSPI1_D2 */ - J721E_WKUP_IOPAD(0x4c, PIN_INPUT, 0) /* (C23) MCU_OSPI1_D3 */ - J721E_WKUP_IOPAD(0x3c, PIN_INPUT, 0) /* (B23) MCU_OSPI1_DQS */ - J721E_WKUP_IOPAD(0x38, PIN_INPUT, 0) /* (A23) MCU_OSPI1_LBCLKO */ - >; - }; }; &usbss0 { -- 2.17.1
[PATCH 0/3] arm: dts: k3-j721e: Enable OSPI1/QSPI
The patch series enables he OSPI1 aka QSPI node. This is a precursor for enabling QSPI boot on j721e. Keerthy (3): arm: dts: k3-j721e-common-proc-board-u-boot: Enable ospi1/qspi arm: dts: k3-j721e-mcu-wakeup: Add assigned-clocks/rates properties for ospi1/qspi arm: dts: k3-j721e-r5-common-proc-board: Add ospi1 flash node .../k3-j721e-common-proc-board-u-boot.dtsi| 23 + arch/arm/dts/k3-j721e-common-proc-board.dts | 13 -- arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 2 ++ .../arm/dts/k3-j721e-r5-common-proc-board.dts | 25 +++ 4 files changed, 50 insertions(+), 13 deletions(-) -- 2.17.1
Re: [PATCH v2 00/10] net: ti: icssg: Add prueth support
On 18/02/20 10:39 am, Keerthy wrote: The series adds support for icssg_prueth functionality on u-boot. This series is based on top of master branch. rproc init needs to be done from uboot command prompt. The pru/rtu firmware loading is done by prueth driver soon after config paramters are setup. A quick update on this series. It seems newer version of this hardware needs more modifications to this series. Hence please ignore v2. Best Regards, Keerthy Currently only slice0/1 of icssg2 instance on am6-evm is supported. i.e Both slices of icssg2 instance are supported. Prebuilt firmware can be obtained from AM65 procSDK [1] rootfs at /lib/firmware/ti-pruss/am65x*.elf [1] http://software-dl.ti.com/processor-sdk-linux/esd/AM65X/latest/index_FDS.html This tests tftp on prueth. Note: Uboot ethernet driver architecture supports once instance per probe. So only one of the ports are supported per instance. So DT of prueth node should have either ethernet-mii0 or ethernet-mii1. Changes in v2: It has been a while since v1 was posted. Here are the changes: * Removed the usage of misc_init_by_ofnode instead used uclass_get_device_by_ofnode. * Introduced started variable to keep track of the status of the prueth device. * Build Tested on Travis: https://travis-ci.org/Keerthyj/u-boot/builds/651449684 Keerthy (10): net: eth-uclass: eth_get_dev based on SEQ_ALIAS instead of probe order soc: ti: pruss: add a misc driver for PRUSS in TI SoCs remoteproc: pruss: add PRU remoteproc driver net: ti: icssg-prueth: Add ICSSG ethernet driver arm: dts: k3-am65-main: Add msmc_ram node arm: dts: k3-am654-base-board-u-boot: Add icssg specific msmc_ram carveout nodes arm: dts: k3-am65-main: Add scm_conf node arm: dts: k3-am65-main: Add pruss nodes for ICSSG2 arm64: dts: ti: am654-base-board: add ICSSG2 Ethernet support configs: am65x_evm_a53_defconfig: Enable CONFIG_TI_AM64_ICSSG_PRUETH arch/arm/dts/k3-am65-main.dtsi | 191 ++ arch/arm/dts/k3-am65.dtsi| 4 +- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 129 configs/am65x_evm_a53_defconfig | 3 + drivers/net/ti/Kconfig | 8 + drivers/net/ti/Makefile | 1 + drivers/net/ti/icssg-prueth.c| 652 +++ drivers/net/ti/icssg.h | 36 + drivers/net/ti/icssg_classifier.c| 396 +++ drivers/remoteproc/Kconfig | 11 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/pru_rproc.c | 405 drivers/soc/ti/Kconfig | 12 + drivers/soc/ti/Makefile | 1 + drivers/soc/ti/pruss.c | 152 + include/ti-pruss.h | 17 + net/eth-uclass.c | 12 +- 17 files changed, 2027 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ti/icssg-prueth.c create mode 100644 drivers/net/ti/icssg.h create mode 100644 drivers/net/ti/icssg_classifier.c create mode 100644 drivers/remoteproc/pru_rproc.c create mode 100644 drivers/soc/ti/pruss.c create mode 100644 include/ti-pruss.h
[PATCH v2 09/10] arm64: dts: ti: am654-base-board: add ICSSG2 Ethernet support
ICSSG2 provide dual Gigabit Ethernet support. Currently mdio clock is part of this node and also the icssg2_rgmii_pins_default pinmux node has the mdio pins as there is no davinci mdio driver. Currently icssg2 instances are supported. Either mii0 or mii1 can be enabled at a time. Signed-off-by: Keerthy --- Changes in v2: * Removed a bunch of inconsistent white space in pins definition. arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 117 +++ 1 file changed, 117 insertions(+) diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi index a5aee02eb8..31038b7802 100644 --- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi +++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi @@ -16,6 +16,64 @@ serial2 = &main_uart0; ethernet0 = &cpsw_port1; }; + + /* Dual Ethernet application node on PRU-ICSSG2 */ + pruss2_eth: pruss2_eth { + compatible = "ti,am654-icssg-prueth"; + pinctrl-names = "default"; + pinctrl-0 = <&icssg2_rgmii_pins_default>; + sram = <&icssg2_sram>; + clocks = <&k3_clks 64 3>; + clock-names = "mdio_fck"; + u-boot,dm-spl; + + prus = <&pru2_0>, <&rtu2_0>, <&pru2_1>, <&rtu2_1>; + firmware-name = "ti-pruss/am65x-pru0-prueth-fw.elf", + "ti-pruss/am65x-rtu0-prueth-fw.elf", + "ti-pruss/am65x-pru1-prueth-fw.elf", + "ti-pruss/am65x-rtu1-prueth-fw.elf"; + mii-g-rt = <&icssg2_mii_g_rt>; + mii-rt = <&icssg2_mii_rt>; + dma-coherent; + dmas = <&mcu_udmap &icssg2 0 UDMA_DIR_TX>, /* egress slice 0 */ + <&mcu_udmap &icssg2 1 UDMA_DIR_TX>, /* egress slice 0 */ + <&mcu_udmap &icssg2 2 UDMA_DIR_TX>, /* egress slice 0 */ + <&mcu_udmap &icssg2 3 UDMA_DIR_TX>, /* mgmnt cmd slice 0 */ + <&mcu_udmap &icssg2 4 UDMA_DIR_TX>, /* egress slice 1 */ + <&mcu_udmap &icssg2 5 UDMA_DIR_TX>, /* egress slice 1 */ + <&mcu_udmap &icssg2 6 UDMA_DIR_TX>, /* egress slice 1 */ + <&mcu_udmap &icssg2 7 UDMA_DIR_TX>, /* mgmnt cmd slice 1 */ + + <&mcu_udmap &icssg2 0 UDMA_DIR_RX>, /* ingress slice 0 */ + <&mcu_udmap &icssg2 1 UDMA_DIR_RX>, /* ingress slice 1 */ + <&mcu_udmap &icssg2 2 UDMA_DIR_RX>, /* mgmnt rsp slice 0 */ + <&mcu_udmap &icssg2 3 UDMA_DIR_RX>; /* mgmnt rsp slice 1 */ + dma-names = "tx0-0", "tx0-1", "tx0-2", "tx0-3", + "tx1-0", "tx1-1", "tx1-2", "tx1-3", + "rx0", "rx1", + "rxmgm0", "rxmgm1"; + + pruss2_emac0: ethernet-mii0 { + phy-handle = <&pruss2_eth0_phy>; + phy-mode = "rgmii-rxid"; + syscon-rgmii-delay = <&scm_conf 0x4120>; + /* Filled in by bootloader */ + local-mac-address = [00 00 00 00 00 00]; + }; + +/* + * Commenting out the second mii interface as the framework + * supports one interface in a single probe + * So either mii1 or mii2 can be used. In case mii1 is needed + * uncomment mii1 and comment out mii0 + pruss2_emac1: ethernet-mii1 { + phy-handle = <&pruss2_eth1_phy>; + phy-mode = "rgmii-rxid"; + syscon-rgmii-delay = <&scm_conf 0x4124>; + local-mac-address = [00 00 00 00 00 00]; + }; +*/ + }; }; &cbass_main{ @@ -275,6 +333,47 @@ u-boot,dm-spl; }; + icssg2_rgmii_pins_default: icssg2_rgmii_pins_default { + pinctrl-single,pins = < + AM65X_IOPAD(0x00ac, PIN_INPUT, 2) /* (AH15) PRG2_PRU1_GPO0.PRG2_RGMII2_RD0 */ + AM65X_IOPAD(0x00b0, PIN_INPUT, 2) /* (AC16) PRG2_PRU1_GPO1.PRG2_RGMII2_RD1 */ + AM65X_IOPAD(0x00b4, PIN_INPUT, 2) /* (AD17) PRG2_PRU1_GPO2.PRG2_RGMII2_RD2 */ + AM65X_IOPAD(0x00b8, PIN_INPUT, 2) /* (AH14) PRG2_PRU1_GPO3.PRG2_RGMII2_RD3 */ + AM65X_IOPAD(0x00cc, PIN_OUTPUT,
[PATCH v2 10/10] configs: am65x_evm_a53_defconfig: Enable CONFIG_TI_AM64_ICSSG_PRUETH
Enable ICSSG_PRUETH & related configs. This enables ethernet functionality on PRU. Signed-off-by: Keerthy --- configs/am65x_evm_a53_defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/am65x_evm_a53_defconfig b/configs/am65x_evm_a53_defconfig index 079cd912ba..1b0bfe6444 100644 --- a/configs/am65x_evm_a53_defconfig +++ b/configs/am65x_evm_a53_defconfig @@ -84,6 +84,7 @@ CONFIG_DM_ETH=y CONFIG_E1000=y CONFIG_CMD_E1000=y CONFIG_TI_AM65_CPSW_NUSS=y +CONFIG_TI_AM64_ICSSG_PRUETH=y CONFIG_PCI=y CONFIG_DM_PCI=y CONFIG_PCI_KEYSTONE=y @@ -98,10 +99,12 @@ CONFIG_PINCTRL_SINGLE=y CONFIG_POWER_DOMAIN=y CONFIG_TI_SCI_POWER_DOMAIN=y CONFIG_REMOTEPROC_TI_K3_R5F=y +CONFIG_REMOTEPROC_TI_PRU=y CONFIG_DM_RESET=y CONFIG_RESET_TI_SCI=y CONFIG_DM_SERIAL=y CONFIG_SOC_TI=y +CONFIG_TI_PRUSS=y CONFIG_SYSRESET=y CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_TI_SCI=y -- 2.17.1
[PATCH v2 07/10] arm: dts: k3-am65-main: Add scm_conf node
Add scm_conf node needed for prueth. Signed-off-by: Keerthy --- arch/arm/dts/k3-am65-main.dtsi | 8 1 file changed, 8 insertions(+) diff --git a/arch/arm/dts/k3-am65-main.dtsi b/arch/arm/dts/k3-am65-main.dtsi index 631134cd65..71a540376f 100644 --- a/arch/arm/dts/k3-am65-main.dtsi +++ b/arch/arm/dts/k3-am65-main.dtsi @@ -53,6 +53,14 @@ }; }; + scm_conf: scm_conf@10 { + compatible = "syscon", "simple-mfd"; + reg = <0 0x0010 0 0x1c000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x0 0x0010 0x1c000>; + }; + secure_proxy_main: mailbox@32c0 { compatible = "ti,am654-secure-proxy"; #mbox-cells = <1>; -- 2.17.1
[PATCH v2 06/10] arm: dts: k3-am654-base-board-u-boot: Add icssg specific msmc_ram carveout nodes
Add icssg specific msmc_ram carveout nodes Signed-off-by: Keerthy --- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 12 1 file changed, 12 insertions(+) diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi index a349edcfa5..a5aee02eb8 100644 --- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi +++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi @@ -365,3 +365,15 @@ &usb1 { dr_mode = "peripheral"; }; + +&msmc_ram { + icssg0_sram: icssg0-sram@4 { + reg = <0x4 0x1>; + }; + icssg1_sram: icssg1-sram@5 { + reg = <0x5 0x1>; + }; + icssg2_sram: icssg2-sram@6 { + reg = <0x6 0x1>; + }; +}; -- 2.17.1
[PATCH v2 05/10] arm: dts: k3-am65-main: Add msmc_ram node
Add msmc_ram node needed for prueth Signed-off-by: Keerthy --- Changes in v2: * Aligned trailing 0s for consistency. arch/arm/dts/k3-am65-main.dtsi | 21 + arch/arm/dts/k3-am65.dtsi | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/k3-am65-main.dtsi b/arch/arm/dts/k3-am65-main.dtsi index ab40dafceb..631134cd65 100644 --- a/arch/arm/dts/k3-am65-main.dtsi +++ b/arch/arm/dts/k3-am65-main.dtsi @@ -9,6 +9,27 @@ #include &cbass_main { + msmc_ram: sram@7000 { + compatible = "mmio-sram"; + reg = <0x0 0x7000 0x0 0x20>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x0 0x7000 0x20>; + u-boot,dm-spl; + + atf-sram@0 { + reg = <0x0 0x2>; + }; + + sysfw-sram@f { + reg = <0xf 0x1>; + }; + + l3cache-sram@10 { + reg = <0x10 0x10>; + }; + }; + gic500: interrupt-controller@180 { compatible = "arm,gic-v3"; #address-cells = <2>; diff --git a/arch/arm/dts/k3-am65.dtsi b/arch/arm/dts/k3-am65.dtsi index 3ead944640..b2e967aaf7 100644 --- a/arch/arm/dts/k3-am65.dtsi +++ b/arch/arm/dts/k3-am65.dtsi @@ -79,7 +79,9 @@ <0x00 0x4204 0x00 0x4204 0x00 0x03ac2400>, <0x00 0x4510 0x00 0x4510 0x00 0x00c24000>, <0x00 0x4600 0x00 0x4600 0x00 0x0020>, -<0x00 0x4700 0x00 0x4700 0x00 0x00068400>; +<0x00 0x4700 0x00 0x4700 0x00 0x00068400>, +<0x07 0x 0x07 0x 0x01 0x>, +<0x00 0x7000 0x00 0x7000 0x00 0x0020>; cbass_mcu: interconnect@2838 { compatible = "simple-bus"; -- 2.17.1
[PATCH v2 04/10] net: ti: icssg-prueth: Add ICSSG ethernet driver
This is the Ethernet driver for TI SoCs with the ICSSG PRU Sub-system running EMAC firmware. This driver caters to either of the slices(pru/rtu pair) of the icssg subsystem. Following are the firmwares needed to run cores: am65x-pru0-prueth-fw.elf for pru0 of slice0 am65x-rtu0-prueth-fw.elf for rtu0 of slice0 am65x-pru1-prueth-fw.elf for pru1 of slice1 am65x-rtu1-prueth-fw.elf for rtu1 of slice1 One and exactly one of the slices is supported as the u-boot ethernet supports probing one interface at a time. Signed-off-by: Keerthy --- Changes in v2: * Added guards defines for icssg.h * returning errors which were missed in v1 * Removed unused prueth_print_buf function. * Removed usage misc_of_init and used uclass_get_device_by_ofnode in place of that. * Introduced started variable to keep track of the status of the prueth device. drivers/net/ti/Kconfig| 8 + drivers/net/ti/Makefile | 1 + drivers/net/ti/icssg-prueth.c | 652 ++ drivers/net/ti/icssg.h| 36 ++ drivers/net/ti/icssg_classifier.c | 396 ++ 5 files changed, 1093 insertions(+) create mode 100644 drivers/net/ti/icssg-prueth.c create mode 100644 drivers/net/ti/icssg.h create mode 100644 drivers/net/ti/icssg_classifier.c diff --git a/drivers/net/ti/Kconfig b/drivers/net/ti/Kconfig index ecf642de10..1b6285709f 100644 --- a/drivers/net/ti/Kconfig +++ b/drivers/net/ti/Kconfig @@ -26,3 +26,11 @@ config TI_AM65_CPSW_NUSS help This driver supports TI K3 MCU CPSW Nuss Ethernet controller in Texas Instruments K3 AM65x SoCs. + +config TI_AM64_ICSSG_PRUETH + bool "TI Gigabit PRU Ethernet driver" + depends on ARCH_K3 + select PHYLIB + help + Support Gigabit Ethernet ports over the ICSSG PRU Subsystem + This subsystem is available starting with the AM65 platform. diff --git a/drivers/net/ti/Makefile b/drivers/net/ti/Makefile index 8d3808bb4b..b486498909 100644 --- a/drivers/net/ti/Makefile +++ b/drivers/net/ti/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o cpsw_mdio.o obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o obj-$(CONFIG_DRIVER_TI_KEYSTONE_NET) += keystone_net.o cpsw_mdio.o obj-$(CONFIG_TI_AM65_CPSW_NUSS) += am65-cpsw-nuss.o cpsw_mdio.o +obj-$(CONFIG_TI_AM64_ICSSG_PRUETH) += icssg-prueth.o cpsw_mdio.o icssg_classifier.o diff --git a/drivers/net/ti/icssg-prueth.c b/drivers/net/ti/icssg-prueth.c new file mode 100644 index 00..0a85ca3ab5 --- /dev/null +++ b/drivers/net/ti/icssg-prueth.c @@ -0,0 +1,652 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Texas Instruments PRU Ethernet Driver + * + * Copyright (C) 2020, Texas Instruments, Incorporated + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cpsw_mdio.h" +#include "icssg.h" + +#define ICSS_SLICE0 0 +#define ICSS_SLICE1 1 + +#ifdef PKTSIZE_ALIGN +#define UDMA_RX_BUF_SIZE PKTSIZE_ALIGN +#else +#define UDMA_RX_BUF_SIZE ALIGN(1522, ARCH_DMA_MINALIGN) +#endif + +#ifdef PKTBUFSRX +#define UDMA_RX_DESC_NUM PKTBUFSRX +#else +#define UDMA_RX_DESC_NUM 4 +#endif + +enum prueth_mac { + PRUETH_MAC0 = 0, + PRUETH_MAC1, + PRUETH_NUM_MACS, +}; + +enum prueth_port { + PRUETH_PORT_HOST = 0, /* host side port */ + PRUETH_PORT_MII0, /* physical port MII 0 */ + PRUETH_PORT_MII1, /* physical port MII 1 */ +}; + +/* Config region lies in shared RAM */ +#define ICSS_CONFIG_OFFSET_SLICE0 0 +#define ICSS_CONFIG_OFFSET_SLICE1 0x8000 + +/* Firmware flags */ +#define ICSS_SET_RUN_FLAG_VLAN_ENABLE BIT(0) /* switch only */ +#define ICSS_SET_RUN_FLAG_FLOOD_UNICASTBIT(1) /* switch only */ +#define ICSS_SET_RUN_FLAG_PROMISC BIT(2) /* MAC only */ +#define ICSS_SET_RUN_FLAG_MULTICAST_PROMISCBIT(3) /* MAC only */ + +/* CTRLMMR_ICSSG_RGMII_CTRL register bits */ +#define ICSSG_CTRL_RGMII_ID_MODE BIT(24) + +/** + * enum pruss_pru_id - PRU core identifiers + */ +enum pruss_pru_id { + PRUSS_PRU0 = 0, + PRUSS_PRU1, + PRUSS_NUM_PRUS, +}; + +struct prueth { + struct udevice *dev; + struct regmap *miig_rt; + struct regmap *mii_rt; + fdt_addr_t mdio_base; + phys_addr_t pruss_shrdram2; + phys_addr_t tmaddr; + struct mii_dev *bus; + u32 port_id; + u32 sram_pa; + struct phy_device *phydev; + boolhas_phy; + ofnode phy_node; + u32 phy_addr; + ofnode eth_node[PRUETH_NUM_MACS]; +
[PATCH v2 08/10] arm: dts: k3-am65-main: Add pruss nodes for ICSSG2
Add pruss nodes. This is based 4.19 DT with interrupt properties removed from pur/rtu nodes. Signed-off-by: Keerthy --- arch/arm/dts/k3-am65-main.dtsi | 162 + 1 file changed, 162 insertions(+) diff --git a/arch/arm/dts/k3-am65-main.dtsi b/arch/arm/dts/k3-am65-main.dtsi index 71a540376f..7499bab309 100644 --- a/arch/arm/dts/k3-am65-main.dtsi +++ b/arch/arm/dts/k3-am65-main.dtsi @@ -8,6 +8,8 @@ #include #include +#include + &cbass_main { msmc_ram: sram@7000 { compatible = "mmio-sram"; @@ -358,4 +360,164 @@ #phy-cells = <0>; ti,dis-chg-det-quirk; }; + + icssg2: icssg@b20 { + compatible = "ti,am654-icssg"; + power-domains = <&k3_pds 64 TI_SCI_PD_EXCLUSIVE>; + reg = <0xb20 0x8>; + #address-cells = <1>; + #size-cells = <1>; + ranges; + dma-ranges; + ti,psil-base = <0x4300>;/* ICSSG2 PSIL thread start */ + + ti,psil-config0 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + ti,psil-config1 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + ti,psil-config2 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + ti,psil-config3 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + ti,psil-config4 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + ti,psil-config5 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + ti,psil-config6 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + ti,psil-config7 { + linux,udma-mode = ; + statictr-type = ; + ti,needs-epib; + ti,psd-size = <16>; + }; + + icssg2_mem: memories@b20 { + reg = <0xb20 0x2000>, + <0xb202000 0x2000>, + <0xb21 0x1>; + reg-names = "dram0", "dram1", + "shrdram2"; + }; + + icssg2_cfg: cfg@b226000 { + compatible = "syscon"; + reg = <0xb226000 0x200>; + }; + + icssg2_iep: iep@b22e000 { + compatible = "syscon"; + reg = <0xb22e000 0x1000>; + }; + + icssg2_mii_rt: mii-rt@b232000 { + compatible = "syscon"; + reg = <0xb232000 0x100>; + }; + + icssg2_mii_g_rt: mii-g-rt@b233000 { + compatible = "syscon"; + reg = <0xb233000 0x1000>; + }; + + icssg2_intc: interrupt-controller@b22 { + compatible = "ti,am654-icssg-intc"; + reg = <0xb22 0x2000>; + interrupt-controller; + #interrupt-cells = <1>; + interrupts = , +, +, +, +, +, +, +; + interrupt-names = "host2", "host3", "host4", + "host5", "host6", "host7", + "host8", "host9"; + }; + + pru2_0: pru@b2340
[PATCH v2 01/10] net: eth-uclass: eth_get_dev based on SEQ_ALIAS instead of probe order
In case of multiple eth interfaces currently eth_get_dev fetches the device based on the probe order which can be random hence try with the alias. Signed-off-by: Keerthy --- Changes in v2: * Fixed comments from Tom & Lokesh as per: https://patchwork.ozlabs.org/patch/1142697/ net/eth-uclass.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/net/eth-uclass.c b/net/eth-uclass.c index ed81cbd537..93855e933b 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -68,9 +68,15 @@ struct udevice *eth_get_dev(void) struct eth_uclass_priv *uc_priv; uc_priv = eth_get_uclass_priv(); - if (!uc_priv->current) - eth_errno = uclass_first_device(UCLASS_ETH, - &uc_priv->current); + + if (!uc_priv->current) { + eth_errno = uclass_get_device_by_seq(UCLASS_ETH, 0, +&uc_priv->current); + if (eth_errno || !uc_priv->current) +eth_errno = uclass_first_device(UCLASS_ETH, +&uc_priv->current); + } + return uc_priv->current; } -- 2.17.1
[PATCH v2 03/10] remoteproc: pruss: add PRU remoteproc driver
The Programmable Real-Time Unit Subsystem (PRUSS) consists of dual 32-bit RISC cores (Programmable Real-Time Units, or PRUs) for program execution. This patch adds a remoteproc platform driver for managing the individual PRU RISC cores life cycle. The driver currently supports the AM65xx SoC Signed-off-by: Keerthy --- drivers/remoteproc/Kconfig | 11 + drivers/remoteproc/Makefile| 1 + drivers/remoteproc/pru_rproc.c | 405 + 3 files changed, 417 insertions(+) create mode 100644 drivers/remoteproc/pru_rproc.c diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 7c2e4804b5..24e536463b 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -81,4 +81,15 @@ config REMOTEPROC_TI_POWER help Say 'y' here to add support for TI power processors such as those found on certain TI keystone and OMAP generation SoCs. + +config REMOTEPROC_TI_PRU + bool "Support for TI's K3 based PRU remoteproc driver" + select REMOTEPROC + depends on DM + depends on TI_PRUSS + depends on ARCH_K3 + depends on OF_CONTROL + help + Say 'y' here to add support for TI' K3 remoteproc driver. + endmenu diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 69ae7bd1e8..f0e83451d6 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_REMOTEPROC_TI_K3_ARM64) += ti_k3_arm64_rproc.o obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o +obj-$(CONFIG_REMOTEPROC_TI_PRU) += pru_rproc.o diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c new file mode 100644 index 00..832cffb1a0 --- /dev/null +++ b/drivers/remoteproc/pru_rproc.c @@ -0,0 +1,405 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PRU-RTU remoteproc driver for various SoCs + * + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + * Keerthy + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* PRU_ICSS_PRU_CTRL registers */ +#define PRU_CTRL_CTRL 0x +#define PRU_CTRL_STS 0x0004 +#define PRU_CTRL_WAKEUP_EN 0x0008 +#define PRU_CTRL_CYCLE 0x000C +#define PRU_CTRL_STALL 0x0010 +#define PRU_CTRL_CTBIR00x0020 +#define PRU_CTRL_CTBIR10x0024 +#define PRU_CTRL_CTPPR00x0028 +#define PRU_CTRL_CTPPR10x002C + +/* CTRL register bit-fields */ +#define CTRL_CTRL_SOFT_RST_N BIT(0) +#define CTRL_CTRL_EN BIT(1) +#define CTRL_CTRL_SLEEPING BIT(2) +#define CTRL_CTRL_CTR_EN BIT(3) +#define CTRL_CTRL_SINGLE_STEP BIT(8) +#define CTRL_CTRL_RUNSTATE BIT(15) + +#define RPROC_FLAGS_SHIFT 16 +#define RPROC_FLAGS_NONE 0 +#define RPROC_FLAGS_ELF_PHDR BIT(0 + RPROC_FLAGS_SHIFT) +#define RPROC_FLAGS_ELF_SHDR BIT(1 + RPROC_FLAGS_SHIFT) + +/** + * enum pru_mem - PRU core memory range identifiers + */ +enum pru_mem { + PRU_MEM_IRAM = 0, + PRU_MEM_CTRL, + PRU_MEM_DEBUG, + PRU_MEM_MAX, +}; + +struct pru_privdata { + phys_addr_t pru_iram; + phys_addr_t pru_ctrl; + phys_addr_t pru_debug; + fdt_size_t pru_iramsz; + fdt_size_t pru_ctrlsz; + fdt_size_t pru_debugsz; + const char *fw_name; + u32 iram_da; + u32 pdram_da; + u32 sdram_da; + u32 shrdram_da; + u32 bootaddr; + int id; + struct pruss *prusspriv; +}; + +/** + * pru_start() - start the pru processor + * @dev: corresponding k3 remote processor device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pru_start(struct udevice *dev) +{ + struct pru_privdata *priv; + int val = 0; + + priv = dev_get_priv(dev); + + val = CTRL_CTRL_EN | ((priv->bootaddr >> 2) << 16); + writel(val, priv->pru_ctrl + PRU_CTRL_CTRL); + + return 0; +} + +/** + * pru_stop() - Stop pru processor + * @dev: corresponding k3 remote processor device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pru_stop(struct udevice *dev) +{ + struct pru_privdata *priv; + int val = 0; + + priv = dev_get_priv(dev); + + val = readl(priv->pru_ctrl + PRU_CTRL_CTRL); + val &= ~CTRL_CTRL_EN; + writel(val, priv->pru_ctrl + PRU_CTRL_CTRL); + + return 0; +} + +/** + * pru_init() - Initialize the remote processor + * @dev: rproc device pointer + * + * Return: 0 if all went ok, else return appropriate error + */ +static int pru_init(struct udevice *dev) +{ + return 0; +} + +/* + * Convert PRU device address (data spaces onl
[PATCH v2 00/10] net: ti: icssg: Add prueth support
The series adds support for icssg_prueth functionality on u-boot. This series is based on top of master branch. rproc init needs to be done from uboot command prompt. The pru/rtu firmware loading is done by prueth driver soon after config paramters are setup. Currently only slice0/1 of icssg2 instance on am6-evm is supported. i.e Both slices of icssg2 instance are supported. Prebuilt firmware can be obtained from AM65 procSDK [1] rootfs at /lib/firmware/ti-pruss/am65x*.elf [1] http://software-dl.ti.com/processor-sdk-linux/esd/AM65X/latest/index_FDS.html This tests tftp on prueth. Note: Uboot ethernet driver architecture supports once instance per probe. So only one of the ports are supported per instance. So DT of prueth node should have either ethernet-mii0 or ethernet-mii1. Changes in v2: It has been a while since v1 was posted. Here are the changes: * Removed the usage of misc_init_by_ofnode instead used uclass_get_device_by_ofnode. * Introduced started variable to keep track of the status of the prueth device. * Build Tested on Travis: https://travis-ci.org/Keerthyj/u-boot/builds/651449684 Keerthy (10): net: eth-uclass: eth_get_dev based on SEQ_ALIAS instead of probe order soc: ti: pruss: add a misc driver for PRUSS in TI SoCs remoteproc: pruss: add PRU remoteproc driver net: ti: icssg-prueth: Add ICSSG ethernet driver arm: dts: k3-am65-main: Add msmc_ram node arm: dts: k3-am654-base-board-u-boot: Add icssg specific msmc_ram carveout nodes arm: dts: k3-am65-main: Add scm_conf node arm: dts: k3-am65-main: Add pruss nodes for ICSSG2 arm64: dts: ti: am654-base-board: add ICSSG2 Ethernet support configs: am65x_evm_a53_defconfig: Enable CONFIG_TI_AM64_ICSSG_PRUETH arch/arm/dts/k3-am65-main.dtsi | 191 ++ arch/arm/dts/k3-am65.dtsi| 4 +- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 129 configs/am65x_evm_a53_defconfig | 3 + drivers/net/ti/Kconfig | 8 + drivers/net/ti/Makefile | 1 + drivers/net/ti/icssg-prueth.c| 652 +++ drivers/net/ti/icssg.h | 36 + drivers/net/ti/icssg_classifier.c| 396 +++ drivers/remoteproc/Kconfig | 11 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/pru_rproc.c | 405 drivers/soc/ti/Kconfig | 12 + drivers/soc/ti/Makefile | 1 + drivers/soc/ti/pruss.c | 152 + include/ti-pruss.h | 17 + net/eth-uclass.c | 12 +- 17 files changed, 2027 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ti/icssg-prueth.c create mode 100644 drivers/net/ti/icssg.h create mode 100644 drivers/net/ti/icssg_classifier.c create mode 100644 drivers/remoteproc/pru_rproc.c create mode 100644 drivers/soc/ti/pruss.c create mode 100644 include/ti-pruss.h -- 2.17.1
[PATCH v2 02/10] soc: ti: pruss: add a misc driver for PRUSS in TI SoCs
The Programmable Real-Time Unit - Industrial Communication Subsystem (PRU-ICSS) is present of various TI SoCs such as AM335x or AM437x or the AM654x family. Each SoC can have one or more PRUSS instances that may or may not be identical. The PRUSS consists of dual 32-bit RISC cores called the Programmable Real-Time Units (PRUs), some shared, data and instruction memories, some internal peripheral modules, and an interrupt controller. The programmable nature of the PRUs provide flexibility to implement custom peripheral interfaces, fast real-time responses, or specialized data handling. Add support for pruss driver. Currently am654x family is supported. Signed-off-by: Keerthy --- Changes in v2: * Fixed multiple comments from Andreas w.r.t header file define guards and Kconfig help typos. drivers/soc/ti/Kconfig | 12 drivers/soc/ti/Makefile | 1 + drivers/soc/ti/pruss.c | 152 include/ti-pruss.h | 17 + 4 files changed, 182 insertions(+) create mode 100644 drivers/soc/ti/pruss.c create mode 100644 include/ti-pruss.h diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig index e4f8834448..19bce14c05 100644 --- a/drivers/soc/ti/Kconfig +++ b/drivers/soc/ti/Kconfig @@ -23,4 +23,16 @@ config TI_KEYSTONE_SERDES SerDes driver for Keystone SoC used for ethernet support on TI K2 platforms. +config TI_PRUSS + bool "Support for TI's K3 based Pruss driver" + depends on DM + depends on ARCH_K3 + depends on OF_CONTROL + depends on SYSCON + help + Support for TI PRU-ICSSG subsystem. + + Currently supported on AM65xx SoCs. Say Y here to support the + Programmable Realtime Unit (PRU). + endif # SOC_TI diff --git a/drivers/soc/ti/Makefile b/drivers/soc/ti/Makefile index 4ec04ee125..34f80aad29 100644 --- a/drivers/soc/ti/Makefile +++ b/drivers/soc/ti/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_TI_K3_NAVSS_RINGACC) += k3-navss-ringacc.o obj-$(CONFIG_TI_KEYSTONE_SERDES) += keystone_serdes.o +obj-$(CONFIG_TI_PRUSS) += pruss.o diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c new file mode 100644 index 00..059ae11805 --- /dev/null +++ b/drivers/soc/ti/pruss.c @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PRU-ICSS platform driver for various TI SoCs + * + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + * Keerthy + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PRUSS_CFG_IEPCLK 0x30 +#define ICSSG_CFG_CORE_SYNC0x3c + +#define ICSSG_TASK_MGR_OFFSET 0x2a000 + +/* PRUSS_IEPCLK register bits */ +#define PRUSS_IEPCLK_IEP_OCP_CLK_ENBIT(0) + +/* ICSSG CORE_SYNC register bits */ +#define ICSSG_CORE_VBUSP_SYNC_EN BIT(0) + +/** + * enum pruss_mem - PRUSS memory range identifiers + */ +enum pruss_mem { + PRUSS_MEM_DRAM0 = 0, + PRUSS_MEM_DRAM1, + PRUSS_MEM_SHRD_RAM2, + PRUSS_MEM_MAX, +}; + +/* + * pruss_request_tm_region() - Request pruss for task manager region + * @dev: corresponding k3 device + * @loc: the task manager physical address + * + * Return: 0 if all goes good, else appropriate error message. + */ +int pruss_request_tm_region(struct udevice *dev, phys_addr_t *loc) +{ + struct pruss *priv; + + priv = dev_get_priv(dev); + if (!priv || !priv->pruss_dram0) + return -EINVAL; + + *loc = priv->pruss_dram0 + ICSSG_TASK_MGR_OFFSET; + + return 0; +} + +/* + * pruss_request_shrmem_region() - Request pruss for shared memory region + * @dev: corresponding k3 device + * @loc: the shared memory physical address + * + * Return: 0 if all goes good, else appropriate error message. + */ +int pruss_request_shrmem_region(struct udevice *dev, phys_addr_t *loc) +{ + struct pruss *priv; + + priv = dev_get_priv(dev); + if (!priv || !priv->pruss_shrdram2) + return -EINVAL; + + *loc = priv->pruss_shrdram2; + + return 0; +} + +/** + * pruss_probe() - Basic probe + * @dev: corresponding k3 device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pruss_probe(struct udevice *dev) +{ + struct pruss *priv; + int ret, idx; + ofnode sub_node, node, memories; + struct regmap *regmap_cfg; + struct udevice *syscon; + + priv = dev_get_priv(dev); + node = dev_ofnode(dev); + sub_node = ofnode_find_subnode(node, "cfg"); + memories = ofnode_find_subnode(node, "memories"); + + idx = ofnode_stringlist_search(memories, "reg-names", "dram0"); + priv->pruss_dram0 = ofnode_get_addr_size_index(memories, idx, + (u64 *)&priv->pruss_d
Re: [PATCH] misc: k3_avs: Fix possible NULL pointer deference
On 14/02/20 5:52 pm, Vignesh Raghavendra wrote: Its possible that k3_avs_priv is NULL because the driver may not have been probed yet. Therefore check if pointer is valid before dereferencing it. Reviewed-by: Keerthy Signed-off-by: Vignesh Raghavendra --- drivers/misc/k3_avs.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c index c19c3c0646b7..adaf75b7165d 100644 --- a/drivers/misc/k3_avs.c +++ b/drivers/misc/k3_avs.c @@ -190,6 +190,10 @@ int k3_avs_notify_freq(int dev_id, int clk_id, u32 freq) struct k3_avs_privdata *priv = k3_avs_priv; struct vd_data *vd; + /* Driver may not be probed yet */ + if (!priv) + return -EINVAL; + for (vd = priv->vd_config->vds; vd->id >= 0; vd++) { if (vd->dev_id != dev_id || vd->clk_id != clk_id) continue;
[PATCH v8 9/9] configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC
Remove saving ENV in eMMC in R5 as the power domains are not setup. Environment in eMMC cannot be read if we do not boot from eMMC. Signed-off-by: Keerthy --- configs/j721e_evm_r5_defconfig | 4 1 file changed, 4 deletions(-) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index b1fc919f6a..67fde3bc5d 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -7,7 +7,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x7 CONFIG_SOC_K3_J721E=y CONFIG_TARGET_J721E_R5_EVM=y CONFIG_ENV_SIZE=0x2 -CONFIG_ENV_OFFSET=0x68 CONFIG_DM_GPIO=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y @@ -52,9 +51,6 @@ CONFIG_CMD_FAT=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board" -CONFIG_ENV_IS_IN_MMC=y -CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_ENV_OFFSET_REDUND=0x70 CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM=y CONFIG_SPL_DM=y -- 2.17.1
[PATCH v8 7/9] include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0
Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 firmware loadaddr and name. Signed-off-by: Keerthy --- include/configs/j721e_evm.h | 4 1 file changed, 4 insertions(+) diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h index 4371c471e5..fc73a9c932 100644 --- a/include/configs/j721e_evm.h +++ b/include/configs/j721e_evm.h @@ -88,6 +88,10 @@ "mmcdev=1\0"\ "bootpart=1:2\0"\ "bootdir=/boot\0" \ + "addr_mainr5f0_0load=8800\0" \ + "name_mainr5f0_0fw=/lib/firmware/j7-main-r5f0_0-fw\0" \ + "addr_mcur5f0_0load=8900\0" \ + "name_mcur5f0_0fw=/lib/firmware/j7-mcu-r5f0_0-fw\0" \ "rd_spec=-\0" \ "init_mmc=run args_all args_mmc\0" \ "get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}\0" \ -- 2.17.1
[PATCH v8 6/9] arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL
Enable MAIN domain r5fss0 cluster and its core0 in R5 spl. Signed-off-by: Keerthy Reviewed-by: Tom Rini --- .../dts/k3-j721e-r5-common-proc-board-u-boot.dtsi| 12 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi index f98be993e8..526f42e3a9 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi @@ -13,3 +13,15 @@ compatible = "u-boot,fs-loader"; }; }; + +&main_r5fss0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core1 { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 1f14d71438..ba2a312602 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -13,6 +13,8 @@ aliases { remoteproc0 = &sysctrler; remoteproc1 = &a72_0; + remoteproc2 = &main_r5fss0_core0; + remoteproc3 = &main_r5fss0_core1; }; chosen { -- 2.17.1
[PATCH v8 4/9] armv7R: K3: Add support for jumping to firmware
MCU Domain rf50 is currently shutting down after loading the ATF. Load elf firmware and jump to firmware post loading ATF. ROM doesn't enable ATCM memory, so make sure that firmware that is being loaded doesn't use ATCM memory or override SPL. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- arch/arm/mach-k3/common.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index b840348c83..c6f1ca737e 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -132,8 +132,10 @@ __weak void start_non_linux_remote_cores(void) void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { + typedef void __noreturn (*image_entry_noargs_t)(void); struct ti_sci_handle *ti_sci = get_ti_sci_handle(); - int ret; + u32 loadaddr = 0; + int ret, size; /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); @@ -144,6 +146,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) init_env(); start_non_linux_remote_cores(); + size = load_firmware("name_mcur5f0_0fw", "addr_mcur5f0_0load", +&loadaddr); + /* * It is assumed that remoteproc device 1 is the corresponding @@ -159,13 +164,18 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) ret = rproc_start(1); if (ret) panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret); + if (!(size > 0 && valid_elf_image(loadaddr))) { + debug("Shutting down...\n"); + release_resources_for_core_shutdown(); + + while (1) + asm volatile("wfe"); + } - debug("Releasing resources...\n"); - release_resources_for_core_shutdown(); + image_entry_noargs_t image_entry = + (image_entry_noargs_t)load_elf_image_phdr(loadaddr); - debug("Finalizing core shutdown...\n"); - while (1) - asm volatile("wfe"); + image_entry(); } #endif -- 2.17.1
[PATCH v8 8/9] configs: j721e_evm_r5: Enable R5F remoteproc support
Enable R5F remoteproc support in R5 defconfig so that R5s can be started in SPL. While at it enable the SPL_FS_EXT4 config option to load the firmwares from file system. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- configs/j721e_evm_r5_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index 19fbd450c7..b1fc919f6a 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -26,6 +26,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_EARLY_BSS=y CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_DM_MAILBOX=y CONFIG_SPL_DM_RESET=y @@ -96,6 +97,7 @@ CONFIG_SPL_DM_REGULATOR=y CONFIG_DM_REGULATOR_TPS65941=y CONFIG_K3_SYSTEM_CONTROLLER=y CONFIG_REMOTEPROC_TI_K3_ARM64=y +CONFIG_REMOTEPROC_TI_K3_R5F=y CONFIG_DM_RESET=y CONFIG_RESET_TI_SCI=y CONFIG_DM_SERIAL=y -- 2.17.1
[PATCH v8 5/9] arm: dts: k3-j721e-r5-u-boot: Add fs_loader node
Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem. Signed-off-by: Keerthy Reviewed-by: Tom Rini --- .../dts/k3-j721e-r5-common-proc-board-u-boot.dtsi | 15 +++ 1 file changed, 15 insertions(+) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi new file mode 100644 index 00..f98be993e8 --- /dev/null +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + */ + +/ { + chosen { + firmware-loader = &fs_loader0; + }; + + fs_loader0: fs_loader@0 { + u-boot,dm-pre-reloc; + compatible = "u-boot,fs-loader"; + }; +}; -- 2.17.1
[PATCH v8 3/9] armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM
Enable execute permission for mcu_r5fss0_core0 BTCM so that we can jump to a firmware directly from SPL. Signed-off-by: Keerthy --- arch/arm/mach-k3/r5_mpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/r5_mpu.c b/arch/arm/mach-k3/r5_mpu.c index ee076ed877..3d2ff6775a 100644 --- a/arch/arm/mach-k3/r5_mpu.c +++ b/arch/arm/mach-k3/r5_mpu.c @@ -26,7 +26,9 @@ struct mpu_region_config k3_mpu_regions[16] = { /* U-Boot's code area marking it as WB and Write allocate */ {CONFIG_SYS_SDRAM_BASE, REGION_2, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, REGION_2GB}, - {0x0, 3, 0x0, 0x0, 0x0, 0x0}, + /* mcu_r5fss0_core0 BTCM area marking it as WB and Write allocate. */ + {0x4101, 3, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, +REGION_8MB}, {0x0, 4, 0x0, 0x0, 0x0, 0x0}, {0x0, 5, 0x0, 0x0, 0x0, 0x0}, {0x0, 6, 0x0, 0x0, 0x0, 0x0}, -- 2.17.1
[PATCH v8 0/9] Add support for loading main_r5fss0_core0
This patch series enables mcu_r5fss0_core0 & main_r5fss0_core0. Tested for firmware loading and execution on J721e. Changes in v8: * Dropped patch to set_env_default in the env/nowhere driver. That was causing memory over run issues on sandbox defconfig with simple_alloc. Instead used env_relocate in place of env_load which does default environment set up to do env_set calls. * Fixed IMX build warning. All the travis tests passed: https://travis-ci.org/Keerthyj/u-boot/builds/649274826 Changes in v7: * Added BSD-2 SPDX on lib/elf.c file. * Added Tom's Reviewed-by for the relevant patches. Changes in v6: * Fixed the imx build issue. Changes in v5: * Moved the fs_loader node under r5-common-proc-board-u-boot.dtsi * Added more information on the envnowhere patch. * Added help LIB_ELF option and removed user configurable description. Changes in v4: * Changed env variable names, config names and enhanced commit logs. Changes in v3: * Removed saving env in MMC and fixed env saving in SPL when nowhere option is set. Changes in v2: * Factored out all the generic elf handling functions under lib/elf.c Keerthy (9): lib: elf: Move the generic elf loading/validating functions to lib arm: k3: Add support for loading non linux remote cores armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM armv7R: K3: Add support for jumping to firmware arm: dts: k3-j721e-r5-u-boot: Add fs_loader node arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 configs: j721e_evm_r5: Enable R5F remoteproc support configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC .../k3-j721e-r5-common-proc-board-u-boot.dtsi | 27 ++ .../arm/dts/k3-j721e-r5-common-proc-board.dts | 2 + arch/arm/mach-imx/imx_bootaux.c | 64 - arch/arm/mach-k3/common.c | 106 +++- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 +++ arch/arm/mach-k3/r5_mpu.c | 4 +- cmd/Kconfig | 1 + cmd/elf.c | 229 configs/j721e_evm_r5_defconfig| 6 +- include/configs/j721e_evm.h | 4 + include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile | 1 + lib/elf.c | 246 ++ 15 files changed, 427 insertions(+), 309 deletions(-) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi create mode 100644 lib/elf.c -- 2.17.1
[PATCH v8 1/9] lib: elf: Move the generic elf loading/validating functions to lib
Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. While at it remove the duplicate static version of load_elf_image_phdr under arch/arm/mach-imx/imx_bootaux.c. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt --- Peng, Let me know if the mach-imx changes are okay. Thanks, Keerthy arch/arm/mach-imx/imx_bootaux.c | 64 - cmd/Kconfig | 1 + cmd/elf.c | 229 - include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile| 1 + lib/elf.c | 246 7 files changed, 258 insertions(+), 293 deletions(-) create mode 100644 lib/elf.c diff --git a/arch/arm/mach-imx/imx_bootaux.c b/arch/arm/mach-imx/imx_bootaux.c index 21e96f8c88..ec0da1164f 100644 --- a/arch/arm/mach-imx/imx_bootaux.c +++ b/arch/arm/mach-imx/imx_bootaux.c @@ -12,70 +12,6 @@ #include #include -#ifndef CONFIG_IMX8M -const __weak struct rproc_att hostmap[] = { }; - -static const struct rproc_att *get_host_mapping(unsigned long auxcore) -{ - const struct rproc_att *mmap = hostmap; - - while (mmap && mmap->size) { - if (mmap->da <= auxcore && - mmap->da + mmap->size > auxcore) - return mmap; - mmap++; - } - - return NULL; -} - -/* - * A very simple elf loader, assumes the image is valid, returns the - * entry point address. - */ -static unsigned long load_elf_image_phdr(unsigned long addr) -{ - Elf32_Ehdr *ehdr; /* ELF header structure pointer */ - Elf32_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf32_Ehdr *)addr; - phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i, ++phdr) { - const struct rproc_att *mmap = get_host_mapping(phdr->p_paddr); - void *dst, *src; - - if (phdr->p_type != PT_LOAD) - continue; - - if (!mmap) { - printf("Invalid aux core address: %08x", - phdr->p_paddr); - return 0; - } - - dst = (void *)(phdr->p_paddr - mmap->da) + mmap->sa; - src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%i bytes)\n", - i, dst, phdr->p_filesz); - - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); - flush_cache((unsigned long)dst & - ~(CONFIG_SYS_CACHELINE_SIZE - 1), - ALIGN(phdr->p_filesz, CONFIG_SYS_CACHELINE_SIZE)); - } - - return ehdr->e_entry; -} -#endif - int arch_auxiliary_core_up(u32 core_id, ulong addr) { ulong stack, pc; diff --git a/cmd/Kconfig b/cmd/Kconfig index 6403bc45a5..faa133da65 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -399,6 +399,7 @@ config CMD_ABOOTIMG config CMD_ELF bool "bootelf, bootvx" default y + select LIB_ELF help Boot an ELF/vxWorks image from the memory. diff --git a/cmd/elf.c b/cmd/elf.c index 036be5f443..10e8264d3c 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -18,211 +18,6 @@ #include #endif -/* - * A very simple ELF64 loader, assumes the image is valid, returns the - * entry point address. - * - * Note if U-Boot is 32-bit, the loader assumes the to segment's - * physical address and size is within the lower 32-bit address space. - */ -static unsigned long load_elf64_image_phdr(unsigned long addr) -{ - Elf64_Ehdr *ehdr; /* Elf header structure pointer */ - Elf64_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf64_Ehdr *)addr; - phdr = (Elf64_Phdr *)(addr + (ulong)ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i) { - void *dst = (void *)(ulong)phdr->p_paddr; - void *src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%lu bytes)\n", - i, dst, (ulong)phdr->p_filesz); - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p
[PATCH v8 2/9] arm: k3: Add support for loading non linux remote cores
Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- Changes in v8: * Dropped patch to set_env_default in the env/nowhere driver. Instead used env_relocate in place of env_load which does sets up the default env. arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 2f82edb970..b840348c83 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -58,6 +62,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_relocate(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); + return 0; + } +#endif + if (!*loadaddr) + return 0; + + if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) { + size = request_firmware_into_buf(fsdev, name, (void *)*loadaddr, +0, 0); + } + + return size; +} +#else +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + return 0; +} +#endif + +__weak void start_non_linux_remote_cores(void) +{ +} + void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -66,15 +138,17 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); + ret = rproc_init(); + if (ret) + panic("rproc failed to be initialized (%d)\n", ret); + + init_env(); + start_non_linux_remote_cores(); + /* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same. */ - ret = rproc_dev_init(1); - if (ret) - panic("%s: ATF failed to initialize on rproc (%d)\n", __func__, - ret); - ret = rproc_load(1, spl_image->entry_point, 0x200); if (ret) panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret); diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index d8b34fe060..42fb8ee6e7 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -24,3 +24,5 @@ void setup_k3_mpu_regions(void); int early_console_init(void); void disable_linefill_optimization(void); void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size); +void start_non_linux_remote_cores(void); +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr); diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c index f7f7398081..13f3791823 100644 --- a/arch/arm/mach-k3/j721e_init.c +++ b/arch/arm/mach-k3/j721e_init.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CO
Re: [PATCH v7 00/10] Add support for loading main_r5fss0_core0
On 2/5/2020 2:45 PM, Lokesh Vutla wrote: On 04/02/20 12:06 PM, Keerthy wrote: This patch series enables mcu_r5fss0_core0 & main_r5fss0_core0. Tested for firmware loading and execution on J721e. I still see build error with multiple imx boards: === arm: + mx7dsabresd_qspi +arch/arm/mach-imx/imx_bootaux.c:18:32: error: 'get_host_mapping' defined but not used [-Werror=unused-function] + static const struct rproc_att *get_host_mapping(unsigned long auxcore) +^~~~ +cc1: all warnings being treated as errors +make[2]: *** [arch/arm/mach-imx/imx_bootaux.o] Error 1 +make[1]: *** [arch/arm/mach-imx] Error 2 +make: *** [sub-make] Error 2 Phew... Local builds did not catch for me. I will make sure i run the travis builds before i submit v8. Thanks and regards, Lokesh Changes in v7: * Added BSD-2 SPDX on lib/elf.c file. * Added Tom's Reviewed-by for the relevant patches. Changes in v6: * Fixed the imx build issue. Changes in v5: * Moved the fs_loader node under r5-common-proc-board-u-boot.dtsi * Added more information on the envnowhere patch. * Added help LIB_ELF option and removed user configurable description. Changes in v4: * Changed env variable names, config names and enhanced commit logs. Changes in v3: * Removed saving env in MMC and fixed env saving in SPL when nowhere option is set. Changes in v2: * Factored out all the generic elf handling functions under lib/elf.c Keerthy (10): env: nowhere: set default enviroment lib: elf: Move the generic elf loading/validating functions to lib arm: k3: Add support for loading non linux remote cores armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM armv7R: K3: Add support for jumping to firmware arm: dts: k3-j721e-r5-u-boot: Add fs_loader node arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 configs: j721e_evm_r5: Enable R5F remoteproc support configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC .../k3-j721e-r5-common-proc-board-u-boot.dtsi | 27 ++ .../arm/dts/k3-j721e-r5-common-proc-board.dts | 2 + arch/arm/mach-imx/imx_bootaux.c | 46 arch/arm/mach-k3/common.c | 106 +++- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 +++ arch/arm/mach-k3/r5_mpu.c | 4 +- cmd/Kconfig | 1 + cmd/elf.c | 229 configs/j721e_evm_r5_defconfig| 6 +- env/nowhere.c | 1 + include/configs/j721e_evm.h | 4 + include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile | 1 + lib/elf.c | 246 ++ 16 files changed, 428 insertions(+), 291 deletions(-) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi create mode 100644 lib/elf.c
[PATCH v7 08/10] include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0
Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 firmware loadaddr and name. Signed-off-by: Keerthy --- include/configs/j721e_evm.h | 4 1 file changed, 4 insertions(+) diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h index 4371c471e5..fc73a9c932 100644 --- a/include/configs/j721e_evm.h +++ b/include/configs/j721e_evm.h @@ -88,6 +88,10 @@ "mmcdev=1\0"\ "bootpart=1:2\0"\ "bootdir=/boot\0" \ + "addr_mainr5f0_0load=8800\0" \ + "name_mainr5f0_0fw=/lib/firmware/j7-main-r5f0_0-fw\0" \ + "addr_mcur5f0_0load=8900\0" \ + "name_mcur5f0_0fw=/lib/firmware/j7-mcu-r5f0_0-fw\0" \ "rd_spec=-\0" \ "init_mmc=run args_all args_mmc\0" \ "get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}\0" \ -- 2.17.1
[PATCH v7 10/10] configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC
Remove saving ENV in eMMC in R5 as the power domains are not setup. Environment in eMMC cannot be read if we do not boot from eMMC. Signed-off-by: Keerthy --- configs/j721e_evm_r5_defconfig | 4 1 file changed, 4 deletions(-) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index b1fc919f6a..67fde3bc5d 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -7,7 +7,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x7 CONFIG_SOC_K3_J721E=y CONFIG_TARGET_J721E_R5_EVM=y CONFIG_ENV_SIZE=0x2 -CONFIG_ENV_OFFSET=0x68 CONFIG_DM_GPIO=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y @@ -52,9 +51,6 @@ CONFIG_CMD_FAT=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board" -CONFIG_ENV_IS_IN_MMC=y -CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_ENV_OFFSET_REDUND=0x70 CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM=y CONFIG_SPL_DM=y -- 2.17.1
[PATCH v7 09/10] configs: j721e_evm_r5: Enable R5F remoteproc support
Enable R5F remoteproc support in R5 defconfig so that R5s can be started in SPL. While at it enable the SPL_FS_EXT4 config option to load the firmwares from file system. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- configs/j721e_evm_r5_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index 19fbd450c7..b1fc919f6a 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -26,6 +26,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_EARLY_BSS=y CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_DM_MAILBOX=y CONFIG_SPL_DM_RESET=y @@ -96,6 +97,7 @@ CONFIG_SPL_DM_REGULATOR=y CONFIG_DM_REGULATOR_TPS65941=y CONFIG_K3_SYSTEM_CONTROLLER=y CONFIG_REMOTEPROC_TI_K3_ARM64=y +CONFIG_REMOTEPROC_TI_K3_R5F=y CONFIG_DM_RESET=y CONFIG_RESET_TI_SCI=y CONFIG_DM_SERIAL=y -- 2.17.1
[PATCH v7 05/10] armv7R: K3: Add support for jumping to firmware
MCU Domain rf50 is currently shutting down after loading the ATF. Load elf firmware and jump to firmware post loading ATF. ROM doesn't enable ATCM memory, so make sure that firmware that is being loaded doesn't use ATCM memory or override SPL. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- arch/arm/mach-k3/common.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index bddb62ea5e..5c5eedb6eb 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -132,8 +132,10 @@ __weak void start_non_linux_remote_cores(void) void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { + typedef void __noreturn (*image_entry_noargs_t)(void); struct ti_sci_handle *ti_sci = get_ti_sci_handle(); - int ret; + u32 loadaddr = 0; + int ret, size; /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); @@ -144,6 +146,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) init_env(); start_non_linux_remote_cores(); + size = load_firmware("name_mcur5f0_0fw", "addr_mcur5f0_0load", +&loadaddr); + /* * It is assumed that remoteproc device 1 is the corresponding @@ -159,13 +164,18 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) ret = rproc_start(1); if (ret) panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret); + if (!(size > 0 && valid_elf_image(loadaddr))) { + debug("Shutting down...\n"); + release_resources_for_core_shutdown(); + + while (1) + asm volatile("wfe"); + } - debug("Releasing resources...\n"); - release_resources_for_core_shutdown(); + image_entry_noargs_t image_entry = + (image_entry_noargs_t)load_elf_image_phdr(loadaddr); - debug("Finalizing core shutdown...\n"); - while (1) - asm volatile("wfe"); + image_entry(); } #endif -- 2.17.1
[PATCH v7 06/10] arm: dts: k3-j721e-r5-u-boot: Add fs_loader node
Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem. Signed-off-by: Keerthy Reviewed-by: Tom Rini --- .../dts/k3-j721e-r5-common-proc-board-u-boot.dtsi | 15 +++ 1 file changed, 15 insertions(+) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi new file mode 100644 index 00..f98be993e8 --- /dev/null +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + */ + +/ { + chosen { + firmware-loader = &fs_loader0; + }; + + fs_loader0: fs_loader@0 { + u-boot,dm-pre-reloc; + compatible = "u-boot,fs-loader"; + }; +}; -- 2.17.1
[PATCH v7 07/10] arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL
Enable MAIN domain r5fss0 cluster and its core0 in R5 spl. Signed-off-by: Keerthy Reviewed-by: Tom Rini --- .../dts/k3-j721e-r5-common-proc-board-u-boot.dtsi| 12 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi index f98be993e8..526f42e3a9 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi @@ -13,3 +13,15 @@ compatible = "u-boot,fs-loader"; }; }; + +&main_r5fss0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core1 { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 1f14d71438..ba2a312602 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -13,6 +13,8 @@ aliases { remoteproc0 = &sysctrler; remoteproc1 = &a72_0; + remoteproc2 = &main_r5fss0_core0; + remoteproc3 = &main_r5fss0_core1; }; chosen { -- 2.17.1
[PATCH v7 03/10] arm: k3: Add support for loading non linux remote cores
Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 2f82edb970..bddb62ea5e 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -58,6 +62,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); + return 0; + } +#endif + if (!*loadaddr) + return 0; + + if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) { + size = request_firmware_into_buf(fsdev, name, (void *)*loadaddr, +0, 0); + } + + return size; +} +#else +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + return 0; +} +#endif + +__weak void start_non_linux_remote_cores(void) +{ +} + void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -66,15 +138,17 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); + ret = rproc_init(); + if (ret) + panic("rproc failed to be initialized (%d)\n", ret); + + init_env(); + start_non_linux_remote_cores(); + /* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same. */ - ret = rproc_dev_init(1); - if (ret) - panic("%s: ATF failed to initialize on rproc (%d)\n", __func__, - ret); - ret = rproc_load(1, spl_image->entry_point, 0x200); if (ret) panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret); diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index d8b34fe060..42fb8ee6e7 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -24,3 +24,5 @@ void setup_k3_mpu_regions(void); int early_console_init(void); void disable_linefill_optimization(void); void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size); +void start_non_linux_remote_cores(void); +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr); diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c index f7f7398081..13f3791823 100644 --- a/arch/arm/mach-k3/j721e_init.c +++ b/arch/arm/mach-k3/j721e_init.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW @@ -295,3 +296,36 @@ void release_resources_for_core_shutdown(void) } } #endif + +#ifdef CONFIG_SYS_K3_SPL_ATF
[PATCH v7 01/10] env: nowhere: set default enviroment
In case only CONFIG_ENV_IS_NOWHERE without any of the memory based configs like CONFIG_ENV_IS_IN_MMC the env_set function fails as the gd->flags & GD_FLG_ENV_READY check fails. Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set. Signed-off-by: Keerthy Reviewed-by: Tom Rini --- env/nowhere.c | 1 + 1 file changed, 1 insertion(+) diff --git a/env/nowhere.c b/env/nowhere.c index f5b0a17652..70c3b3e011 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -23,6 +23,7 @@ static int env_nowhere_init(void) { gd->env_addr= (ulong)&default_environment[0]; gd->env_valid = ENV_INVALID; + env_set_default(NULL, 0); return 0; } -- 2.17.1
[PATCH v7 02/10] lib: elf: Move the generic elf loading/validating functions to lib
Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. While at it remove the duplicate static version of load_elf_image_phdr under arch/arm/mach-imx/imx_bootaux.c. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt --- arch/arm/mach-imx/imx_bootaux.c | 46 -- cmd/Kconfig | 1 + cmd/elf.c | 229 - include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile| 1 + lib/elf.c | 246 7 files changed, 258 insertions(+), 275 deletions(-) create mode 100644 lib/elf.c diff --git a/arch/arm/mach-imx/imx_bootaux.c b/arch/arm/mach-imx/imx_bootaux.c index 21e96f8c88..8092268a3b 100644 --- a/arch/arm/mach-imx/imx_bootaux.c +++ b/arch/arm/mach-imx/imx_bootaux.c @@ -28,52 +28,6 @@ static const struct rproc_att *get_host_mapping(unsigned long auxcore) return NULL; } - -/* - * A very simple elf loader, assumes the image is valid, returns the - * entry point address. - */ -static unsigned long load_elf_image_phdr(unsigned long addr) -{ - Elf32_Ehdr *ehdr; /* ELF header structure pointer */ - Elf32_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf32_Ehdr *)addr; - phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i, ++phdr) { - const struct rproc_att *mmap = get_host_mapping(phdr->p_paddr); - void *dst, *src; - - if (phdr->p_type != PT_LOAD) - continue; - - if (!mmap) { - printf("Invalid aux core address: %08x", - phdr->p_paddr); - return 0; - } - - dst = (void *)(phdr->p_paddr - mmap->da) + mmap->sa; - src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%i bytes)\n", - i, dst, phdr->p_filesz); - - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); - flush_cache((unsigned long)dst & - ~(CONFIG_SYS_CACHELINE_SIZE - 1), - ALIGN(phdr->p_filesz, CONFIG_SYS_CACHELINE_SIZE)); - } - - return ehdr->e_entry; -} #endif int arch_auxiliary_core_up(u32 core_id, ulong addr) diff --git a/cmd/Kconfig b/cmd/Kconfig index e6ba57035e..9819dd1aaf 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -399,6 +399,7 @@ config CMD_ABOOTIMG config CMD_ELF bool "bootelf, bootvx" default y + select LIB_ELF help Boot an ELF/vxWorks image from the memory. diff --git a/cmd/elf.c b/cmd/elf.c index ba06df06cf..c129077e20 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -27,211 +27,6 @@ #include #endif -/* - * A very simple ELF64 loader, assumes the image is valid, returns the - * entry point address. - * - * Note if U-Boot is 32-bit, the loader assumes the to segment's - * physical address and size is within the lower 32-bit address space. - */ -static unsigned long load_elf64_image_phdr(unsigned long addr) -{ - Elf64_Ehdr *ehdr; /* Elf header structure pointer */ - Elf64_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf64_Ehdr *)addr; - phdr = (Elf64_Phdr *)(addr + (ulong)ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i) { - void *dst = (void *)(ulong)phdr->p_paddr; - void *src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%lu bytes)\n", - i, dst, (ulong)phdr->p_filesz); - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); - flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN), - roundup(phdr->p_memsz, ARCH_DMA_MINALIGN)); - ++phdr; - } - - if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags & - EF_PPC64_ELFV1_ABI)) { - /* -* For the 64-bit PowerPC ELF V1 ABI, e_entry is a function -* descriptor point
[PATCH v7 04/10] armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM
Enable execute permission for mcu_r5fss0_core0 BTCM so that we can jump to a firmware directly from SPL. Signed-off-by: Keerthy --- arch/arm/mach-k3/r5_mpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/r5_mpu.c b/arch/arm/mach-k3/r5_mpu.c index ee076ed877..3d2ff6775a 100644 --- a/arch/arm/mach-k3/r5_mpu.c +++ b/arch/arm/mach-k3/r5_mpu.c @@ -26,7 +26,9 @@ struct mpu_region_config k3_mpu_regions[16] = { /* U-Boot's code area marking it as WB and Write allocate */ {CONFIG_SYS_SDRAM_BASE, REGION_2, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, REGION_2GB}, - {0x0, 3, 0x0, 0x0, 0x0, 0x0}, + /* mcu_r5fss0_core0 BTCM area marking it as WB and Write allocate. */ + {0x4101, 3, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, +REGION_8MB}, {0x0, 4, 0x0, 0x0, 0x0, 0x0}, {0x0, 5, 0x0, 0x0, 0x0, 0x0}, {0x0, 6, 0x0, 0x0, 0x0, 0x0}, -- 2.17.1
[PATCH v7 00/10] Add support for loading main_r5fss0_core0
This patch series enables mcu_r5fss0_core0 & main_r5fss0_core0. Tested for firmware loading and execution on J721e. Changes in v7: * Added BSD-2 SPDX on lib/elf.c file. * Added Tom's Reviewed-by for the relevant patches. Changes in v6: * Fixed the imx build issue. Changes in v5: * Moved the fs_loader node under r5-common-proc-board-u-boot.dtsi * Added more information on the envnowhere patch. * Added help LIB_ELF option and removed user configurable description. Changes in v4: * Changed env variable names, config names and enhanced commit logs. Changes in v3: * Removed saving env in MMC and fixed env saving in SPL when nowhere option is set. Changes in v2: * Factored out all the generic elf handling functions under lib/elf.c Keerthy (10): env: nowhere: set default enviroment lib: elf: Move the generic elf loading/validating functions to lib arm: k3: Add support for loading non linux remote cores armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM armv7R: K3: Add support for jumping to firmware arm: dts: k3-j721e-r5-u-boot: Add fs_loader node arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 configs: j721e_evm_r5: Enable R5F remoteproc support configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC .../k3-j721e-r5-common-proc-board-u-boot.dtsi | 27 ++ .../arm/dts/k3-j721e-r5-common-proc-board.dts | 2 + arch/arm/mach-imx/imx_bootaux.c | 46 arch/arm/mach-k3/common.c | 106 +++- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 +++ arch/arm/mach-k3/r5_mpu.c | 4 +- cmd/Kconfig | 1 + cmd/elf.c | 229 configs/j721e_evm_r5_defconfig| 6 +- env/nowhere.c | 1 + include/configs/j721e_evm.h | 4 + include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile | 1 + lib/elf.c | 246 ++ 16 files changed, 428 insertions(+), 291 deletions(-) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi create mode 100644 lib/elf.c -- 2.17.1
Re: [PATCH v5 02/10] lib: elf: Move the generic elf loading/validating functions to lib
On 29/01/20 9:27 pm, Tom Rini wrote: On Tue, Jan 28, 2020 at 04:21:07PM +0530, Keerthy wrote: Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt [snip] diff --git a/lib/elf.c b/lib/elf.c new file mode 100644 index 00..c2097305ec --- /dev/null +++ b/lib/elf.c @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2001 William L. Pitts + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ Ah, I see. cmd/elf.c is missing the SPDX tag, which this also needs. I looked and I don't think it's fair to ask you to put the SDPX tag on cmd/elf.c so I'm going to update it to BSD-2-Clause. You should depend on that patch and use the same tag here. Tom, I fixed that myself for lib/elf.c. Sending v7 with that fixed and with your Reviewed-by for the relevant patches. Let me know if that version looks good. Thanks, Keerthy
[PATCH v6 02/10] lib: elf: Move the generic elf loading/validating functions to lib
Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. While at it remove the duplicate static version of load_elf_image_phdr under arch/arm/mach-imx/imx_bootaux.c. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt --- Changes in v6: * Fixed a build issue due to duplicate static version of load_elf_image_phdr under arch/arm/mach-imx/imx_bootaux.c arch/arm/mach-imx/imx_bootaux.c | 46 -- cmd/Kconfig | 1 + cmd/elf.c | 229 include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile| 1 + lib/elf.c | 256 7 files changed, 268 insertions(+), 275 deletions(-) create mode 100644 lib/elf.c diff --git a/arch/arm/mach-imx/imx_bootaux.c b/arch/arm/mach-imx/imx_bootaux.c index 21e96f8c88..8092268a3b 100644 --- a/arch/arm/mach-imx/imx_bootaux.c +++ b/arch/arm/mach-imx/imx_bootaux.c @@ -28,52 +28,6 @@ static const struct rproc_att *get_host_mapping(unsigned long auxcore) return NULL; } - -/* - * A very simple elf loader, assumes the image is valid, returns the - * entry point address. - */ -static unsigned long load_elf_image_phdr(unsigned long addr) -{ - Elf32_Ehdr *ehdr; /* ELF header structure pointer */ - Elf32_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf32_Ehdr *)addr; - phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i, ++phdr) { - const struct rproc_att *mmap = get_host_mapping(phdr->p_paddr); - void *dst, *src; - - if (phdr->p_type != PT_LOAD) - continue; - - if (!mmap) { - printf("Invalid aux core address: %08x", - phdr->p_paddr); - return 0; - } - - dst = (void *)(phdr->p_paddr - mmap->da) + mmap->sa; - src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%i bytes)\n", - i, dst, phdr->p_filesz); - - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); - flush_cache((unsigned long)dst & - ~(CONFIG_SYS_CACHELINE_SIZE - 1), - ALIGN(phdr->p_filesz, CONFIG_SYS_CACHELINE_SIZE)); - } - - return ehdr->e_entry; -} #endif int arch_auxiliary_core_up(u32 core_id, ulong addr) diff --git a/cmd/Kconfig b/cmd/Kconfig index e6ba57035e..9819dd1aaf 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -399,6 +399,7 @@ config CMD_ABOOTIMG config CMD_ELF bool "bootelf, bootvx" default y + select LIB_ELF help Boot an ELF/vxWorks image from the memory. diff --git a/cmd/elf.c b/cmd/elf.c index ba06df06cf..c129077e20 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -27,211 +27,6 @@ #include #endif -/* - * A very simple ELF64 loader, assumes the image is valid, returns the - * entry point address. - * - * Note if U-Boot is 32-bit, the loader assumes the to segment's - * physical address and size is within the lower 32-bit address space. - */ -static unsigned long load_elf64_image_phdr(unsigned long addr) -{ - Elf64_Ehdr *ehdr; /* Elf header structure pointer */ - Elf64_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf64_Ehdr *)addr; - phdr = (Elf64_Phdr *)(addr + (ulong)ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i) { - void *dst = (void *)(ulong)phdr->p_paddr; - void *src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%lu bytes)\n", - i, dst, (ulong)phdr->p_filesz); - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); - flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN), - roundup(phdr->p_memsz, ARCH_DMA_MINALIGN)); - ++phdr; - } - - if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags & - EF_PPC64_ELFV1_ABI)) {
Re: [PATCH v5 00/10] Add support for loading main_r5fss0_core0
On 29/01/20 8:05 am, Lokesh Vutla wrote: On 28/01/20 4:21 PM, Keerthy wrote: This patch series enables mcu_r5fss0_core0 & main_r5fss0_core0. Tested for firmware loading and execution on J721e. Changes in v5: * Moved the fs_loader node under r5-common-proc-board-u-boot.dtsi * Added more information on the envnowhere patch. * Added help LIB_ELF option and removed user configurable description. There are many build errors with this series. https://travis-ci.org/lokeshvutla/u-boot/builds/642979303 Ah there is a static declaration of load_elf_image_phdr in arch/arm/mach-imx/imx_bootaux.c Should i send a fix patch alone on top? Thanks and regards, Lokesh Changes in v4: * Changed env variable names, config names and enhanced commit logs. Changes in v3: * Removed saving env in MMC and fixed env saving in SPL when nowhere option is set. Changes in v2: * Factored out all the generic elf handling functions under lib/elf.c Keerthy (10): env: nowhere: set default enviroment lib: elf: Move the generic elf loading/validating functions to lib arm: k3: Add support for loading non linux remote cores armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM armv7R: K3: Add support for jumping to firmware arm: dts: k3-j721e-r5-u-boot: Add fs_loader node arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 configs: j721e_evm_r5: Enable R5F remoteproc support configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC .../k3-j721e-r5-common-proc-board-u-boot.dtsi | 27 ++ .../arm/dts/k3-j721e-r5-common-proc-board.dts | 2 + arch/arm/mach-k3/common.c | 106 +++- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 +++ arch/arm/mach-k3/r5_mpu.c | 4 +- cmd/Kconfig | 1 + cmd/elf.c | 229 configs/j721e_evm_r5_defconfig| 6 +- env/nowhere.c | 1 + include/configs/j721e_evm.h | 4 + include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile | 1 + lib/elf.c | 256 ++ 15 files changed, 438 insertions(+), 245 deletions(-) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi create mode 100644 lib/elf.c
[PATCH v5 09/10] configs: j721e_evm_r5: Enable R5F remoteproc support
Enable R5F remoteproc support in R5 defconfig so that R5s can be started in SPL. While at it enable the SPL_FS_EXT4 config option to load the firmwares from file system. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- configs/j721e_evm_r5_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index d5e9fdd089..36fb71b84d 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -28,6 +28,7 @@ CONFIG_SPL_EARLY_BSS=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x400 CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_DM_MAILBOX=y CONFIG_SPL_DM_RESET=y @@ -99,6 +100,7 @@ CONFIG_SPL_DM_REGULATOR=y CONFIG_DM_REGULATOR_TPS65941=y CONFIG_K3_SYSTEM_CONTROLLER=y CONFIG_REMOTEPROC_TI_K3_ARM64=y +CONFIG_REMOTEPROC_TI_K3_R5F=y CONFIG_DM_RESET=y CONFIG_RESET_TI_SCI=y CONFIG_DM_SERIAL=y -- 2.17.1
[PATCH v5 08/10] include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0
Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 firmware loadaddr and name. Signed-off-by: Keerthy --- include/configs/j721e_evm.h | 4 1 file changed, 4 insertions(+) diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h index 4371c471e5..fc73a9c932 100644 --- a/include/configs/j721e_evm.h +++ b/include/configs/j721e_evm.h @@ -88,6 +88,10 @@ "mmcdev=1\0"\ "bootpart=1:2\0"\ "bootdir=/boot\0" \ + "addr_mainr5f0_0load=8800\0" \ + "name_mainr5f0_0fw=/lib/firmware/j7-main-r5f0_0-fw\0" \ + "addr_mcur5f0_0load=8900\0" \ + "name_mcur5f0_0fw=/lib/firmware/j7-mcu-r5f0_0-fw\0" \ "rd_spec=-\0" \ "init_mmc=run args_all args_mmc\0" \ "get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}\0" \ -- 2.17.1
[PATCH v5 05/10] armv7R: K3: Add support for jumping to firmware
MCU Domain rf50 is currently shutting down after loading the ATF. Load elf firmware and jump to firmware post loading ATF. ROM doesn't enable ATCM memory, so make sure that firmware that is being loaded doesn't use ATCM memory or override SPL. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- arch/arm/mach-k3/common.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index bddb62ea5e..5c5eedb6eb 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -132,8 +132,10 @@ __weak void start_non_linux_remote_cores(void) void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { + typedef void __noreturn (*image_entry_noargs_t)(void); struct ti_sci_handle *ti_sci = get_ti_sci_handle(); - int ret; + u32 loadaddr = 0; + int ret, size; /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); @@ -144,6 +146,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) init_env(); start_non_linux_remote_cores(); + size = load_firmware("name_mcur5f0_0fw", "addr_mcur5f0_0load", +&loadaddr); + /* * It is assumed that remoteproc device 1 is the corresponding @@ -159,13 +164,18 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) ret = rproc_start(1); if (ret) panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret); + if (!(size > 0 && valid_elf_image(loadaddr))) { + debug("Shutting down...\n"); + release_resources_for_core_shutdown(); + + while (1) + asm volatile("wfe"); + } - debug("Releasing resources...\n"); - release_resources_for_core_shutdown(); + image_entry_noargs_t image_entry = + (image_entry_noargs_t)load_elf_image_phdr(loadaddr); - debug("Finalizing core shutdown...\n"); - while (1) - asm volatile("wfe"); + image_entry(); } #endif -- 2.17.1
[PATCH v5 07/10] arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL
Enable MAIN domain r5fss0 cluster and its core0 in R5 spl. Signed-off-by: Keerthy --- .../dts/k3-j721e-r5-common-proc-board-u-boot.dtsi| 12 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi index f98be993e8..526f42e3a9 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi @@ -13,3 +13,15 @@ compatible = "u-boot,fs-loader"; }; }; + +&main_r5fss0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core1 { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 1f14d71438..ba2a312602 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -13,6 +13,8 @@ aliases { remoteproc0 = &sysctrler; remoteproc1 = &a72_0; + remoteproc2 = &main_r5fss0_core0; + remoteproc3 = &main_r5fss0_core1; }; chosen { -- 2.17.1
[PATCH v5 10/10] configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC
Remove saving ENV in eMMC in R5 as the power domains are not setup. Environment in eMMC cannot be read if we do not boot from eMMC. Signed-off-by: Keerthy --- configs/j721e_evm_r5_defconfig | 4 1 file changed, 4 deletions(-) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index 36fb71b84d..39e32caec2 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -7,7 +7,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x7 CONFIG_SOC_K3_J721E=y CONFIG_TARGET_J721E_R5_EVM=y CONFIG_ENV_SIZE=0x2 -CONFIG_ENV_OFFSET=0x68 CONFIG_DM_GPIO=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y @@ -54,9 +53,6 @@ CONFIG_CMD_FAT=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board" -CONFIG_ENV_IS_IN_MMC=y -CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_ENV_OFFSET_REDUND=0x70 CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM=y CONFIG_SPL_DM=y -- 2.17.1
[PATCH v5 06/10] arm: dts: k3-j721e-r5-u-boot: Add fs_loader node
Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem. Signed-off-by: Keerthy --- .../dts/k3-j721e-r5-common-proc-board-u-boot.dtsi | 15 +++ 1 file changed, 15 insertions(+) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi new file mode 100644 index 00..f98be993e8 --- /dev/null +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + */ + +/ { + chosen { + firmware-loader = &fs_loader0; + }; + + fs_loader0: fs_loader@0 { + u-boot,dm-pre-reloc; + compatible = "u-boot,fs-loader"; + }; +}; -- 2.17.1
[PATCH v5 04/10] armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM
Enable execute permission for mcu_r5fss0_core0 BTCM so that we can jump to a firmware directly from SPL. Signed-off-by: Keerthy --- arch/arm/mach-k3/r5_mpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/r5_mpu.c b/arch/arm/mach-k3/r5_mpu.c index ee076ed877..3d2ff6775a 100644 --- a/arch/arm/mach-k3/r5_mpu.c +++ b/arch/arm/mach-k3/r5_mpu.c @@ -26,7 +26,9 @@ struct mpu_region_config k3_mpu_regions[16] = { /* U-Boot's code area marking it as WB and Write allocate */ {CONFIG_SYS_SDRAM_BASE, REGION_2, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, REGION_2GB}, - {0x0, 3, 0x0, 0x0, 0x0, 0x0}, + /* mcu_r5fss0_core0 BTCM area marking it as WB and Write allocate. */ + {0x4101, 3, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, +REGION_8MB}, {0x0, 4, 0x0, 0x0, 0x0, 0x0}, {0x0, 5, 0x0, 0x0, 0x0, 0x0}, {0x0, 6, 0x0, 0x0, 0x0, 0x0}, -- 2.17.1
[PATCH v5 02/10] lib: elf: Move the generic elf loading/validating functions to lib
Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt --- cmd/Kconfig | 1 + cmd/elf.c | 229 include/elf.h | 4 + lib/Kconfig | 6 ++ lib/Makefile | 1 + lib/elf.c | 256 ++ 6 files changed, 268 insertions(+), 229 deletions(-) create mode 100644 lib/elf.c diff --git a/cmd/Kconfig b/cmd/Kconfig index e6ba57035e..9819dd1aaf 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -399,6 +399,7 @@ config CMD_ABOOTIMG config CMD_ELF bool "bootelf, bootvx" default y + select LIB_ELF help Boot an ELF/vxWorks image from the memory. diff --git a/cmd/elf.c b/cmd/elf.c index ba06df06cf..c129077e20 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -27,211 +27,6 @@ #include #endif -/* - * A very simple ELF64 loader, assumes the image is valid, returns the - * entry point address. - * - * Note if U-Boot is 32-bit, the loader assumes the to segment's - * physical address and size is within the lower 32-bit address space. - */ -static unsigned long load_elf64_image_phdr(unsigned long addr) -{ - Elf64_Ehdr *ehdr; /* Elf header structure pointer */ - Elf64_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf64_Ehdr *)addr; - phdr = (Elf64_Phdr *)(addr + (ulong)ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i) { - void *dst = (void *)(ulong)phdr->p_paddr; - void *src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%lu bytes)\n", - i, dst, (ulong)phdr->p_filesz); - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); - flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN), - roundup(phdr->p_memsz, ARCH_DMA_MINALIGN)); - ++phdr; - } - - if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags & - EF_PPC64_ELFV1_ABI)) { - /* -* For the 64-bit PowerPC ELF V1 ABI, e_entry is a function -* descriptor pointer with the first double word being the -* address of the entry point of the function. -*/ - uintptr_t addr = ehdr->e_entry; - - return *(Elf64_Addr *)addr; - } - - return ehdr->e_entry; -} - -static unsigned long load_elf64_image_shdr(unsigned long addr) -{ - Elf64_Ehdr *ehdr; /* Elf header structure pointer */ - Elf64_Shdr *shdr; /* Section header structure pointer */ - unsigned char *strtab = 0; /* String table pointer */ - unsigned char *image; /* Binary image pointer */ - int i; /* Loop counter */ - - ehdr = (Elf64_Ehdr *)addr; - - /* Find the section header string table for output info */ - shdr = (Elf64_Shdr *)(addr + (ulong)ehdr->e_shoff + -(ehdr->e_shstrndx * sizeof(Elf64_Shdr))); - - if (shdr->sh_type == SHT_STRTAB) - strtab = (unsigned char *)(addr + (ulong)shdr->sh_offset); - - /* Load each appropriate section */ - for (i = 0; i < ehdr->e_shnum; ++i) { - shdr = (Elf64_Shdr *)(addr + (ulong)ehdr->e_shoff + -(i * sizeof(Elf64_Shdr))); - - if (!(shdr->sh_flags & SHF_ALLOC) || - shdr->sh_addr == 0 || shdr->sh_size == 0) { - continue; - } - - if (strtab) { - debug("%sing %s @ 0x%08lx (%ld bytes)\n", - (shdr->sh_type == SHT_NOBITS) ? "Clear" : "Load", - &strtab[shdr->sh_name], - (unsigned long)shdr->sh_addr, - (long)shdr->sh_size); - } - - if (shdr->sh_type == SHT_NOBITS) { - memset((void *)(uintptr_t)shdr->sh_addr, 0, - shdr->sh_size); - } else { - image = (unsigned char *)addr + (ulong)shdr->sh_offset; - memcpy((void *)(uintptr_t)shdr->sh_addr, - (const void *)image, shdr->sh_size); - } - flush_cache(rounddown(shdr->sh_addr, ARCH_DMA_MINAL
[PATCH v5 03/10] arm: k3: Add support for loading non linux remote cores
Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 2f82edb970..bddb62ea5e 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -58,6 +62,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); + return 0; + } +#endif + if (!*loadaddr) + return 0; + + if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) { + size = request_firmware_into_buf(fsdev, name, (void *)*loadaddr, +0, 0); + } + + return size; +} +#else +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + return 0; +} +#endif + +__weak void start_non_linux_remote_cores(void) +{ +} + void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -66,15 +138,17 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); + ret = rproc_init(); + if (ret) + panic("rproc failed to be initialized (%d)\n", ret); + + init_env(); + start_non_linux_remote_cores(); + /* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same. */ - ret = rproc_dev_init(1); - if (ret) - panic("%s: ATF failed to initialize on rproc (%d)\n", __func__, - ret); - ret = rproc_load(1, spl_image->entry_point, 0x200); if (ret) panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret); diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index d8b34fe060..42fb8ee6e7 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -24,3 +24,5 @@ void setup_k3_mpu_regions(void); int early_console_init(void); void disable_linefill_optimization(void); void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size); +void start_non_linux_remote_cores(void); +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr); diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c index 0994522f6c..d80813e8bb 100644 --- a/arch/arm/mach-k3/j721e_init.c +++ b/arch/arm/mach-k3/j721e_init.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW @@ -326,3 +327,36 @@ void release_resources_for_core_shutdown(void) } } #endif + +#ifdef CONFIG_SYS_K3_SPL_ATF
[PATCH v5 01/10] env: nowhere: set default enviroment
In case only CONFIG_ENV_IS_NOWHERE without any of the memory based configs like CONFIG_ENV_IS_IN_MMC the env_set function fails as the gd->flags & GD_FLG_ENV_READY check fails. Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set. Signed-off-by: Keerthy --- env/nowhere.c | 1 + 1 file changed, 1 insertion(+) diff --git a/env/nowhere.c b/env/nowhere.c index f5b0a17652..70c3b3e011 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -23,6 +23,7 @@ static int env_nowhere_init(void) { gd->env_addr= (ulong)&default_environment[0]; gd->env_valid = ENV_INVALID; + env_set_default(NULL, 0); return 0; } -- 2.17.1
[PATCH v5 00/10] Add support for loading main_r5fss0_core0
This patch series enables mcu_r5fss0_core0 & main_r5fss0_core0. Tested for firmware loading and execution on J721e. Changes in v5: * Moved the fs_loader node under r5-common-proc-board-u-boot.dtsi * Added more information on the envnowhere patch. * Added help LIB_ELF option and removed user configurable description. Changes in v4: * Changed env variable names, config names and enhanced commit logs. Changes in v3: * Removed saving env in MMC and fixed env saving in SPL when nowhere option is set. Changes in v2: * Factored out all the generic elf handling functions under lib/elf.c Keerthy (10): env: nowhere: set default enviroment lib: elf: Move the generic elf loading/validating functions to lib arm: k3: Add support for loading non linux remote cores armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM armv7R: K3: Add support for jumping to firmware arm: dts: k3-j721e-r5-u-boot: Add fs_loader node arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 configs: j721e_evm_r5: Enable R5F remoteproc support configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC .../k3-j721e-r5-common-proc-board-u-boot.dtsi | 27 ++ .../arm/dts/k3-j721e-r5-common-proc-board.dts | 2 + arch/arm/mach-k3/common.c | 106 +++- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 +++ arch/arm/mach-k3/r5_mpu.c | 4 +- cmd/Kconfig | 1 + cmd/elf.c | 229 configs/j721e_evm_r5_defconfig| 6 +- env/nowhere.c | 1 + include/configs/j721e_evm.h | 4 + include/elf.h | 4 + lib/Kconfig | 6 + lib/Makefile | 1 + lib/elf.c | 256 ++ 15 files changed, 438 insertions(+), 245 deletions(-) create mode 100644 arch/arm/dts/k3-j721e-r5-common-proc-board-u-boot.dtsi create mode 100644 lib/elf.c -- 2.17.1
Re: [PATCH v4 06/10] arm: dts: k3-j721e-r5: Add fs_loader node
On 27/01/20 7:44 pm, Tom Rini wrote: On Mon, Jan 27, 2020 at 10:07:31AM +0530, Keerthy wrote: On 24/01/20 8:25 pm, Tom Rini wrote: On Wed, Jan 22, 2020 at 09:30:01AM +0530, Keerthy wrote: Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 28a355d49c..caeee8defe 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -18,6 +18,12 @@ chosen { stdout-path = "serial2:115200n8"; tick-timer = &timer1; + firmware-loader = &fs_loader0; + }; + + fs_loader0: fs_loader@0 { + u-boot,dm-pre-reloc; + compatible = "u-boot,fs-loader"; }; a72_0: a72@0 { All u-boot, properties need to be in a -u-boot.dtsi file so it's very clear what things we are adding and what files can be replaced directly from Linux. Please fixup anything else in this area that wasn't already doing this and then add what you need here, thanks! Tom, I believe we are safe here as the k3-j721e-r5-common-proc-board.dts entire file is u-boot specific. k3-j721e-r5-common-proc-board.dts is not present in Linux DT. Perhaps something is out of sync as we have both k3-j721e-common-proc-board.dts and k3-j721e-common-proc-board-u-boot.dtsi which leads me to believe that the former just hasn't made its way upstream yet. Thanks! Tom, k3-j721e-common-proc-board.dts is for A72 which is linux & that has corresponding k3-j721e-common-proc-board-u-boot.dtsi. Where as k3-j721e-r5-common-proc-board.dts is only for R5 SPL that is only for u-boot repo. Am i clear now. Regards, Keerthy
Re: [PATCH v4 02/10] lib: elf: Move the generic elf loading/validating functions to lib
On 27/01/20 7:46 pm, Tom Rini wrote: On Mon, Jan 27, 2020 at 10:46:19AM +0530, Keerthy wrote: On 27/01/20 10:01 am, Keerthy wrote: On 24/01/20 8:24 pm, Tom Rini wrote: On Wed, Jan 22, 2020 at 09:29:57AM +0530, Keerthy wrote: Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt [snip] diff --git a/lib/Kconfig b/lib/Kconfig index d040a87d26..5ca86cd7fb 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -601,4 +601,7 @@ config TEST_FDTDEC config LIB_DATE bool +config LIB_ELF + bool "enable basic elf loading/validating functions" + endmenu This shouldn't be a user-selectable symbol, it should be select'd as needed. So no bool text but a help text that mentions what it does provide is needed. Thanks! Tom, Just for my confirmation. Do you want the symbol type to be removed or just the bool text? I believe symbol type is must. I want it converted from a user visible symbol, which in Kconfig means: config VARIABLE TYPE "Some text the user sees" help Description and made a non-visible symbol which means: config VARIABLE TYPE help Description Thanks. Clear now :-) Thanks!
Re: [PATCH v4 01/10] env: nowhere: set default enviroment
On 27/01/20 7:42 pm, Tom Rini wrote: On Mon, Jan 27, 2020 at 02:34:17PM +0100, Wolfgang Denk wrote: Dear Keerthy, In message you wrote: Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set. Signed-off-by: Keerthy --- Changes in v4: * Reworded commit log env/nowhere.c | 1 + 1 file changed, 1 insertion(+) diff --git a/env/nowhere.c b/env/nowhere.c index f5b0a17652..70c3b3e011 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -23,6 +23,7 @@ static int env_nowhere_init(void) { gd->env_addr = (ulong)&default_environment[0]; gd->env_valid= ENV_INVALID; + (NULL, 0); ^^ You are inserting this line of "C code" only. I think something got ate along the way. The patch is at http://patchwork.ozlabs.org/patch/1226946/ and the full line is: + env_set_default(NULL, 0); Thanks Tom. Wolfgang, env_set_default(NULL, 0); sets the required flag for us in the nowhere path as well. That enabled set_env. Thanks, Keerthy
Re: [PATCH v4 02/10] lib: elf: Move the generic elf loading/validating functions to lib
On 27/01/20 10:01 am, Keerthy wrote: On 24/01/20 8:24 pm, Tom Rini wrote: On Wed, Jan 22, 2020 at 09:29:57AM +0530, Keerthy wrote: Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt [snip] diff --git a/lib/Kconfig b/lib/Kconfig index d040a87d26..5ca86cd7fb 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -601,4 +601,7 @@ config TEST_FDTDEC config LIB_DATE bool +config LIB_ELF + bool "enable basic elf loading/validating functions" + endmenu This shouldn't be a user-selectable symbol, it should be select'd as needed. So no bool text but a help text that mentions what it does provide is needed. Thanks! Tom, Just for my confirmation. Do you want the symbol type to be removed or just the bool text? I believe symbol type is must. - Keerthy Okay. I will change that.
Re: [PATCH v4 06/10] arm: dts: k3-j721e-r5: Add fs_loader node
On 24/01/20 8:25 pm, Tom Rini wrote: On Wed, Jan 22, 2020 at 09:30:01AM +0530, Keerthy wrote: Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 28a355d49c..caeee8defe 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -18,6 +18,12 @@ chosen { stdout-path = "serial2:115200n8"; tick-timer = &timer1; + firmware-loader = &fs_loader0; + }; + + fs_loader0: fs_loader@0 { + u-boot,dm-pre-reloc; + compatible = "u-boot,fs-loader"; }; a72_0: a72@0 { All u-boot, properties need to be in a -u-boot.dtsi file so it's very clear what things we are adding and what files can be replaced directly from Linux. Please fixup anything else in this area that wasn't already doing this and then add what you need here, thanks! Tom, I believe we are safe here as the k3-j721e-r5-common-proc-board.dts entire file is u-boot specific. k3-j721e-r5-common-proc-board.dts is not present in Linux DT. Thanks, Keerthy
Re: [PATCH v4 02/10] lib: elf: Move the generic elf loading/validating functions to lib
On 24/01/20 8:24 pm, Tom Rini wrote: On Wed, Jan 22, 2020 at 09:29:57AM +0530, Keerthy wrote: Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt [snip] diff --git a/lib/Kconfig b/lib/Kconfig index d040a87d26..5ca86cd7fb 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -601,4 +601,7 @@ config TEST_FDTDEC config LIB_DATE bool +config LIB_ELF + bool "enable basic elf loading/validating functions" + endmenu This shouldn't be a user-selectable symbol, it should be select'd as needed. So no bool text but a help text that mentions what it does provide is needed. Thanks! Okay. I will change that.
Re: [PATCH v4 01/10] env: nowhere: set default enviroment
On 24/01/20 8:22 pm, Tom Rini wrote: On Wed, Jan 22, 2020 at 09:29:56AM +0530, Keerthy wrote: Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set. Signed-off-by: Keerthy --- Changes in v4: * Reworded commit log env/nowhere.c | 1 + 1 file changed, 1 insertion(+) diff --git a/env/nowhere.c b/env/nowhere.c index f5b0a17652..70c3b3e011 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -23,6 +23,7 @@ static int env_nowhere_init(void) { gd->env_addr = (ulong)&default_environment[0]; gd->env_valid= ENV_INVALID; + (NULL, 0); return 0; } What exactly do you mean by this? Can you give an example or two (code and/or shell) where things didn't work before but do now? And please CC Joe/Wolfgang in the future on env patches, thanks. Tom, I have a case where only ENV_IS_NOWHERE is set in SPL without any of the memory based env configs like ENV_IS_IN_FAT or ENV_IS_IN_MMC. With that if i try to use env_set it does not work. env_set checks for (gd->flags & GD_FLG_ENV_READY) which never is true for the nowhere case and hence env_set returns 1. If any of the memory based ENV config is set i see that env_set_default is called hence env_set works nicely. So we need to have env_set_default in the case of nowhere configuration as well. Best Regards, Keerthy
Re: [PATCH v3 02/10] arm: k3: Add support for loading non linux remote cores
On 23/01/20 10:49 pm, Keerthy wrote: On 23/01/20 10:35 pm, Andrew F. Davis wrote: On 1/23/20 11:44 AM, Keerthy wrote: On 23/01/20 6:54 pm, Andrew F. Davis wrote: On 1/22/20 11:10 PM, Keerthy wrote: On 22/01/20 9:55 pm, Andrew F. Davis wrote: On 1/21/20 8:10 PM, keerthy wrote: On 1/21/2020 6:26 PM, Andrew F. Davis wrote: On 1/21/20 6:07 AM, Keerthy wrote: Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 8d1529062d..f0ac0c39f1 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -16,6 +16,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -57,6 +61,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); This will print for almost every boot mode.. I can keep this under debug. + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); This whole thing seems very MMC specific, if early firmware loading is important it should work for all boot modes. Find a way to include it in the next boot stage FIT image (tispl.bin) so it works for all modes. That was not NAKd. We are going with fs_loader approach. When, where, link? I had implemented that way internally. That was rejected for multiple right reasons: I must have missed the internal reviews for this, anyway this is posted upstream so lets discus it here. 1) SPL size would bloat based on the size of the firmware. SPL size would remain constant, the combined FIT (tispl.bin) would grow, but that is okay as DRAM is enabled at this point so we have no hard memory constraints. I meant the FIT image containing the SPL will bloat. Exactly what I said, and so size is not a huge deal. 2) There are multiple cores that need to be loaded and hence adding all the firmwares under a fit can be really painful. Bundling images is what FIT is for, are you saying the better solution is to hard-code each firmware starting like done here? How many firmwares will you go on bundling. Firmwares are already kept in file system. It is a matter of reading them from there. If we are early booting them from SPL then they don't really need to be on the filesystem. 3) Changing firmware means building the tispl.bin again. FIT images can be disassembled and reassembled with a script around tools/dumpimage. And you expect everyone to master that instead of looking at couple of aliases in DT to figure out which core corresponds to which ID? Your patches do more than add DT aliases to add a firmware image. I think you are responding to the wrong comment here, the ID part is below. SPL should be simple and load the one next stage. The FIT solution can not scale well. How does this current series scale at all? At least with FIT you can add more images without adding code for request_firmware() and rproc_load(). That all could be encoded in the FIT data. I understand and as explained earlier i have even implemented that once before. fs_loader was meant to address the
Re: [PATCH v3 02/10] arm: k3: Add support for loading non linux remote cores
On 23/01/20 10:35 pm, Andrew F. Davis wrote: On 1/23/20 11:44 AM, Keerthy wrote: On 23/01/20 6:54 pm, Andrew F. Davis wrote: On 1/22/20 11:10 PM, Keerthy wrote: On 22/01/20 9:55 pm, Andrew F. Davis wrote: On 1/21/20 8:10 PM, keerthy wrote: On 1/21/2020 6:26 PM, Andrew F. Davis wrote: On 1/21/20 6:07 AM, Keerthy wrote: Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 8d1529062d..f0ac0c39f1 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -16,6 +16,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -57,6 +61,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); This will print for almost every boot mode.. I can keep this under debug. + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); This whole thing seems very MMC specific, if early firmware loading is important it should work for all boot modes. Find a way to include it in the next boot stage FIT image (tispl.bin) so it works for all modes. That was not NAKd. We are going with fs_loader approach. When, where, link? I had implemented that way internally. That was rejected for multiple right reasons: I must have missed the internal reviews for this, anyway this is posted upstream so lets discus it here. 1) SPL size would bloat based on the size of the firmware. SPL size would remain constant, the combined FIT (tispl.bin) would grow, but that is okay as DRAM is enabled at this point so we have no hard memory constraints. I meant the FIT image containing the SPL will bloat. Exactly what I said, and so size is not a huge deal. 2) There are multiple cores that need to be loaded and hence adding all the firmwares under a fit can be really painful. Bundling images is what FIT is for, are you saying the better solution is to hard-code each firmware starting like done here? How many firmwares will you go on bundling. Firmwares are already kept in file system. It is a matter of reading them from there. If we are early booting them from SPL then they don't really need to be on the filesystem. 3) Changing firmware means building the tispl.bin again. FIT images can be disassembled and reassembled with a script around tools/dumpimage. And you expect everyone to master that instead of looking at couple of aliases in DT to figure out which core corresponds to which ID? Your patches do more than add DT aliases to add a firmware image. I think you are responding to the wrong comment here, the ID part is below. SPL should be simple and load the one next stage. The FIT solution can not scale well. How does this current series scale at all? At least with FIT you can add more images without adding code for request_firmware() and rproc_load(). That all could be encoded in the FIT data. I understand and as explained earlier i have even implemented that once before. fs_loader was meant to address the exact use case we are discussing about. Even in u
Re: [PATCH v3 02/10] arm: k3: Add support for loading non linux remote cores
On 23/01/20 6:54 pm, Andrew F. Davis wrote: On 1/22/20 11:10 PM, Keerthy wrote: On 22/01/20 9:55 pm, Andrew F. Davis wrote: On 1/21/20 8:10 PM, keerthy wrote: On 1/21/2020 6:26 PM, Andrew F. Davis wrote: On 1/21/20 6:07 AM, Keerthy wrote: Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 8d1529062d..f0ac0c39f1 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -16,6 +16,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -57,6 +61,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); This will print for almost every boot mode.. I can keep this under debug. + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); This whole thing seems very MMC specific, if early firmware loading is important it should work for all boot modes. Find a way to include it in the next boot stage FIT image (tispl.bin) so it works for all modes. That was not NAKd. We are going with fs_loader approach. When, where, link? I had implemented that way internally. That was rejected for multiple right reasons: I must have missed the internal reviews for this, anyway this is posted upstream so lets discus it here. 1) SPL size would bloat based on the size of the firmware. SPL size would remain constant, the combined FIT (tispl.bin) would grow, but that is okay as DRAM is enabled at this point so we have no hard memory constraints. I meant the FIT image containing the SPL will bloat. 2) There are multiple cores that need to be loaded and hence adding all the firmwares under a fit can be really painful. Bundling images is what FIT is for, are you saying the better solution is to hard-code each firmware starting like done here? How many firmwares will you go on bundling. Firmwares are already kept in file system. It is a matter of reading them from there. 3) Changing firmware means building the tispl.bin again. FIT images can be disassembled and reassembled with a script around tools/dumpimage. And you expect everyone to master that instead of looking at couple of aliases in DT to figure out which core corresponds to which ID? SPL should be simple and load the one next stage. The FIT solution can not scale well. How does this current series scale at all? At least with FIT you can add more images without adding code for request_firmware() and rproc_load(). That all could be encoded in the FIT data. I understand and as explained earlier i have even implemented that once before. fs_loader was meant to address the exact use case we are discussing about. Even in u-boot remotecores are started/loaded by indices. Users need to know them. This is no different than that. I am not convinced about FIT approach. I would let Lokesh take a call on this. Thanks, Keerthy Andrew - Keerthy + return 0; + } +#endif + if (!*loadaddr) + return 0; + + if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) { + size
Re: [PATCH v3 02/10] arm: k3: Add support for loading non linux remote cores
On 22/01/20 9:55 pm, Andrew F. Davis wrote: On 1/21/20 8:10 PM, keerthy wrote: On 1/21/2020 6:26 PM, Andrew F. Davis wrote: On 1/21/20 6:07 AM, Keerthy wrote: Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 8d1529062d..f0ac0c39f1 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -16,6 +16,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -57,6 +61,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); This will print for almost every boot mode.. I can keep this under debug. + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); This whole thing seems very MMC specific, if early firmware loading is important it should work for all boot modes. Find a way to include it in the next boot stage FIT image (tispl.bin) so it works for all modes. That was not NAKd. We are going with fs_loader approach. When, where, link? I had implemented that way internally. That was rejected for multiple right reasons: 1) SPL size would bloat based on the size of the firmware. 2) There are multiple cores that need to be loaded and hence adding all the firmwares under a fit can be really painful. 3) Changing firmware means building the tispl.bin again. The FIT solution can not scale well. - Keerthy + return 0; + } +#endif + if (!*loadaddr) + return 0; + + if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) { + size = request_firmware_into_buf(fsdev, name, (void *)*loadaddr, + 0, 0); + } + + return size; +} +#else +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + return 0; +} +#endif + +__weak void start_non_linux_remote_cores(void) +{ +} + void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -65,15 +137,17 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); + ret = rproc_init(); + if (ret) + panic("rproc failed to be initialized (%d)\n", ret); + + init_env(); + start_non_linux_remote_cores(); + /* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same. */ - ret = rproc_dev_init(1); - if (ret) - panic("%s: ATF failed to initialize on rproc (%d)\n", __func__, - ret); - Where did this code go? rproc_init takes care of that. Is that new behavior then? It should be it's own patch with a commit message about that. ret = rproc_load(1, spl_image->entry_point, 0x200); if (ret) panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret); diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index d8b34fe060
[PATCH v4 10/10] configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC
Remove saving ENV in eMMC in R5 as the power domains are not setup. Environment in eMMC cannot be read if we do not boot from eMMC. Signed-off-by: Keerthy --- configs/j721e_evm_r5_defconfig | 4 1 file changed, 4 deletions(-) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index 0925690e10..0f391ff98e 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -7,7 +7,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x55000 CONFIG_SOC_K3_J721E=y CONFIG_TARGET_J721E_R5_EVM=y CONFIG_ENV_SIZE=0x2 -CONFIG_ENV_OFFSET=0x68 CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y @@ -48,9 +47,6 @@ CONFIG_CMD_FAT=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board" -CONFIG_ENV_IS_IN_MMC=y -CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_ENV_OFFSET_REDUND=0x70 CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM=y CONFIG_SPL_DM=y -- 2.17.1
[PATCH v4 09/10] configs: j721e_evm_r5: Enable R5F remoteproc support
Enable R5F remoteproc support in R5 defconfig so that R5s can be started in SPL. While at it enable the SPL_FS_EXT4 config option to load the firmwares from file system. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- configs/j721e_evm_r5_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index cb6c74d7bf..0925690e10 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -25,6 +25,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_EARLY_BSS=y CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_DM_MAILBOX=y CONFIG_SPL_DM_RESET=y @@ -92,6 +93,7 @@ CONFIG_SPL_DM_REGULATOR=y CONFIG_DM_REGULATOR_TPS65941=y CONFIG_K3_SYSTEM_CONTROLLER=y CONFIG_REMOTEPROC_TI_K3_ARM64=y +CONFIG_REMOTEPROC_TI_K3_R5F=y CONFIG_DM_RESET=y CONFIG_RESET_TI_SCI=y CONFIG_DM_SERIAL=y -- 2.17.1
[PATCH v4 08/10] include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0
Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 firmware loadaddr and name. Signed-off-by: Keerthy --- Changes in v4: * Env variable names changed. include/configs/j721e_evm.h | 4 1 file changed, 4 insertions(+) diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h index eaed520e6b..da0ca2b74f 100644 --- a/include/configs/j721e_evm.h +++ b/include/configs/j721e_evm.h @@ -84,6 +84,10 @@ "mmcdev=1\0"\ "bootpart=1:2\0"\ "bootdir=/boot\0" \ + "addr_mainr5f0_0load=8800\0" \ + "name_mainr5f0_0fw=/lib/firmware/j7-main-r5f0_0-fw\0" \ + "addr_mcur5f0_0load=8900\0" \ + "name_mcur5f0_0fw=/lib/firmware/j7-mcu-r5f0_0-fw\0" \ "rd_spec=-\0" \ "init_mmc=run args_all args_mmc\0" \ "get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}\0" \ -- 2.17.1
[PATCH v4 05/10] armv7R: K3: Add support for jumping to firmware
MCU Domain rf50 is currently shutting down after loading the ATF. Load elf firmware and jump to firmware post loading ATF. ROM doesn't enable ATCM memory, so make sure that firmware that is being loaded doesn't use ATCM memory or override SPL. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- Changes in v4: * Env variable names changed. arch/arm/mach-k3/common.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index f0ac0c39f1..675a9dc4f7 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -131,8 +131,10 @@ __weak void start_non_linux_remote_cores(void) void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { + typedef void __noreturn (*image_entry_noargs_t)(void); struct ti_sci_handle *ti_sci = get_ti_sci_handle(); - int ret; + u32 loadaddr = 0; + int ret, size; /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); @@ -143,6 +145,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) init_env(); start_non_linux_remote_cores(); + size = load_firmware("name_mcur5f0_0fw", "addr_mcur5f0_0load", +&loadaddr); + /* * It is assumed that remoteproc device 1 is the corresponding @@ -158,13 +163,18 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) ret = rproc_start(1); if (ret) panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret); + if (!(size > 0 && valid_elf_image(loadaddr))) { + debug("Shutting down...\n"); + release_resources_for_core_shutdown(); + + while (1) + asm volatile("wfe"); + } - debug("Releasing resources...\n"); - release_resources_for_core_shutdown(); + image_entry_noargs_t image_entry = + (image_entry_noargs_t)load_elf_image_phdr(loadaddr); - debug("Finalizing core shutdown...\n"); - while (1) - asm volatile("wfe"); + image_entry(); } #endif -- 2.17.1
[PATCH v4 06/10] arm: dts: k3-j721e-r5: Add fs_loader node
Add fs_loader node which will be needed for loading firmwares from the boot media/filesystem. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 28a355d49c..caeee8defe 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -18,6 +18,12 @@ chosen { stdout-path = "serial2:115200n8"; tick-timer = &timer1; + firmware-loader = &fs_loader0; + }; + + fs_loader0: fs_loader@0 { + u-boot,dm-pre-reloc; + compatible = "u-boot,fs-loader"; }; a72_0: a72@0 { -- 2.17.1
[PATCH v4 07/10] arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL
Enable MAIN domain r5fss0 cluster and its core0 in R5 spl. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index caeee8defe..d9f33bf4a4 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -13,6 +13,8 @@ aliases { remoteproc0 = &sysctrler; remoteproc1 = &a72_0; + remoteproc2 = &main_r5fss0_core0; + remoteproc3 = &main_r5fss0_core1; }; chosen { @@ -213,4 +215,16 @@ u-boot,dm-spl; }; +&main_r5fss0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core0 { + u-boot,dm-spl; +}; + +&main_r5fss0_core1 { + u-boot,dm-spl; +}; + #include "k3-j721e-common-proc-board-u-boot.dtsi" -- 2.17.1
[PATCH v4 04/10] armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM
Enable execute permission for mcu_r5fss0_core0 BTCM so that we can jump to a firmware directly from SPL. Signed-off-by: Keerthy --- arch/arm/mach-k3/r5_mpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/r5_mpu.c b/arch/arm/mach-k3/r5_mpu.c index ee076ed877..3d2ff6775a 100644 --- a/arch/arm/mach-k3/r5_mpu.c +++ b/arch/arm/mach-k3/r5_mpu.c @@ -26,7 +26,9 @@ struct mpu_region_config k3_mpu_regions[16] = { /* U-Boot's code area marking it as WB and Write allocate */ {CONFIG_SYS_SDRAM_BASE, REGION_2, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, REGION_2GB}, - {0x0, 3, 0x0, 0x0, 0x0, 0x0}, + /* mcu_r5fss0_core0 BTCM area marking it as WB and Write allocate. */ + {0x4101, 3, XN_DIS, PRIV_RW_USR_RW, O_I_WB_RD_WR_ALLOC, +REGION_8MB}, {0x0, 4, 0x0, 0x0, 0x0, 0x0}, {0x0, 5, 0x0, 0x0, 0x0, 0x0}, {0x0, 6, 0x0, 0x0, 0x0, 0x0}, -- 2.17.1
[PATCH v4 03/10] arm: k3: Add support for loading non linux remote cores
Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- Changes in v4: * Env variable names changed. arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 8d1529062d..f0ac0c39f1 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -16,6 +16,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -57,6 +61,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); + return 0; + } +#endif + if (!*loadaddr) + return 0; + + if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) { + size = request_firmware_into_buf(fsdev, name, (void *)*loadaddr, +0, 0); + } + + return size; +} +#else +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + return 0; +} +#endif + +__weak void start_non_linux_remote_cores(void) +{ +} + void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -65,15 +137,17 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); + ret = rproc_init(); + if (ret) + panic("rproc failed to be initialized (%d)\n", ret); + + init_env(); + start_non_linux_remote_cores(); + /* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same. */ - ret = rproc_dev_init(1); - if (ret) - panic("%s: ATF failed to initialize on rproc (%d)\n", __func__, - ret); - ret = rproc_load(1, spl_image->entry_point, 0x200); if (ret) panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret); diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index d8b34fe060..42fb8ee6e7 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -24,3 +24,5 @@ void setup_k3_mpu_regions(void); int early_console_init(void); void disable_linefill_optimization(void); void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size); +void start_non_linux_remote_cores(void); +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr); diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c index f7f7398081..13f3791823 100644 --- a/arch/arm/mach-k3/j721e_init.c +++ b/arch/arm/mach-k3/j721e_init.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW @@ -295,3 +296,36 @@ void release_resources_for_core_shutdown(void) } } #endif + +#ifde
[PATCH v4 01/10] env: nowhere: set default enviroment
Set default enviroment so that set_env calls succeed when only ENV_IS_NOWHERE set. Signed-off-by: Keerthy --- Changes in v4: * Reworded commit log env/nowhere.c | 1 + 1 file changed, 1 insertion(+) diff --git a/env/nowhere.c b/env/nowhere.c index f5b0a17652..70c3b3e011 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -23,6 +23,7 @@ static int env_nowhere_init(void) { gd->env_addr= (ulong)&default_environment[0]; gd->env_valid = ENV_INVALID; + env_set_default(NULL, 0); return 0; } -- 2.17.1
[PATCH v4 02/10] lib: elf: Move the generic elf loading/validating functions to lib
Move the generic elf loading/validating functions to lib/ so that they can be re-used and accessed by code existing outside cmd. Signed-off-by: Keerthy Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt --- Changes in v4: * /s/ELF/LIB_ELF config option name cmd/Kconfig | 1 + cmd/elf.c | 229 include/elf.h | 4 + lib/Kconfig | 3 + lib/Makefile | 1 + lib/elf.c | 256 ++ 6 files changed, 265 insertions(+), 229 deletions(-) create mode 100644 lib/elf.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 298feae24d..ac0a985596 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -375,6 +375,7 @@ config CMD_ADTIMG config CMD_ELF bool "bootelf, bootvx" default y + select LIB_ELF help Boot an ELF/vxWorks image from the memory. diff --git a/cmd/elf.c b/cmd/elf.c index 32f12a72b9..23cc17aebc 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -26,211 +26,6 @@ #include #endif -/* - * A very simple ELF64 loader, assumes the image is valid, returns the - * entry point address. - * - * Note if U-Boot is 32-bit, the loader assumes the to segment's - * physical address and size is within the lower 32-bit address space. - */ -static unsigned long load_elf64_image_phdr(unsigned long addr) -{ - Elf64_Ehdr *ehdr; /* Elf header structure pointer */ - Elf64_Phdr *phdr; /* Program header structure pointer */ - int i; - - ehdr = (Elf64_Ehdr *)addr; - phdr = (Elf64_Phdr *)(addr + (ulong)ehdr->e_phoff); - - /* Load each program header */ - for (i = 0; i < ehdr->e_phnum; ++i) { - void *dst = (void *)(ulong)phdr->p_paddr; - void *src = (void *)addr + phdr->p_offset; - - debug("Loading phdr %i to 0x%p (%lu bytes)\n", - i, dst, (ulong)phdr->p_filesz); - if (phdr->p_filesz) - memcpy(dst, src, phdr->p_filesz); - if (phdr->p_filesz != phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); - flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN), - roundup(phdr->p_memsz, ARCH_DMA_MINALIGN)); - ++phdr; - } - - if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags & - EF_PPC64_ELFV1_ABI)) { - /* -* For the 64-bit PowerPC ELF V1 ABI, e_entry is a function -* descriptor pointer with the first double word being the -* address of the entry point of the function. -*/ - uintptr_t addr = ehdr->e_entry; - - return *(Elf64_Addr *)addr; - } - - return ehdr->e_entry; -} - -static unsigned long load_elf64_image_shdr(unsigned long addr) -{ - Elf64_Ehdr *ehdr; /* Elf header structure pointer */ - Elf64_Shdr *shdr; /* Section header structure pointer */ - unsigned char *strtab = 0; /* String table pointer */ - unsigned char *image; /* Binary image pointer */ - int i; /* Loop counter */ - - ehdr = (Elf64_Ehdr *)addr; - - /* Find the section header string table for output info */ - shdr = (Elf64_Shdr *)(addr + (ulong)ehdr->e_shoff + -(ehdr->e_shstrndx * sizeof(Elf64_Shdr))); - - if (shdr->sh_type == SHT_STRTAB) - strtab = (unsigned char *)(addr + (ulong)shdr->sh_offset); - - /* Load each appropriate section */ - for (i = 0; i < ehdr->e_shnum; ++i) { - shdr = (Elf64_Shdr *)(addr + (ulong)ehdr->e_shoff + -(i * sizeof(Elf64_Shdr))); - - if (!(shdr->sh_flags & SHF_ALLOC) || - shdr->sh_addr == 0 || shdr->sh_size == 0) { - continue; - } - - if (strtab) { - debug("%sing %s @ 0x%08lx (%ld bytes)\n", - (shdr->sh_type == SHT_NOBITS) ? "Clear" : "Load", - &strtab[shdr->sh_name], - (unsigned long)shdr->sh_addr, - (long)shdr->sh_size); - } - - if (shdr->sh_type == SHT_NOBITS) { - memset((void *)(uintptr_t)shdr->sh_addr, 0, - shdr->sh_size); - } else { - image = (unsigned char *)addr + (ulong)shdr->sh_offset; - memcpy((void *)(uintptr_t)shdr->sh_addr, - (const void *)image, shdr->sh_size); - } -
[PATCH v4 00/10] Add support for loading main_r5fss0_core0
This patch series enables mcu_r5fss0_core0 & main_r5fss0_core0. Tested for firmware loading and execution on J721e. Changes in v4: * Changed env variable names, config names and enhanced commit logs. Changes in v3: * Removed saving env in MMC and fixed env saving in SPL when nowhere option is set. Changes in v2: * Factored out all the generic elf handling functions under lib/elf.c Keerthy (10): env: nowhere: set default enviroment lib: elf: Move the generic elf loading/validating functions to lib arm: k3: Add support for loading non linux remote cores armv7R: K3: r5_mpu: Enable execute permission for MCU0 BTCM armv7R: K3: Add support for jumping to firmware arm: dts: k3-j721e-r5: Add fs_loader node arm: dts: k3-j721e-r5: Enable r5fss0 cluster in SPL include: configs: j721e_evm: Add env variables for mcu_r5fss0_core0 & main_r5fss0_core0 configs: j721e_evm_r5: Enable R5F remoteproc support configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC .../arm/dts/k3-j721e-r5-common-proc-board.dts | 20 ++ arch/arm/mach-k3/common.c | 106 +++- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 +++ arch/arm/mach-k3/r5_mpu.c | 4 +- cmd/Kconfig | 1 + cmd/elf.c | 229 configs/j721e_evm_r5_defconfig| 6 +- env/nowhere.c | 1 + include/configs/j721e_evm.h | 4 + include/elf.h | 4 + lib/Kconfig | 3 + lib/Makefile | 1 + lib/elf.c | 256 ++ 14 files changed, 426 insertions(+), 245 deletions(-) create mode 100644 lib/elf.c -- 2.17.1
Re: [PATCH v3 02/10] arm: k3: Add support for loading non linux remote cores
On 1/21/2020 6:26 PM, Andrew F. Davis wrote: On 1/21/20 6:07 AM, Keerthy wrote: Add MAIN domain R5FSS0 remoteproc support from spl. This enables loading the elf firmware in SPL and starting the remotecore. In order to start the core, there should be a file with path "/lib/firmware/j7-main-r5f0_0-fw" under filesystem of respective boot mode. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla [Guard start_non_linux_remote_cores under CONFIG_FS_LOADER] Signed-off-by: Andreas Dannenberg --- arch/arm/mach-k3/common.c | 84 --- arch/arm/mach-k3/common.h | 2 + arch/arm/mach-k3/j721e_init.c | 34 ++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 8d1529062d..f0ac0c39f1 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -16,6 +16,10 @@ #include #include #include +#include +#include +#include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -57,6 +61,74 @@ int early_console_init(void) #endif #ifdef CONFIG_SYS_K3_SPL_ATF + +void init_env(void) +{ +#ifdef CONFIG_SPL_ENV_SUPPORT + char *part; + + env_init(); + env_load(); + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + part = env_get("bootpart"); + env_set("storage_interface", "mmc"); + env_set("fw_dev_part", part); + break; + case BOOT_DEVICE_SPI: + env_set("storage_interface", "ubi"); + env_set("fw_ubi_mtdpart", "UBI"); + env_set("fw_ubi_volume", "UBI0"); + break; + default: + printf("%s from device %u not supported!\n", + __func__, spl_boot_device()); This will print for almost every boot mode.. I can keep this under debug. + return; + } +#endif +} + +#ifdef CONFIG_FS_LOADER +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + struct udevice *fsdev; + char *name = NULL; + int size = 0; + + *loadaddr = 0; +#ifdef CONFIG_SPL_ENV_SUPPORT + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC2: + name = env_get(name_fw); + *loadaddr = env_get_hex(name_loadaddr, *loadaddr); + break; + default: + printf("Loading rproc fw image from device %u not supported!\n", + spl_boot_device()); This whole thing seems very MMC specific, if early firmware loading is important it should work for all boot modes. Find a way to include it in the next boot stage FIT image (tispl.bin) so it works for all modes. That was not NAKd. We are going with fs_loader approach. + return 0; + } +#endif + if (!*loadaddr) + return 0; + + if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, &fsdev)) { + size = request_firmware_into_buf(fsdev, name, (void *)*loadaddr, +0, 0); + } + + return size; +} +#else +int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr) +{ + return 0; +} +#endif + +__weak void start_non_linux_remote_cores(void) +{ +} + void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -65,15 +137,17 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) /* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci); + ret = rproc_init(); + if (ret) + panic("rproc failed to be initialized (%d)\n", ret); + + init_env(); + start_non_linux_remote_cores(); + /* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same. */ - ret = rproc_dev_init(1); - if (ret) - panic("%s: ATF failed to initialize on rproc (%d)\n", __func__, - ret); - Where did this code go? rproc_init takes care of that. ret = rproc_load(1, spl_image->entry_point, 0x200); if (ret) panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret); diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index d8b34fe060..42fb8ee6e7 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -24,3 +24,5 @@ void setup_k3_mpu_regions(void); int early_console_init(void); void disable_linefill_optimization(void); void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size); +void start_non_linux_remote_cores
[PATCH v3 10/10] env: nowhere: set default enviroment
set default enviroment so that set_env calls succeed when ENV_IS_NOWHERE is alone set. Signed-off-by: Keerthy --- env/nowhere.c | 1 + 1 file changed, 1 insertion(+) diff --git a/env/nowhere.c b/env/nowhere.c index f5b0a17652..70c3b3e011 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -23,6 +23,7 @@ static int env_nowhere_init(void) { gd->env_addr= (ulong)&default_environment[0]; gd->env_valid = ENV_INVALID; + env_set_default(NULL, 0); return 0; } -- 2.17.1
[PATCH v3 09/10] configs: j721e_evm_r5_defconfig: Remove saving ENV in eMMC
Remove saving ENV in eMMC in r5 as the power domains are not setup. Environment in eMMC cannot be read if we do not boot from eMMC. Signed-off-by: Keerthy --- configs/j721e_evm_r5_defconfig | 4 1 file changed, 4 deletions(-) diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index 0925690e10..0f391ff98e 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -7,7 +7,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x55000 CONFIG_SOC_K3_J721E=y CONFIG_TARGET_J721E_R5_EVM=y CONFIG_ENV_SIZE=0x2 -CONFIG_ENV_OFFSET=0x68 CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y @@ -48,9 +47,6 @@ CONFIG_CMD_FAT=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board" -CONFIG_ENV_IS_IN_MMC=y -CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_ENV_OFFSET_REDUND=0x70 CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM=y CONFIG_SPL_DM=y -- 2.17.1