mbox series

[v5,net-next,00/10] net: Korina improvements

Message ID 20210416085207.63181-1-tsbogend@alpha.franken.de
Headers show
Series net: Korina improvements | expand

Message

Thomas Bogendoerfer April 16, 2021, 8:51 a.m. UTC
While converting Mikrotik RB532 support to use device tree I stumbled
over the korina ethernet driver, which used way too many MIPS specific
hacks. This series cleans this all up and adds support for device tree.

Changes in v5:
  - fixed email address in binding document, which prevented sending it

Changes in v4:
  - improve error returns in mdio_read further
  - added clock name and improved clk handling
  - fixed bindind errors

Changes in v3:
  - use readl_poll_timeout_atomic in mdio_wait
  - return -ETIMEDOUT, if mdio_wait failed
  - added DT binding and changed name to idt,3243x-emac
  - fixed usage of of_get_mac_address for net-next

Changes in v2:
  - added device tree support to get rid of idt_cpu_freq
  - fixed compile test on 64bit archs
  - fixed descriptor current address handling by storing/using mapped
    dma addresses (dma controller modifies current address)

Thomas Bogendoerfer (10):
  net: korina: Fix MDIO functions
  net: korina: Use devres functions
  net: korina: Remove not needed cache flushes
  net: korina: Remove nested helpers
  net: korina: Use DMA API
  net: korina: Only pass mac address via platform data
  net: korina: Add support for device tree
  net: korina: Get mdio input clock via common clock framework
  net: korina: Make driver COMPILE_TESTable
  dt-bindings: net: korina: Add DT bindings for IDT 79RC3243x SoCs

 .../bindings/net/idt,3243x-emac.yaml          |  74 +++
 arch/mips/rb532/devices.c                     |   5 +-
 drivers/net/ethernet/Kconfig                  |   3 +-
 drivers/net/ethernet/korina.c                 | 601 +++++++++++++-----
 4 files changed, 511 insertions(+), 172 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/idt,3243x-emac.yaml

Comments

