This patch serie extends the Microchip Sparx5 reset driver to support
lan966x
v2->v3:
- rename variable reset_gpio to phy_reset_gpio
- rename gpios property in documentation to phy-reset-gpios
v1->v2:
- add reviewed-by tag
- extend driver to be able to release the reset also for external PHYs
Horatiu Vultur (2):
dt-bindings: reset: Add lan966x support
reset: mchp: sparx5: Extend support for lan966x
.../bindings/reset/microchip,rst.yaml | 14 +++-
drivers/reset/Kconfig | 2 +-
drivers/reset/reset-microchip-sparx5.c | 81 +++++++++++++++++--
3 files changed, 87 insertions(+), 10 deletions(-)
--
2.33.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
@@ -37,6 +41,14 @@ properties:$ref:"/schemas/types.yaml#/definitions/phandle"description:syscon used to access CPU reset+cuphy-syscon:+$ref:"/schemas/types.yaml#/definitions/phandle"+description:syscon used to access CuPHY++phy-reset-gpios:+description:used for release of reset of the external PHY+maxItems:1+required:-compatible-reg
--
2.33.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
This patch extends sparx5 driver to support also the lan966x. The
process to reset the switch is the same only it has different offsets.
Therefore make the driver more generic and add support for lan966x.
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/reset/Kconfig | 2 +-
drivers/reset/reset-microchip-sparx5.c | 81 +++++++++++++++++++++++---
2 files changed, 74 insertions(+), 9 deletions(-)
@@ -36,17 +44,39 @@ static int sparx5_switch_reset(struct reset_controller_dev *rcdev,structmchp_reset_context*ctx=container_of(rcdev,structmchp_reset_context,rcdev);u32val;+interr;/* Make sure the core is PROTECTED from reset */-regmap_update_bits(ctx->cpu_ctrl,PROTECT_REG,PROTECT_BIT,PROTECT_BIT);+regmap_update_bits(ctx->cpu_ctrl,ctx->props->protect_reg,+ctx->props->protect_bit,ctx->props->protect_bit);/* Start soft reset */-regmap_write(ctx->gcb_ctrl,SOFT_RESET_REG,SOFT_RESET_BIT);+regmap_write(ctx->gcb_ctrl,ctx->props->reset_reg,+ctx->props->reset_bit);/* Wait for soft reset done */-returnregmap_read_poll_timeout(ctx->gcb_ctrl,SOFT_RESET_REG,val,-(val&SOFT_RESET_BIT)==0,+err=regmap_read_poll_timeout(ctx->gcb_ctrl,ctx->props->reset_reg,val,+(val&ctx->props->reset_bit)==0,1,100);+if(err)+returnerr;++if(!ctx->cuphy_ctrl)+return0;++/* In case there are external PHYs toggle the GPIO to release the reset+*ofthePHYs+*/+if(ctx->phy_reset_gpio){+gpiod_direction_output(ctx->phy_reset_gpio,1);+gpiod_set_value(ctx->phy_reset_gpio,0);+gpiod_set_value(ctx->phy_reset_gpio,1);+gpiod_set_value(ctx->phy_reset_gpio,0);+}++/* Release the reset of internal PHY */+returnregmap_update_bits(ctx->cuphy_ctrl,ctx->props->cuphy_reg,+ctx->props->cuphy_bit,ctx->props->cuphy_bit);}staticconststructreset_control_opssparx5_reset_ops={
@@ -111,17 +141,52 @@ static int mchp_sparx5_reset_probe(struct platform_device *pdev)if(err)returnerr;+/* This resource is required on lan966x, to take the internal PHYs out+*ofreset+*/+err=mchp_sparx5_map_syscon(pdev,"cuphy-syscon",&ctx->cuphy_ctrl);+if(err&&err!=-ENODEV)+returnerr;+ctx->rcdev.owner=THIS_MODULE;ctx->rcdev.nr_resets=1;ctx->rcdev.ops=&sparx5_reset_ops;ctx->rcdev.of_node=dn;+ctx->props=device_get_match_data(&pdev->dev);++ctx->phy_reset_gpio=devm_gpiod_get_optional(&pdev->dev,"phy-reset",+GPIOD_OUT_LOW);+if(IS_ERR(ctx->phy_reset_gpio)){+dev_err(&pdev->dev,"Could not get reset GPIO\n");+returnPTR_ERR(ctx->phy_reset_gpio);+}returndevm_reset_controller_register(&pdev->dev,&ctx->rcdev);}+staticconststructreset_propsreset_props_sparx5={+.protect_reg=0x84,+.protect_bit=BIT(10),+.reset_reg=0x0,+.reset_bit=BIT(1),+};++staticconststructreset_propsreset_props_lan966x={+.protect_reg=0x88,+.protect_bit=BIT(5),+.reset_reg=0x0,+.reset_bit=BIT(1),+.cuphy_reg=0x10,+.cuphy_bit=BIT(0),+};+staticconststructof_device_idmchp_sparx5_reset_of_match[]={{.compatible="microchip,sparx5-switch-reset",+.data=&reset_props_sparx5,+},{+.compatible="microchip,lan966x-switch-reset",+.data=&reset_props_lan966x,},{}};
--
2.33.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
@@ -37,6 +41,14 @@ properties:$ref:"/schemas/types.yaml#/definitions/phandle"description:syscon used to access CPU reset+cuphy-syscon:+$ref:"/schemas/types.yaml#/definitions/phandle"+description:syscon used to access CuPHY
Can this be used on sparx5?
Is it optional on lan966x?
+ phy-reset-gpios:
+ description: used for release of reset of the external PHY
+ maxItems: 1
+
required:
- compatible
- reg
I'd like somebody to reassure me that putting the CuPHY reset and
external PHY GPIO reset in the reset controller is the right thing to
do.
It looks fine to me, but I'm not sure if these should rather be in
separate phy nodes that are referenced from the switch.
regards
Philipp
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2021-10-14 12:00:58
On Wed, 2021-10-13 at 09:38 +0200, Horatiu Vultur wrote:
quoted hunk
This patch extends sparx5 driver to support also the lan966x. The
process to reset the switch is the same only it has different offsets.
Therefore make the driver more generic and add support for lan966x.
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/reset/Kconfig | 2 +-
drivers/reset/reset-microchip-sparx5.c | 81 +++++++++++++++++++++++---
2 files changed, 74 insertions(+), 9 deletions(-)
@@ -36,17 +44,39 @@ static int sparx5_switch_reset(struct reset_controller_dev *rcdev,structmchp_reset_context*ctx=container_of(rcdev,structmchp_reset_context,rcdev);u32val;+interr;/* Make sure the core is PROTECTED from reset */-regmap_update_bits(ctx->cpu_ctrl,PROTECT_REG,PROTECT_BIT,PROTECT_BIT);+regmap_update_bits(ctx->cpu_ctrl,ctx->props->protect_reg,+ctx->props->protect_bit,ctx->props->protect_bit);/* Start soft reset */-regmap_write(ctx->gcb_ctrl,SOFT_RESET_REG,SOFT_RESET_BIT);+regmap_write(ctx->gcb_ctrl,ctx->props->reset_reg,+ctx->props->reset_bit);/* Wait for soft reset done */-returnregmap_read_poll_timeout(ctx->gcb_ctrl,SOFT_RESET_REG,val,-(val&SOFT_RESET_BIT)==0,+err=regmap_read_poll_timeout(ctx->gcb_ctrl,ctx->props->reset_reg,val,+(val&ctx->props->reset_bit)==0,1,100);+if(err)+returnerr;++if(!ctx->cuphy_ctrl)+return0;++/* In case there are external PHYs toggle the GPIO to release the reset+*ofthePHYs+*/+if(ctx->phy_reset_gpio){+gpiod_direction_output(ctx->phy_reset_gpio,1);+gpiod_set_value(ctx->phy_reset_gpio,0);+gpiod_set_value(ctx->phy_reset_gpio,1);+gpiod_set_value(ctx->phy_reset_gpio,0);+}++/* Release the reset of internal PHY */+returnregmap_update_bits(ctx->cuphy_ctrl,ctx->props->cuphy_reg,+ctx->props->cuphy_bit,ctx->props->cuphy_bit);}staticconststructreset_control_opssparx5_reset_ops={
@@ -111,17 +141,52 @@ static int mchp_sparx5_reset_probe(struct platform_device *pdev)if(err)returnerr;+/* This resource is required on lan966x, to take the internal PHYs out+*ofreset
Ah, here we go, required on lan966x. This should be reflected in the
binding yaml.
@@ -37,6 +41,14 @@ properties:$ref:"/schemas/types.yaml#/definitions/phandle"description:syscon used to access CPU reset+cuphy-syscon:+$ref:"/schemas/types.yaml#/definitions/phandle"+description:syscon used to access CuPHY
Can this be used on sparx5?
No, because the sparx5 doesn't have any internal PHYs that need to
be released of the reset.
Is it optional on lan966x?
No, it is required on lan966x. I will update the binding to show this.
quoted
+ phy-reset-gpios:
+ description: used for release of reset of the external PHY
+ maxItems: 1
+
required:
- compatible
- reg
I'd like somebody to reassure me that putting the CuPHY reset and
external PHY GPIO reset in the reset controller is the right thing to
do.
It looks fine to me, but I'm not sure if these should rather be in
separate phy nodes that are referenced from the switch.
regards
Philipp
On Wed, 2021-10-13 at 09:38 +0200, Horatiu Vultur wrote:
quoted
This patch extends sparx5 driver to support also the lan966x. The
process to reset the switch is the same only it has different offsets.
Therefore make the driver more generic and add support for lan966x.
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/reset/Kconfig | 2 +-
drivers/reset/reset-microchip-sparx5.c | 81 +++++++++++++++++++++++---
2 files changed, 74 insertions(+), 9 deletions(-)
@@ -36,17 +44,39 @@ static int sparx5_switch_reset(struct reset_controller_dev *rcdev,structmchp_reset_context*ctx=container_of(rcdev,structmchp_reset_context,rcdev);u32val;+interr;/* Make sure the core is PROTECTED from reset */-regmap_update_bits(ctx->cpu_ctrl,PROTECT_REG,PROTECT_BIT,PROTECT_BIT);+regmap_update_bits(ctx->cpu_ctrl,ctx->props->protect_reg,+ctx->props->protect_bit,ctx->props->protect_bit);/* Start soft reset */-regmap_write(ctx->gcb_ctrl,SOFT_RESET_REG,SOFT_RESET_BIT);+regmap_write(ctx->gcb_ctrl,ctx->props->reset_reg,+ctx->props->reset_bit);/* Wait for soft reset done */-returnregmap_read_poll_timeout(ctx->gcb_ctrl,SOFT_RESET_REG,val,-(val&SOFT_RESET_BIT)==0,+err=regmap_read_poll_timeout(ctx->gcb_ctrl,ctx->props->reset_reg,val,+(val&ctx->props->reset_bit)==0,1,100);+if(err)+returnerr;++if(!ctx->cuphy_ctrl)+return0;++/* In case there are external PHYs toggle the GPIO to release the reset+*ofthePHYs+*/+if(ctx->phy_reset_gpio){+gpiod_direction_output(ctx->phy_reset_gpio,1);+gpiod_set_value(ctx->phy_reset_gpio,0);+gpiod_set_value(ctx->phy_reset_gpio,1);+gpiod_set_value(ctx->phy_reset_gpio,0);+}++/* Release the reset of internal PHY */+returnregmap_update_bits(ctx->cuphy_ctrl,ctx->props->cuphy_reg,+ctx->props->cuphy_bit,ctx->props->cuphy_bit);}staticconststructreset_control_opssparx5_reset_ops={
@@ -111,17 +141,52 @@ static int mchp_sparx5_reset_probe(struct platform_device *pdev)if(err)returnerr;+/* This resource is required on lan966x, to take the internal PHYs out+*ofreset
Ah, here we go, required on lan966x. This should be reflected in the
binding yaml.
So -ENODEV should return an error if .cuphy_reg is set?
I am not sure I follow this.
If cuphy-syscon is not set then mchp_sparx5_map_syscon will return
-ENODEV. This can be ignored for sparx5 as this is not required.
If cuphy-syscon is set then if mchp_sparx5_map_syscon returns an error
then report this error.
@@ -37,6 +41,14 @@ properties:$ref:"/schemas/types.yaml#/definitions/phandle"description:syscon used to access CPU reset+cuphy-syscon:+$ref:"/schemas/types.yaml#/definitions/phandle"+description:syscon used to access CuPHY
Can this be used on sparx5?
No, because the sparx5 doesn't have any internal PHYs that need to
be released of the reset.
quoted
Is it optional on lan966x?
No, it is required on lan966x. I will update the binding to show this.
quoted
quoted
+ phy-reset-gpios:
+ description: used for release of reset of the external PHY
+ maxItems: 1
+
required:
- compatible
- reg
I'd like somebody to reassure me that putting the CuPHY reset and
external PHY GPIO reset in the reset controller is the right thing to
do.
It looks fine to me, but I'm not sure if these should rather be in
separate phy nodes that are referenced from the switch.
Were you thinking to have just another reset driver('phy-reset') and then
the switch to refer to both of them?
I like this idea because then is more clear what is doing each driver.
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2021-10-18 10:41:00
On Fri, 2021-10-15 at 16:14 +0200, Horatiu Vultur wrote:
[...]
Were you thinking to have just another reset driver('phy-reset') and then
the switch to refer to both of them?
I like this idea because then is more clear what is doing each driver.
Yes, especially if there is no requirement to handle switch and PHY
resets at the same time: this would allow the sgpio driver to trigger
the required switch reset without already releasing the PHYs from reset.
regards
Philipp
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
So -ENODEV should return an error if .cuphy_reg is set?
I am not sure I follow this.
If cuphy-syscon is not set then mchp_sparx5_map_syscon will return
-ENODEV. This can be ignored for sparx5 as this is not required.
If cuphy-syscon is set then if mchp_sparx5_map_syscon returns an error
then report this error.
My point was that in case of cuphy-syscon missing from the DT, the
lan966x compatible reset controller should probably throw the error
instead of ignoring it. With v4 this is not relevant any more.
regards
Philipp
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel