Commit 87566b44 authored by David S. Miller's avatar David S. Miller

Merge branch 'mediatek-add-support-for-MediaTek-Ethernet-MAC'

Bartosz Golaszewski says:

====================
mediatek: add support for MediaTek Ethernet MAC

This series adds support for the STAR Ethernet Controller present on MediaTeK
SoCs from the MT8* family.

First we convert the existing DT bindings for the PERICFG controller to YAML
and add a new compatible string for mt8516 variant of it. Then we add the DT
bindings for the MAC.

Next we do some cleanup of the mediatek ethernet drivers directory.

The largest patch in the series adds the actual new driver.

The rest of the patches add DT fixups for the boards already supported
upstream.

v1 -> v2:
- add a generic helper for retrieving the net_device associated with given
  private data
- fix several typos in commit messages
- remove MTK_MAC_VERSION and don't set the driver version
- use NET_IP_ALIGN instead of a magic number (2) but redefine it as it defaults
  to 0 on arm64
- don't manually turn the carrier off in mtk_mac_enable()
- process TX cleanup in napi poll callback
- configure pause in the adjust_link callback
- use regmap_read_poll_timeout() instead of handcoding the polling
- use devres_find() to verify that struct net_device is managed by devres in
  devm_register_netdev()
- add a patch moving all networking devres helpers into net/devres.c
- tweak the dma barriers: remove where unnecessary and add comments to the
  remaining barriers
- don't reset internal counters when enabling the NIC
- set the net_device's mtu size instead of checking the framesize in
  ndo_start_xmit() callback
- fix a race condition in waking up the netif queue
- don't emit log messages on OOM errors
- use dma_set_mask_and_coherent()
- use eth_hw_addr_random()
- rework the receive callback so that we reuse the previous skb if unmapping
  fails, like we already do if skb allocation fails
- rework hash table operations: add proper timeout handling and clear bits when
  appropriate

v2 -> v3:
- drop the patch adding priv_to_netdev() and store the netdev pointer in the
  driver private data
- add an additional dma_wmb() after reseting the descriptor in
  mtk_mac_ring_pop_tail()
- check the return value of dma_set_mask_and_coherent()
- improve the DT bindings for mtk-eth-mac: make the reg property in the example
  use single-cell address and size, extend the description of the PERICFG
  phandle and document the mdio sub-node
- add a patch converting the old .txt bindings for PERICFG to yaml
- limit reading the DMA memory by storing the mapped addresses in the driver
  private structure
- add a patch documenting the existing networking devres helpers

v3 -> v4:
- drop the devres patches: they will be sent separately
- call netdev_sent_queue() & netdev_completed_queue() where appropriate
- don't redefine NET_IP_ALIGN: define a private constant in the driver
- fix a couple typos
- only disabe/enable the MAC in suspend/resume if netif is running
- drop the count field from the ring structure and instead calculate the number
  of used descriptors from the tail and head indicies
- rework the locking used to protect the ring structures from concurrent
  access: use cheaper spin_lock_bh() and completely disable the internal
  spinlock used by regmap
- rework the interrupt handling to make it more fine-grained: onle re-enable
  TX and RX interrupts while they're needed, process the stats updates in a
  workqueue, not in napi context
- shrink the code responsible for unmapping and freeing skb memory
- rework the barriers as advised by Arnd

v4 -> v5:
- rename the driver to make it less confusing with the existing mtk_eth_soc
  ethernet driver
- unregister the mdiobus at device's detachment
- open-code spin lock calls to avoid calling the _bh variants where unnecessary
- limit read-modify-write operations where possible when accessing descriptor
  memory
