net: micrel : ks8851-ml: add vdd-supply support
Subsystems (3)
PATCH 1/1 net: micrel : ks8851-ml: add vdd-supply support
Few platforms use external regulator to keep the ethernet MAC supplied. So, request and enable the regulator for driver functionality.
---
This fixes a regression in SDP4430 platform as reported by Russel here:
http://marc.info/?t=139509918200014&r=1&w=2
Patch is based on [v3.14-rc7] tag, if it is too late to submit, I can repost rebased to git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
.../devicetree/bindings/net/micrel-ks8851.txt | 1 + drivers/net/ethernet/micrel/ks8851.c | 30 +++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/micrel-ks8851.txt +1 -0
@@ -7,3 +7,4 @@ Required properties: Optional properties: - local-mac-address : Ethernet mac address to use +- vdd-supply: supply for Ethernet mac
drivers/net/ethernet/micrel/ks8851.c +29 -1
@@ -23,6 +23,7 @@#include <linux/crc32.h> #include <linux/mii.h> #include <linux/eeprom_93cx6.h> +#include <linux/regulator/consumer.h> #include <linux/spi/spi.h>
@@ -83,6 +84,7 @@ union ks8851_tx_hdr {* @rc_rxqcr: Cached copy of KS_RXQCR. * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM. +* @vdd_reg: Optional regulator supplying the chip * * The @lock ensures that the chip is protected when certain operations are * in progress. When the read or write packet transfer is in progress, most
@@ -130,6 +132,7 @@ struct ks8851_net {struct spi_transfer spi_xfer2[2 ];struct eeprom_93cx6 eeprom; +struct regulator *vdd_reg; };static int msg_enable;
@@ -1414,6 +1417,21 @@ static int ks8851_probe(struct spi_device *spi) ks->spidev = spi; ks->tx_space =6144 ; + ks->vdd_reg =regulator_get_optional (&spi->dev,"vdd" ); +if (IS_ERR (ks->vdd_reg)) { + ret =PTR_ERR (ks->vdd_reg); +if (ret == -EPROBE_DEFER ) + goto err_reg; + }else { + ret =regulator_enable (ks->vdd_reg); +if (ret) { +dev_err (&spi->dev,"regulator enable fail: %d\n" , + ret); + goto err_reg_en; + } + } + +mutex_init (&ks->lock);spin_lock_init (&ks->statelock);
@@ -1508,8 +1526,14 @@ static int ks8851_probe(struct spi_device *spi) err_netdev:free_irq (ndev->irq, ks); -err_id: err_irq: +err_id: +if (!IS_ERR (ks->vdd_reg)) +regulator_disable (ks->vdd_reg); +err_reg_en: +if (!IS_ERR (ks->vdd_reg)) +regulator_put (ks->vdd_reg); +err_reg:free_netdev (ndev);return ret; }
@@ -1523,6 +1547,10 @@ static int ks8851_remove(struct spi_device *spi)unregister_netdev (priv->netdev);free_irq (spi->irq, priv); +if (!IS_ERR (priv->vdd_reg)) { +regulator_disable (priv->vdd_reg); +regulator_put (priv->vdd_reg); + }free_netdev (priv->netdev);return 0 ;
Signature · 1 line
1.7.9.5
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Quoted 57 lines · Nishanth Menon
Few platforms use external regulator to keep the ethernet MAC supplied. So, request and enable the regulator for driver functionality.
Fixes 66fda75f47dc (regulator: core: Replace direct ops->disable usage)Reported-by Russell King <[email protected]>Suggested-by Markus Pargmann <[email protected]>Signed-off-by Nishanth Menon <[email protected]>---
This fixes a regression in SDP4430 platform as reported by Russel here:
http://marc.info/?t=139509918200014&r=1&w=2Patch is based on [v3.14-rc7] tag, if it is too late to submit, I can repost rebased to
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git.../devicetree/bindings/net/micrel-ks8851.txt | 1 + drivers/net/ethernet/micrel/ks8851.c | 30 +++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/net/micrel-ks8851.txt +1
-0@@ -7,3 +7,4 @@ Required properties: Optional properties: - local-mac-address : Ethernet mac address to use +- vdd-supply: supply for Ethernet macdrivers/net/ethernet/micrel/ks8851.c +3
-0@@ -23,6 +23,7 @@#include <linux/crc32.h> #include <linux/mii.h> #include <linux/eeprom_93cx6.h> +#include <linux/regulator/consumer.h> #include <linux/spi/spi.h> @@ -83,6 +84,7 @@ union ks8851_tx_hdr {* @rc_rxqcr: Cached copy of KS_RXQCR. * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM. +* @vdd_reg: Optional regulator supplying the chip * * The @lock ensures that the chip is protected when certain operations are * in progress. When the read or write packet transfer is in progress, most @@ -130,6 +132,7 @@ struct ks8851_net {struct spi_transfer spi_xfer2[2 ];struct eeprom_93cx6 eeprom; +struct regulator *vdd_reg; };static int msg_enable;
drivers/net/ethernet/micrel/ks8851.c static int ks8851_probe(struct spi_device *spi) · line 1420
Quoted 4 lines
drivers/net/ethernet/micrel/ks8851.c +1
-0@@ -1414,6 +1417,21 @@ static int ks8851_probe(struct spi_device *spi) ks->spidev = spi; ks->tx_space =6144 ; + ks->vdd_reg =regulator_get_optional (&spi->dev,"vdd" );
You could use devm_regulator_get_optional here and remove the regulator_put.
Regards,
Markus
Quoted 48 lines
drivers/net/ethernet/micrel/ks8851.c +25
-1+if (IS_ERR (ks->vdd_reg)) { + ret =PTR_ERR (ks->vdd_reg); +if (ret == -EPROBE_DEFER ) + goto err_reg; + }else { + ret =regulator_enable (ks->vdd_reg); +if (ret) { +dev_err (&spi->dev,"regulator enable fail: %d\n" , + ret); + goto err_reg_en; + } + } + +mutex_init (&ks->lock);spin_lock_init (&ks->statelock);@@ -1508,8 +1526,14 @@ static int ks8851_probe(struct spi_device *spi) err_netdev:free_irq (ndev->irq, ks); -err_id: err_irq: +err_id: +if (!IS_ERR (ks->vdd_reg)) +regulator_disable (ks->vdd_reg); +err_reg_en: +if (!IS_ERR (ks->vdd_reg)) +regulator_put (ks->vdd_reg); +err_reg:free_netdev (ndev);return ret; }@@ -1523,6 +1547,10 @@ static int ks8851_remove(struct spi_device *spi)unregister_netdev (priv->netdev);free_irq (spi->irq, priv); +if (!IS_ERR (priv->vdd_reg)) { +regulator_disable (priv->vdd_reg); +regulator_put (priv->vdd_reg); + }free_netdev (priv->netdev);return 0 ;Signature · 1 line
1.7.9.5
Signature · 11 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140321/57d3cc26/attachment-0001.sig>
PATCH v2 1/1 net: micrel : ks8851-ml: add vdd-supply support
Few platforms use external regulator to keep the ethernet MAC supplied. So, request and enable the regulator for driver functionality.
---
This fixes a regression in SDP4430 platform as reported by Russel here:
http://marc.info/?t=139509918200014&r=1&w=2
Patch is based on [v3.14-rc7] tag, if it is too late to submit, I can repost rebased to git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
Changes in v2: based on Marcus's comment, switched to managed regulator_get,
however retained the enable/disable as balanced.
v1: https://patchwork.kernel.org/patch/3871401/
.../devicetree/bindings/net/micrel-ks8851.txt | 1 + drivers/net/ethernet/micrel/ks8851.c | 24 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/micrel-ks8851.txt +1 -0
@@ -7,3 +7,4 @@ Required properties: Optional properties: - local-mac-address : Ethernet mac address to use +- vdd-supply: supply for Ethernet mac
drivers/net/ethernet/micrel/ks8851.c +23 -1
@@ -23,6 +23,7 @@#include <linux/crc32.h> #include <linux/mii.h> #include <linux/eeprom_93cx6.h> +#include <linux/regulator/consumer.h> #include <linux/spi/spi.h>
@@ -83,6 +84,7 @@ union ks8851_tx_hdr {* @rc_rxqcr: Cached copy of KS_RXQCR. * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM. +* @vdd_reg: Optional regulator supplying the chip * * The @lock ensures that the chip is protected when certain operations are * in progress. When the read or write packet transfer is in progress, most
@@ -130,6 +132,7 @@ struct ks8851_net {struct spi_transfer spi_xfer2[2 ];struct eeprom_93cx6 eeprom; +struct regulator *vdd_reg; };static int msg_enable;
@@ -1414,6 +1417,20 @@ static int ks8851_probe(struct spi_device *spi) ks->spidev = spi; ks->tx_space =6144 ; + ks->vdd_reg =regulator_get_optional (&spi->dev,"vdd" ); +if (IS_ERR (ks->vdd_reg)) { + ret =PTR_ERR (ks->vdd_reg); +if (ret == -EPROBE_DEFER ) + goto err_reg; + }else { + ret =regulator_enable (ks->vdd_reg); +if (ret) { +dev_err (&spi->dev,"regulator enable fail: %d\n" , + ret); + goto err_reg; + } + } +mutex_init (&ks->lock);spin_lock_init (&ks->statelock);
@@ -1508,8 +1525,11 @@ static int ks8851_probe(struct spi_device *spi) err_netdev:free_irq (ndev->irq, ks); -err_id: err_irq: +err_id: +if (!IS_ERR (ks->vdd_reg)) +regulator_disable (ks->vdd_reg); +err_reg:free_netdev (ndev);return ret; }
@@ -1523,6 +1543,8 @@ static int ks8851_remove(struct spi_device *spi)unregister_netdev (priv->netdev);free_irq (spi->irq, priv); +if (!IS_ERR (priv->vdd_reg)) +regulator_disable (priv->vdd_reg);free_netdev (priv->netdev);return 0 ;
Signature · 1 line
1.7.9.5
drivers/net/ethernet/micrel/ks8851.c static int ks8851_probe(struct spi_device *spi) · line 1420
Quoted 1 line · Nishanth Menon
drivers/net/ethernet/micrel/ks8851.c +1
-0+ ks->vdd_reg =regulator_get_optional (&spi->dev,"vdd" );
ok, that is unbelievable.. no git commit --amend :(.. Apologies on the spam.. will resent.
Signature · 2 lines
Regards, Nishanth Menon
PATCH RESEND v2 1/1 net: micrel : ks8851-ml: add vdd-supply support
In reply to Markus PargmannFew platforms use external regulator to keep the ethernet MAC supplied. So, request and enable the regulator for driver functionality.
---
This fixes a regression in SDP4430 platform as reported by Russell here:
http://marc.info/?t=139509918200014&r=1&w=2
Patch is based on [v3.14-rc7] tag, if it is too late to submit, I can repost rebased to git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
Changes in v2(resend): based on Marcus's comment, switched to managed regulator
get, however retained the enable/disable as balanced.
v1: https://patchwork.kernel.org/patch/3871401/
.../devicetree/bindings/net/micrel-ks8851.txt | 1 + drivers/net/ethernet/micrel/ks8851.c | 24 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/micrel-ks8851.txt +1 -0
@@ -7,3 +7,4 @@ Required properties: Optional properties: - local-mac-address : Ethernet mac address to use +- vdd-supply: supply for Ethernet mac
drivers/net/ethernet/micrel/ks8851.c +23 -1
@@ -23,6 +23,7 @@#include <linux/crc32.h> #include <linux/mii.h> #include <linux/eeprom_93cx6.h> +#include <linux/regulator/consumer.h> #include <linux/spi/spi.h>
@@ -83,6 +84,7 @@ union ks8851_tx_hdr {* @rc_rxqcr: Cached copy of KS_RXQCR. * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM. +* @vdd_reg: Optional regulator supplying the chip * * The @lock ensures that the chip is protected when certain operations are * in progress. When the read or write packet transfer is in progress, most
@@ -130,6 +132,7 @@ struct ks8851_net {struct spi_transfer spi_xfer2[2 ];struct eeprom_93cx6 eeprom; +struct regulator *vdd_reg; };static int msg_enable;
@@ -1414,6 +1417,20 @@ static int ks8851_probe(struct spi_device *spi) ks->spidev = spi; ks->tx_space =6144 ; + ks->vdd_reg =devm_regulator_get_optional (&spi->dev,"vdd" ); +if (IS_ERR (ks->vdd_reg)) { + ret =PTR_ERR (ks->vdd_reg); +if (ret == -EPROBE_DEFER ) + goto err_reg; + }else { + ret =regulator_enable (ks->vdd_reg); +if (ret) { +dev_err (&spi->dev,"regulator enable fail: %d\n" , + ret); + goto err_reg; + } + } +mutex_init (&ks->lock);spin_lock_init (&ks->statelock);
@@ -1508,8 +1525,11 @@ static int ks8851_probe(struct spi_device *spi) err_netdev:free_irq (ndev->irq, ks); -err_id: err_irq: +err_id: +if (!IS_ERR (ks->vdd_reg)) +regulator_disable (ks->vdd_reg); +err_reg:free_netdev (ndev);return ret; }
@@ -1523,6 +1543,8 @@ static int ks8851_remove(struct spi_device *spi)unregister_netdev (priv->netdev);free_irq (spi->irq, priv); +if (!IS_ERR (priv->vdd_reg)) +regulator_disable (priv->vdd_reg);free_netdev (priv->netdev);return 0 ;
Signature · 1 line
1.7.9.5
From: Nishanth Menon <[email protected]>
Date: Fri, 21 Mar 2014 01:52:48 -0500
Quoted 7 lines
Few platforms use external regulator to keep the ethernet MAC supplied. So, request and enable the regulator for driver functionality.
Fixes 66fda75f47dc (regulator: core: Replace direct ops->disable usage)Reported-by Russell King <[email protected]>Suggested-by Markus Pargmann <[email protected]>Signed-off-by Nishanth Menon <[email protected]>
Applied, thanks.
Hi,
Quoted 6 lines · David Miller
From: Nishanth Menon <[email protected]>
Date: Fri, 21 Mar 2014 01:52:48 -0500Quoted 3 lines
Few platforms use external regulator to keep the ethernet MAC supplied. So, request and enable the regulator for driver functionality.
Quoted 7 lines
Quoted 4 lines
Fixes 66fda75f47dc (regulator: core: Replace direct ops->disable usage)Reported-by Russell King <[email protected]>Suggested-by Markus Pargmann <[email protected]>Signed-off-by Nishanth Menon <[email protected]>Applied, thanks.
The two regulator patches for enable and disable are going into the stable trees so this should also be submitted to stable for 3.10 to 3.13.
Regards,
Markus
Signature · 11 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140325/9409b7fe/attachment.sig>