Thomas Bogendoerfer April 16, 2021, 1:35 p.m. UTC | #1
On Fri, Apr 16, 2021 at 12:29:46PM +0300, Sergei Shtylyov wrote:
> On 16.04.2021 11:52, Thomas Bogendoerfer wrote:
> 
> > Add device tree bindings for ethernet controller integrated into
> > IDT 79RC3243x SoCs.
> > 
> > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > ---
> >   .../bindings/net/idt,3243x-emac.yaml          | 74 +++++++++++++++++++
> >   1 file changed, 74 insertions(+)
> >   create mode 100644 Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml b/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
> > new file mode 100644
> > index 000000000000..3697af5cb66f
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
> > @@ -0,0 +1,74 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/idt,3243x-emac.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: IDT 79rc3243x Ethernet controller
> > +
> > +description: Ethernet controller integrated into IDT 79RC3243x family SoCs
> > +
> > +maintainers:
> > +  - Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > +
> > +allOf:
> > +  - $ref: ethernet-controller.yaml#
> > +
> > +properties:
> > +  compatible:
> > +    const: idt,3243x-emac
> > +
> > +  reg:
> > +    maxItems: 3
> > +
> > +  reg-names:
> > +    items:
> > +      - const: korina_regs
> > +      - const: korina_dma_rx
> > +      - const: korina_dma_tx
> > +
> > +  interrupts:
> > +    items:
> > +      - description: RX interrupt
> > +      - description: TX interrupt
> > +
> > +  interrupt-names:
> > +    items:
> > +      - const: korina_rx
> > +      - const: korina_tx
> > +
> > +  clocks:
> > +    maxItems: 1
> > +
> > +  clock-names:
> > +    items:
> > +      - const: mdioclk
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - reg-names
> > +  - interrupts
> > +  - interrupt-names
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +
> > +    ethernet@60000 {
> > +        compatible = "idt,3243x-emac";
> > +
> > +        reg = <0x60000 0x10000>,
> > +              <0x40000 0x14>,
> > +              <0x40014 0x14>;
> > +        reg-names = "korina_regs",
> > +                    "korina_dma_rx",
> > +                    "korina_dma_tx";
> > +
> > +        interrupts-extended = <&rcpic3 0>, <&rcpic3 1>;
> 
>    You use this prop, yet don't describe it?

that's just interrupt-parent and interrupts in one statement. And since
make dt_binding_check didn't complained I thought that's good this way.
Rob, do I need to describe interrupts-extended as well ?

I could change that to interrupt-parent/interrupts as the driver no
longer uses dma under/overrun interrupts, which have a different
interrupt-parent.

Thomas.
Rob Herring April 16, 2021, 7:11 p.m. UTC | #2
On Fri, Apr 16, 2021 at 03:35:36PM +0200, Thomas Bogendoerfer wrote:
> On Fri, Apr 16, 2021 at 12:29:46PM +0300, Sergei Shtylyov wrote:
> > On 16.04.2021 11:52, Thomas Bogendoerfer wrote:
> > 
> > > Add device tree bindings for ethernet controller integrated into
> > > IDT 79RC3243x SoCs.
> > > 
> > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > ---
> > >   .../bindings/net/idt,3243x-emac.yaml          | 74 +++++++++++++++++++
> > >   1 file changed, 74 insertions(+)
> > >   create mode 100644 Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
> > > 
> > > diff --git a/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml b/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
> > > new file mode 100644
> > > index 000000000000..3697af5cb66f
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
> > > @@ -0,0 +1,74 @@
> > > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/net/idt,3243x-emac.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: IDT 79rc3243x Ethernet controller
> > > +
> > > +description: Ethernet controller integrated into IDT 79RC3243x family SoCs
> > > +
> > > +maintainers:
> > > +  - Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > +
> > > +allOf:
> > > +  - $ref: ethernet-controller.yaml#
> > > +
> > > +properties:
> > > +  compatible:
> > > +    const: idt,3243x-emac
> > > +
> > > +  reg:
> > > +    maxItems: 3
> > > +
> > > +  reg-names:
> > > +    items:
> > > +      - const: korina_regs
> > > +      - const: korina_dma_rx
> > > +      - const: korina_dma_tx
> > > +
> > > +  interrupts:
> > > +    items:
> > > +      - description: RX interrupt
> > > +      - description: TX interrupt
> > > +
> > > +  interrupt-names:
> > > +    items:
> > > +      - const: korina_rx
> > > +      - const: korina_tx
> > > +
> > > +  clocks:
> > > +    maxItems: 1
> > > +
> > > +  clock-names:
> > > +    items:
> > > +      - const: mdioclk
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - reg-names
> > > +  - interrupts
> > > +  - interrupt-names
> > > +
> > > +additionalProperties: false
> > > +
> > > +examples:
> > > +  - |
> > > +
> > > +    ethernet@60000 {
> > > +        compatible = "idt,3243x-emac";
> > > +
> > > +        reg = <0x60000 0x10000>,
> > > +              <0x40000 0x14>,
> > > +              <0x40014 0x14>;
> > > +        reg-names = "korina_regs",
> > > +                    "korina_dma_rx",
> > > +                    "korina_dma_tx";
> > > +
> > > +        interrupts-extended = <&rcpic3 0>, <&rcpic3 1>;
> > 
> >    You use this prop, yet don't describe it?
> 
> that's just interrupt-parent and interrupts in one statement. And since
> make dt_binding_check didn't complained I thought that's good this way.
> Rob, do I need to describe interrupts-extended as well ?

No, the tooling handles both cases. What the parent is is outside the 
scope of a binding.

> I could change that to interrupt-parent/interrupts as the driver no
> longer uses dma under/overrun interrupts, which have a different
> interrupt-parent.

Humm, you should be describing the interrupt connections the h/w block 
has, not what the driver uses (today) or not.

Rob
Sergei Shtylyov April 17, 2021, 10:19 a.m. UTC | #3
On 16.04.2021 16:35, Thomas Bogendoerfer wrote:
> On Fri, Apr 16, 2021 at 12:29:46PM +0300, Sergei Shtylyov wrote:
>> On 16.04.2021 11:52, Thomas Bogendoerfer wrote:
>>
>>> Add device tree bindings for ethernet controller integrated into
>>> IDT 79RC3243x SoCs.
>>>
>>> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
>>> ---
>>>    .../bindings/net/idt,3243x-emac.yaml          | 74 +++++++++++++++++++
>>>    1 file changed, 74 insertions(+)
>>>    create mode 100644 Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
>>>
>>> diff --git a/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml b/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
>>> new file mode 100644
>>> index 000000000000..3697af5cb66f
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/net/idt,3243x-emac.yaml
>>> @@ -0,0 +1,74 @@
>>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/net/idt,3243x-emac.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: IDT 79rc3243x Ethernet controller
>>> +
>>> +description: Ethernet controller integrated into IDT 79RC3243x family SoCs
>>> +
>>> +maintainers:
>>> +  - Thomas Bogendoerfer <tsbogend@alpha.franken.de>
>>> +
>>> +allOf:
>>> +  - $ref: ethernet-controller.yaml#
>>> +
>>> +properties:
>>> +  compatible:
>>> +    const: idt,3243x-emac
>>> +
>>> +  reg:
>>> +    maxItems: 3
>>> +
>>> +  reg-names:
>>> +    items:
>>> +      - const: korina_regs
>>> +      - const: korina_dma_rx
>>> +      - const: korina_dma_tx
>>> +
>>> +  interrupts:
>>> +    items:
>>> +      - description: RX interrupt
>>> +      - description: TX interrupt
>>> +
>>> +  interrupt-names:
>>> +    items:
>>> +      - const: korina_rx
>>> +      - const: korina_tx
>>> +
>>> +  clocks:
>>> +    maxItems: 1
>>> +
>>> +  clock-names:
>>> +    items:
>>> +      - const: mdioclk
>>> +
>>> +required:
>>> +  - compatible
>>> +  - reg
>>> +  - reg-names
>>> +  - interrupts
>>> +  - interrupt-names
>>> +
>>> +additionalProperties: false
>>> +
>>> +examples:
>>> +  - |
>>> +
>>> +    ethernet@60000 {
>>> +        compatible = "idt,3243x-emac";
>>> +
>>> +        reg = <0x60000 0x10000>,
>>> +              <0x40000 0x14>,
>>> +              <0x40014 0x14>;
>>> +        reg-names = "korina_regs",
>>> +                    "korina_dma_rx",
>>> +                    "korina_dma_tx";
>>> +
>>> +        interrupts-extended = <&rcpic3 0>, <&rcpic3 1>;
>>
>>     You use this prop, yet don't describe it?
> 
> that's just interrupt-parent and interrupts in one statement. And since

    I know. :-) Yet you don't mention it, making the "interrupts" prop 
mandatory instead. And as both interrupt parents are the same here, it does 
not even seem justified...

> make dt_binding_check didn't complained I thought that's good this way.
> Rob, do I need to describe interrupts-extended as well ?
> 
> I could change that to interrupt-parent/interrupts as the driver no
> longer uses dma under/overrun interrupts, which have a different
> interrupt-parent.

    In DT, we describe the hardware,  not the driver's capabilities.

> Thomas.

MBR, Sergei