Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reset: microchip-sparx5: issue a reset on startup

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
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/20220826115607.1148489-2-michael@walle.cc

authored by

Michael Walle and committed by
Philipp Zabel
51fd1914 051d9eb4

+17 -5
+17 -5
drivers/reset/reset-microchip-sparx5.c
··· 33 33 .reg_stride = 4, 34 34 }; 35 35 36 - static int sparx5_switch_reset(struct reset_controller_dev *rcdev, 37 - unsigned long id) 36 + static int sparx5_switch_reset(struct mchp_reset_context *ctx) 38 37 { 39 - struct mchp_reset_context *ctx = 40 - container_of(rcdev, struct mchp_reset_context, rcdev); 41 38 u32 val; 42 39 43 40 /* Make sure the core is PROTECTED from reset */ ··· 51 54 1, 100); 52 55 } 53 56 57 + static int sparx5_reset_noop(struct reset_controller_dev *rcdev, 58 + unsigned long id) 59 + { 60 + return 0; 61 + } 62 + 54 63 static const struct reset_control_ops sparx5_reset_ops = { 55 - .reset = sparx5_switch_reset, 64 + .reset = sparx5_reset_noop, 56 65 }; 57 66 58 67 static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name, ··· 125 122 ctx->rcdev.of_node = dn; 126 123 ctx->props = device_get_match_data(&pdev->dev); 127 124 125 + /* Issue the reset very early, our actual reset callback is a noop. */ 126 + err = sparx5_switch_reset(ctx); 127 + if (err) 128 + return err; 129 + 128 130 return devm_reset_controller_register(&pdev->dev, &ctx->rcdev); 129 131 } 130 132 ··· 171 163 return platform_driver_register(&mchp_sparx5_reset_driver); 172 164 } 173 165 166 + /* 167 + * Because this is a global reset, keep this postcore_initcall() to issue the 168 + * reset as early as possible during the kernel startup. 169 + */ 174 170 postcore_initcall(mchp_sparx5_reset_init); 175 171 176 172 MODULE_DESCRIPTION("Microchip Sparx5 switch reset driver");