* [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY
@ 2022-09-12 19:56 Horatiu Vultur
2022-09-12 21:13 ` Andrew Lunn
2022-09-13 8:18 ` Michael Walle
0 siblings, 2 replies; 5+ messages in thread
From: Horatiu Vultur @ 2022-09-12 19:56 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
UNGLinuxDriver, Horatiu Vultur
Add support for interrupts for LAN8804 PHY.
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
drivers/net/phy/micrel.c | 55 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 7b8c5c8d013e..98e9bc101d96 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -2676,6 +2676,59 @@ static int lan8804_config_init(struct phy_device *phydev)
return 0;
}
+static irqreturn_t lan8804_handle_interrupt(struct phy_device *phydev)
+{
+ int status;
+
+ status = phy_read(phydev, LAN8814_INTS);
+ if (status < 0) {
+ phy_error(phydev);
+ return IRQ_NONE;
+ }
+
+ if (status > 0)
+ phy_trigger_machine(phydev);
+
+ return IRQ_HANDLED;
+}
+
+#define LAN8804_OUTPUT_CONTROL 25
+#define LAN8804_OUTPUT_CONTROL_INTR_BUFFER BIT(14)
+#define LAN8804_CONTROL 31
+#define LAN8804_CONTROL_INTR_POLARITY BIT(14)
+
+static int lan8804_config_intr(struct phy_device *phydev)
+{
+ int err;
+
+ /* Change interrupt polarity */
+ phy_write(phydev, LAN8804_CONTROL, LAN8804_CONTROL_INTR_POLARITY);
+
+ /* Change interrupt buffer type */
+ phy_write(phydev, LAN8804_OUTPUT_CONTROL,
+ LAN8804_OUTPUT_CONTROL_INTR_BUFFER);
+
+ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
+ err = phy_read(phydev, LAN8814_INTS);
+ if (err < 0)
+ return err;
+
+ err = phy_write(phydev, LAN8814_INTC, LAN8814_INT_LINK);
+ if (err)
+ return err;
+ } else {
+ err = phy_write(phydev, LAN8814_INTC, 0);
+ if (err)
+ return err;
+
+ err = phy_read(phydev, LAN8814_INTS);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
+}
+
static irqreturn_t lan8814_handle_interrupt(struct phy_device *phydev)
{
int irq_status, tsu_irq_status;
@@ -3137,6 +3190,8 @@ static struct phy_driver ksphy_driver[] = {
.get_stats = kszphy_get_stats,
.suspend = genphy_suspend,
.resume = kszphy_resume,
+ .config_intr = lan8804_config_intr,
+ .handle_interrupt = lan8804_handle_interrupt,
}, {
.phy_id = PHY_ID_KSZ9131,
.phy_id_mask = MICREL_PHY_ID_MASK,
--
2.33.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY
2022-09-12 19:56 [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY Horatiu Vultur
@ 2022-09-12 21:13 ` Andrew Lunn
2022-09-13 8:18 ` Michael Walle
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2022-09-12 21:13 UTC (permalink / raw)
To: Horatiu Vultur
Cc: netdev, linux-kernel, hkallweit1, linux, davem, edumazet, kuba,
pabeni, UNGLinuxDriver
On Mon, Sep 12, 2022 at 09:56:50PM +0200, Horatiu Vultur wrote:
> Add support for interrupts for LAN8804 PHY.
>
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY
2022-09-12 19:56 [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY Horatiu Vultur
2022-09-12 21:13 ` Andrew Lunn
@ 2022-09-13 8:18 ` Michael Walle
2022-09-13 9:45 ` Michael Walle
2022-09-13 12:23 ` Horatiu Vultur
1 sibling, 2 replies; 5+ messages in thread
From: Michael Walle @ 2022-09-13 8:18 UTC (permalink / raw)
To: horatiu.vultur
Cc: UNGLinuxDriver, andrew, davem, edumazet, hkallweit1, kuba,
linux-kernel, linux, netdev, pabeni, Michael Walle
> Add support for interrupts for LAN8804 PHY.
>
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
> drivers/net/phy/micrel.c | 55 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 55 insertions(+)
>
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 7b8c5c8d013e..98e9bc101d96 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -2676,6 +2676,59 @@ static int lan8804_config_init(struct phy_device *phydev)
> return 0;
> }
>
> +static irqreturn_t lan8804_handle_interrupt(struct phy_device *phydev)
> +{
> + int status;
> +
> + status = phy_read(phydev, LAN8814_INTS);
> + if (status < 0) {
> + phy_error(phydev);
> + return IRQ_NONE;
> + }
> +
> + if (status > 0)
> + phy_trigger_machine(phydev);
> +
> + return IRQ_HANDLED;
> +}
> +
> +#define LAN8804_OUTPUT_CONTROL 25
> +#define LAN8804_OUTPUT_CONTROL_INTR_BUFFER BIT(14)
> +#define LAN8804_CONTROL 31
> +#define LAN8804_CONTROL_INTR_POLARITY BIT(14)
> +
> +static int lan8804_config_intr(struct phy_device *phydev)
> +{
> + int err;
> +
> + /* Change interrupt polarity */
> + phy_write(phydev, LAN8804_CONTROL, LAN8804_CONTROL_INTR_POLARITY);
I assume you change the polarity to high active? Could you add a note?
The LAN966x nor the LAN8804 datasheet describe this bit. You might also add
a note, that this is an internal PHY and you cannot change the polarity on
the GIC. Which begs the question, is this really only an internal PHY or
can you actually buy it as a dedicated one. Then you'd change the polarity
in a really unusual way.
> +
> + /* Change interrupt buffer type */
To what? Push-pull?
-michael
> + phy_write(phydev, LAN8804_OUTPUT_CONTROL,
> + LAN8804_OUTPUT_CONTROL_INTR_BUFFER);
> +
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY
2022-09-13 8:18 ` Michael Walle
@ 2022-09-13 9:45 ` Michael Walle
2022-09-13 12:23 ` Horatiu Vultur
1 sibling, 0 replies; 5+ messages in thread
From: Michael Walle @ 2022-09-13 9:45 UTC (permalink / raw)
To: michael
Cc: UNGLinuxDriver, andrew, davem, edumazet, hkallweit1,
horatiu.vultur, kuba, linux-kernel, linux, netdev, pabeni
>> Add support for interrupts for LAN8804 PHY.
>>
>> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
>> ---
>> drivers/net/phy/micrel.c | 55 ++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 55 insertions(+)
>>
>> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
>> index 7b8c5c8d013e..98e9bc101d96 100644
>> --- a/drivers/net/phy/micrel.c
>> +++ b/drivers/net/phy/micrel.c
>> @@ -2676,6 +2676,59 @@ static int lan8804_config_init(struct phy_device *phydev)
>> return 0;
>> }
>>
>> +static irqreturn_t lan8804_handle_interrupt(struct phy_device *phydev)
>> +{
>> + int status;
>> +
>> + status = phy_read(phydev, LAN8814_INTS);
>> + if (status < 0) {
>> + phy_error(phydev);
>> + return IRQ_NONE;
>> + }
>> +
>> + if (status > 0)
>> + phy_trigger_machine(phydev);
>> +
>> + return IRQ_HANDLED;
>> +}
>> +
>> +#define LAN8804_OUTPUT_CONTROL 25
>> +#define LAN8804_OUTPUT_CONTROL_INTR_BUFFER BIT(14)
>> +#define LAN8804_CONTROL 31
>> +#define LAN8804_CONTROL_INTR_POLARITY BIT(14)
>> +
>> +static int lan8804_config_intr(struct phy_device *phydev)
>> +{
>> + int err;
>> +
>> + /* Change interrupt polarity */
>> + phy_write(phydev, LAN8804_CONTROL, LAN8804_CONTROL_INTR_POLARITY);
>
> I assume you change the polarity to high active? Could you add a note?
> The LAN966x nor the LAN8804 datasheet describe this bit. You might also add
> a note, that this is an internal PHY and you cannot change the polarity on
> the GIC. Which begs the question, is this really only an internal PHY or
> can you actually buy it as a dedicated one. Then you'd change the polarity
> in a really unusual way.
>
>
> > +
> > + /* Change interrupt buffer type */
>
> To what? Push-pull?
Regardless of my remarks, the code itself is working fine:
Tested-by: Michael Walle <michael@walle.cc> # on kontron-kswitch-d10
-michael
> + phy_write(phydev, LAN8804_OUTPUT_CONTROL,
> + LAN8804_OUTPUT_CONTROL_INTR_BUFFER);
> +
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY
2022-09-13 8:18 ` Michael Walle
2022-09-13 9:45 ` Michael Walle
@ 2022-09-13 12:23 ` Horatiu Vultur
1 sibling, 0 replies; 5+ messages in thread
From: Horatiu Vultur @ 2022-09-13 12:23 UTC (permalink / raw)
To: Michael Walle
Cc: UNGLinuxDriver, andrew, davem, edumazet, hkallweit1, kuba,
linux-kernel, linux, netdev, pabeni
The 09/13/2022 10:18, Michael Walle wrote:
>
> > Add support for interrupts for LAN8804 PHY.
> >
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> > ---
> > drivers/net/phy/micrel.c | 55 ++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 55 insertions(+)
> >
> > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> > index 7b8c5c8d013e..98e9bc101d96 100644
> > --- a/drivers/net/phy/micrel.c
> > +++ b/drivers/net/phy/micrel.c
> > @@ -2676,6 +2676,59 @@ static int lan8804_config_init(struct phy_device *phydev)
> > return 0;
> > }
> >
> > +static irqreturn_t lan8804_handle_interrupt(struct phy_device *phydev)
> > +{
> > + int status;
> > +
> > + status = phy_read(phydev, LAN8814_INTS);
> > + if (status < 0) {
> > + phy_error(phydev);
> > + return IRQ_NONE;
> > + }
> > +
> > + if (status > 0)
> > + phy_trigger_machine(phydev);
> > +
> > + return IRQ_HANDLED;
> > +}
> > +
> > +#define LAN8804_OUTPUT_CONTROL 25
> > +#define LAN8804_OUTPUT_CONTROL_INTR_BUFFER BIT(14)
> > +#define LAN8804_CONTROL 31
> > +#define LAN8804_CONTROL_INTR_POLARITY BIT(14)
> > +
> > +static int lan8804_config_intr(struct phy_device *phydev)
> > +{
> > + int err;
> > +
> > + /* Change interrupt polarity */
> > + phy_write(phydev, LAN8804_CONTROL, LAN8804_CONTROL_INTR_POLARITY);
>
> I assume you change the polarity to high active? Could you add a note?
> The LAN966x nor the LAN8804 datasheet describe this bit. You might also add
> a note, that this is an internal PHY and you cannot change the polarity on
> the GIC. Which begs the question, is this really only an internal PHY or
> can you actually buy it as a dedicated one. Then you'd change the polarity
> in a really unusual way.
That is correct, as you described it, I change the polarity to high.
From what I know, you can't buy a dedicated PHY.
I will add these notes in the next version.
>
>
> > +
> > + /* Change interrupt buffer type */
>
> To what? Push-pull?
Yes, I have changed it to push-pull.
I will add a node in the next version.
>
> -michael
>
> > + phy_write(phydev, LAN8804_OUTPUT_CONTROL,
> > + LAN8804_OUTPUT_CONTROL_INTR_BUFFER);
> > +
--
/Horatiu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-13 12:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-12 19:56 [PATCH net-next] net: phy: micrel: Add interrupts support for LAN8804 PHY Horatiu Vultur
2022-09-12 21:13 ` Andrew Lunn
2022-09-13 8:18 ` Michael Walle
2022-09-13 9:45 ` Michael Walle
2022-09-13 12:23 ` Horatiu Vultur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).