Messages in this thread | | | Date | Tue, 23 Aug 2022 16:33:14 +0200 | From | Andrew Lunn <> | Subject | Re: [RFC Patch net-next v2] net: dsa: microchip: lan937x: enable interrupt for internal phy link detection |
| |
> I used the same gpio line number of switch as the interrupt for > internal phy. And when phy link up/down happens, it triggers both the > switch and phy interrupt routine.
Ah, shared interrupt. O.K.
> I have not used irq_domain before. Can you please brief on how phy > interrupt handler is called from chip.c & global2.
There are two different ways this can all be glued together.
Using irq_domain, each interrupt source becomes a full interrupt in Linux. You can see these individual interrupt sources in /proc/interrupts. You can use request_threaded_irq() on it. The mv88e6xxx driver is also an interrupt controller as well as an Ethernet switch.
> The dts file I used for testing, > spi1: spi@f8008000 { > cs-gpios = <0>, <0>, <0>, <&pioC 28 0>; > id = <1>; > status = "okay"; > > lan9370: lan9370@3 { > compatible = "microchip,lan9370"; > reg = <3>; > spi-max-frequency = <44000000>; > interrupt-parent = <&pioB>; > interrupts = <28 IRQ_TYPE_LEVEL_LOW>; > interrupt-controller; > status = "okay"; > ports { > #address-cells = <1>; > #size-cells = <0>; > port@0 { > reg = <0x0>; > phy-handle = <&t1phy0>; > phy-mode = "internal"; > label = "lan1"; > }; > port@1 { > reg = <0x1>; > phy-handle = <&t1phy1>; > phy-mode = "internal"; > label = "lan2"; > }; > } > } > > mdio { > #address-cells = <1>; > #size-cells = <0>; > compatible = "microchip,lan937x-mdio"; > > t1phy0: ethernet-phy@0{ > interrupt-parent = <&lan9370>; > interrupts = <28 IRQ_TYPE_LEVEL_LOW>;
So here you would use the interrupt number within the domain. Ideally you want port 0 to use interrupt 0.
> reg = <0x0>; > }; > t1phy1: ethernet-phy@1{ > interrupt-parent = <&lan9370>; > interrupts = <28 IRQ_TYPE_LEVEL_LOW>;
and here port 1 uses interrupt 1.
> reg = <0x1>; > }; > } > }
You can see this for an Marvell switch here:
https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts#L93
Doing it this way is however very verbose. I later discovered a short cut:
https://elixir.bootlin.com/linux/latest/source/drivers/net/dsa/mv88e6xxx/global2.c#L1164
by setting mdiobus->irq[] to the interrupt number, phylib will automatically use the correct interrupt without needing an DT.
Andrew
| |