Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(stm32) drivers: stm32_tamp: add support for stm32mp25x platforms + backup register config from DT #7129

Merged
merged 7 commits into from
Nov 27, 2024

Conversation

GseoC
Copy link
Contributor

@GseoC GseoC commented Nov 14, 2024

This P-R implements the backup registers configuration from the device tree and the stm32mp25x support.
It has a dependency on #7125 and should be merged afterwards.

There is a default st,backup-zones property at SoC level as it is mandatory to configure the backup registers secure level on our platforms. It can be superseeded at platform level.

core/drivers/stm32_tamp.c Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/include/drivers/stm32_tamp.h Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Show resolved Hide resolved
core/include/drivers/stm32_tamp.h Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/arch/arm/plat-stm32mp1/main.c Show resolved Hide resolved
@GseoC
Copy link
Contributor Author

GseoC commented Nov 18, 2024

Patchset reorganized and most of the comments applied. Some answers to you suggestions remaining.

core/drivers/stm32_tamp.c Show resolved Hide resolved
bkpregs_count = fdt32_to_cpu(cuint[0]);

pdata->bkpregs_conf->zone2_end = bkpregs_count +
fdt32_to_cpu(cuint[1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check DT property consistency?

assert(pdata->bkpregs_conf->zone2_end + fdt32_to_cpu(cuint[2]) ==
       stm32_tamp_dev->hwconf1 & _TAMP_HWCFGR1_BKPREG);

More than checking the consistency, it would highlight why we expect 3 cells but read only the 2 first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot do this at this stage of the probe sequence. I'll keep as is.

core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
@GseoC
Copy link
Contributor Author

GseoC commented Nov 19, 2024

Comments addressed. Added a temporary stm32_bkpregs_conf_new conf in the first source code commit to better handle the transition

*/
struct stm32_bkpregs_conf {
uint32_t nb_zone1_regs;
uint32_t nb_zone2_regs;
uint32_t *rif_offsets;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can discard changes in stm32_tamp.h.

core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Show resolved Hide resolved
Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment for commit "drivers: stm32_tamp: configure the backup registers when driver is probing".

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 added comments. (+ note the minor signedness issue than makes build to fail)

core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
@GseoC
Copy link
Contributor Author

GseoC commented Nov 25, 2024

Comments addressed

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments for commit "drivers: stm32_tamp: add stm32mp25 support for RIF configuration".

*
* (BHK => First 8 registers)
*/
pdata->bkpregs_conf.rif_offsets = calloc(4, sizeof(uint32_t));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/4/TAMP_RIF_OFFSET_CNT/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also adding a define for the number of zones.

core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments for commit "drivers: stm32_tamp: configure the backup registers when driver is probing".

core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
core/drivers/stm32_tamp.c Outdated Show resolved Hide resolved
@GseoC
Copy link
Contributor Author

GseoC commented Nov 27, 2024

Comments addressed

@etienne-lms
Copy link
Contributor

Reviewed-by: Etienne Carriere <[email protected]> for the whole series.

Add st,backup-zones property in TAMP node in stm32mp131.dtsi.
It defines the topology of the backup registers zones. The number of zones
on stm32mp13x platforms is 3.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
Add st,backup-zones property in TAMP node in stm32mp151.dtsi.
It defines the topology of the backup registers zones. The number of zones
on stm32mp13x platforms is 3.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
Add support for the RIF configuration of the TAMP peripheral. It covers
the TAMP resources such as monotonic counters but also backup registers
regions and sub-regions.

Create a stm32_tamp_platdata structure to hold platform data.

Add temporary stm32_bkpregs_conf_new structure that will be used by the
new implementation and renamed to stm32_bkpregs_conf when the old one
disappear.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
Add TAMP peripheral node in stm32mp251.dtsi. The TAMP peripheral manages
monotonic counters, tamper events and backup registers.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
Add a TAMP RIF configuration for stm32mp257f-ev1 board to configure
backup registers and TAMP resources.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
…obing

Update the driver to be able to configure the backup registers when
the driver is probing and remove call to stm32_tamp_set_secure_bkpregs()
in plat-stm32mp1 main.c.

Remove old implementation of stm32_bkpregs_conf structure and rename
stm32_bkpregs_conf_new to stm32_bkpregs_conf.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
Default enable TAMP peripheral support for stm32mp2x platforms.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
@GseoC
Copy link
Contributor Author

GseoC commented Nov 27, 2024

Tags applied, thanks

@jforissier jforissier merged commit b812547 into OP-TEE:master Nov 27, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants