Skip to content

Commit 5833e05

Browse files
gclementdavem330
authored andcommitted
net/macb: add support for resetting PHY using GPIO
With device tree it is no more possible to reset the PHY at board level. Furthermore, doing in the driver allow to power down the PHY when the network interface is no more used. This reset can't be done at the PHY driver level. The PHY must be able to answer the to the mii bus scan to let the kernel creating a PHY device. The patch introduces a new optional property "phy-reset-gpios" inspired from the one use for the FEC. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bda13fe commit 5833e05

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

Documentation/devicetree/bindings/net/macb.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Required properties:
1919
Optional elements: 'tx_clk'
2020
- clocks: Phandles to input clocks.
2121

22+
Optional properties:
23+
- phy-reset-gpios : Should specify the gpio for phy reset
24+
2225
Examples:
2326

2427
macb0: ethernet@fffc4000 {

drivers/net/ethernet/cadence/macb.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,6 +2904,10 @@ static int macb_probe(struct platform_device *pdev)
29042904
else
29052905
macb_get_hwaddr(bp);
29062906

2907+
/* Power up the PHY if there is a GPIO reset */
2908+
bp->reset_gpio = devm_gpiod_get_optional(&bp->pdev->dev, "phy-reset",
2909+
GPIOD_OUT_HIGH);
2910+
29072911
err = of_get_phy_mode(np);
29082912
if (err < 0) {
29092913
pdata = dev_get_platdata(&pdev->dev);
@@ -2970,6 +2974,10 @@ static int macb_remove(struct platform_device *pdev)
29702974
mdiobus_unregister(bp->mii_bus);
29712975
kfree(bp->mii_bus->irq);
29722976
mdiobus_free(bp->mii_bus);
2977+
2978+
/* Shutdown the PHY if there is a GPIO reset */
2979+
gpiod_set_value(bp->reset_gpio, 0);
2980+
29732981
unregister_netdev(dev);
29742982
clk_disable_unprepare(bp->tx_clk);
29752983
clk_disable_unprepare(bp->hclk);

drivers/net/ethernet/cadence/macb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ struct macb {
829829
unsigned int dma_burst_length;
830830

831831
phy_interface_t phy_interface;
832+
struct gpio_desc *reset_gpio;
832833

833834
/* AT91RM9200 transmit */
834835
struct sk_buff *skb; /* holds skb until xmit interrupt completes */

0 commit comments

Comments
 (0)