¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Date   
[PATCH v2 1/5] power: regulator: Trigger probe of regulators which are always-on or boot-on 3
In case a regulator DT node contains regulator-always-on or regulator-boo= t-on property, make sure the regulator gets correctly configured by U-Boot on = start up. Unconditionally probe such regulator drivers. This is a preparatory p= atch for introduction of .regulator_post_probe() which would trigger the regul= ator configuration. Parsing of regulator-always-on and regulator-boot-on DT property has been moved to regulator_post_bind() as the information is required early, the rest of the DT parsing has been kept in regulator_pre_probe() to avoid slowing down the boot process. Signed-off-by: Marek Vasut <marex@...> --- Cc: Ben Wolsieffer <benwolsieffer@...> Cc: Caleb Connolly <caleb.connolly@...> Cc: Chris Morgan <macromorgan@...> Cc: Dragan Simic <dsimic@...> Cc: Eugen Hristev <eugen.hristev@...> Cc: Francesco Dolcini <francesco.dolcini@...> Cc: Heinrich Schuchardt <xypron.glpk@...> Cc: Jaehoon Chung <jh80.chung@...> Cc: Jagan Teki <jagan@...> Cc: Jonas Karlman <jonas@...> Cc: Kever Yang <kever.yang@...> Cc: Kostya Porotchkin <kostap@...> Cc: Matteo Lisi <matteo.lisi@...> Cc: Mattijs Korpershoek <mkorpershoek@...> Cc: Max Krummenacher <max.krummenacher@...> Cc: Neil Armstrong <neil.armstrong@...> Cc: Patrice Chotard <patrice.chotard@...> Cc: Patrick Delaunay <patrick.delaunay@...> Cc: Philipp Tomsich <philipp.tomsich@...> Cc: Quentin Schulz <quentin.schulz@...> Cc: Sam Day <me@...> Cc: Simon Glass <sjg@...> Cc: Sumit Garg <sumit.garg@...> Cc: Svyatoslav Ryhel <clamor95@...> Cc: Thierry Reding <treding@...> Cc: Tom Rini <trini@...> Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...> Cc: [email protected] Cc: [email protected] Cc: u-boot@... Cc: u-boot@... Cc: uboot-stm32@... --- V2: - Rebase on current u-boot/next - Update test cases to handle already started regulators correctly --- drivers/power/regulator/regulator-uclass.c | 22 +++++++++++++++------- test/dm/panel.c | 2 +- test/dm/regulator.c | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/r= egulator/regulator-uclass.c index 88a8525b3c4..e2f703702e3 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -433,6 +433,8 @@ static int regulator_post_bind(struct udevice *dev) const char *property =3D "regulator-name"; =20 uc_pdata =3D dev_get_uclass_plat(dev); + uc_pdata->always_on =3D dev_read_bool(dev, "regulator-always-on"); + uc_pdata->boot_on =3D dev_read_bool(dev, "regulator-boot-on"); =20 /* Regulator's mandatory constraint */ uc_pdata->name =3D dev_read_string(dev, property); @@ -444,13 +446,21 @@ static int regulator_post_bind(struct udevice *dev) return -EINVAL; } =20 - if (regulator_name_is_unique(dev, uc_pdata->name)) - return 0; + if (!regulator_name_is_unique(dev, uc_pdata->name)) { + debug("'%s' of dev: '%s', has nonunique value: '%s\n", + property, dev->name, uc_pdata->name); + return -EINVAL; + } =20 - debug("'%s' of dev: '%s', has nonunique value: '%s\n", - property, dev->name, uc_pdata->name); + /* + * In case the regulator has regulator-always-on or + * regulator-boot-on DT property, trigger probe() to + * configure its default state during startup. + */ + if (uc_pdata->always_on && uc_pdata->boot_on) + dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); =20 - return -EINVAL; + return 0; } =20 static int regulator_pre_probe(struct udevice *dev) @@ -473,8 +483,6 @@ static int regulator_pre_probe(struct udevice *dev) -ENODATA); uc_pdata->max_uA =3D dev_read_u32_default(dev, "regulator-max-microamp"= , -ENODATA); - uc_pdata->always_on =3D dev_read_bool(dev, "regulator-always-on"); - uc_pdata->boot_on =3D dev_read_bool(dev, "regulator-boot-on"); uc_pdata->ramp_delay =3D dev_read_u32_default(dev, "regulator-ramp-dela= y", 0); uc_pdata->force_off =3D dev_read_bool(dev, "regulator-force-boot-off"); diff --git a/test/dm/panel.c b/test/dm/panel.c index ce835c96ed0..ec85a9b1e6e 100644 --- a/test/dm/panel.c +++ b/test/dm/panel.c @@ -33,7 +33,7 @@ static int dm_test_panel(struct unit_test_state *uts) ut_assertok(sandbox_pwm_get_co
Started by Marek Vasut @ · Most recent @
[PATCH v2 3/5] power: regulator: Exit from regulator_set_suspend_value on poorly described regulators 2
Hi Marek, I sent a different fix for this some time ago, please check it out: https://patchwork.ozlabs.org/patch/1964571/ Regards, Jonas
Started by Jonas Karlman @ · Most recent @
[PATCH v2 4/5] power: regulator: Drop regulator_unset()
This function is never called, drop it. Signed-off-by: Marek Vasut <marex@...> --- Cc: Ben Wolsieffer <benwolsieffer@...> Cc: Caleb Connolly <caleb.connolly@...> Cc: Chris Morgan <macromorgan@...> Cc: Dragan Simic <dsimic@...> Cc: Eugen Hristev <eugen.hristev@...> Cc: Francesco Dolcini <francesco.dolcini@...> Cc: Heinrich Schuchardt <xypron.glpk@...> Cc: Jaehoon Chung <jh80.chung@...> Cc: Jagan Teki <jagan@...> Cc: Jonas Karlman <jonas@...> Cc: Kever Yang <kever.yang@...> Cc: Matteo Lisi <matteo.lisi@...> Cc: Mattijs Korpershoek <mkorpershoek@...> Cc: Max Krummenacher <max.krummenacher@...> Cc: Neil Armstrong <neil.armstrong@...> Cc: Patrice Chotard <patrice.chotard@...> Cc: Patrick Delaunay <patrick.delaunay@...> Cc: Philipp Tomsich <philipp.tomsich@...> Cc: Quentin Schulz <quentin.schulz@...> Cc: Sam Day <me@...> Cc: Simon Glass <sjg@...> Cc: Sumit Garg <sumit.garg@...> Cc: Svyatoslav Ryhel <clamor95@...> Cc: Thierry Reding <treding@...> Cc: Tom Rini <trini@...> Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...> Cc: [email protected] Cc: [email protected] Cc: u-boot@... Cc: u-boot@... Cc: uboot-stm32@... --- V2: Rebase on current u-boot/next --- drivers/power/regulator/regulator-uclass.c | 11 ----------- include/power/regulator.h | 14 +------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/r= egulator/regulator-uclass.c index 3c05fdf1966..34c2a36ec44 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -343,17 +343,6 @@ out: return ret; } =20 -int regulator_unset(struct udevice *dev) -{ - struct dm_regulator_uclass_plat *uc_pdata; - - uc_pdata =3D dev_get_uclass_plat(dev); - if (uc_pdata && uc_pdata->force_off) - return regulator_set_enable(dev, false); - - return -EMEDIUMTYPE; -} - static void regulator_show(struct udevice *dev, int ret) { struct dm_regulator_uclass_plat *uc_pdata; diff --git a/include/power/regulator.h b/include/power/regulator.h index bb07a814c79..5363483d02a 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -430,7 +430,7 @@ int regulators_enable_boot_on(bool verbose); * * This disables all regulators which are marked to be off at boot time. * - * This effectively calls regulator_unset() for every regulator. + * This effectively does nothing. */ int regulators_enable_boot_off(bool verbose); =20 @@ -453,18 +453,6 @@ int regulators_enable_boot_off(bool verbose); */ int regulator_autoset(struct udevice *dev); =20 -/** - * regulator_unset: turn off a regulator - * - * The setup depends on constraints found in device's uclass's platform = data - * (struct dm_regulator_uclass_platdata): - * - * - Disable - will set - if 'force_off' is set to true, - * - * The function returns on the first-encountered error. - */ -int regulator_unset(struct udevice *dev); - /** * regulator_autoset_by_name: setup the regulator given by its uclass's * platform data name field. The setup depends on constraints found in d= evice's --=20 2.45.2
Started by Marek Vasut @
[PATCH v2 3/5] power: regulator: Exit from regulator_set_suspend_value on poorly described regulators
In case the DT regulator node does not contain 'regulator-max-microvolt' property and does not contain 'regulator-state-mem' subnode (like the test.dts regul1_scmi: reg@1 {} regulator node), then regulator_pre_probe(= ) will parse this regulator node and set uc_pdata->suspend_on =3D true and uc_pdata->suspend_uV =3D uc_pdata->max_uV, where uc_pdata->max_uV is set to -ENODATA because "regulator-max-microvolt" is missing, and therefore uc_pdata->suspend_uV is also -ENODATA. In case regulator_autoset() is used afterward, it will attempt to call regulator_set_suspend_value() with uV =3D uc_pdata->suspend_uV =3D -ENODATA and fail with -EINVAL. Chec= k for this case in regulator_set_suspend_value() and immediately return 0, because there is no way to set meaningful suspend voltage, so do nothing and retain the existing settings of the regulator. Signed-off-by: Marek Vasut <marex@...> --- Cc: Ben Wolsieffer <benwolsieffer@...> Cc: Caleb Connolly <caleb.connolly@...> Cc: Chris Morgan <macromorgan@...> Cc: Dragan Simic <dsimic@...> Cc: Eugen Hristev <eugen.hristev@...> Cc: Francesco Dolcini <francesco.dolcini@...> Cc: Heinrich Schuchardt <xypron.glpk@...> Cc: Jaehoon Chung <jh80.chung@...> Cc: Jagan Teki <jagan@...> Cc: Jonas Karlman <jonas@...> Cc: Kever Yang <kever.yang@...> Cc: Matteo Lisi <matteo.lisi@...> Cc: Mattijs Korpershoek <mkorpershoek@...> Cc: Max Krummenacher <max.krummenacher@...> Cc: Neil Armstrong <neil.armstrong@...> Cc: Patrice Chotard <patrice.chotard@...> Cc: Patrick Delaunay <patrick.delaunay@...> Cc: Philipp Tomsich <philipp.tomsich@...> Cc: Quentin Schulz <quentin.schulz@...> Cc: Sam Day <me@...> Cc: Simon Glass <sjg@...> Cc: Sumit Garg <sumit.garg@...> Cc: Svyatoslav Ryhel <clamor95@...> Cc: Thierry Reding <treding@...> Cc: Tom Rini <trini@...> Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...> Cc: [email protected] Cc: [email protected] Cc: u-boot@... Cc: u-boot@... Cc: uboot-stm32@... --- V2: New patch --- drivers/power/regulator/regulator-uclass.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/r= egulator/regulator-uclass.c index 14cf3159203..3c05fdf1966 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -85,6 +85,10 @@ int regulator_set_suspend_value(struct udevice *dev, i= nt uV) const struct dm_regulator_ops *ops =3D dev_get_driver_ops(dev); struct dm_regulator_uclass_plat *uc_pdata; =20 + /* Regulator did not set limits, assume already configured. */ + if (uV =3D=3D -ENODATA) + return 0; + uc_pdata =3D dev_get_uclass_plat(dev); if (uc_pdata->min_uV !=3D -ENODATA && uV < uc_pdata->min_uV) return -EINVAL; --=20 2.45.2
Started by Marek Vasut @
[PATCH v2 2/5] power: regulator: Convert regulators_enable_boot_on/off() to regulator_post_probe
Turn regulators_enable_boot_on() and regulators_enable_boot_off() into empty functions. Implement matching functionality in regulator_post_probe= () instead. The regulator_post_probe() is called for all regulators after th= ey probe, and regulators that have regulator-always-on or regulator-boot-on = DT properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on such regulators in regulator_post_bind(). Finally, fold regulator_unset() functionality into regulator_autoset(). Signed-off-by: Marek Vasut <marex@...> --- Cc: Ben Wolsieffer <benwolsieffer@...> Cc: Caleb Connolly <caleb.connolly@...> Cc: Chris Morgan <macromorgan@...> Cc: Dragan Simic <dsimic@...> Cc: Eugen Hristev <eugen.hristev@...> Cc: Francesco Dolcini <francesco.dolcini@...> Cc: Heinrich Schuchardt <xypron.glpk@...> Cc: Jaehoon Chung <jh80.chung@...> Cc: Jagan Teki <jagan@...> Cc: Jonas Karlman <jonas@...> Cc: Kever Yang <kever.yang@...> Cc: Matteo Lisi <matteo.lisi@...> Cc: Mattijs Korpershoek <mkorpershoek@...> Cc: Max Krummenacher <max.krummenacher@...> Cc: Neil Armstrong <neil.armstrong@...> Cc: Patrice Chotard <patrice.chotard@...> Cc: Patrick Delaunay <patrick.delaunay@...> Cc: Philipp Tomsich <philipp.tomsich@...> Cc: Quentin Schulz <quentin.schulz@...> Cc: Sam Day <me@...> Cc: Simon Glass <sjg@...> Cc: Sumit Garg <sumit.garg@...> Cc: Svyatoslav Ryhel <clamor95@...> Cc: Thierry Reding <treding@...> Cc: Tom Rini <trini@...> Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...> Cc: [email protected] Cc: [email protected] Cc: u-boot@... Cc: u-boot@... Cc: uboot-stm32@... --- V2: Rebase on current u-boot/next --- drivers/power/regulator/regulator-uclass.c | 60 +++++++--------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/r= egulator/regulator-uclass.c index e2f703702e3..14cf3159203 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -308,6 +308,11 @@ int regulator_autoset(struct udevice *dev) return ret; } =20 + if (uc_pdata->force_off) { + ret =3D regulator_set_enable(dev, false); + goto out; + } + if (!uc_pdata->always_on && !uc_pdata->boot_on) { ret =3D -EMEDIUMTYPE; goto out; @@ -512,56 +517,28 @@ static int regulator_pre_probe(struct udevice *dev) return 0; } =20 -int regulators_enable_boot_on(bool verbose) +static int regulator_post_probe(struct udevice *dev) { - struct udevice *dev; - struct uclass *uc; int ret; =20 - ret =3D uclass_get(UCLASS_REGULATOR, &uc); - if (ret) + ret =3D regulator_autoset(dev); + if (ret && ret !=3D -EMEDIUMTYPE && ret !=3D -EALREADY && ret !=3D ENOS= YS) return ret; - for (uclass_first_device(UCLASS_REGULATOR, &dev); - dev; - uclass_next_device(&dev)) { - ret =3D regulator_autoset(dev); - if (ret =3D=3D -EMEDIUMTYPE || ret =3D=3D -EALREADY) { - ret =3D 0; - continue; - } - if (verbose) - regulator_show(dev, ret); - if (ret =3D=3D -ENOSYS) - ret =3D 0; - } =20 - return ret; + if (_DEBUG) + regulator_show(dev, ret); + + return 0; } =20 -int regulators_enable_boot_off(bool verbose) +int regulators_enable_boot_on(bool verbose) { - struct udevice *dev; - struct uclass *uc; - int ret; - - ret =3D uclass_get(UCLASS_REGULATOR, &uc); - if (ret) - return ret; - for (uclass_first_device(UCLASS_REGULATOR, &dev); - dev; - uclass_next_device(&dev)) { - ret =3D regulator_unset(dev); - if (ret =3D=3D -EMEDIUMTYPE) { - ret =3D 0; - continue; - } - if (verbose) - regulator_show(dev, ret); - if (ret =3D=3D -ENOSYS) - ret =3D 0; - } + return 0; +} =20 - return ret; +int regulators_enable_boot_off(bool verbose) +{ + return 0; } =20 UCLASS_DRIVER(regulator) =3D { @@ -569,5 +546,6 @@ UCLASS_DRIVER(regulator) =3D { .name =3D "regulator", .post_bind =3D regulator_post_bind, .pre_probe =3D regulator_pre_probe, + .post_probe =3D regulator_post_probe, .per_device_plat_auto =3D sizeof(struct dm_regulator_uclass_plat), }; --=20 2.45.2
Started by Marek Vasut @
[PATCH v2 5/5] power: regulator: Drop regulators_enable_boot_on/off()
Both regulators_enable_boot_on/off() are unused and superseded by regulator uclass regulator_post_probe(). Remove both functions. Signed-off-by: Marek Vasut <marex@...> --- Cc: Ben Wolsieffer <benwolsieffer@...> Cc: Caleb Connolly <caleb.connolly@...> Cc: Chris Morgan <macromorgan@...> Cc: Dragan Simic <dsimic@...> Cc: Eugen Hristev <eugen.hristev@...> Cc: Francesco Dolcini <francesco.dolcini@...> Cc: Heinrich Schuchardt <xypron.glpk@...> Cc: Jaehoon Chung <jh80.chung@...> Cc: Jagan Teki <jagan@...> Cc: Jonas Karlman <jonas@...> Cc: Kever Yang <kever.yang@...> Cc: Matteo Lisi <matteo.lisi@...> Cc: Mattijs Korpershoek <mkorpershoek@...> Cc: Max Krummenacher <max.krummenacher@...> Cc: Neil Armstrong <neil.armstrong@...> Cc: Patrice Chotard <patrice.chotard@...> Cc: Patrick Delaunay <patrick.delaunay@...> Cc: Philipp Tomsich <philipp.tomsich@...> Cc: Quentin Schulz <quentin.schulz@...> Cc: Sam Day <me@...> Cc: Simon Glass <sjg@...> Cc: Sumit Garg <sumit.garg@...> Cc: Svyatoslav Ryhel <clamor95@...> Cc: Thierry Reding <treding@...> Cc: Tom Rini <trini@...> Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...> Cc: [email protected] Cc: [email protected] Cc: u-boot@... Cc: u-boot@... Cc: uboot-stm32@... --- V2: Rebase on current u-boot/next --- arch/arm/mach-rockchip/board.c | 8 ------ arch/arm/mach-snapdragon/board.c | 1 - arch/arm/mach-tegra/board2.c | 3 --- board/Marvell/octeontx2_cn913x/board.c | 5 ---- .../amlogic/odroid-go-ultra/odroid-go-ultra.c | 2 -- board/dhelectronics/dh_imx6/dh_imx6.c | 2 -- .../dh_imx8mp/imx8mp_dhcom_pdk2.c | 2 -- board/dhelectronics/dh_stm32mp1/board.c | 2 -- board/engicam/stm32mp1/stm32mp1.c | 3 --- board/google/veyron/veyron.c | 4 --- board/samsung/common/exynos5-dt.c | 4 --- board/st/stm32mp1/stm32mp1.c | 2 -- drivers/power/regulator/regulator-uclass.c | 10 -------- include/power/regulator.h | 25 ------------------- 14 files changed, 73 deletions(-) diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/boar= d.c index 0fdf9365b41..3fadf7e4122 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -202,14 +202,6 @@ int board_late_init(void) =20 int board_init(void) { - int ret; - -#ifdef CONFIG_DM_REGULATOR - ret =3D regulators_enable_boot_on(false); - if (ret) - debug("%s: Cannot enable boot on regulator\n", __func__); -#endif - return 0; } =20 diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/= board.c index 0af297470a6..2ab2ceb5138 100644 --- a/arch/arm/mach-snapdragon/board.c +++ b/arch/arm/mach-snapdragon/board.c @@ -237,7 +237,6 @@ void __weak qcom_board_init(void) =20 int board_init(void) { - regulators_enable_boot_on(false); show_psci_version(); qcom_of_fixup_nodes(); qcom_board_init(); diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c index 7971e3b68d5..5c5838629b2 100644 --- a/arch/arm/mach-tegra/board2.c +++ b/arch/arm/mach-tegra/board2.c @@ -187,9 +187,6 @@ int board_init(void) warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE); #endif =20 - /* Set up boot-on regulators */ - regulators_enable_boot_on(_DEBUG); - return nvidia_board_init(); } =20 diff --git a/board/Marvell/octeontx2_cn913x/board.c b/board/Marvell/octeo= ntx2_cn913x/board.c index 3d20cfb2fab..3ffe15d42b8 100644 --- a/board/Marvell/octeontx2_cn913x/board.c +++ b/board/Marvell/octeontx2_cn913x/board.c @@ -23,11 +23,6 @@ int board_early_init_f(void) =20 int board_early_init_r(void) { - if (CONFIG_IS_ENABLED(DM_REGULATOR)) { - /* Check if any existing regulator should be turned down */ - regulators_enable_boot_off(false); - } - return 0; } =20 diff --git a/board/amlogic/odroid-go-ultra/odroid-go-ultra.c b/board/amlo= gic/odroid-go-ultra/odroid-go-ultra.c index 8f3f2045d74..f9412071737 100644 --- a/board/amlogic/odroid-go-ultra/odroid-go-ultra.c +++ b/board/amlogic/odroid-go-ultra/odroid-go-ultra.c @@ -16,7 +16,5 @@ int mmc_get_env_dev(void) =20 int board_init(void) { - regulators_enable_boot_on(_DEBUG); - return 0; } diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/= dh_imx6/dh_imx6.c index ada44e01424..f
Started by Marek Vasut @
[PATCH 2/2] board: libre-computer: aml-s805-cc: Enable capsule updates 2
Since the aml-s805-cc works well using EFI, and now the capsule updates backend has been merged, let's enable the missing configs and add the required structures to support it. The GUID is dynamically generated for the board, to get it: => efidebug capsule esrt ======================================== ESRT: fw_resource_count=1 ESRT: fw_resource_count_max=1 ESRT: fw_resource_version=1 [entry 0]============================== ESRT: fw_class=B8079027-9B2C-57D4-86AA-CC782ADA598C ESRT: fw_type=unknown ESRT: fw_version=0 ESRT: lowest_supported_fw_version=0 ESRT: capsule_flags=0 ESRT: last_attempt_version=0 ESRT: last_attempt_status=success ======================================== On the host (with the aml_encrypt_gxl result binary): $ eficapsule --guid B8079027-9B2C-57D4-86AA-CC782ADA598C -i 1 u-boot.bin u-boot.cap On the board (from USB disk containing u-boot.cap at root): => load usb 0:1 $kernel_addr_r u-boot.cap => efidebug capsule update $kernel_addr_r The binary will then be flashed on the SPI. Signed-off-by: Neil Armstrong <neil.armstrong@...> --- board/libre-computer/aml-s805x-ac/aml-s805x-ac.c | 14 ++++++++++++++ configs/libretech-ac_defconfig | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c index ae9834c0bf8..ba14df54967 100644 --- a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c +++ b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c @@ -8,6 +8,7 @@ #include <env.h> #include <init.h> #include <net.h> +#include <efi_loader.h> #include <asm/io.h> #include <asm/arch/gx.h> #include <asm/arch/sm.h> @@ -19,6 +20,19 @@ #define EFUSE_MAC_OFFSET 52 #define EFUSE_MAC_SIZE 6 +struct efi_fw_image fw_images[] = { + { + .fw_name = u"AML_S805X_AC_BOOT", + .image_index = 1, + }, +}; + +struct efi_capsule_update_info update_info = { + .dfu_string = "sf 0:0=u-boot-bin raw 0 0x10000", + .num_images = ARRAY_SIZE(fw_images), + .images = fw_images, +}; + int misc_init_r(void) { u8 mac_addr[EFUSE_MAC_SIZE + 1]; diff --git a/configs/libretech-ac_defconfig b/configs/libretech-ac_defconfig index 11d9795e05d..f146a495654 100644 --- a/configs/libretech-ac_defconfig +++ b/configs/libretech-ac_defconfig @@ -35,6 +35,7 @@ CONFIG_SYS_MAXARGS=32 # CONFIG_CMD_IMI is not set CONFIG_CMD_ADC=y CONFIG_CMD_DFU=y +CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_GPIO=y # CONFIG_CMD_LOADS is not set CONFIG_CMD_MMC=y @@ -42,6 +43,7 @@ CONFIG_CMD_SF_TEST=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y CONFIG_CMD_USB_MASS_STORAGE=y +CONFIG_CMD_EFIDEBUG=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_REGULATOR=y CONFIG_OF_CONTROL=y @@ -49,6 +51,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_SARADC_MESON=y CONFIG_DFU_RAM=y +CONFIG_DFU_SF=y CONFIG_MMC_MESON_GX=y CONFIG_MTD=y CONFIG_DM_MTD=y @@ -98,3 +101,5 @@ CONFIG_VIDEO_BMP_RLE8=y CONFIG_BMP_16BPP=y CONFIG_BMP_24BPP=y CONFIG_BMP_32BPP=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y -- 2.34.1
Started by Neil Armstrong @ · Most recent @
Quick Reminder- IBC Convention Data List- 2024
Hi, Would you be interested in acquiring IBC Convention Attendees Data List-2024? Number of Contacts:- 40,236. Cost:-$1,889 Interested? Email me back; I would love to provide more information on the list. Kind Regards, Peyton Marketing Coordinator
Started by Peyton Jack @
[PATCH 16/26] phy: dphy: Correct clk_pre parameter
From: Michael Trimarchi <michael@...> Upstream linux commit 9a8406ba1a9a29. The D-PHY specification (v1.2) explicitly mentions that the T-CLK-PRE parameter's unit is Unit Interval(UI) and the minimum value is 8. Also, kernel doc of the 'clk_pre' member of struct phy_configure_opts_mipi_dphy mentions that it should be in UI. However, the dphy core driver wrongly sets 'clk_pre' to 8000, which seems to hint that it's in picoseconds. So, let's fix the dphy core driver to correctly reflect the T-CLK-PRE parameter's minimum value according to the D-PHY specification. I'm assuming that all impacted custom drivers shall program values in TxByteClkHS cycles into hardware for the T-CLK-PRE parameter. The D-PHY specification mentions that the frequency of TxByteClkHS is exactly 1/8 the High-Speed(HS) bit rate(each HS bit consumes one UI). So, relevant custom driver code is changed to program those values as DIV_ROUND_UP(cfg->clk_pre, BITS_PER_BYTE), then. Note that I've only tested the patch with RM67191 DSI panel on i.MX8mq EVK. Help is needed to test with other i.MX8mq, Meson and Rockchip platforms, as I don't have the hardwares. Tested-by: Liu Ying <victor.liu@...> # RM67191 DSI panel on i.MX8mq EVK Reviewed-by: Andrzej Hajda <andrzej.hajda@...> Reviewed-by: Neil Armstrong <narmstrong@...> # for phy-meson-axg-mipi-dphy.c Tested-by: Neil Armstrong <narmstrong@...> # for phy-meson-axg-mipi-dphy.c Tested-by: Guido G¨¹nther <agx@...> # Librem 5 (imx8mq) with it's rather picky panel Reviewed-by: Laurent Pinchart <laurent.pinchart@...> Signed-off-by: Liu Ying <victor.liu@...> Link: https://lore.kernel.org/r/20220124024007.1465018-1-victor.liu@... Signed-off-by: Vinod Koul <vkoul@...> Signed-off-by: Michael Trimarchi <michael@...> Signed-off-by: Dario Binacchi <dario.binacchi@...> --- drivers/phy/meson-axg-mipi-dphy.c | 2 +- drivers/phy/phy-core-mipi-dphy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/phy/meson-axg-mipi-dphy.c b/drivers/phy/meson-axg-mipi-dphy.c index 3f89de19970b..fb10ccca6ac1 100644 --- a/drivers/phy/meson-axg-mipi-dphy.c +++ b/drivers/phy/meson-axg-mipi-dphy.c @@ -237,7 +237,7 @@ static int phy_meson_axg_mipi_dphy_power_on(struct phy *phy) (DIV_ROUND_UP(priv->config.clk_zero, temp) << 16) | (DIV_ROUND_UP(priv->config.clk_prepare, temp) << 24)); regmap_write(priv->regmap, MIPI_DSI_CLK_TIM1, - DIV_ROUND_UP(priv->config.clk_pre, temp)); + DIV_ROUND_UP(priv->config.clk_pre, BITS_PER_BYTE)); regmap_write(priv->regmap, MIPI_DSI_HS_TIM, DIV_ROUND_UP(priv->config.hs_exit, temp) | diff --git a/drivers/phy/phy-core-mipi-dphy.c b/drivers/phy/phy-core-mipi-dphy.c index 79cab9125002..27cff85709d9 100644 --- a/drivers/phy/phy-core-mipi-dphy.c +++ b/drivers/phy/phy-core-mipi-dphy.c @@ -36,7 +36,7 @@ static int phy_mipi_dphy_calc_config(unsigned long pixel_clock, cfg->clk_miss = 0; cfg->clk_post = 60000 + 52 * ui; - cfg->clk_pre = 8000; + cfg->clk_pre = 8; cfg->clk_prepare = 38000; cfg->clk_settle = 95000; cfg->clk_term_en = 0; -- 2.43.0
Started by Dario Binacchi @
[PATCH 0/2] ARM: meson: libretech-ac: add suppor for EFI Capsules Update 3
The necessary changes were made in U-Boot to easily support EFI Capsules Update and be compliant with Arm SystemReady SR. Let's add support for the libretech-ac/AML-S805X-CC since it's an easy well-supported target having a dedicated SPI Flash to store U-Boot. Signed-off-by: Neil Armstrong <neil.armstrong@...> --- Neil Armstrong (2): board: libretech-ac: move board support into dedicated directory board: libre-computer: aml-s805-cc: Enable capsule updates board/amlogic/p212/MAINTAINERS | 2 - board/libre-computer/aml-s805x-ac/MAINTAINERS | 8 ++++ board/libre-computer/aml-s805x-ac/Makefile | 6 +++ board/libre-computer/aml-s805x-ac/aml-s805x-ac.c | 61 ++++++++++++++++++++++++ configs/libretech-ac_defconfig | 7 +++ 5 files changed, 82 insertions(+), 2 deletions(-) --- base-commit: df84c019c46e6833cc79385bdb23efba4882c09d change-id: 20240916-u-boot-topic-dynamic-uuid-a871c25236a4 Best regards, -- Neil Armstrong <neil.armstrong@...>
Started by Neil Armstrong @ · Most recent @
[PATCH v2 2/2] board: libre-computer: aml-s805x-cc: Enable capsule updates
Since the aml-s805-cc works well using EFI, and now the capsule updates backend has been merged, let's enable the missing configs and add the required structures to support it. The GUID is dynamically generated for the board, to get it: => efidebug capsule esrt ======================================== ESRT: fw_resource_count=1 ESRT: fw_resource_count_max=1 ESRT: fw_resource_version=1 [entry 0]============================== ESRT: fw_class=B8079027-9B2C-57D4-86AA-CC782ADA598C ESRT: fw_type=unknown ESRT: fw_version=0 ESRT: lowest_supported_fw_version=0 ESRT: capsule_flags=0 ESRT: last_attempt_version=0 ESRT: last_attempt_status=success ======================================== On the host (with the aml_encrypt_gxl result binary): $ eficapsule --guid B8079027-9B2C-57D4-86AA-CC782ADA598C -i 1 u-boot.bin u-boot.cap On the board (from USB disk containing u-boot.cap at root): => load usb 0:1 $kernel_addr_r u-boot.cap => efidebug capsule update $kernel_addr_r The binary will then be flashed on the SPI. Reviewed-by: Ilias Apalodimas <ilias.apalodimas@...> Signed-off-by: Neil Armstrong <neil.armstrong@...> --- board/libre-computer/aml-s805x-ac/aml-s805x-ac.c | 24 ++++++++++++++++++++++++ configs/libretech-ac_defconfig | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c index ae9834c0bf8..94cf5b4361f 100644 --- a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c +++ b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c @@ -8,6 +8,7 @@ #include <env.h> #include <init.h> #include <net.h> +#include <efi_loader.h> #include <asm/io.h> #include <asm/arch/gx.h> #include <asm/arch/sm.h> @@ -19,6 +20,29 @@ #define EFUSE_MAC_OFFSET 52 #define EFUSE_MAC_SIZE 6 +struct efi_fw_image fw_images[] = { + { + .fw_name = u"AML_S805X_AC_BOOT", + .image_index = 1, + }, +}; + +struct efi_capsule_update_info update_info = { + .dfu_string = "sf 0:0=u-boot-bin raw 0 0x10000", + .num_images = ARRAY_SIZE(fw_images), + .images = fw_images, +}; + +#if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO) +void set_dfu_alt_info(char *interface, char *devstr) +{ + if (strcmp(interface, "ram") == 0) + env_set("dfu_alt_info", "fitimage ram 0x08080000 0x4000000"); + else if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) + env_set("dfu_alt_info", update_info.dfu_string); +} +#endif + int misc_init_r(void) { u8 mac_addr[EFUSE_MAC_SIZE + 1]; diff --git a/configs/libretech-ac_defconfig b/configs/libretech-ac_defconfig index 11d9795e05d..7763a14f203 100644 --- a/configs/libretech-ac_defconfig +++ b/configs/libretech-ac_defconfig @@ -35,6 +35,7 @@ CONFIG_SYS_MAXARGS=32 # CONFIG_CMD_IMI is not set CONFIG_CMD_ADC=y CONFIG_CMD_DFU=y +CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_GPIO=y # CONFIG_CMD_LOADS is not set CONFIG_CMD_MMC=y @@ -42,6 +43,7 @@ CONFIG_CMD_SF_TEST=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y CONFIG_CMD_USB_MASS_STORAGE=y +CONFIG_CMD_EFIDEBUG=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_REGULATOR=y CONFIG_OF_CONTROL=y @@ -49,6 +51,8 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_SARADC_MESON=y CONFIG_DFU_RAM=y +CONFIG_DFU_SF=y +CONFIG_SET_DFU_ALT_INFO=y CONFIG_MMC_MESON_GX=y CONFIG_MTD=y CONFIG_DM_MTD=y @@ -98,3 +102,5 @@ CONFIG_VIDEO_BMP_RLE8=y CONFIG_BMP_16BPP=y CONFIG_BMP_24BPP=y CONFIG_BMP_32BPP=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y -- 2.34.1
Started by Neil Armstrong @
[PATCH v2 1/2] board: libretech-ac: move board support into dedicated directory
The libretech-ac aka aml-s805x-ac supports mainline U-boot from a dedicated SPI flash, move the board support into a dedicated vendor/board subdirectory in order to support vendor specific customization. It also aligns with the vendor downstream changes. Signed-off-by: Neil Armstrong <neil.armstrong@...> --- board/amlogic/p212/MAINTAINERS | 2 - board/libre-computer/aml-s805x-ac/MAINTAINERS | 8 ++++ board/libre-computer/aml-s805x-ac/Makefile | 6 +++ board/libre-computer/aml-s805x-ac/aml-s805x-ac.c | 47 ++++++++++++++++++++++++ configs/libretech-ac_defconfig | 2 + 5 files changed, 63 insertions(+), 2 deletions(-) diff --git a/board/amlogic/p212/MAINTAINERS b/board/amlogic/p212/MAINTAINERS index b2e3205fdf0..e73a4e52c1f 100644 --- a/board/amlogic/p212/MAINTAINERS +++ b/board/amlogic/p212/MAINTAINERS @@ -5,11 +5,9 @@ L: [email protected] F: board/amlogic/p212/ F: include/configs/p212.h F: configs/khadas-vim_defconfig -F: configs/libretech-ac_defconfig F: configs/libretech-cc_defconfig F: configs/libretech-cc_v2_defconfig F: configs/p212_defconfig F: doc/board/amlogic/p212.rst -F: doc/board/amlogic/libretech-ac.rst F: doc/board/amlogic/libretech-cc.rst F: doc/board/amlogic/khadas-vim.rst diff --git a/board/libre-computer/aml-s805x-ac/MAINTAINERS b/board/libre-computer/aml-s805x-ac/MAINTAINERS new file mode 100644 index 00000000000..7cbc08aeb6c --- /dev/null +++ b/board/libre-computer/aml-s805x-ac/MAINTAINERS @@ -0,0 +1,8 @@ +LIBRE-COMPUTER AML-S805X-AC +M: Neil Armstrong <neil.armstrong@...> +S: Maintained +L: [email protected] +F: board/amlogic/aml-s805x-ac/ +F: include/configs/libretech-ac.h +F: configs/libretech-ac_defconfig +F: doc/board/amlogic/libretech-ac.rst diff --git a/board/libre-computer/aml-s805x-ac/Makefile b/board/libre-computer/aml-s805x-ac/Makefile new file mode 100644 index 00000000000..b4367ea522b --- /dev/null +++ b/board/libre-computer/aml-s805x-ac/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2016 BayLibre, SAS +# Author: Neil Armstrong <narmstrong@...> + +obj-y := aml-s805x-ac.o diff --git a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c new file mode 100644 index 00000000000..ae9834c0bf8 --- /dev/null +++ b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016 BayLibre, SAS + * Author: Neil Armstrong <narmstrong@...> + */ + +#include <dm.h> +#include <env.h> +#include <init.h> +#include <net.h> +#include <asm/io.h> +#include <asm/arch/gx.h> +#include <asm/arch/sm.h> +#include <asm/arch/eth.h> +#include <asm/arch/mem.h> + +#define EFUSE_SN_OFFSET 20 +#define EFUSE_SN_SIZE 16 +#define EFUSE_MAC_OFFSET 52 +#define EFUSE_MAC_SIZE 6 + +int misc_init_r(void) +{ + u8 mac_addr[EFUSE_MAC_SIZE + 1]; + char serial[EFUSE_SN_SIZE + 1]; + ssize_t len; + + if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { + len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, + mac_addr, EFUSE_MAC_SIZE); + mac_addr[len] = '\0'; + if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) + eth_env_set_enetaddr("ethaddr", mac_addr); + else + meson_generate_serial_ethaddr(); + } + + if (!env_get("serial#")) { + len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, + EFUSE_SN_SIZE); + serial[len] = '\0'; + if (len == EFUSE_SN_SIZE) + env_set("serial#", serial); + } + + return 0; +} diff --git a/configs/libretech-ac_defconfig b/configs/libretech-ac_defconfig index 6ad04570022..11d9795e05d 100644 --- a/configs/libretech-ac_defconfig +++ b/configs/libretech-ac_defconfig @@ -1,5 +1,7 @@ CONFIG_ARM=y CONFIG_SYS_CONFIG_NAME="libretech-ac" +CONFIG_SYS_VENDOR="libre-computer" +CONFIG_SYS_BOARD="aml-s805x-ac" CONFIG_ARCH_MESON=y CONFIG_TEXT_BASE=0x01000000 CONFIG_NR_DRAM_BANKS=1 -- 2.34.1
Started by Neil Armstrong @
[PATCH 1/2] board: libretech-ac: move board support into dedicated directory
The libretech-ac aka aml-s805x-ac supports mainline U-boot from a dedicated SPI flash, move the board support into a dedicated vendor/board subdirectory in order to support vendor specific customization. It also aligns with the vendor downstream changes. Signed-off-by: Neil Armstrong <neil.armstrong@...> --- board/amlogic/p212/MAINTAINERS | 2 - board/libre-computer/aml-s805x-ac/MAINTAINERS | 8 ++++ board/libre-computer/aml-s805x-ac/Makefile | 6 +++ board/libre-computer/aml-s805x-ac/aml-s805x-ac.c | 47 ++++++++++++++++++++++++ configs/libretech-ac_defconfig | 2 + 5 files changed, 63 insertions(+), 2 deletions(-) diff --git a/board/amlogic/p212/MAINTAINERS b/board/amlogic/p212/MAINTAINERS index b2e3205fdf0..e73a4e52c1f 100644 --- a/board/amlogic/p212/MAINTAINERS +++ b/board/amlogic/p212/MAINTAINERS @@ -5,11 +5,9 @@ L: [email protected] F: board/amlogic/p212/ F: include/configs/p212.h F: configs/khadas-vim_defconfig -F: configs/libretech-ac_defconfig F: configs/libretech-cc_defconfig F: configs/libretech-cc_v2_defconfig F: configs/p212_defconfig F: doc/board/amlogic/p212.rst -F: doc/board/amlogic/libretech-ac.rst F: doc/board/amlogic/libretech-cc.rst F: doc/board/amlogic/khadas-vim.rst diff --git a/board/libre-computer/aml-s805x-ac/MAINTAINERS b/board/libre-computer/aml-s805x-ac/MAINTAINERS new file mode 100644 index 00000000000..7cbc08aeb6c --- /dev/null +++ b/board/libre-computer/aml-s805x-ac/MAINTAINERS @@ -0,0 +1,8 @@ +LIBRE-COMPUTER AML-S805X-AC +M: Neil Armstrong <neil.armstrong@...> +S: Maintained +L: [email protected] +F: board/amlogic/aml-s805x-ac/ +F: include/configs/libretech-ac.h +F: configs/libretech-ac_defconfig +F: doc/board/amlogic/libretech-ac.rst diff --git a/board/libre-computer/aml-s805x-ac/Makefile b/board/libre-computer/aml-s805x-ac/Makefile new file mode 100644 index 00000000000..b4367ea522b --- /dev/null +++ b/board/libre-computer/aml-s805x-ac/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2016 BayLibre, SAS +# Author: Neil Armstrong <narmstrong@...> + +obj-y := aml-s805x-ac.o diff --git a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c new file mode 100644 index 00000000000..ae9834c0bf8 --- /dev/null +++ b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016 BayLibre, SAS + * Author: Neil Armstrong <narmstrong@...> + */ + +#include <dm.h> +#include <env.h> +#include <init.h> +#include <net.h> +#include <asm/io.h> +#include <asm/arch/gx.h> +#include <asm/arch/sm.h> +#include <asm/arch/eth.h> +#include <asm/arch/mem.h> + +#define EFUSE_SN_OFFSET 20 +#define EFUSE_SN_SIZE 16 +#define EFUSE_MAC_OFFSET 52 +#define EFUSE_MAC_SIZE 6 + +int misc_init_r(void) +{ + u8 mac_addr[EFUSE_MAC_SIZE + 1]; + char serial[EFUSE_SN_SIZE + 1]; + ssize_t len; + + if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { + len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, + mac_addr, EFUSE_MAC_SIZE); + mac_addr[len] = '\0'; + if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) + eth_env_set_enetaddr("ethaddr", mac_addr); + else + meson_generate_serial_ethaddr(); + } + + if (!env_get("serial#")) { + len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, + EFUSE_SN_SIZE); + serial[len] = '\0'; + if (len == EFUSE_SN_SIZE) + env_set("serial#", serial); + } + + return 0; +} diff --git a/configs/libretech-ac_defconfig b/configs/libretech-ac_defconfig index 6ad04570022..11d9795e05d 100644 --- a/configs/libretech-ac_defconfig +++ b/configs/libretech-ac_defconfig @@ -1,5 +1,7 @@ CONFIG_ARM=y CONFIG_SYS_CONFIG_NAME="libretech-ac" +CONFIG_SYS_VENDOR="libre-computer" +CONFIG_SYS_BOARD="aml-s805x-ac" CONFIG_ARCH_MESON=y CONFIG_TEXT_BASE=0x01000000 CONFIG_NR_DRAM_BANKS=1 -- 2.34.1
Started by Neil Armstrong @
[GIT PULL] Please pull u-boot-amlogic-next-20240902 2
Hi Tom, A simple set of changes to allow using the bootrom NAND pages, ported from Linux. Thanks, Neil The following changes since commit ee2af844ba1b27b2e959c4e649e4b769fbeb4074: Merge tag 'efi-2024-10-rc4' of https://source.denx.de/u-boot/custodians/u-boot-efi (2024-08-24 14:03:28 -0600) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-amlogic.git tags/u-boot-amlogic-next-20240902 for you to fetch changes up to 35ff967a99e97b523732096628bdbc78758922f6: mtd: rawnand: meson: read/write access for boot ROM pages (2024-08-28 16:05:45 +0200) ---------------------------------------------------------------- - meson_nand: R/W support for pages used by boot ROM ---------------------------------------------------------------- Arseniy Krasnov (3): mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()' mtd: rawnand: meson: read/write access for boot ROM pages drivers/mtd/nand/raw/meson_nand.c | 84 ++++++++++++++++++++++++++------------- drivers/mtd/nand/raw/nand_base.c | 3 ++ include/linux/mtd/rawnand.h | 5 +++ 3 files changed, 65 insertions(+), 27 deletions(-)
Started by Neil Armstrong @ · Most recent @
[PATCH v3 0/3] Meson: R/W support for pages used by boot ROM 2
Patchset is based on patchset for Linux (today merged to nand-next): https://lore.kernel.org/linux-mtd/20240507230903.3399594-1-avkrasnov@.../ Here is description from it: > Amlogic's boot ROM code needs that some pages on NAND must be written > in special "short" ECC mode with scrambling enabled. Such pages: > 1) Contain some metadata about hardware. > 2) Located with some interval starting from 0 offset, until some > specified offset. Interval and second offset are set in the > device tree. > > This patchset adds R/W support for such pages. To enable it we can setup > it in dts: > > nand-is-boot-medium; > amlogic,boot-pages = <1024>; > amlogic,boot-page-step = <128>; > > It means that each 128th page in range 0 to 1024 pages will be accessed > in special mode ("short" ECC + scrambling). In practice this feature is > needed when we want to update first block of NAND - driver will enable > required mode by itself using value from device tree. The only difference is that patchset for Linux updates DT bindings, while this adds NAND_IS_BOOT_MEDIUM flag support. Changelog: v1 -> v2: * Pls see per-patch changelog. v2 -> v3: * Pls see per-patch changelog. Arseniy Krasnov (3): mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()' mtd: rawnand: meson: read/write access for boot ROM pages drivers/mtd/nand/raw/meson_nand.c | 84 +++++++++++++++++++++---------- drivers/mtd/nand/raw/nand_base.c | 3 ++ include/linux/mtd/rawnand.h | 5 ++ 3 files changed, 65 insertions(+), 27 deletions(-) -- 2.30.1
Started by Arseniy Krasnov @ · Most recent @
[PATCH v3 3/3] mtd: rawnand: meson: read/write access for boot ROM pages
Boot ROM on Meson needs some pages to be read/written in a special mode: 384 byte ECC mode (so called "short" by Amlogic) and with scrambling enabled. Such pages are located on the chip in the following way (for example): [ p0 ][ p1 ][ p2 ][ p3 ][ p4 ][ p5 ][ p6 ][ p7 ] ... [ pN ] ^ ^ ^ ^ pX is page number "X". "^" means "special" page used by boot ROM - e.g. every 2nd page in the range of [0, 7]. Step (2 here) and last page in range is read from the device tree. Signed-off-by: Arseniy Krasnov <avkrasnov@...> Reviewed-by: Michael Trimarchi <michael@...> --- drivers/mtd/nand/raw/meson_nand.c | 56 +++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 2d77ee51ce..28c851f103 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -39,6 +39,7 @@ #define NFC_CMD_RB BIT(20) #define NFC_CMD_SCRAMBLER_ENABLE BIT(19) #define NFC_CMD_SCRAMBLER_DISABLE 0 +#define NFC_CMD_SHORTMODE_ENABLE 1 #define NFC_CMD_SHORTMODE_DISABLE 0 #define NFC_CMD_RB_INT BIT(14) #define NFC_CMD_RB_INT_NO_PIN ((0xb << 10) | BIT(18) | BIT(16)) @@ -77,6 +78,8 @@ #define DMA_DIR(dir) ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N) +#define NFC_SHORT_MODE_ECC_SZ 384 + #define ECC_CHECK_RETURN_FF -1 #define NAND_CE0 (0xe << 10) @@ -140,6 +143,8 @@ struct meson_nfc_nand_chip { struct list_head node; struct nand_chip nand; + u32 boot_pages; + u32 boot_page_step; u32 bch_mode; u8 *data_buf; @@ -228,33 +233,46 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) nfc->reg_base + NFC_REG_CMD); } +static int meson_nfc_is_boot_page(struct nand_chip *nand, int page) +{ + const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); + + return (nand->options & NAND_IS_BOOT_MEDIUM) && + !(page % meson_chip->boot_page_step) && + (page < meson_chip->boot_pages); +} + static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page) { + const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); struct mtd_info *mtd = nand_to_mtd(nand); const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd)); - const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); - u32 bch = meson_chip->bch_mode, cmd; int len = mtd->writesize, pagesize, pages; unsigned int scrambler; + u32 cmd; if (nand->options & NAND_NEED_SCRAMBLING) scrambler = NFC_CMD_SCRAMBLER_ENABLE; else scrambler = NFC_CMD_SCRAMBLER_DISABLE; - pagesize = nand->ecc.size; - if (raw) { len = mtd->writesize + mtd->oobsize; cmd = len | scrambler | DMA_DIR(dir); - writel(cmd, nfc->reg_base + NFC_REG_CMD); - return; - } + } else if (meson_nfc_is_boot_page(nand, page)) { + pagesize = NFC_SHORT_MODE_ECC_SZ >> 3; + pages = mtd->writesize / 512; - pages = len / nand->ecc.size; + scrambler = NFC_CMD_SCRAMBLER_ENABLE; + cmd = CMDRWGEN(DMA_DIR(dir), scrambler, NFC_ECC_BCH8_1K, + NFC_CMD_SHORTMODE_ENABLE, pagesize, pages); + } else { + pagesize = nand->ecc.size >> 3; + pages = len / nand->ecc.size; - cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch, - NFC_CMD_SHORTMODE_DISABLE, pagesize, pages); + cmd = CMDRWGEN(DMA_DIR(dir), scrambler, meson_chip->bch_mode, + NFC_CMD_SHORTMODE_DISABLE, pagesize, pages); + } if (scrambler == NFC_CMD_SCRAMBLER_ENABLE) meson_nfc_cmd_seed(nfc, page); @@ -1131,6 +1149,24 @@ static int meson_nfc_nand_chip_init(struct udevice *dev, struct meson_nfc *nfc, goto err_chip_buf_free; } + if (nand->options & NAND_IS_BOOT_MEDIUM) { + ret = ofnode_read_u32(node, "amlogic,boot-pages", + &meson_chip->boot_pages); + if (ret) { + dev_err(dev, "could not retrieve 'amlogic,boot-pages' property: %d", + ret); + goto err_chip_buf_free; + } + + ret = ofnode_read_u32(node, "amlogic,boot-page-step", + &meson_chip->boot_page_step); + if (ret) { + dev_err(dev, "could not retrieve 'amlogic,boot-page-step' property: %d", + ret); + goto err_chip_buf_free; + } + } + ret = nand_register(0, mtd); if (ret) { dev_err(dev, "'nand_register()' failed: %d\n", ret); -- 2.30.1
Started by Arseniy Krasnov @
[PATCH v2 3/3] mtd: rawnand: meson: read/write access for boot ROM pages 5
Boot ROM on Meson needs some pages to be read/written in a special mode: 384 byte ECC mode (so called "short" by Amlogic) and with scrambling enabled. Such pages are located on the chip in the following way (for example): [ p0 ][ p1 ][ p2 ][ p3 ][ p4 ][ p5 ][ p6 ][ p7 ] ... [ pN ] ^ ^ ^ ^ pX is page number "X". "^" means "special" page used by boot ROM - e.g. every 2nd page in the range of [0, 7]. Step (2 here) and last page in range is read from the device tree. Signed-off-by: Arseniy Krasnov <avkrasnov@...> --- drivers/mtd/nand/raw/meson_nand.c | 56 +++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 19f005202b..54ea035d8d 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -40,6 +40,7 @@ #define NFC_CMD_RB BIT(20) #define NFC_CMD_SCRAMBLER_ENABLE BIT(19) #define NFC_CMD_SCRAMBLER_DISABLE 0 +#define NFC_CMD_SHORTMODE_ENABLE 1 #define NFC_CMD_SHORTMODE_DISABLE 0 #define NFC_CMD_RB_INT BIT(14) #define NFC_CMD_RB_INT_NO_PIN ((0xb << 10) | BIT(18) | BIT(16)) @@ -78,6 +79,8 @@ #define DMA_DIR(dir) ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N) +#define NFC_SHORT_MODE_ECC_SZ 384 + #define ECC_CHECK_RETURN_FF -1 #define NAND_CE0 (0xe << 10) @@ -141,6 +144,8 @@ struct meson_nfc_nand_chip { struct list_head node; struct nand_chip nand; + u32 boot_pages; + u32 boot_page_step; u32 bch_mode; u8 *data_buf; @@ -229,33 +234,46 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) nfc->reg_base + NFC_REG_CMD); } +static int meson_nfc_is_boot_page(struct nand_chip *nand, int page) +{ + const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); + + return (nand->options & NAND_IS_BOOT_MEDIUM) && + !(page % meson_chip->boot_page_step) && + (page < meson_chip->boot_pages); +} + static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page) { + const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); struct mtd_info *mtd = nand_to_mtd(nand); const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd)); - const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); - u32 bch = meson_chip->bch_mode, cmd; int len = mtd->writesize, pagesize, pages; int scrambler; + u32 cmd; if (nand->options & NAND_NEED_SCRAMBLING) scrambler = NFC_CMD_SCRAMBLER_ENABLE; else scrambler = NFC_CMD_SCRAMBLER_DISABLE; - pagesize = nand->ecc.size; - if (raw) { len = mtd->writesize + mtd->oobsize; cmd = len | scrambler | DMA_DIR(dir); - writel(cmd, nfc->reg_base + NFC_REG_CMD); - return; - } + } else if (meson_nfc_is_boot_page(nand, page)) { + pagesize = NFC_SHORT_MODE_ECC_SZ >> 3; + pages = mtd->writesize / 512; - pages = len / nand->ecc.size; + scrambler = NFC_CMD_SCRAMBLER_ENABLE; + cmd = CMDRWGEN(DMA_DIR(dir), scrambler, NFC_ECC_BCH8_1K, + NFC_CMD_SHORTMODE_ENABLE, pagesize, pages); + } else { + pagesize = nand->ecc.size >> 3; + pages = len / nand->ecc.size; - cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch, - NFC_CMD_SHORTMODE_DISABLE, pagesize, pages); + cmd = CMDRWGEN(DMA_DIR(dir), scrambler, meson_chip->bch_mode, + NFC_CMD_SHORTMODE_DISABLE, pagesize, pages); + } if (scrambler == NFC_CMD_SCRAMBLER_ENABLE) meson_nfc_cmd_seed(nfc, page); @@ -1132,6 +1150,24 @@ static int meson_nfc_nand_chip_init(struct udevice *dev, struct meson_nfc *nfc, goto err_chip_buf_free; } + if (nand->options & NAND_IS_BOOT_MEDIUM) { + ret = ofnode_read_u32(node, "amlogic,boot-pages", + &meson_chip->boot_pages); + if (ret) { + dev_err(dev, "could not retrieve 'amlogic,boot-pages' property: %d", + ret); + goto err_chip_buf_free; + } + + ret = ofnode_read_u32(node, "amlogic,boot-page-step", + &meson_chip->boot_page_step); + if (ret) { + dev_err(dev, "could not retrieve 'amlogic,boot-page-step' property: %d", + ret); + goto err_chip_buf_free; + } + } + ret = nand_register(0, mtd); if (ret) { dev_err(dev, "'nand_register()' failed: %d\n", ret); -- 2.30.1
Started by Arseniy Krasnov @ · Most recent @
[PATCH v3 1/3] mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag
Based on Linux kernel: commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device") Allow to define a NAND chip as a boot device. This can be helpful for the selection of the ECC algorithm and strength in case the boot ROM supports only a subset of controller provided options. Signed-off-by: Arseniy Krasnov <avkrasnov@...> Reviewed-by: Michael Trimarchi <michael@...> --- Changelog: v1 -> v2: * Place 'NAND_IS_BOOT_MEDIUM' according its numerical value. v2 -> v3: * Rebase on last master. drivers/mtd/nand/raw/nand_base.c | 3 +++ include/linux/mtd/rawnand.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 688d17ba3c..a7474574f8 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod if (ret == 16) chip->options |= NAND_BUSWIDTH_16; + if (ofnode_read_bool(node, "nand-is-boot-medium")) + chip->options |= NAND_IS_BOOT_MEDIUM; + if (ofnode_read_bool(node, "nand-on-flash-bbt")) chip->bbt_options |= NAND_BBT_USE_FLASH; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 4abaf4734c..0e7b5f852c 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -248,6 +248,11 @@ enum nand_ecc_algo { * kmap'ed, vmalloc'ed highmem buffers being passed from upper layers */ #define NAND_USE_BOUNCE_BUFFER 0x00100000 +/* + * Whether the NAND chip is a boot medium. Drivers might use this information + * to select ECC algorithms supported by the boot ROM or similar restrictions. + */ +#define NAND_IS_BOOT_MEDIUM 0x00400000 /* * Do not try to tweak the timings at runtime. This is needed when the -- 2.30.1
Started by Arseniy Krasnov @
[PATCH v3 2/3] mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()'
Move call 'meson_nfc_cmd_seed()' and check for 'NAND_NEED_SCRAMBLING' to 'meson_nfc_cmd_access()', thus removing code duplication. Signed-off-by: Arseniy Krasnov <avkrasnov@...> Reviewed-by: Michael Trimarchi <michael@...> --- Changelog: v2 -> v3: * Declare 'scrambler' as 'unsigned int'. drivers/mtd/nand/raw/meson_nand.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 12499a7947..2d77ee51ce 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -228,14 +228,19 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) nfc->reg_base + NFC_REG_CMD); } -static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, - int scrambler) +static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page) { struct mtd_info *mtd = nand_to_mtd(nand); const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd)); const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); u32 bch = meson_chip->bch_mode, cmd; int len = mtd->writesize, pagesize, pages; + unsigned int scrambler; + + if (nand->options & NAND_NEED_SCRAMBLING) + scrambler = NFC_CMD_SCRAMBLER_ENABLE; + else + scrambler = NFC_CMD_SCRAMBLER_DISABLE; pagesize = nand->ecc.size; @@ -251,6 +256,9 @@ static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch, NFC_CMD_SHORTMODE_DISABLE, pagesize, pages); + if (scrambler == NFC_CMD_SCRAMBLER_ENABLE) + meson_nfc_cmd_seed(nfc, page); + writel(cmd, nfc->reg_base + NFC_REG_CMD); } @@ -565,14 +573,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand, return ret; } - if (nand->options & NAND_NEED_SCRAMBLING) { - meson_nfc_cmd_seed(nfc, page); - meson_nfc_cmd_access(nand, raw, DIRWRITE, - NFC_CMD_SCRAMBLER_ENABLE); - } else { - meson_nfc_cmd_access(nand, raw, DIRWRITE, - NFC_CMD_SCRAMBLER_DISABLE); - } + meson_nfc_cmd_access(nand, raw, DIRWRITE, page); cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG; writel(cmd, nfc->reg_base + NFC_REG_CMD); @@ -643,14 +644,7 @@ static int meson_nfc_read_page_sub(struct nand_chip *nand, if (ret) return ret; - if (nand->options & NAND_NEED_SCRAMBLING) { - meson_nfc_cmd_seed(nfc, page); - meson_nfc_cmd_access(nand, raw, DIRREAD, - NFC_CMD_SCRAMBLER_ENABLE); - } else { - meson_nfc_cmd_access(nand, raw, DIRREAD, - NFC_CMD_SCRAMBLER_DISABLE); - } + meson_nfc_cmd_access(nand, raw, DIRREAD, page); meson_nfc_wait_dma_finish(nfc); meson_nfc_check_ecc_pages_valid(nfc, nand, raw); -- 2.30.1
Started by Arseniy Krasnov @
[PATCH v2 0/3] Meson: R/W support for pages used by boot ROM 9
Patchset is based on patchset for Linux (today merged to nand-next): https://lore.kernel.org/linux-mtd/20240507230903.3399594-1-avkrasnov@.../ Here is description from it: > Amlogic's boot ROM code needs that some pages on NAND must be written > in special "short" ECC mode with scrambling enabled. Such pages: > 1) Contain some metadata about hardware. > 2) Located with some interval starting from 0 offset, until some > specified offset. Interval and second offset are set in the > device tree. > > This patchset adds R/W support for such pages. To enable it we can setup > it in dts: > > nand-is-boot-medium; > amlogic,boot-pages = <1024>; > amlogic,boot-page-step = <128>; > > It means that each 128th page in range 0 to 1024 pages will be accessed > in special mode ("short" ECC + scrambling). In practice this feature is > needed when we want to update first block of NAND - driver will enable > required mode by itself using value from device tree. The only difference is that patchset for Linux updates DT bindings, while this adds NAND_IS_BOOT_MEDIUM flag support. Changelog: v1 -> v2: * Pls see per-patch changelog. Arseniy Krasnov (3): mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()' mtd: rawnand: meson: read/write access for boot ROM pages drivers/mtd/nand/raw/meson_nand.c | 84 +++++++++++++++++++++---------- drivers/mtd/nand/raw/nand_base.c | 3 ++ include/linux/mtd/rawnand.h | 5 ++ 3 files changed, 65 insertions(+), 27 deletions(-) -- 2.30.1
Started by Arseniy Krasnov @ · Most recent @
Current Image
Image Name
Sat 8:39am