Message ID | 20220826115607.1148489-2-michael@walle.cc (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | reset: microchip-sparx5: fix the broken switch reset | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/cc_maintainers | success | CCed 5 of 5 maintainers |
netdev/build_clang | success | Errors and warnings before: 5 this patch: 5 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 48 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
Hi Michael, On Fri, 2022-08-26 at 13:56 +0200, Michael Walle wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > Originally this was used in by the switch core driver to issue a reset. > But it turns out, this isn't just a switch core reset but instead it > will reset almost the complete SoC. > > Instead of adding almost all devices of the SoC a shared reset line, > issue the reset once early on startup. Keep the reset controller for > backwards compatibility, but make the actual reset a noop. > > Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> > Signed-off-by: Michael Walle <michael@walle.cc> > --- > drivers/reset/reset-microchip-sparx5.c | 22 +++++++++++++++++----- > 1 file changed, 17 insertions(+), 5 deletions(-) > > diff --git a/drivers/reset/reset-microchip-sparx5.c b/drivers/reset/reset-microchip-sparx5.c > index 00b612a0effa..f3528dd1d084 100644 > --- a/drivers/reset/reset-microchip-sparx5.c > +++ b/drivers/reset/reset-microchip-sparx5.c > @@ -33,11 +33,8 @@ static struct regmap_config sparx5_reset_regmap_config = { > .reg_stride = 4, > }; > > -static int sparx5_switch_reset(struct reset_controller_dev *rcdev, > - unsigned long id) > +static int sparx5_switch_reset(struct mchp_reset_context *ctx) > { > - struct mchp_reset_context *ctx = > - container_of(rcdev, struct mchp_reset_context, rcdev); > u32 val; > > /* Make sure the core is PROTECTED from reset */ > @@ -54,8 +51,14 @@ static int sparx5_switch_reset(struct reset_controller_dev *rcdev, > 1, 100); > } > > +static int sparx5_reset_noop(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + return 0; > +} > + > static const struct reset_control_ops sparx5_reset_ops = { > - .reset = sparx5_switch_reset, > + .reset = sparx5_reset_noop, > }; > > static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name, > @@ -122,6 +125,11 @@ static int mchp_sparx5_reset_probe(struct platform_device *pdev) > ctx->rcdev.of_node = dn; > ctx->props = device_get_match_data(&pdev->dev); > > + /* Issue the reset very early, our actual reset callback is a noop. */ > + err = sparx5_switch_reset(ctx); > + if (err) > + return err; > + > return devm_reset_controller_register(&pdev->dev, &ctx->rcdev); > } > > @@ -163,6 +171,10 @@ static int __init mchp_sparx5_reset_init(void) > return platform_driver_register(&mchp_sparx5_reset_driver); > } > > +/* > + * Because this is a global reset, keep this postcore_initcall() to issue the > + * reset as early as possible during the kernel startup. > + */ > postcore_initcall(mchp_sparx5_reset_init); > > MODULE_DESCRIPTION("Microchip Sparx5 switch reset driver"); > -- > 2.30.2 > Tested-by: Steen Hegelund <Steen.Hegelund@microchip.com> on Sparx5 BR Steen
Hi Steen, Am 2022-08-29 11:14, schrieb Steen Hegelund: > On Fri, 2022-08-26 at 13:56 +0200, Michael Walle wrote: >> EXTERNAL EMAIL: Do not click links or open attachments unless you know >> the content is safe >> >> Originally this was used in by the switch core driver to issue a >> reset. >> But it turns out, this isn't just a switch core reset but instead it >> will reset almost the complete SoC. >> >> Instead of adding almost all devices of the SoC a shared reset line, >> issue the reset once early on startup. Keep the reset controller for >> backwards compatibility, but make the actual reset a noop. >> >> Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> >> Signed-off-by: Michael Walle <michael@walle.cc> .. > Tested-by: Steen Hegelund <Steen.Hegelund@microchip.com> on Sparx5 Thanks for testing! -michael
On Fr, 2022-08-26 at 13:56 +0200, Michael Walle wrote: > Originally this was used in by the switch core driver to issue a reset. > But it turns out, this isn't just a switch core reset but instead it > will reset almost the complete SoC. > > Instead of adding almost all devices of the SoC a shared reset line, > issue the reset once early on startup. Keep the reset controller for > backwards compatibility, but make the actual reset a noop. > > Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> > Signed-off-by: Michael Walle <michael@walle.cc> I've applied this patch to the reset/fixes branch. regards Philipp
diff --git a/drivers/reset/reset-microchip-sparx5.c b/drivers/reset/reset-microchip-sparx5.c index 00b612a0effa..f3528dd1d084 100644 --- a/drivers/reset/reset-microchip-sparx5.c +++ b/drivers/reset/reset-microchip-sparx5.c @@ -33,11 +33,8 @@ static struct regmap_config sparx5_reset_regmap_config = { .reg_stride = 4, }; -static int sparx5_switch_reset(struct reset_controller_dev *rcdev, - unsigned long id) +static int sparx5_switch_reset(struct mchp_reset_context *ctx) { - struct mchp_reset_context *ctx = - container_of(rcdev, struct mchp_reset_context, rcdev); u32 val; /* Make sure the core is PROTECTED from reset */ @@ -54,8 +51,14 @@ static int sparx5_switch_reset(struct reset_controller_dev *rcdev, 1, 100); } +static int sparx5_reset_noop(struct reset_controller_dev *rcdev, + unsigned long id) +{ + return 0; +} + static const struct reset_control_ops sparx5_reset_ops = { - .reset = sparx5_switch_reset, + .reset = sparx5_reset_noop, }; static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name, @@ -122,6 +125,11 @@ static int mchp_sparx5_reset_probe(struct platform_device *pdev) ctx->rcdev.of_node = dn; ctx->props = device_get_match_data(&pdev->dev); + /* Issue the reset very early, our actual reset callback is a noop. */ + err = sparx5_switch_reset(ctx); + if (err) + return err; + return devm_reset_controller_register(&pdev->dev, &ctx->rcdev); } @@ -163,6 +171,10 @@ static int __init mchp_sparx5_reset_init(void) return platform_driver_register(&mchp_sparx5_reset_driver); } +/* + * Because this is a global reset, keep this postcore_initcall() to issue the + * reset as early as possible during the kernel startup. + */ postcore_initcall(mchp_sparx5_reset_init); MODULE_DESCRIPTION("Microchip Sparx5 switch reset driver");
Originally this was used in by the switch core driver to issue a reset. But it turns out, this isn't just a switch core reset but instead it will reset almost the complete SoC. Instead of adding almost all devices of the SoC a shared reset line, issue the reset once early on startup. Keep the reset controller for backwards compatibility, but make the actual reset a noop. Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Michael Walle <michael@walle.cc> --- drivers/reset/reset-microchip-sparx5.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)