reset: stm32: Add support of MCU HOLD BOOT
Subsystems (5)
PATCH 1/3 reset: stm32: Add support of MCU HOLD BOOT
Handle the register RCC_MP_GCR without SET/CLR registers but with a direct access to bit BOOT_MCU:
- deassert => set the bit: The MCU will not be in HOLD_BOOT
- assert => clear the bit: The MCU will be set in HOLD_BOOT
With this patch the RCC driver handles the MCU_HOLD_BOOT_R value added in binding stm32mp1-resets.h
---
drivers/reset/stm32-reset.c | 17 +++++++++++++---- include/dt-bindings/reset/stm32mp1-resets.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/reset/stm32-reset.c +13 -4
@@ -14,6 +14,9 @@#include <asm/io.h> #include <linux/bitops.h> +/* offset of register without set/clear management */ +#define RCC_MP_GCR_OFFSET 0x10C +/* reset clear offset for STM32MP RCC */ #define RCC_CL 0x4
@@ -40,8 +43,11 @@ static int stm32_reset_assert(struct reset_ctl *reset_ctl) reset_ctl->id, bank, offset);if (dev_get_driver_data (reset_ctl->dev) ==STM32MP1 ) -/* reset assert is done in rcc set register */ -writel (BIT (offset), priv->base + bank); +if (bank !=RCC_MP_GCR_OFFSET ) +/* reset assert is done in rcc set register */ +writel (BIT (offset), priv->base + bank); +else +clrbits_le32 (priv->base + bank,BIT (offset));else setbits_le32 (priv->base + bank,BIT (offset));
@@ -57,8 +63,11 @@ static int stm32_reset_deassert(struct reset_ctl *reset_ctl) reset_ctl->id, bank, offset);if (dev_get_driver_data (reset_ctl->dev) ==STM32MP1 ) -/* reset deassert is done in rcc clr register */ -writel (BIT (offset), priv->base + bank +RCC_CL ); +if (bank !=RCC_MP_GCR_OFFSET ) +/* reset deassert is done in rcc clr register */ +writel (BIT (offset), priv->base + bank +RCC_CL ); +else +setbits_le32 (priv->base + bank,BIT (offset));else clrbits_le32 (priv->base + bank,BIT (offset));
include/dt-bindings/reset/stm32mp1-resets.h +1 -0
@@ -7,6 +7,7 @@#ifndef _DT_BINDINGS_STM32MP1_RESET_H_#define _DT_BINDINGS_STM32MP1_RESET_H_ +#define MCU_HOLD_BOOT_R 2144#define LTDC_R 3072#define DSI_R 3076#define DDRPERFM_R 3080
Signature · 1 line
2.17.1
PATCH 1/3 reset: stm32: Add support of MCU HOLD BOOT
Hi,
Quoted 11 lines
From: Patrick DELAUNAY <[email protected]>
Sent: jeudi 15 octobre 2020 15:01Handle the register
RCC_MP_GCRwithout SET/CLR registers but with a direct access to bitBOOT_MCU:
- deassert => set the bit: The MCU will not be inHOLD_BOOT
- assert => clear the bit: The MCU will be set inHOLD_BOOTWith this patch the RCC driver handles the
MCU_HOLD_BOOT_Rvalue added in bindingstm32mp1-resets.h
Quoted 9 lines
Cc Fabien DESSENNE <[email protected]>Cc Arnaud POULIQUEN <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
drivers/reset/stm32-reset.c | 17 +++++++++++++---- include/dt-bindings/reset/stm32mp1-resets.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-)
Applied to u-boot-stm/master, thanks!
Regards
Patrick
PATCH 2/3 remoteproc: stm32: use reset for hold boot
In reply to Patrick DelaunayUse the reset function to handle the hold boot bit in RCC with device tree handle with MCU_HOLD_BOOT identifier.
This generic reset allows to remove the two specific properties:
- st,syscfg-holdboot
- st,syscfg-tz
This patch prepares alignment with kernel device tree.
---
arch/arm/dts/stm32mp15-u-boot.dtsi | 7 +++ drivers/remoteproc/stm32_copro.c | 93 ++++++++---------------------- 2 files changed, 32 insertions(+), 68 deletions(-)
arch/arm/dts/stm32mp15-u-boot.dtsi +7 -0
@@ -159,6 +159,13 @@ u-boot,dm-pre-proper; }; +/* temp = waiting kernel update */ +&m4_rproc { + resets = <&rcc MCU_R>, + <&rcc MCU_HOLD_BOOT_R>; + reset-names = "mcu_rst", "hold_boot"; +}; + &pinctrl { u-boot,dm-pre-reloc; };
drivers/remoteproc/stm32_copro.c +25 -68
156 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 2/3 remoteproc: stm32: use reset for hold boot
Hi Patrick
Quoted 192 lines · Patrick Delaunay
Use the reset function to handle the hold boot bit in RCC with device tree handle with
MCU_HOLD_BOOTidentifier.This generic reset allows to remove the two specific properties:
- st,syscfg-holdboot
- st,syscfg-tzThis patch prepares alignment with kernel device tree.
Signed-off-by Patrick Delaunay <[email protected]>Cc Fabien DESSENNE <[email protected]>Cc Arnaud POULIQUEN <[email protected]>---
arch/arm/dts/stm32mp15-u-boot.dtsi | 7 +++ drivers/remoteproc/stm32_copro.c | 93 ++++++++---------------------- 2 files changed, 32 insertions(+), 68 deletions(-)arch/arm/dts/stm32mp15-u-boot.dtsi +7
-0@@ -159,6 +159,13 @@ u-boot,dm-pre-proper; }; +/* temp = waiting kernel update */ +&m4_rproc { + resets = <&rcc MCU_R>, + <&rcc MCU_HOLD_BOOT_R>; + reset-names = "mcu_rst", "hold_boot"; +}; + &pinctrl { u-boot,dm-pre-reloc; };drivers/remoteproc/stm32_copro.c +21
-66@@ -8,30 +8,21 @@#include <errno.h> #include <fdtdec.h> #include <log.h> -#include <regmap.h> #include <remoteproc.h> #include <reset.h> -#include <syscon.h> #include <asm/io.h> #include <dm/device_compat.h> #include <linux/err.h> -#define RCC_GCR_HOLD_BOOT 0 -#define RCC_GCR_RELEASE_BOOT 1 -/** * struct stm32_copro_privdata - power processor private data * @reset_ctl: reset controller handle -* @hold_boot_regmap: regmap for remote processor reset hold boot -* @hold_boot_offset: offset of the register controlling the hold boot setting -* @hold_boot_mask: bitmask of the register for the hold boot field +* @hold_boot: hold boot controller handle * @rsc_table_addr: resource table address */ struct stm32_copro_privdata {struct reset_ctl reset_ctl; -struct regmap *hold_boot_regmap; -uint hold_boot_offset; -uint hold_boot_mask; +struct reset_ctl hold_boot;ulong rsc_table_addr; };@@ -43,32 +34,19 @@ struct stm32_copro_privdata {static int stm32_copro_probe (struct udevice *dev) {struct stm32_copro_privdata *priv; -struct regmap *regmap; -const fdt32_t *cell; -int len, ret; +int ret; priv =dev_get_priv (dev); - regmap =syscon_regmap_lookup_by_phandle (dev,"st,syscfg-holdboot" ); -if (IS_ERR (regmap)) { -dev_err (dev,"unable to find holdboot regmap (%ld)\n" , -PTR_ERR (regmap)); -return PTR_ERR (regmap); - } - - cell =dev_read_prop (dev,"st,syscfg-holdboot" , &len); -if (len <3 *sizeof (fdt32_t)) { -dev_err (dev,"holdboot offset and mask not available\n" ); -return -EINVAL ; + ret =reset_get_by_name (dev,"mcu_rst" , &priv->reset_ctl); +if (ret) { +dev_err (dev,"failed to get reset (%d)\n" , ret); +return ret; } - priv->hold_boot_regmap = regmap; - priv->hold_boot_offset =fdtdec_get_number (cell +1 ,1 ); - priv->hold_boot_mask =fdtdec_get_number (cell +2 ,1 ); - - ret =reset_get_by_index (dev,0 , &priv->reset_ctl); + ret =reset_get_by_name (dev,"hold_boot" , &priv->hold_boot);if (ret) { -dev_err (dev,"failed to get reset (%d)\n" , ret); +dev_err (dev,"failed to get hold boot (%d)\n" , ret);return ret; }@@ -77,35 +55,6 @@ static int stm32_copro_probe(struct udevice *dev)return 0 ; } -/** -* stm32_copro_set_hold_boot() - Hold boot bit management -* @dev: corresponding STM32 remote processor device -* @hold: hold boot value -* @return 0 if all went ok, else corresponding -ve error -*/ -static int stm32_copro_set_hold_boot (struct udevice *dev,bool hold) -{ -struct stm32_copro_privdata *priv; -uint val; -int ret; - - priv =dev_get_priv (dev); - - val = hold ?RCC_GCR_HOLD_BOOT :RCC_GCR_RELEASE_BOOT ; - -/* -* Note: shall run an SMC call (STM32_SMC_RCC) if platform is secured. -* To be updated when the code for this SMC service is available which -* is not the case for the time being. -*/ - ret =regmap_update_bits (priv->hold_boot_regmap, priv->hold_boot_offset, - priv->hold_boot_mask, val); -if (ret) -dev_err (dev,"failed to set hold boot\n" ); - -return ret; -} -/** * stm32_copro_device_to_virt() - Convert device address to virtual address * @dev: corresponding STM32 remote processor device @@ -149,9 +98,11 @@ static int stm32_copro_load(struct udevice *dev, ulong addr, ulong size) priv =dev_get_priv (dev); - ret =stm32_copro_set_hold_boot (dev, true); -if (ret) + ret =reset_assert (&priv->hold_boot); +if (ret) { +dev_err (dev,"Unable to assert hold boot (ret=%d)\n" , ret);return ret; + } ret =reset_assert (&priv->reset_ctl);if (ret) {@@ -180,16 +131,20 @@ static int stm32_copro_start(struct udevice *dev) priv =dev_get_priv (dev); -/* move hold boot from true to false start the copro */ - ret =stm32_copro_set_hold_boot (dev, false); -if (ret) + ret =reset_deassert (&priv->hold_boot); +if (ret) { +dev_err (dev,"Unable to deassert hold boot (ret=%d)\n" , ret);return ret; + }/* * Once copro running, reset hold boot flag to avoid copro * rebooting autonomously */ - ret =stm32_copro_set_hold_boot (dev, true); + ret =reset_assert (&priv->hold_boot); +if (ret) +dev_err (dev,"Unable to assert hold boot (ret=%d)\n" , ret); +writel (ret ?TAMP_COPRO_STATE_OFF :TAMP_COPRO_STATE_CRUN ,TAMP_COPRO_STATE );if (!ret)@@ -211,9 +166,11 @@ static int stm32_copro_reset(struct udevice *dev) priv =dev_get_priv (dev);
drivers/remoteproc/stm32_copro.c static int stm32_copro_reset(struct udevice *dev) · line 176
Quoted 10 lines
drivers/remoteproc/stm32_copro.c +4
-2- ret =stm32_copro_set_hold_boot (dev, true); -if (ret) + ret =reset_assert (&priv->hold_boot); +if (ret) { +dev_err (dev,"Unable to assert hold boot (ret=%d)\n" , ret);return ret; + } ret =reset_assert (&priv->reset_ctl);if (ret) {
Thanks
PATCH 2/3 remoteproc: stm32: use reset for hold boot
In reply to Patrick DelaunayHi,
Quoted 19 lines
From: Patrick DELAUNAY <[email protected]>
Sent: jeudi 15 octobre 2020 15:01
To: u-boot at lists.denx.de
Cc: Patrick DELAUNAY <[email protected]>; Fabien DESSENNE <[email protected]>; Arnaud POULIQUEN <[email protected]>; Patrice CHOTARD <[email protected]>; U-Boot STM32 <uboot-stm32@st- md-mailman.stormreply.com>
Subject: [PATCH 2/3] remoteproc: stm32: use reset for hold boot
Importance: HighUse the reset function to handle the hold boot bit in RCC with device tree handle with
MCU_HOLD_BOOTidentifier.This generic reset allows to remove the two specific properties:
- st,syscfg-holdboot
- st,syscfg-tzThis patch prepares alignment with kernel device tree.
Quoted 9 lines
Signed-off-by Patrick Delaunay <[email protected]>Cc Fabien DESSENNE <[email protected]>Cc Arnaud POULIQUEN <[email protected]>---
arch/arm/dts/stm32mp15-u-boot.dtsi | 7 +++ drivers/remoteproc/stm32_copro.c | 93 ++++++++---------------------- 2 files changed, 32 insertions(+), 68 deletions(-)
Applied to u-boot-stm/master, thanks!
Regards
Patrick
PATCH 1/3 reset: stm32: Add support of MCU HOLD BOOT
In reply to Patrick DelaunayHi Patrick
Quoted 64 lines · Patrick Delaunay
Handle the register
RCC_MP_GCRwithout SET/CLR registers but with a direct access to bitBOOT_MCU:
- deassert => set the bit: The MCU will not be inHOLD_BOOT
- assert => clear the bit: The MCU will be set inHOLD_BOOTWith this patch the RCC driver handles the
MCU_HOLD_BOOT_Rvalue added in bindingstm32mp1-resets.hCc Fabien DESSENNE <[email protected]>Cc Arnaud POULIQUEN <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
drivers/reset/stm32-reset.c | 17 +++++++++++++---- include/dt-bindings/reset/stm32mp1-resets.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-)drivers/reset/stm32-reset.c +13
-4@@ -14,6 +14,9 @@#include <asm/io.h> #include <linux/bitops.h> +/* offset of register without set/clear management */ +#define RCC_MP_GCR_OFFSET 0x10C +/* reset clear offset for STM32MP RCC */ #define RCC_CL 0x4@@ -40,8 +43,11 @@ static int stm32_reset_assert(struct reset_ctl *reset_ctl) reset_ctl->id, bank, offset);if (dev_get_driver_data (reset_ctl->dev) ==STM32MP1 ) -/* reset assert is done in rcc set register */ -writel (BIT (offset), priv->base + bank); +if (bank !=RCC_MP_GCR_OFFSET ) +/* reset assert is done in rcc set register */ +writel (BIT (offset), priv->base + bank); +else +clrbits_le32 (priv->base + bank,BIT (offset));else setbits_le32 (priv->base + bank,BIT (offset));@@ -57,8 +63,11 @@ static int stm32_reset_deassert(struct reset_ctl *reset_ctl) reset_ctl->id, bank, offset);if (dev_get_driver_data (reset_ctl->dev) ==STM32MP1 ) -/* reset deassert is done in rcc clr register */ -writel (BIT (offset), priv->base + bank +RCC_CL ); +if (bank !=RCC_MP_GCR_OFFSET ) +/* reset deassert is done in rcc clr register */ +writel (BIT (offset), priv->base + bank +RCC_CL ); +else +setbits_le32 (priv->base + bank,BIT (offset));else clrbits_le32 (priv->base + bank,BIT (offset));include/dt-bindings/reset/stm32mp1-resets.h +0
-0
include/dt-bindings/reset/stm32mp1-resets.h line 13
Quoted 7 lines
include/dt-bindings/reset/stm32mp1-resets.h +1
-0@@ -7,6 +7,7 @@#ifndef _DT_BINDINGS_STM32MP1_RESET_H_#define _DT_BINDINGS_STM32MP1_RESET_H_ +#define MCU_HOLD_BOOT_R 2144#define LTDC_R 3072#define DSI_R 3076#define DDRPERFM_R 3080
Thanks
PATCH 3/3 remoteproc: stm32: update error management in stm32_copro_start
In reply to Patrick DelaunayThe coprocessor is running as soon as the hold boot is de-asserted.
So indicate this running state and save the resource table even if the protective assert, to avoid autonomous reboot, is failed.
This error case should never occurs.
---
drivers/remoteproc/stm32_copro.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/remoteproc/stm32_copro.c +6 -7
@@ -139,19 +139,18 @@ static int stm32_copro_start(struct udevice *dev)/* * Once copro running, reset hold boot flag to avoid copro -* rebooting autonomously +* rebooting autonomously (error should never occur) */ ret =reset_assert (&priv->hold_boot);if (ret)dev_err (dev,"Unable to assert hold boot (ret=%d)\n" , ret); -writel (ret ?TAMP_COPRO_STATE_OFF :TAMP_COPRO_STATE_CRUN , -TAMP_COPRO_STATE ); -if (!ret) -/* Store rsc_address in bkp register */ -writel (priv->rsc_table_addr,TAMP_COPRO_RSC_TBL_ADDRESS ); +/* indicates that copro is running */ +writel (TAMP_COPRO_STATE_CRUN ,TAMP_COPRO_STATE ); +/* Store rsc_address in bkp register */ +writel (priv->rsc_table_addr,TAMP_COPRO_RSC_TBL_ADDRESS ); -return ret; +return 0 ; }/**
Signature · 1 line
2.17.1
PATCH 3/3 remoteproc: stm32: update error management in stm32_copro_start
Hi Patrick
Quoted 36 lines · Patrick Delaunay
The coprocessor is running as soon as the hold boot is de-asserted.
So indicate this running state and save the resource table even if the protective assert, to avoid autonomous reboot, is failed.
This error case should never occurs.
Cc Fabien DESSENNE <[email protected]>Cc Arnaud POULIQUEN <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
drivers/remoteproc/stm32_copro.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/remoteproc/stm32_copro.c +1
-6@@ -139,19 +139,18 @@ static int stm32_copro_start(struct udevice *dev)/* * Once copro running, reset hold boot flag to avoid copro -* rebooting autonomously +* rebooting autonomously (error should never occur) */ ret =reset_assert (&priv->hold_boot);if (ret)dev_err (dev,"Unable to assert hold boot (ret=%d)\n" , ret); -writel (ret ?TAMP_COPRO_STATE_OFF :TAMP_COPRO_STATE_CRUN , -TAMP_COPRO_STATE ); -if (!ret) -/* Store rsc_address in bkp register */ -writel (priv->rsc_table_addr,TAMP_COPRO_RSC_TBL_ADDRESS );
drivers/remoteproc/stm32_copro.c static int stm32_copro_start(struct udevice *dev) · line 156
Quoted 10 lines
drivers/remoteproc/stm32_copro.c +5
-1+/* indicates that copro is running */ +writel (TAMP_COPRO_STATE_CRUN ,TAMP_COPRO_STATE ); +/* Store rsc_address in bkp register */ +writel (priv->rsc_table_addr,TAMP_COPRO_RSC_TBL_ADDRESS ); -return ret; +return 0 ; }/**
Thanks
PATCH 3/3 remoteproc: stm32: update error management in stm32_copro_start
In reply to Patrick DelaunayHi,
Quoted 11 lines
From: Patrick DELAUNAY <[email protected]>
Sent: jeudi 15 octobre 2020 15:01The coprocessor is running as soon as the hold boot is de-asserted.
So indicate this running state and save the resource table even if the protective assert, to avoid autonomous reboot, is failed.
This error case should never occurs.
Quoted 8 lines
Cc Fabien DESSENNE <[email protected]>Cc Arnaud POULIQUEN <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
drivers/remoteproc/stm32_copro.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Applied to u-boot-stm/master, thanks!
Regards
Patrick