Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1628032

Re: [PATCH v3 net-next] mdio_bus: Issue GPIO RESET to PHYs.

From Roger Quadros <rogerq@ti.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 net-next] mdio_bus: Issue GPIO RESET to PHYs.
Date 2017-04-21 10:10 +0200
Message-ID <tyBNF-3rQ-45@gated-at.bofh.it> (permalink)
References <tsODU-f3-17@gated-at.bofh.it> <txU5X-1Gt-7@gated-at.bofh.it> <tyfN8-6Do-9@gated-at.bofh.it> <tyl6a-1yM-35@gated-at.bofh.it> <tyvyx-7Vc-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Florian,

On 21/04/17 04:23, Florian Fainelli wrote:
> Hi Roger,
> 
> On 04/20/2017 07:11 AM, Roger Quadros wrote:
>> Some boards [1] leave the PHYs at an invalid state
>> during system power-up or reset thus causing unreliability
>> issues with the PHY which manifests as PHY not being detected
>> or link not functional. To fix this, these PHYs need to be RESET
>> via a GPIO connected to the PHY's RESET pin.
>>
>> Some boards have a single GPIO controlling the PHY RESET pin of all
>> PHYs on the bus whereas some others have separate GPIOs controlling
>> individual PHY RESETs.
>>
>> In both cases, the RESET de-assertion cannot be done in the PHY driver
>> as the PHY will not probe till its reset is de-asserted.
>> So do the RESET de-assertion in the MDIO bus driver.
>>
>> [1] - am572x-idk, am571x-idk, a437x-idk
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
> 
> A few comments on the binding and the code, sorry for this late review.

No problem at all.
> 
>> +Example :
>> +This example shows these optional properties, plus other properties
>> +required for the TI Davinci MDIO driver.
>> +
>> +	davinci_mdio: ethernet@0x5c030000 {
>> +		compatible = "ti,davinci_mdio";
>> +		reg = <0x5c030000 0x1000>;
>> +		#address-cells = <1>;
>> +		#size-cells = <0>;
>> +
>> +		reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
>> +		reset-delay-us = <2>;   /* PHY datasheet states 1uS min */
> 
> us is micro seconds, uS is micro siemens.

OK.

> 
>> +
>> +		ethphy0: ethernet-phy@1 {
>> +			reg = <1>;
>> +		};
>> +
>> +		ethphy1: ethernet-phy@3 {
>> +			reg = <3>;
>> +		};
>> +	};
> 
>>  
>> +	/* de-assert bus level PHY GPIO resets */
>> +	for (i = 0; i < bus->num_reset_gpios; i++) {
>> +		gpiod = devm_gpiod_get_index(&bus->dev, "reset", i,
>> +					     GPIOD_OUT_LOW);
>> +		if (IS_ERR(gpiod)) {
>> +			err = PTR_ERR(gpiod);
>> +			if (err != -ENOENT) {
>> +				pr_err("mii_bus %s couldn't get reset GPIO\n",
>> +				       bus->id);
> 
> Could we use dev_err(&bus->dev) here to better identify which MDIO bus
> is returning the problem?

Sure.
> 
>> +				return err;
> 
> Should we somehow "unwind" the reset lines we were able to successfully
> take out of reset and therefore put back into reset state? How about
> mdiobus_unregister()? Should we have similar code there, if not for
> correctness to be more power efficient?

Al right.

> 
>> +			}
>> +		} else {
>> +			gpiod_set_value_cansleep(gpiod, 1);
>> +			udelay(bus->reset_delay_us);
>> +			gpiod_set_value_cansleep(gpiod, 0);
> 
> Does that work even if the polarity of the reset line is active low?
> 

Yes. The polarity needs to be specified at DT as explained by Andrew already.

cheers,
-roger

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-19 11:30 +0200
  Re: [PATCH] mdio_bus: Issue GPIO RESET to PHYs. Andrew Lunn <andrew@lunn.ch> - 2017-04-19 13:50 +0200
    Re: [PATCH] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-19 14:00 +0200
      Re: [PATCH] mdio_bus: Issue GPIO RESET to PHYs. Andrew Lunn <andrew@lunn.ch> - 2017-04-19 15:40 +0200
        Re: [PATCH] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-20 10:00 +0200
  [PATCH v2] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-20 10:40 +0200
    Re: [PATCH v2] mdio_bus: Issue GPIO RESET to PHYs. Andrew Lunn <andrew@lunn.ch> - 2017-04-20 15:20 +0200
      Re: [PATCH v2] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-20 16:00 +0200
    [PATCH v3 net-next] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-20 16:20 +0200
      Re: [PATCH v3 net-next] mdio_bus: Issue GPIO RESET to PHYs. Andrew Lunn <andrew@lunn.ch> - 2017-04-21 03:20 +0200
      Re: [PATCH v3 net-next] mdio_bus: Issue GPIO RESET to PHYs. Florian Fainelli <f.fainelli@gmail.com> - 2017-04-21 03:30 +0200
        Re: [PATCH v3 net-next] mdio_bus: Issue GPIO RESET to PHYs. Andrew Lunn <andrew@lunn.ch> - 2017-04-21 03:40 +0200
        Re: [PATCH v3 net-next] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-21 10:10 +0200
      [PATCH v4 net-next] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-21 15:20 +0200
        Re: [PATCH v4 net-next] mdio_bus: Issue GPIO RESET to PHYs. Lars-Peter Clausen <lars@metafoo.de> - 2017-04-21 15:40 +0200
          Re: [PATCH v4 net-next] mdio_bus: Issue GPIO RESET to PHYs. Andrew Lunn <andrew@lunn.ch> - 2017-04-24 01:40 +0200
            Re: [PATCH v4 net-next] mdio_bus: Issue GPIO RESET to PHYs. Roger Quadros <rogerq@ti.com> - 2017-04-24 11:10 +0200
              Re: [PATCH v4 net-next] mdio_bus: Issue GPIO RESET to PHYs. Florian Fainelli <f.fainelli@gmail.com> - 2017-04-24 18:40 +0200
        Re: [PATCH v4 net-next] mdio_bus: Issue GPIO RESET to PHYs. David Miller <davem@davemloft.net> - 2017-04-24 18:50 +0200

csiph-web