Merge branch 'actions-semi-ethernet-mac'

Cristian Ciocaltea says:

====================
Add support for Actions Semi Owl Ethernet MAC

This patch series adds support for the Ethernet MAC found on the Actions
Semi Owl family of SoCs.

For the moment I have only tested the driver on RoseapplePi SBC, which is
based on the S500 SoC variant. It might work on S900 as well, but I cannot
tell for sure since the S900 datasheet I currently have doesn't provide
any information regarding the MAC registers - so I couldn't check the
compatibility with S500.

Similar story for S700: the datasheet I own is incomplete, but it seems
the MAC is advertised with Gigabit capabilities. For that reason most
probably we need to extend the current implementation in order to support
this SoC variant as well.

Please note that for testing the driver it is also necessary to update the
S500 clock subsystem:

https://lore.kernel.org/lkml/cover.1615221459.git.cristian.ciocaltea@gmail.com/

The DTS changes for the S500 SBCs will be provided separately.

Thanks,
Cristi

Changes in v3:
 - Dropped the 'debug' module parameter and passed the default NETIF_MSG flags
to netif_msg_init(), according to David's review

 - Removed the owl_emac_generate_mac_addr() function and the related
OWL_EMAC_GEN_ADDR_SYS_SN config option until a portable solution to get
the system serial number is found - when building on arm64 the following
error is thrown (as reported by Rob's kernel bot):
 '[...]/owl-emac.c:9:10: fatal error: asm/system_info.h: No such file or directory'

 - Rebased patchset on v5.12-rc4

Changes in v2:
* According to Philipp's review
 - Requested exclusive control over serial line via
   devm_reset_control_get_exclusive()
 - Optimized error handling by using dev_err_probe()

* According to Andrew's review
 - Dropped the inline keywords
 - Applied Reverse Christmas Tree format to local variable declarations
 - Renamed owl_emac_phy_config() to owl_emac_update_link_state()
 - Documented the purpose of the special descriptor used in the context of
   owl_emac_setup_frame_xmit()
 - Updated comment inside owl_emac_mdio_clock_enable() regarding the MDC
   clock divider setup
 - Indicated MAC support for symmetric pause via phy_set_sym_pause()
   in owl_emac_phy_init()
 - Changed the MAC addr generation algorithm in owl_emac_generate_mac_addr()
   by setting the locally administered bit in byte 0 and replacing bytes 1 & 2
   with additional entries from enc_sn
 - Moved devm_add_action_or_reset() before clk_set_rate() in owl_emac_probe()

* Other
 - Added SMII interface support: updated owl_emac_core_sw_reset(), added
   owl_emac_clk_set_rate(), updated description in the YAML binding
 - Changed OWL_EMAC_TX_TIMEOUT from 0.05*HZ to 2*HZ
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2021-03-22 12:56:21 -07:00
commit 5e83028215
8 changed files with 2033 additions and 0 deletions

View file

@ -0,0 +1,92 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/actions,owl-emac.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Actions Semi Owl SoCs Ethernet MAC Controller
maintainers:
- Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
description: |
This Ethernet MAC is used on the Owl family of SoCs from Actions Semi.
It provides the RMII and SMII interfaces and is compliant with the
IEEE 802.3 CSMA/CD standard, supporting both half-duplex and full-duplex
operation modes at 10/100 Mb/s data transfer rates.
allOf:
- $ref: "ethernet-controller.yaml#"
properties:
compatible:
oneOf:
- const: actions,owl-emac
- items:
- enum:
- actions,s500-emac
- const: actions,owl-emac
reg:
maxItems: 1
interrupts:
maxItems: 1
clocks:
minItems: 2
maxItems: 2
clock-names:
additionalItems: false
items:
- const: eth
- const: rmii
resets:
maxItems: 1
actions,ethcfg:
$ref: /schemas/types.yaml#/definitions/phandle
description:
Phandle to the device containing custom config.
required:
- compatible
- reg
- interrupts
- clocks
- clock-names
- resets
- phy-mode
- phy-handle
unevaluatedProperties: false
examples:
- |
#include <dt-bindings/clock/actions,s500-cmu.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/reset/actions,s500-reset.h>
ethernet@b0310000 {
compatible = "actions,s500-emac", "actions,owl-emac";
reg = <0xb0310000 0x10000>;
interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cmu 59 /*CLK_ETHERNET*/>, <&cmu CLK_RMII_REF>;
clock-names = "eth", "rmii";
resets = <&cmu RESET_ETHERNET>;
phy-mode = "rmii";
phy-handle = <&eth_phy>;
mdio {
#address-cells = <1>;
#size-cells = <0>;
eth_phy: ethernet-phy@3 {
reg = <0x3>;
interrupt-parent = <&sirq>;
interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
};
};
};

View file

@ -1530,6 +1530,7 @@ F: Documentation/devicetree/bindings/dma/owl-dma.yaml
F: Documentation/devicetree/bindings/i2c/i2c-owl.yaml
F: Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.yaml
F: Documentation/devicetree/bindings/mmc/owl-mmc.yaml
F: Documentation/devicetree/bindings/net/actions,owl-emac.yaml
F: Documentation/devicetree/bindings/pinctrl/actions,*
F: Documentation/devicetree/bindings/power/actions,owl-sps.txt
F: Documentation/devicetree/bindings/timer/actions,owl-timer.txt
@ -1542,6 +1543,7 @@ F: drivers/dma/owl-dma.c
F: drivers/i2c/busses/i2c-owl.c
F: drivers/irqchip/irq-owl-sirq.c
F: drivers/mmc/host/owl-mmc.c
F: drivers/net/ethernet/actions/
F: drivers/pinctrl/actions/*
F: drivers/soc/actions/
F: include/dt-bindings/power/owl-*

View file

@ -19,6 +19,7 @@ config SUNGEM_PHY
tristate
source "drivers/net/ethernet/3com/Kconfig"
source "drivers/net/ethernet/actions/Kconfig"
source "drivers/net/ethernet/adaptec/Kconfig"
source "drivers/net/ethernet/aeroflex/Kconfig"
source "drivers/net/ethernet/agere/Kconfig"

View file

@ -5,6 +5,7 @@
obj-$(CONFIG_NET_VENDOR_3COM) += 3com/
obj-$(CONFIG_NET_VENDOR_8390) += 8390/
obj-$(CONFIG_NET_VENDOR_ACTIONS) += actions/
obj-$(CONFIG_NET_VENDOR_ADAPTEC) += adaptec/
obj-$(CONFIG_GRETH) += aeroflex/
obj-$(CONFIG_NET_VENDOR_AGERE) += agere/

View file

@ -0,0 +1,26 @@
# SPDX-License-Identifier: GPL-2.0-only
config NET_VENDOR_ACTIONS
bool "Actions Semi devices"
default y
depends on ARCH_ACTIONS
help
If you have a network (Ethernet) card belonging to this class, say Y.
Note that the answer to this question doesn't directly affect the
kernel: saying N will just cause the configurator to skip all the
questions about Actions Semi devices. If you say Y, you will be
asked for your specific card in the following questions.
if NET_VENDOR_ACTIONS
config OWL_EMAC
tristate "Actions Semi Owl Ethernet MAC support"
select PHYLIB
help
This driver supports the Actions Semi Ethernet Media Access
Controller (EMAC) found on the S500 and S900 SoCs. The controller
is compliant with the IEEE 802.3 CSMA/CD standard and supports
both half-duplex and full-duplex operation modes at 10/100 Mb/s.
endif # NET_VENDOR_ACTIONS

View file

@ -0,0 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Makefile for the Actions Semi Owl SoCs built-in ethernet macs
#
obj-$(CONFIG_OWL_EMAC) += owl-emac.o

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,280 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Actions Semi Owl SoCs Ethernet MAC driver
*
* Copyright (c) 2012 Actions Semi Inc.
* Copyright (c) 2021 Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
*/
#ifndef __OWL_EMAC_H__
#define __OWL_EMAC_H__
#define OWL_EMAC_DRVNAME "owl-emac"
#define OWL_EMAC_POLL_DELAY_USEC 5
#define OWL_EMAC_MDIO_POLL_TIMEOUT_USEC 1000
#define OWL_EMAC_RESET_POLL_TIMEOUT_USEC 2000
#define OWL_EMAC_TX_TIMEOUT (2 * HZ)
#define OWL_EMAC_MTU_MIN ETH_MIN_MTU
#define OWL_EMAC_MTU_MAX ETH_DATA_LEN
#define OWL_EMAC_RX_FRAME_MAX_LEN (ETH_FRAME_LEN + ETH_FCS_LEN)
#define OWL_EMAC_SKB_ALIGN 4
#define OWL_EMAC_SKB_RESERVE 18
#define OWL_EMAC_MAX_MULTICAST_ADDRS 14
#define OWL_EMAC_SETUP_FRAME_LEN 192
#define OWL_EMAC_RX_RING_SIZE 64
#define OWL_EMAC_TX_RING_SIZE 32
/* Bus mode register */
#define OWL_EMAC_REG_MAC_CSR0 0x0000
#define OWL_EMAC_BIT_MAC_CSR0_SWR BIT(0) /* Software reset */
/* Transmit/receive poll demand registers */
#define OWL_EMAC_REG_MAC_CSR1 0x0008
#define OWL_EMAC_VAL_MAC_CSR1_TPD 0x01
#define OWL_EMAC_REG_MAC_CSR2 0x0010
#define OWL_EMAC_VAL_MAC_CSR2_RPD 0x01
/* Receive/transmit descriptor list base address registers */
#define OWL_EMAC_REG_MAC_CSR3 0x0018
#define OWL_EMAC_REG_MAC_CSR4 0x0020
/* Status register */
#define OWL_EMAC_REG_MAC_CSR5 0x0028
#define OWL_EMAC_MSK_MAC_CSR5_TS GENMASK(22, 20) /* Transmit process state */
#define OWL_EMAC_OFF_MAC_CSR5_TS 20
#define OWL_EMAC_VAL_MAC_CSR5_TS_DATA 0x03 /* Transferring data HOST -> FIFO */
#define OWL_EMAC_VAL_MAC_CSR5_TS_CDES 0x07 /* Closing transmit descriptor */
#define OWL_EMAC_MSK_MAC_CSR5_RS GENMASK(19, 17) /* Receive process state */
#define OWL_EMAC_OFF_MAC_CSR5_RS 17
#define OWL_EMAC_VAL_MAC_CSR5_RS_FDES 0x01 /* Fetching receive descriptor */
#define OWL_EMAC_VAL_MAC_CSR5_RS_CDES 0x05 /* Closing receive descriptor */
#define OWL_EMAC_VAL_MAC_CSR5_RS_DATA 0x07 /* Transferring data FIFO -> HOST */
#define OWL_EMAC_BIT_MAC_CSR5_NIS BIT(16) /* Normal interrupt summary */
#define OWL_EMAC_BIT_MAC_CSR5_AIS BIT(15) /* Abnormal interrupt summary */
#define OWL_EMAC_BIT_MAC_CSR5_ERI BIT(14) /* Early receive interrupt */
#define OWL_EMAC_BIT_MAC_CSR5_GTE BIT(11) /* General-purpose timer expiration */
#define OWL_EMAC_BIT_MAC_CSR5_ETI BIT(10) /* Early transmit interrupt */
#define OWL_EMAC_BIT_MAC_CSR5_RPS BIT(8) /* Receive process stopped */
#define OWL_EMAC_BIT_MAC_CSR5_RU BIT(7) /* Receive buffer unavailable */
#define OWL_EMAC_BIT_MAC_CSR5_RI BIT(6) /* Receive interrupt */
#define OWL_EMAC_BIT_MAC_CSR5_UNF BIT(5) /* Transmit underflow */
#define OWL_EMAC_BIT_MAC_CSR5_LCIS BIT(4) /* Link change status */
#define OWL_EMAC_BIT_MAC_CSR5_LCIQ BIT(3) /* Link change interrupt */
#define OWL_EMAC_BIT_MAC_CSR5_TU BIT(2) /* Transmit buffer unavailable */
#define OWL_EMAC_BIT_MAC_CSR5_TPS BIT(1) /* Transmit process stopped */
#define OWL_EMAC_BIT_MAC_CSR5_TI BIT(0) /* Transmit interrupt */
/* Operation mode register */
#define OWL_EMAC_REG_MAC_CSR6 0x0030
#define OWL_EMAC_BIT_MAC_CSR6_RA BIT(30) /* Receive all */
#define OWL_EMAC_BIT_MAC_CSR6_TTM BIT(22) /* Transmit threshold mode */
#define OWL_EMAC_BIT_MAC_CSR6_SF BIT(21) /* Store and forward */
#define OWL_EMAC_MSK_MAC_CSR6_SPEED GENMASK(17, 16) /* Eth speed selection */
#define OWL_EMAC_OFF_MAC_CSR6_SPEED 16
#define OWL_EMAC_VAL_MAC_CSR6_SPEED_100M 0x00
#define OWL_EMAC_VAL_MAC_CSR6_SPEED_10M 0x02
#define OWL_EMAC_BIT_MAC_CSR6_ST BIT(13) /* Start/stop transmit command */
#define OWL_EMAC_BIT_MAC_CSR6_LP BIT(10) /* Loopback mode */
#define OWL_EMAC_BIT_MAC_CSR6_FD BIT(9) /* Full duplex mode */
#define OWL_EMAC_BIT_MAC_CSR6_PM BIT(7) /* Pass all multicast */
#define OWL_EMAC_BIT_MAC_CSR6_PR BIT(6) /* Promiscuous mode */
#define OWL_EMAC_BIT_MAC_CSR6_IF BIT(4) /* Inverse filtering */
#define OWL_EMAC_BIT_MAC_CSR6_PB BIT(3) /* Pass bad frames */
#define OWL_EMAC_BIT_MAC_CSR6_HO BIT(2) /* Hash only filtering mode */
#define OWL_EMAC_BIT_MAC_CSR6_SR BIT(1) /* Start/stop receive command */
#define OWL_EMAC_BIT_MAC_CSR6_HP BIT(0) /* Hash/perfect receive filtering mode */
#define OWL_EMAC_MSK_MAC_CSR6_STSR (OWL_EMAC_BIT_MAC_CSR6_ST | \
OWL_EMAC_BIT_MAC_CSR6_SR)
/* Interrupt enable register */
#define OWL_EMAC_REG_MAC_CSR7 0x0038
#define OWL_EMAC_BIT_MAC_CSR7_NIE BIT(16) /* Normal interrupt summary enable */
#define OWL_EMAC_BIT_MAC_CSR7_AIE BIT(15) /* Abnormal interrupt summary enable */
#define OWL_EMAC_BIT_MAC_CSR7_ERE BIT(14) /* Early receive interrupt enable */
#define OWL_EMAC_BIT_MAC_CSR7_GTE BIT(11) /* General-purpose timer overflow */
#define OWL_EMAC_BIT_MAC_CSR7_ETE BIT(10) /* Early transmit interrupt enable */
#define OWL_EMAC_BIT_MAC_CSR7_RSE BIT(8) /* Receive stopped enable */
#define OWL_EMAC_BIT_MAC_CSR7_RUE BIT(7) /* Receive buffer unavailable enable */
#define OWL_EMAC_BIT_MAC_CSR7_RIE BIT(6) /* Receive interrupt enable */
#define OWL_EMAC_BIT_MAC_CSR7_UNE BIT(5) /* Underflow interrupt enable */
#define OWL_EMAC_BIT_MAC_CSR7_TUE BIT(2) /* Transmit buffer unavailable enable */
#define OWL_EMAC_BIT_MAC_CSR7_TSE BIT(1) /* Transmit stopped enable */
#define OWL_EMAC_BIT_MAC_CSR7_TIE BIT(0) /* Transmit interrupt enable */
#define OWL_EMAC_BIT_MAC_CSR7_ALL_NOT_TUE (OWL_EMAC_BIT_MAC_CSR7_ERE | \
OWL_EMAC_BIT_MAC_CSR7_GTE | \
OWL_EMAC_BIT_MAC_CSR7_ETE | \
OWL_EMAC_BIT_MAC_CSR7_RSE | \
OWL_EMAC_BIT_MAC_CSR7_RUE | \
OWL_EMAC_BIT_MAC_CSR7_RIE | \
OWL_EMAC_BIT_MAC_CSR7_UNE | \
OWL_EMAC_BIT_MAC_CSR7_TSE | \
OWL_EMAC_BIT_MAC_CSR7_TIE)
/* Missed frames and overflow counter register */
#define OWL_EMAC_REG_MAC_CSR8 0x0040
/* MII management and serial ROM register */
#define OWL_EMAC_REG_MAC_CSR9 0x0048
/* MII serial management register */
#define OWL_EMAC_REG_MAC_CSR10 0x0050
#define OWL_EMAC_BIT_MAC_CSR10_SB BIT(31) /* Start transfer or busy */
#define OWL_EMAC_MSK_MAC_CSR10_CLKDIV GENMASK(30, 28) /* Clock divider */
#define OWL_EMAC_OFF_MAC_CSR10_CLKDIV 28
#define OWL_EMAC_VAL_MAC_CSR10_CLKDIV_128 0x04
#define OWL_EMAC_VAL_MAC_CSR10_OPCODE_WR 0x01 /* Register write command */
#define OWL_EMAC_OFF_MAC_CSR10_OPCODE 26 /* Operation mode */
#define OWL_EMAC_VAL_MAC_CSR10_OPCODE_DCG 0x00 /* Disable clock generation */
#define OWL_EMAC_VAL_MAC_CSR10_OPCODE_WR 0x01 /* Register write command */
#define OWL_EMAC_VAL_MAC_CSR10_OPCODE_RD 0x02 /* Register read command */
#define OWL_EMAC_VAL_MAC_CSR10_OPCODE_CDS 0x03 /* Clock divider set */
#define OWL_EMAC_MSK_MAC_CSR10_PHYADD GENMASK(25, 21) /* Physical layer address */
#define OWL_EMAC_OFF_MAC_CSR10_PHYADD 21
#define OWL_EMAC_MSK_MAC_CSR10_REGADD GENMASK(20, 16) /* Register address */
#define OWL_EMAC_OFF_MAC_CSR10_REGADD 16
#define OWL_EMAC_MSK_MAC_CSR10_DATA GENMASK(15, 0) /* Register data */
/* General-purpose timer and interrupt mitigation control register */
#define OWL_EMAC_REG_MAC_CSR11 0x0058
#define OWL_EMAC_OFF_MAC_CSR11_TT 27 /* Transmit timer */
#define OWL_EMAC_OFF_MAC_CSR11_NTP 24 /* No. of transmit packets */
#define OWL_EMAC_OFF_MAC_CSR11_RT 20 /* Receive timer */
#define OWL_EMAC_OFF_MAC_CSR11_NRP 17 /* No. of receive packets */
/* MAC address low/high registers */
#define OWL_EMAC_REG_MAC_CSR16 0x0080
#define OWL_EMAC_REG_MAC_CSR17 0x0088
/* Pause time & cache thresholds register */
#define OWL_EMAC_REG_MAC_CSR18 0x0090
#define OWL_EMAC_OFF_MAC_CSR18_CPTL 24 /* Cache pause threshold level */
#define OWL_EMAC_OFF_MAC_CSR18_CRTL 16 /* Cache restart threshold level */
#define OWL_EMAC_OFF_MAC_CSR18_PQT 0 /* Flow control pause quanta time */
/* FIFO pause & restart threshold register */
#define OWL_EMAC_REG_MAC_CSR19 0x0098
#define OWL_EMAC_OFF_MAC_CSR19_FPTL 16 /* FIFO pause threshold level */
#define OWL_EMAC_OFF_MAC_CSR19_FRTL 0 /* FIFO restart threshold level */
/* Flow control setup & status register */
#define OWL_EMAC_REG_MAC_CSR20 0x00A0
#define OWL_EMAC_BIT_MAC_CSR20_FCE BIT(31) /* Flow Control Enable */
#define OWL_EMAC_BIT_MAC_CSR20_TUE BIT(30) /* Transmit Un-pause frames Enable */
#define OWL_EMAC_BIT_MAC_CSR20_TPE BIT(29) /* Transmit Pause frames Enable */
#define OWL_EMAC_BIT_MAC_CSR20_RPE BIT(28) /* Receive Pause frames Enable */
#define OWL_EMAC_BIT_MAC_CSR20_BPE BIT(27) /* Back pressure (half-duplex) Enable */
/* MII control register */
#define OWL_EMAC_REG_MAC_CTRL 0x00B0
#define OWL_EMAC_BIT_MAC_CTRL_RRSB BIT(8) /* RMII_REFCLK select bit */
#define OWL_EMAC_OFF_MAC_CTRL_SSDC 4 /* SMII SYNC delay cycle */
#define OWL_EMAC_BIT_MAC_CTRL_RCPS BIT(1) /* REF_CLK phase select */
#define OWL_EMAC_BIT_MAC_CTRL_RSIS BIT(0) /* RMII/SMII interface select */
/* Receive descriptor status field */
#define OWL_EMAC_BIT_RDES0_OWN BIT(31) /* Ownership bit */
#define OWL_EMAC_BIT_RDES0_FF BIT(30) /* Filtering fail */
#define OWL_EMAC_MSK_RDES0_FL GENMASK(29, 16) /* Frame length */
#define OWL_EMAC_OFF_RDES0_FL 16
#define OWL_EMAC_BIT_RDES0_ES BIT(15) /* Error summary */
#define OWL_EMAC_BIT_RDES0_DE BIT(14) /* Descriptor error */
#define OWL_EMAC_BIT_RDES0_RF BIT(11) /* Runt frame */
#define OWL_EMAC_BIT_RDES0_MF BIT(10) /* Multicast frame */
#define OWL_EMAC_BIT_RDES0_FS BIT(9) /* First descriptor */
#define OWL_EMAC_BIT_RDES0_LS BIT(8) /* Last descriptor */
#define OWL_EMAC_BIT_RDES0_TL BIT(7) /* Frame too long */
#define OWL_EMAC_BIT_RDES0_CS BIT(6) /* Collision seen */
#define OWL_EMAC_BIT_RDES0_FT BIT(5) /* Frame type */
#define OWL_EMAC_BIT_RDES0_RE BIT(3) /* Report on MII error */
#define OWL_EMAC_BIT_RDES0_DB BIT(2) /* Dribbling bit */
#define OWL_EMAC_BIT_RDES0_CE BIT(1) /* CRC error */
#define OWL_EMAC_BIT_RDES0_ZERO BIT(0) /* Legal frame length indicator */
/* Receive descriptor control and count field */
#define OWL_EMAC_BIT_RDES1_RER BIT(25) /* Receive end of ring */
#define OWL_EMAC_MSK_RDES1_RBS1 GENMASK(10, 0) /* Buffer 1 size */
/* Transmit descriptor status field */
#define OWL_EMAC_BIT_TDES0_OWN BIT(31) /* Ownership bit */
#define OWL_EMAC_BIT_TDES0_ES BIT(15) /* Error summary */
#define OWL_EMAC_BIT_TDES0_LO BIT(11) /* Loss of carrier */
#define OWL_EMAC_BIT_TDES0_NC BIT(10) /* No carrier */
#define OWL_EMAC_BIT_TDES0_LC BIT(9) /* Late collision */
#define OWL_EMAC_BIT_TDES0_EC BIT(8) /* Excessive collisions */
#define OWL_EMAC_MSK_TDES0_CC GENMASK(6, 3) /* Collision count */
#define OWL_EMAC_BIT_TDES0_UF BIT(1) /* Underflow error */
#define OWL_EMAC_BIT_TDES0_DE BIT(0) /* Deferred */
/* Transmit descriptor control and count field */
#define OWL_EMAC_BIT_TDES1_IC BIT(31) /* Interrupt on completion */
#define OWL_EMAC_BIT_TDES1_LS BIT(30) /* Last descriptor */
#define OWL_EMAC_BIT_TDES1_FS BIT(29) /* First descriptor */
#define OWL_EMAC_BIT_TDES1_FT1 BIT(28) /* Filtering type */
#define OWL_EMAC_BIT_TDES1_SET BIT(27) /* Setup packet */
#define OWL_EMAC_BIT_TDES1_AC BIT(26) /* Add CRC disable */
#define OWL_EMAC_BIT_TDES1_TER BIT(25) /* Transmit end of ring */
#define OWL_EMAC_BIT_TDES1_DPD BIT(23) /* Disabled padding */
#define OWL_EMAC_BIT_TDES1_FT0 BIT(22) /* Filtering type */
#define OWL_EMAC_MSK_TDES1_TBS1 GENMASK(10, 0) /* Buffer 1 size */
static const char *const owl_emac_clk_names[] = { "eth", "rmii" };
#define OWL_EMAC_NCLKS ARRAY_SIZE(owl_emac_clk_names)
enum owl_emac_clk_map {
OWL_EMAC_CLK_ETH = 0,
OWL_EMAC_CLK_RMII
};
struct owl_emac_addr_list {
u8 addrs[OWL_EMAC_MAX_MULTICAST_ADDRS][ETH_ALEN];
int count;
};
/* TX/RX descriptors */
struct owl_emac_ring_desc {
u32 status;
u32 control;
u32 buf_addr;
u32 reserved; /* 2nd buffer address is not used */
};
struct owl_emac_ring {
struct owl_emac_ring_desc *descs;
dma_addr_t descs_dma;
struct sk_buff **skbs;
dma_addr_t *skbs_dma;
unsigned int size;
unsigned int head;
unsigned int tail;
};
struct owl_emac_priv {
struct net_device *netdev;
void __iomem *base;
struct clk_bulk_data clks[OWL_EMAC_NCLKS];
struct reset_control *reset;
struct owl_emac_ring rx_ring;
struct owl_emac_ring tx_ring;
struct mii_bus *mii;
struct napi_struct napi;
phy_interface_t phy_mode;
unsigned int link;
int speed;
int duplex;
int pause;
struct owl_emac_addr_list mcaddr_list;
struct work_struct mac_reset_task;
u32 msg_enable; /* Debug message level */
spinlock_t lock; /* Sync concurrent ring access */
};
#endif /* __OWL_EMAC_H__ */