Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-add-reset-controller-driven-PHY-reset'

David Bauer says:

====================
net: add reset-controller driven PHY reset

This patchset adds support for a PHY reset driven by a reset-controller.
Currently, only GPIO driven resets are supported by the PHY subsystem.
It also renames the reset-gpio from 'reset' to 'reset_gpio' to
better differentiate between resets wired to a GPIO and resets wired to
a reset-controller driven pin.

Some systems have the PHY reset-line wired to a pin controlled by a
reset-controller (eg. some Atheros AR9132 based boards). In case the
bootloader asserts reset before loading the kernel, we currently do not
have a clean way of deasserting reset to probe the PHY.

v3:
- add missing newline in mdio_bus.c

v2:
- fixed missed rename of "reset" in at803x.c
- move initial reset to mdio_device_reset
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+48 -9
+6
Documentation/devicetree/bindings/net/phy.txt
··· 51 51 to ensure the integrated PHY is used. The absence of this property indicates 52 52 the muxers should be configured so that the external PHY is used. 53 53 54 + - resets: The reset-controller phandle and specifier for the PHY reset signal. 55 + 56 + - reset-names: Must be "phy" for the PHY reset signal. 57 + 54 58 - reset-gpios: The GPIO phandle and specifier for the PHY reset signal. 55 59 56 60 - reset-assert-us: Delay after the reset was asserted in microseconds. ··· 71 67 interrupts = <35 IRQ_TYPE_EDGE_RISING>; 72 68 reg = <0>; 73 69 70 + resets = <&rst 8>; 71 + reset-names = "phy"; 74 72 reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; 75 73 reset-assert-us = <1000>; 76 74 reset-deassert-us = <2000>;
+1 -1
drivers/net/phy/at803x.c
··· 331 331 * in the FIFO. In such cases, the FIFO enters an error mode it 332 332 * cannot recover from by software. 333 333 */ 334 - if (phydev->state == PHY_NOLINK && phydev->mdio.reset) { 334 + if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { 335 335 struct at803x_context context; 336 336 337 337 at803x_context_save(phydev, &context);
+28 -5
drivers/net/phy/mdio_bus.c
··· 24 24 #include <linux/of_gpio.h> 25 25 #include <linux/netdevice.h> 26 26 #include <linux/etherdevice.h> 27 + #include <linux/reset.h> 27 28 #include <linux/skbuff.h> 28 29 #include <linux/spinlock.h> 29 30 #include <linux/mm.h> ··· 56 55 return PTR_ERR(gpiod); 57 56 } 58 57 59 - mdiodev->reset = gpiod; 58 + mdiodev->reset_gpio = gpiod; 60 59 61 - /* Assert the reset signal again */ 62 - mdio_device_reset(mdiodev, 1); 60 + return 0; 61 + } 62 + 63 + static int mdiobus_register_reset(struct mdio_device *mdiodev) 64 + { 65 + struct reset_control *reset = NULL; 66 + 67 + if (mdiodev->dev.of_node) 68 + reset = devm_reset_control_get_exclusive(&mdiodev->dev, 69 + "phy"); 70 + if (PTR_ERR(reset) == -ENOENT || 71 + PTR_ERR(reset) == -ENOTSUPP) 72 + reset = NULL; 73 + else if (IS_ERR(reset)) 74 + return PTR_ERR(reset); 75 + 76 + mdiodev->reset_ctrl = reset; 63 77 64 78 return 0; 65 79 } ··· 90 74 err = mdiobus_register_gpiod(mdiodev); 91 75 if (err) 92 76 return err; 77 + 78 + err = mdiobus_register_reset(mdiodev); 79 + if (err) 80 + return err; 81 + 82 + /* Assert the reset signal */ 83 + mdio_device_reset(mdiodev, 1); 93 84 } 94 85 95 86 mdiodev->bus->mdio_map[mdiodev->addr] = mdiodev; ··· 469 446 if (!mdiodev) 470 447 continue; 471 448 472 - if (mdiodev->reset) 473 - gpiod_put(mdiodev->reset); 449 + if (mdiodev->reset_gpio) 450 + gpiod_put(mdiodev->reset_gpio); 474 451 475 452 mdiodev->device_remove(mdiodev); 476 453 mdiodev->device_free(mdiodev);
+11 -2
drivers/net/phy/mdio_device.c
··· 16 16 #include <linux/mii.h> 17 17 #include <linux/module.h> 18 18 #include <linux/phy.h> 19 + #include <linux/reset.h> 19 20 #include <linux/slab.h> 20 21 #include <linux/string.h> 21 22 #include <linux/unistd.h> ··· 117 116 { 118 117 unsigned int d; 119 118 120 - if (!mdiodev->reset) 119 + if (!mdiodev->reset_gpio && !mdiodev->reset_ctrl) 121 120 return; 122 121 123 - gpiod_set_value(mdiodev->reset, value); 122 + if (mdiodev->reset_gpio) 123 + gpiod_set_value(mdiodev->reset_gpio, value); 124 + 125 + if (mdiodev->reset_ctrl) { 126 + if (value) 127 + reset_control_assert(mdiodev->reset_ctrl); 128 + else 129 + reset_control_deassert(mdiodev->reset_ctrl); 130 + } 124 131 125 132 d = value ? mdiodev->reset_assert_delay : mdiodev->reset_deassert_delay; 126 133 if (d)
+2 -1
include/linux/mdio.h
··· 39 39 /* Bus address of the MDIO device (0-31) */ 40 40 int addr; 41 41 int flags; 42 - struct gpio_desc *reset; 42 + struct gpio_desc *reset_gpio; 43 + struct reset_control *reset_ctrl; 43 44 unsigned int reset_assert_delay; 44 45 unsigned int reset_deassert_delay; 45 46 };