diff mbox series

[net-next,v1,3/3] net: phy: micrel: add coma mode GPIO

Message ID 20220427214406.1348872-4-michael@walle.cc (mailing list archive)
State Accepted
Commit 738871b09250ee9043c0e05101fcc254059f1492
Delegated to: Netdev Maintainers
Headers show
Series net: phy: micrel: add coma mode support | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Walle April 27, 2022, 9:44 p.m. UTC
The LAN8814 has a coma mode pin which puts the PHY into isolate and
power-dowm mode. Unfortunately, the mode cannot be disabled by a
register. Usually, the input pin has a pull-up and connected to a GPIO
which can then be used to disable the mode. Try to get the GPIO and
deassert it.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/net/phy/micrel.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Florian Fainelli April 27, 2022, 10:06 p.m. UTC | #1
On 4/27/2022 2:44 PM, Michael Walle wrote:
> The LAN8814 has a coma mode pin which puts the PHY into isolate and
> power-dowm mode. Unfortunately, the mode cannot be disabled by a
> register. Usually, the input pin has a pull-up and connected to a GPIO
> which can then be used to disable the mode. Try to get the GPIO and
> deassert it.

Poor choice of word, how about deep sleep, dormant, super isolate?
Michael Walle April 27, 2022, 10:08 p.m. UTC | #2
Am 2022-04-28 00:06, schrieb Florian Fainelli:
> On 4/27/2022 2:44 PM, Michael Walle wrote:
>> The LAN8814 has a coma mode pin which puts the PHY into isolate and
>> power-dowm mode. Unfortunately, the mode cannot be disabled by a
s/dowm/down/

>> register. Usually, the input pin has a pull-up and connected to a GPIO
>> which can then be used to disable the mode. Try to get the GPIO and
>> deassert it.
> 
> Poor choice of word, how about deep sleep, dormant, super isolate?

Which one do you mean? Super isolate sounded like broadcom wording ;)

-michael
Florian Fainelli April 27, 2022, 10:12 p.m. UTC | #3
On 4/27/22 15:08, Michael Walle wrote:
> Am 2022-04-28 00:06, schrieb Florian Fainelli:
>> On 4/27/2022 2:44 PM, Michael Walle wrote:
>>> The LAN8814 has a coma mode pin which puts the PHY into isolate and
>>> power-dowm mode. Unfortunately, the mode cannot be disabled by a
> s/dowm/down/
> 
>>> register. Usually, the input pin has a pull-up and connected to a GPIO
>>> which can then be used to disable the mode. Try to get the GPIO and
>>> deassert it.
>>
>> Poor choice of word, how about deep sleep, dormant, super isolate?
> 
> Which one do you mean? Super isolate sounded like broadcom wording ;)

Coma is not a great term to use IMHO. Yes Super isolate (tm) is a 
Broadcom thing, and you can come out of super isolate mode with register 
writes, so maybe not the best suggestion.
Michael Walle April 27, 2022, 10:17 p.m. UTC | #4
Am 2022-04-28 00:12, schrieb Florian Fainelli:
> On 4/27/22 15:08, Michael Walle wrote:
>> Am 2022-04-28 00:06, schrieb Florian Fainelli:
>>> On 4/27/2022 2:44 PM, Michael Walle wrote:
>>>> The LAN8814 has a coma mode pin which puts the PHY into isolate and
>>>> power-dowm mode. Unfortunately, the mode cannot be disabled by a
>> s/dowm/down/
>> 
>>>> register. Usually, the input pin has a pull-up and connected to a 
>>>> GPIO
>>>> which can then be used to disable the mode. Try to get the GPIO and
>>>> deassert it.
>>> 
>>> Poor choice of word, how about deep sleep, dormant, super isolate?
>> 
>> Which one do you mean? Super isolate sounded like broadcom wording ;)
> 
> Coma is not a great term to use IMHO. Yes Super isolate (tm) is a
> Broadcom thing, and you can come out of super isolate mode with
> register writes, so maybe not the best suggestion.

I didn't come up with that name. It's all in the datasheets and it's
actually already used grep for "COMA_MODE" in phy/mscc. (Yes on that
one you can actually disable it with register access..). Even if
it is not a great name (which I agree), I'd use the same naming as
the datasheet and esp. the pin name.

-michael
Florian Fainelli April 27, 2022, 10:23 p.m. UTC | #5
On 4/27/22 15:17, Michael Walle wrote:
> Am 2022-04-28 00:12, schrieb Florian Fainelli:
>> On 4/27/22 15:08, Michael Walle wrote:
>>> Am 2022-04-28 00:06, schrieb Florian Fainelli:
>>>> On 4/27/2022 2:44 PM, Michael Walle wrote:
>>>>> The LAN8814 has a coma mode pin which puts the PHY into isolate and
>>>>> power-dowm mode. Unfortunately, the mode cannot be disabled by a
>>> s/dowm/down/
>>>
>>>>> register. Usually, the input pin has a pull-up and connected to a GPIO
>>>>> which can then be used to disable the mode. Try to get the GPIO and
>>>>> deassert it.
>>>>
>>>> Poor choice of word, how about deep sleep, dormant, super isolate?
>>>
>>> Which one do you mean? Super isolate sounded like broadcom wording ;)
>>
>> Coma is not a great term to use IMHO. Yes Super isolate (tm) is a
>> Broadcom thing, and you can come out of super isolate mode with
>> register writes, so maybe not the best suggestion.
> 
> I didn't come up with that name. It's all in the datasheets and it's
> actually already used grep for "COMA_MODE" in phy/mscc. (Yes on that
> one you can actually disable it with register access..). Even if
> it is not a great name (which I agree), I'd use the same naming as
> the datasheet and esp. the pin name.

OK then, makes sense to use the datasheet name.
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index b981c5eaac33..685a0ab5453c 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -32,6 +32,7 @@ 
 #include <linux/ptp_clock.h>
 #include <linux/ptp_classify.h>
 #include <linux/net_tstamp.h>
+#include <linux/gpio/consumer.h>
 
 /* Operation Mode Strap Override */
 #define MII_KSZPHY_OMSO				0x16
@@ -2837,6 +2838,21 @@  static int lan8814_config_init(struct phy_device *phydev)
 	return 0;
 }
 
+static int lan8814_release_coma_mode(struct phy_device *phydev)
+{
+	struct gpio_desc *gpiod;
+
+	gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode",
+					GPIOD_OUT_HIGH_OPEN_DRAIN);
+	if (IS_ERR(gpiod))
+		return PTR_ERR(gpiod);
+
+	gpiod_set_consumer_name(gpiod, "LAN8814 coma mode");
+	gpiod_set_value_cansleep(gpiod, 0);
+
+	return 0;
+}
+
 static int lan8814_probe(struct phy_device *phydev)
 {
 	struct kszphy_priv *priv;
@@ -2859,6 +2875,10 @@  static int lan8814_probe(struct phy_device *phydev)
 			      addr, sizeof(struct lan8814_shared_priv));
 
 	if (phy_package_init_once(phydev)) {
+		err = lan8814_release_coma_mode(phydev);
+		if (err)
+			return err;
+
 		err = lan8814_ptp_probe_once(phydev);
 		if (err)
 			return err;