From: Robert Marko <robert.marko@sartura.hr> Date: 2021-05-31 12:52:02
Delta TN48M switches have a Lattice CPLD that serves
multiple purposes including being a GPIO expander.
So, lets use the simple I2C MFD driver to provide the MFD core.
Also add a virtual symbol which pulls in the simple-mfd-i2c driver and
provide a common symbol on which the subdevice drivers can depend on.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Changes in v2:
* Drop the custom MFD driver and header
* Use simple I2C MFD driver
drivers/mfd/Kconfig | 10 ++++++++++
drivers/mfd/simple-mfd-i2c.c | 1 +
2 files changed, 11 insertions(+)
From: Robert Marko <robert.marko@sartura.hr> Date: 2021-05-31 12:52:08
Delta TN48M CPLD is used as a GPIO expander for the SFP GPIOs.
It is a mix of input only and output only pins.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Reviewed-by: Andy Shevchenko <redacted>
Acked-by: Bartosz Golaszewski <redacted>
Reviewed-by: Linus Walleij <redacted>
---
Changes in v2:
* Rewrite to use simple I2C MFD and GPIO regmap
* Drop DT bindings for pin numbering
drivers/gpio/Kconfig | 12 ++++++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-tn48m.c | 89 +++++++++++++++++++++++++++++++++++++++
3 files changed, 102 insertions(+)
create mode 100644 drivers/gpio/gpio-tn48m.c
@@ -0,0 +1,42 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/gpio/delta,tn48m-gpio.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Delta Networks TN48M CPLD GPIO controller++maintainers:+-Robert Marko <robert.marko@sartura.hr>++description:|+This module is part of the Delta TN48M multi-function device. For more+details see ../mfd/delta,tn48m-cpld.yaml.++GPIO controller module provides GPIO-s for the SFP slots.+It is split into 3 controllers, one output only for the SFP TX disable+pins, one input only for the SFP present pins and one input only for+the SFP LOS pins.++properties:+compatible:+enum:+-delta,tn48m-gpio-sfp-tx-disable+-delta,tn48m-gpio-sfp-present+-delta,tn48m-gpio-sfp-los++reg:+maxItems:1++"#gpio-cells":+const:2++gpio-controller:true++required:+-compatible+-reg+-"#gpio-cells"+-gpio-controller++additionalProperties:false
@@ -0,0 +1,90 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/mfd/delta,tn48m-cpld.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Delta Networks TN48M CPLD controller++maintainers:+-Robert Marko <robert.marko@sartura.hr>++description:|+Lattice CPLD onboard the TN48M switches is used for system+management.++It provides information about the hardware model, revision,+PSU status etc.++It is also being used as a GPIO expander for the SFP slots and+reset controller for the switch MAC-s and other peripherals.++properties:+compatible:+const:delta,tn48m-cpld++reg:+description:+I2C device address.+maxItems:1++"#address-cells":+const:1++"#size-cells":+const:0++required:+-compatible+-reg+-"#address-cells"+-"#size-cells"++patternProperties:+"^gpio(@[0-9a-f]+)?$":+$ref:../gpio/delta,tn48m-gpio.yaml++"^reset-controller?$":+$ref:../reset/delta,tn48m-reset.yaml++additionalProperties:false++examples:+-|+i2c {+#address-cells = <1>;+#size-cells = <0>;++cpld@41 {+compatible = "delta,tn48m-cpld";+reg = <0x41>;+#address-cells = <1>;+#size-cells = <0>;++gpio@31 {+compatible = "delta,tn48m-gpio-sfp-tx-disable";+reg = <0x31>;+gpio-controller;+#gpio-cells = <2>;+};++gpio@3a {+compatible = "delta,tn48m-gpio-sfp-present";+reg = <0x3a>;+gpio-controller;+#gpio-cells = <2>;+};++gpio@40 {+compatible = "delta,tn48m-gpio-sfp-los";+reg = <0x40>;+gpio-controller;+#gpio-cells = <2>;+};++reset-controller {+compatible = "delta,tn48m-reset";+#reset-cells = <1>;+};+};+};
@@ -0,0 +1,35 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/reset/delta,tn48m-reset.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Delta Networks TN48M CPLD reset controller++maintainers:+-Robert Marko <robert.marko@sartura.hr>++description:|+This module is part of the Delta TN48M multi-function device. For more+details see ../mfd/delta,tn48m-cpld.yaml.++Reset controller modules provides resets for the following:+*88F7040 SoC+*88F6820 SoC+*98DX3265 switch MAC-s+*88E1680 PHY-s+*88E1512 PHY+*PoE PSE controller++properties:+compatible:+const:delta,tn48m-reset++"#reset-cells":+const:1++required:+-compatible+-"#reset-cells"++additionalProperties:false
From: Robert Marko <robert.marko@sartura.hr> Date: 2021-05-31 12:52:45
Add maintainers entry for the Delta Networks TN48M
CPLD MFD drivers.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Changes in v3:
* Add reset driver documentation
Changes in v2:
* Drop no more existing files
MAINTAINERS | 9 +++++++++
1 file changed, 9 insertions(+)
From: Lee Jones <hidden> Date: 2021-06-01 08:39:50
On Mon, 31 May 2021, Robert Marko wrote:
Delta TN48M switches have a Lattice CPLD that serves
multiple purposes including being a GPIO expander.
So, lets use the simple I2C MFD driver to provide the MFD core.
Also add a virtual symbol which pulls in the simple-mfd-i2c driver and
provide a common symbol on which the subdevice drivers can depend on.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Changes in v2:
* Drop the custom MFD driver and header
* Use simple I2C MFD driver
drivers/mfd/Kconfig | 10 ++++++++++
drivers/mfd/simple-mfd-i2c.c | 1 +
2 files changed, 11 insertions(+)
I responded to a previous version of this.
The question still remains - why do you need one single Regmap
encompassing all functionality. The register banks look separated to
me at first glance.
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
From: Robert Marko <robert.marko@sartura.hr> Date: 2021-06-01 09:12:44
On Tue, Jun 1, 2021 at 10:39 AM Lee Jones [off-list ref] wrote:
On Mon, 31 May 2021, Robert Marko wrote:
quoted
Delta TN48M switches have a Lattice CPLD that serves
multiple purposes including being a GPIO expander.
So, lets use the simple I2C MFD driver to provide the MFD core.
Also add a virtual symbol which pulls in the simple-mfd-i2c driver and
provide a common symbol on which the subdevice drivers can depend on.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Changes in v2:
* Drop the custom MFD driver and header
* Use simple I2C MFD driver
drivers/mfd/Kconfig | 10 ++++++++++
drivers/mfd/simple-mfd-i2c.c | 1 +
2 files changed, 11 insertions(+)
I responded to a previous version of this.
The question still remains - why do you need one single Regmap
encompassing all functionality. The register banks look separated to
me at first glance.
Hi Lee,
In the end, I replied to your v2 comments as well.
It's quite extensive so I don't want to copy the replies here again.
Is that okay, or should I copy the answers here as well?
Regards,
Robert
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
--
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
10000 Zagreb, Croatia
Email: robert.marko@sartura.hr
Web: www.sartura.hr
All of the reset are self-clearing, so no need for it.
quoted
+static int tn48m_control_reset(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return tn48m_control_assert(rcdev, id);
Is this a self-clearing (or rather self re-setting) bit that triggers a
reset pulse?
If so, assert shouldn't be implemented.
Yes, it's self-clearing, per spec they will be cleared after 100ms.
Will drop assert then, I saw that reset was for self-clearing, but other
drivers I looked for example implemented both which was confusing.
This driver depends on having a parent as it needs to get the
regmap from it.
The parent is a CPLD using simple-i2c-mfd.
So it's nice to check.
Regards, Robert
--
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
10000 Zagreb, Croatia
Email: robert.marko@sartura.hr
Web: www.sartura.hr
From: Philipp Zabel <p.zabel@pengutronix.de> Date: 2021-06-02 08:47:12
On Tue, 2021-06-01 at 19:09 +0200, Robert Marko wrote:
[...]
Yes, it's self-clearing, per spec they will be cleared after 100ms.
Can you make sure the function only returns after the reset is
deasserted again, for example by using regmap_read_poll_timeout() on the
reset bit?
Will drop assert then, I saw that reset was for self-clearing, but other
drivers I looked for example implemented both which was confusing.
If you have full control over the reset line, you can implement .reset
by manually asserting and deasserting (possibly after a delay). But if
the reset is self-clearing, you can't properly implement .(de)assert,
which have an expectation about the state of the reset line after the
function returns.
@@ -0,0 +1,90 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/mfd/delta,tn48m-cpld.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Delta Networks TN48M CPLD controller++maintainers:+-Robert Marko <robert.marko@sartura.hr>++description:|+Lattice CPLD onboard the TN48M switches is used for system+management.++It provides information about the hardware model, revision,+PSU status etc.++It is also being used as a GPIO expander for the SFP slots and+reset controller for the switch MAC-s and other peripherals.++properties:+compatible:+const:delta,tn48m-cpld++reg:+description:+I2C device address.+maxItems:1++"#address-cells":+const:1++"#size-cells":+const:0++required:+-compatible+-reg+-"#address-cells"+-"#size-cells"++patternProperties:+"^gpio(@[0-9a-f]+)?$":+$ref:../gpio/delta,tn48m-gpio.yaml++"^reset-controller?$":+$ref:../reset/delta,tn48m-reset.yaml++additionalProperties:false++examples:+-|+i2c {+#address-cells = <1>;+#size-cells = <0>;++cpld@41 {+compatible = "delta,tn48m-cpld";+reg = <0x41>;+#address-cells = <1>;+#size-cells = <0>;++gpio@31 {+compatible = "delta,tn48m-gpio-sfp-tx-disable";+reg = <0x31>;+gpio-controller;+#gpio-cells = <2>;+};++gpio@3a {+compatible = "delta,tn48m-gpio-sfp-present";+reg = <0x3a>;+gpio-controller;+#gpio-cells = <2>;+};++gpio@40 {+compatible = "delta,tn48m-gpio-sfp-los";+reg = <0x40>;+gpio-controller;+#gpio-cells = <2>;+};++reset-controller {+compatible = "delta,tn48m-reset";+#reset-cells = <1>;+};
How is the Reset component addressed?
+ };
+ };
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
From: Lee Jones <hidden> Date: 2021-06-02 10:50:27
On Mon, 31 May 2021, Robert Marko wrote:
65;6200;1c
quoted hunk
Delta TN48M switches have a Lattice CPLD that serves
multiple purposes including being a GPIO expander.
So, lets use the simple I2C MFD driver to provide the MFD core.
Also add a virtual symbol which pulls in the simple-mfd-i2c driver and
provide a common symbol on which the subdevice drivers can depend on.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Changes in v2:
* Drop the custom MFD driver and header
* Use simple I2C MFD driver
drivers/mfd/Kconfig | 10 ++++++++++
drivers/mfd/simple-mfd-i2c.c | 1 +
2 files changed, 11 insertions(+)
Not entirely sure what MFD means in this context.
Please replace the MFD mention with Reset.
quoted hunk
+ for the SFP slots as well as power supply related information.
+ SFP support depends on the GPIO driver being selected.
+
config PMIC_DA903X
bool "Dialog Semiconductor DA9030/DA9034 PMIC Support"
depends on I2C=y
@@ -39,6 +39,7 @@ static int simple_mfd_i2c_probe(struct i2c_client *i2c)staticconststructof_device_idsimple_mfd_i2c_of_match[]={{.compatible="kontron,sl28cpld"},+{.compatible="delta,tn48m-cpld"},{}};MODULE_DEVICE_TABLE(of,simple_mfd_i2c_of_match);
Once fixed, please apply my:
For my own reference (apply this as-is to your sign-off block):
Acked-for-MFD-by: Lee Jones [off-list ref]
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
@@ -0,0 +1,90 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/mfd/delta,tn48m-cpld.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Delta Networks TN48M CPLD controller++maintainers:+-Robert Marko <robert.marko@sartura.hr>++description:|+Lattice CPLD onboard the TN48M switches is used for system+management.++It provides information about the hardware model, revision,+PSU status etc.++It is also being used as a GPIO expander for the SFP slots and+reset controller for the switch MAC-s and other peripherals.++properties:+compatible:+const:delta,tn48m-cpld++reg:+description:+I2C device address.+maxItems:1++"#address-cells":+const:1++"#size-cells":+const:0++required:+-compatible+-reg+-"#address-cells"+-"#size-cells"++patternProperties:+"^gpio(@[0-9a-f]+)?$":+$ref:../gpio/delta,tn48m-gpio.yaml++"^reset-controller?$":+$ref:../reset/delta,tn48m-reset.yaml++additionalProperties:false++examples:+-|+i2c {+#address-cells = <1>;+#size-cells = <0>;++cpld@41 {+compatible = "delta,tn48m-cpld";+reg = <0x41>;+#address-cells = <1>;+#size-cells = <0>;++gpio@31 {+compatible = "delta,tn48m-gpio-sfp-tx-disable";+reg = <0x31>;+gpio-controller;+#gpio-cells = <2>;+};++gpio@3a {+compatible = "delta,tn48m-gpio-sfp-present";+reg = <0x3a>;+gpio-controller;+#gpio-cells = <2>;+};++gpio@40 {+compatible = "delta,tn48m-gpio-sfp-los";+reg = <0x40>;+gpio-controller;+#gpio-cells = <2>;+};++reset-controller {+compatible = "delta,tn48m-reset";+#reset-cells = <1>;+};
How is the Reset component addressed?
It has a defined register in the driver.
Now that I think of it, it would make sense to use reg for it like for the GPIO
and not hardcode it.
Regards,
Robert
quoted
+ };
+ };
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
--
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
10000 Zagreb, Croatia
Email: robert.marko@sartura.hr
Web: www.sartura.hr
From: Robert Marko <robert.marko@sartura.hr> Date: 2021-06-02 11:48:39
On Wed, Jun 2, 2021 at 10:47 AM Philipp Zabel [off-list ref] wrote:
On Tue, 2021-06-01 at 19:09 +0200, Robert Marko wrote:
[...]
quoted
Yes, it's self-clearing, per spec they will be cleared after 100ms.
Can you make sure the function only returns after the reset is
deasserted again, for example by using regmap_read_poll_timeout() on the
reset bit?
Yes, that is simple to implement.
quoted
Will drop assert then, I saw that reset was for self-clearing, but other
drivers I looked for example implemented both which was confusing.
If you have full control over the reset line, you can implement .reset
by manually asserting and deasserting (possibly after a delay). But if
the reset is self-clearing, you can't properly implement .(de)assert,
which have an expectation about the state of the reset line after the
function returns.
This driver depends on having a parent as it needs to get the
regmap from it.
The parent is a CPLD using simple-i2c-mfd.
So it's nice to check.
pdev->dev.parent is always set to &platform_bus if there is no parent.
Ok, so it's useless to check.
Will send a new version today.
Regards,
Robert
regards
Philipp
--
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
10000 Zagreb, Croatia
Email: robert.marko@sartura.hr
Web: www.sartura.hr
From: Robert Marko <robert.marko@sartura.hr> Date: 2021-06-02 11:53:41
On Wed, Jun 2, 2021 at 12:49 PM Lee Jones [off-list ref] wrote:
On Mon, 31 May 2021, Robert Marko wrote:
65;6200;1c
quoted
Delta TN48M switches have a Lattice CPLD that serves
multiple purposes including being a GPIO expander.
So, lets use the simple I2C MFD driver to provide the MFD core.
Also add a virtual symbol which pulls in the simple-mfd-i2c driver and
provide a common symbol on which the subdevice drivers can depend on.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Changes in v2:
* Drop the custom MFD driver and header
* Use simple I2C MFD driver
drivers/mfd/Kconfig | 10 ++++++++++
drivers/mfd/simple-mfd-i2c.c | 1 +
2 files changed, 11 insertions(+)
Not entirely sure what MFD means in this context.
Please replace the MFD mention with Reset.
Sure, that is a leftover from before.
quoted
+ for the SFP slots as well as power supply related information.
+ SFP support depends on the GPIO driver being selected.
+
config PMIC_DA903X
bool "Dialog Semiconductor DA9030/DA9034 PMIC Support"
depends on I2C=y
@@ -39,6 +39,7 @@ static int simple_mfd_i2c_probe(struct i2c_client *i2c)staticconststructof_device_idsimple_mfd_i2c_of_match[]={{.compatible="kontron,sl28cpld"},+{.compatible="delta,tn48m-cpld"},{}};MODULE_DEVICE_TABLE(of,simple_mfd_i2c_of_match);
Once fixed, please apply my:
For my own reference (apply this as-is to your sign-off block):
Acked-for-MFD-by: Lee Jones [off-list ref]
Sure, will do.
Regards,
Robert
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
--
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
10000 Zagreb, Croatia
Email: robert.marko@sartura.hr
Web: www.sartura.hr