diff options
author | Nishanth Menon <nm@ti.com> | 2014-03-21 02:52:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-24 00:36:47 -0400 |
commit | ebf4ad955d3e26d4d2a33709624fc7b5b9d3b969 (patch) | |
tree | da93c4744f9787a30027dda791b6101aebaa89e2 | |
parent | b74d3feccc3f5e6e4cf98cf88daa2e0cdbc4ca62 (diff) |
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.
Fixes: 66fda75f47dc (regulator: core: Replace direct ops->disable usage)
Reported-by: Russell King <rmk+kernel@arm.linux.org.uk>
Suggested-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | Documentation/devicetree/bindings/net/micrel-ks8851.txt | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/micrel/ks8851.c | 30 |
2 files changed, 30 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/net/micrel-ks8851.txt b/Documentation/devicetree/bindings/net/micrel-ks8851.txt index 11ace3c3d805..4fc392763611 100644 --- a/Documentation/devicetree/bindings/net/micrel-ks8851.txt +++ b/Documentation/devicetree/bindings/net/micrel-ks8851.txt | |||
@@ -7,3 +7,4 @@ Required properties: | |||
7 | 7 | ||
8 | Optional properties: | 8 | Optional properties: |
9 | - local-mac-address : Ethernet mac address to use | 9 | - local-mac-address : Ethernet mac address to use |
10 | - vdd-supply: supply for Ethernet mac | ||
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 727b546a9eb8..e0c92e0e5e1d 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/crc32.h> | 23 | #include <linux/crc32.h> |
24 | #include <linux/mii.h> | 24 | #include <linux/mii.h> |
25 | #include <linux/eeprom_93cx6.h> | 25 | #include <linux/eeprom_93cx6.h> |
26 | #include <linux/regulator/consumer.h> | ||
26 | 27 | ||
27 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
28 | 29 | ||
@@ -83,6 +84,7 @@ union ks8851_tx_hdr { | |||
83 | * @rc_rxqcr: Cached copy of KS_RXQCR. | 84 | * @rc_rxqcr: Cached copy of KS_RXQCR. |
84 | * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom | 85 | * @eeprom_size: Companion eeprom size in Bytes, 0 if no eeprom |
85 | * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM. | 86 | * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM. |
87 | * @vdd_reg: Optional regulator supplying the chip | ||
86 | * | 88 | * |
87 | * The @lock ensures that the chip is protected when certain operations are | 89 | * The @lock ensures that the chip is protected when certain operations are |
88 | * in progress. When the read or write packet transfer is in progress, most | 90 | * in progress. When the read or write packet transfer is in progress, most |
@@ -130,6 +132,7 @@ struct ks8851_net { | |||
130 | struct spi_transfer spi_xfer2[2]; | 132 | struct spi_transfer spi_xfer2[2]; |
131 | 133 | ||
132 | struct eeprom_93cx6 eeprom; | 134 | struct eeprom_93cx6 eeprom; |
135 | struct regulator *vdd_reg; | ||
133 | }; | 136 | }; |
134 | 137 | ||
135 | static int msg_enable; | 138 | static int msg_enable; |
@@ -1414,6 +1417,21 @@ static int ks8851_probe(struct spi_device *spi) | |||
1414 | ks->spidev = spi; | 1417 | ks->spidev = spi; |
1415 | ks->tx_space = 6144; | 1418 | ks->tx_space = 6144; |
1416 | 1419 | ||
1420 | ks->vdd_reg = regulator_get_optional(&spi->dev, "vdd"); | ||
1421 | if (IS_ERR(ks->vdd_reg)) { | ||
1422 | ret = PTR_ERR(ks->vdd_reg); | ||
1423 | if (ret == -EPROBE_DEFER) | ||
1424 | goto err_reg; | ||
1425 | } else { | ||
1426 | ret = regulator_enable(ks->vdd_reg); | ||
1427 | if (ret) { | ||
1428 | dev_err(&spi->dev, "regulator enable fail: %d\n", | ||
1429 | ret); | ||
1430 | goto err_reg_en; | ||
1431 | } | ||
1432 | } | ||
1433 | |||
1434 | |||
1417 | mutex_init(&ks->lock); | 1435 | mutex_init(&ks->lock); |
1418 | spin_lock_init(&ks->statelock); | 1436 | spin_lock_init(&ks->statelock); |
1419 | 1437 | ||
@@ -1508,8 +1526,14 @@ static int ks8851_probe(struct spi_device *spi) | |||
1508 | err_netdev: | 1526 | err_netdev: |
1509 | free_irq(ndev->irq, ks); | 1527 | free_irq(ndev->irq, ks); |
1510 | 1528 | ||
1511 | err_id: | ||
1512 | err_irq: | 1529 | err_irq: |
1530 | err_id: | ||
1531 | if (!IS_ERR(ks->vdd_reg)) | ||
1532 | regulator_disable(ks->vdd_reg); | ||
1533 | err_reg_en: | ||
1534 | if (!IS_ERR(ks->vdd_reg)) | ||
1535 | regulator_put(ks->vdd_reg); | ||
1536 | err_reg: | ||
1513 | free_netdev(ndev); | 1537 | free_netdev(ndev); |
1514 | return ret; | 1538 | return ret; |
1515 | } | 1539 | } |
@@ -1523,6 +1547,10 @@ static int ks8851_remove(struct spi_device *spi) | |||
1523 | 1547 | ||
1524 | unregister_netdev(priv->netdev); | 1548 | unregister_netdev(priv->netdev); |
1525 | free_irq(spi->irq, priv); | 1549 | free_irq(spi->irq, priv); |
1550 | if (!IS_ERR(priv->vdd_reg)) { | ||
1551 | regulator_disable(priv->vdd_reg); | ||
1552 | regulator_put(priv->vdd_reg); | ||
1553 | } | ||
1526 | free_netdev(priv->netdev); | 1554 | free_netdev(priv->netdev); |
1527 | 1555 | ||
1528 | return 0; | 1556 | return 0; |