- use READ_ONCE/WRITE_ONCE when modifying the status and data_ptr descriptor
  fields
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 199671ea 4e4ad686
Mediatek pericfg controller
===========================
The Mediatek pericfg controller provides various clocks and reset
outputs to the system.
Required Properties:
- compatible: Should be one of:
- "mediatek,mt2701-pericfg", "syscon"
- "mediatek,mt2712-pericfg", "syscon"
- "mediatek,mt7622-pericfg", "syscon"
- "mediatek,mt7623-pericfg", "mediatek,mt2701-pericfg", "syscon"
- "mediatek,mt7629-pericfg", "syscon"
- "mediatek,mt8135-pericfg", "syscon"
- "mediatek,mt8173-pericfg", "syscon"
- "mediatek,mt8183-pericfg", "syscon"
- #clock-cells: Must be 1
- #reset-cells: Must be 1
The pericfg controller uses the common clk binding from
Documentation/devicetree/bindings/clock/clock-bindings.txt
The available clocks are defined in dt-bindings/clock/mt*-clk.h.
Also it uses the common reset controller binding from
Documentation/devicetree/bindings/reset/reset.txt.
The available reset outputs are defined in
dt-bindings/reset/mt*-resets.h
Example:
pericfg: power-controller@10003000 {
compatible = "mediatek,mt8173-pericfg", "syscon";
reg = <0 0x10003000 0 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: "http://devicetree.org/schemas/arm/mediatek/mediatek,pericfg.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"
title: MediaTek Peripheral Configuration Controller
maintainers:
- Bartosz Golaszewski <bgolaszewski@baylibre.com>
description:
The Mediatek pericfg controller provides various clocks and reset outputs
to the system.
properties:
compatible:
oneOf:
- items:
- enum:
- mediatek,mt2701-pericfg
- mediatek,mt2712-pericfg
- mediatek,mt7622-pericfg
- mediatek,mt7629-pericfg
- mediatek,mt8135-pericfg
- mediatek,mt8173-pericfg
- mediatek,mt8183-pericfg
- mediatek,mt8516-pericfg
- const: syscon
- items:
# Special case for mt7623 for backward compatibility
- const: mediatek,mt7623-pericfg
- const: mediatek,mt2701-pericfg
- const: syscon
reg:
maxItems: 1
'#clock-cells':
const: 1
'#reset-cells':
const: 1
required:
- compatible
- reg
examples:
- |
pericfg@10003000 {
compatible = "mediatek,mt8173-pericfg", "syscon";
reg = <0x10003000 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
- |
pericfg@10003000 {
compatible = "mediatek,mt7623-pericfg", "mediatek,mt2701-pericfg", "syscon";
reg = <0x10003000 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/mediatek,eth-mac.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: MediaTek STAR Ethernet MAC Controller
maintainers:
- Bartosz Golaszewski <bgolaszewski@baylibre.com>
description:
This Ethernet MAC is used on the MT8* family of SoCs from MediaTek.
It's compliant with 802.3 standards and supports half- and full-duplex
modes with flow-control as well as CRC offloading and VLAN tags.
allOf:
- $ref: "ethernet-controller.yaml#"
properties:
compatible:
enum:
- mediatek,mt8516-eth
- mediatek,mt8518-eth
- mediatek,mt8175-eth
reg:
maxItems: 1
interrupts:
maxItems: 1
clocks:
minItems: 3
maxItems: 3
clock-names:
additionalItems: false
items:
- const: core
- const: reg
- const: trans
mediatek,pericfg:
$ref: /schemas/types.yaml#definitions/phandle
description:
Phandle to the device containing the PERICFG register range. This is used
to control the MII mode.
mdio:
type: object
description:
Creates and registers an MDIO bus.
required:
- compatible
- reg
- interrupts
- clocks
- clock-names
- mediatek,pericfg
- phy-handle
examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/clock/mt8516-clk.h>
ethernet: ethernet@11180000 {
compatible = "mediatek,mt8516-eth";
reg = <0x11180000 0x1000>;
mediatek,pericfg = <&pericfg>;
interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>;
clocks = <&topckgen CLK_TOP_RG_ETH>,
<&topckgen CLK_TOP_66M_ETH>,
<&topckgen CLK_TOP_133M_ETH>;
clock-names = "core", "reg", "trans";
phy-handle = <&eth_phy>;
phy-mode = "rmii";
mdio {
#address-cells = <1>;
#size-cells = <0>;
eth_phy: ethernet-phy@0 {
reg = <0>;
};
};
};
......@@ -191,6 +191,11 @@ infracfg: infracfg@10001000 {
#clock-cells = <1>;
};
pericfg: pericfg@10003050 {
compatible = "mediatek,mt8516-pericfg", "syscon";
reg = <0 0x10003050 0 0x1000>;
};
apmixedsys: apmixedsys@10018000 {
compatible = "mediatek,mt8516-apmixedsys", "syscon";
reg = <0 0x10018000 0 0x710>;
......@@ -401,6 +406,18 @@ mmc2: mmc@11170000 {
status = "disabled";
};
ethernet: ethernet@11180000 {
compatible = "mediatek,mt8516-eth";
reg = <0 0x11180000 0 0x1000>;
mediatek,pericfg = <&pericfg>;
interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>;
clocks = <&topckgen CLK_TOP_RG_ETH>,
<&topckgen CLK_TOP_66M_ETH>,
<&topckgen CLK_TOP_133M_ETH>;
clock-names = "core", "reg", "trans";
status = "disabled";
};
rng: rng@1020c000 {
compatible = "mediatek,mt8516-rng",
"mediatek,mt7623-rng";
......
......@@ -9,6 +9,7 @@
/ {
aliases {
serial0 = &uart0;
ethernet0 = &ethernet;
};
chosen {
......@@ -166,6 +167,24 @@ &uart0 {
status = "okay";
};
&ethernet {
pinctrl-names = "default";
pinctrl-0 = <&ethernet_pins_default>;
phy-handle = <&eth_phy>;
phy-mode = "rmii";
mac-address = [00 00 00 00 00 00];
status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
eth_phy: ethernet-phy@0 {
reg = <0>;
};
};
};
&usb0 {
status = "okay";
dr_mode = "peripheral";
......@@ -218,4 +237,19 @@ gpio_mux_int_n_pin {
bias-pull-up;
};
};
ethernet_pins_default: ethernet {
pins_ethernet {
pinmux = <MT8516_PIN_0_EINT0__FUNC_EXT_TXD0>,
<MT8516_PIN_1_EINT1__FUNC_EXT_TXD1>,
<MT8516_PIN_5_EINT5__FUNC_EXT_RXER>,
<MT8516_PIN_6_EINT6__FUNC_EXT_RXC>,
<MT8516_PIN_7_EINT7__FUNC_EXT_RXDV>,
<MT8516_PIN_8_EINT8__FUNC_EXT_RXD0>,
<MT8516_PIN_9_EINT9__FUNC_EXT_RXD1>,
<MT8516_PIN_12_EINT12__FUNC_EXT_TXEN>,
<MT8516_PIN_38_MRG_DI__FUNC_EXT_MDIO>,
<MT8516_PIN_39_MRG_DO__FUNC_EXT_MDC>;
};
};
};
# SPDX-License-Identifier: GPL-2.0-only
config NET_VENDOR_MEDIATEK
bool "MediaTek ethernet driver"
bool "MediaTek devices"
depends on ARCH_MEDIATEK || SOC_MT7621 || SOC_MT7620
---help---
If you have a Mediatek SoC with ethernet, say Y.
......@@ -14,4 +14,11 @@ config NET_MEDIATEK_SOC
This driver supports the gigabit ethernet MACs in the
MediaTek SoC family.
config NET_MEDIATEK_STAR_EMAC
tristate "MediaTek STAR Ethernet MAC support"
select PHYLIB
help
This driver supports the ethernet MAC IP first used on
MediaTek MT85** SoCs.
endif #NET_VENDOR_MEDIATEK
......@@ -3,5 +3,6 @@
# Makefile for the Mediatek SoCs built-in ethernet macs
#
obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o
obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o
mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o
obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment