Skip to content

Commit 8bf993a

Browse files
joabreudavem330
authored andcommitted
net: stmmac: Add support for DWMAC5 and implement Safety Features
This adds initial suport for DWMAC5 and implements the Automotive Safety Package which is available from core version 5.10. The Automotive Safety Pacakge (also called Safety Features) offers us with error protection in the core by implementing ECC Protection in memories, on-chip data path parity protection, FSM parity and timeout protection and Application/CSR interface timeout protection. In case of an uncorrectable error we call stmmac_global_err() and reconfigure the whole core. Signed-off-by: Jose Abreu <[email protected]> Cc: David S. Miller <[email protected]> Cc: Joao Pinto <[email protected]> Cc: Giuseppe Cavallaro <[email protected]> Cc: Alexandre Torgue <[email protected]> Cc: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 34877a1 commit 8bf993a

File tree

10 files changed

+494
-3
lines changed

10 files changed

+494
-3
lines changed

drivers/net/ethernet/stmicro/stmmac/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \
44
chain_mode.o dwmac_lib.o dwmac1000_core.o dwmac1000_dma.o \
55
dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o \
66
mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \
7-
dwmac4_dma.o dwmac4_lib.o dwmac4_core.o $(stmmac-y)
7+
dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o $(stmmac-y)
88

99
# Ordering matters. Generic driver must be last.
1010
obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o

drivers/net/ethernet/stmicro/stmmac/common.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#define DWMAC_CORE_3_40 0x34
3939
#define DWMAC_CORE_3_50 0x35
4040
#define DWMAC_CORE_4_00 0x40
41+
#define DWMAC_CORE_5_00 0x50
42+
#define DWMAC_CORE_5_10 0x51
4143
#define STMMAC_CHAN0 0 /* Always supported and default for all chips */
4244

4345
/* These need to be power of two, and >= 4 */
@@ -174,6 +176,17 @@ struct stmmac_extra_stats {
174176
unsigned long tx_tso_nfrags;
175177
};
176178

179+
/* Safety Feature statistics exposed by ethtool */
180+
struct stmmac_safety_stats {
181+
unsigned long mac_errors[32];
182+
unsigned long mtl_errors[32];
183+
unsigned long dma_errors[32];
184+
};
185+
186+
/* Number of fields in Safety Stats */
187+
#define STMMAC_SAFETY_FEAT_SIZE \
188+
(sizeof(struct stmmac_safety_stats) / sizeof(unsigned long))
189+
177190
/* CSR Frequency Access Defines*/
178191
#define CSR_F_35M 35000000
179192
#define CSR_F_60M 60000000
@@ -336,6 +349,8 @@ struct dma_features {
336349
/* TX and RX FIFO sizes */
337350
unsigned int tx_fifo_size;
338351
unsigned int rx_fifo_size;
352+
/* Automotive Safety Package */
353+
unsigned int asp;
339354
};
340355

341356
/* GMAC TX FIFO is 8K, Rx FIFO is 16K */
@@ -532,6 +547,13 @@ struct stmmac_ops {
532547
bool loopback);
533548
void (*pcs_rane)(void __iomem *ioaddr, bool restart);
534549
void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv);
550+
/* Safety Features */
551+
int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp);
552+
bool (*safety_feat_irq_status)(struct net_device *ndev,
553+
void __iomem *ioaddr, unsigned int asp,
554+
struct stmmac_safety_stats *stats);
555+
const char *(*safety_feat_dump)(struct stmmac_safety_stats *stats,
556+
int index, unsigned long *count);
535557
};
536558

537559
/* PTP and HW Timer helpers */

drivers/net/ethernet/stmicro/stmmac/dwmac4.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define GMAC_HW_FEATURE0 0x0000011c
4040
#define GMAC_HW_FEATURE1 0x00000120
4141
#define GMAC_HW_FEATURE2 0x00000124
42+
#define GMAC_HW_FEATURE3 0x00000128
4243
#define GMAC_MDIO_ADDR 0x00000200
4344
#define GMAC_MDIO_DATA 0x00000204
4445
#define GMAC_ADDR_HIGH(reg) (0x300 + reg * 8)
@@ -192,6 +193,9 @@ enum power_event {
192193
#define GMAC_HW_FEAT_TXQCNT GENMASK(9, 6)
193194
#define GMAC_HW_FEAT_RXQCNT GENMASK(3, 0)
194195

196+
/* MAC HW features3 bitmap */
197+
#define GMAC_HW_FEAT_ASP GENMASK(29, 28)
198+
195199
/* MAC HW ADDR regs */
196200
#define GMAC_HI_DCS GENMASK(18, 16)
197201
#define GMAC_HI_DCS_SHIFT 16

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <net/dsa.h>
2121
#include "stmmac_pcs.h"
2222
#include "dwmac4.h"
23+
#include "dwmac5.h"
2324

2425
static void dwmac4_core_init(struct mac_device_info *hw,
2526
struct net_device *dev)
@@ -768,6 +769,40 @@ static const struct stmmac_ops dwmac410_ops = {
768769
.set_filter = dwmac4_set_filter,
769770
};
770771

772+
static const struct stmmac_ops dwmac510_ops = {
773+
.core_init = dwmac4_core_init,
774+
.set_mac = stmmac_dwmac4_set_mac,
775+
.rx_ipc = dwmac4_rx_ipc_enable,
776+
.rx_queue_enable = dwmac4_rx_queue_enable,
777+
.rx_queue_prio = dwmac4_rx_queue_priority,
778+
.tx_queue_prio = dwmac4_tx_queue_priority,
779+
.rx_queue_routing = dwmac4_rx_queue_routing,
780+
.prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms,
781+
.prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms,
782+
.set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
783+
.map_mtl_to_dma = dwmac4_map_mtl_dma,
784+
.config_cbs = dwmac4_config_cbs,
785+
.dump_regs = dwmac4_dump_regs,
786+
.host_irq_status = dwmac4_irq_status,
787+
.host_mtl_irq_status = dwmac4_irq_mtl_status,
788+
.flow_ctrl = dwmac4_flow_ctrl,
789+
.pmt = dwmac4_pmt,
790+
.set_umac_addr = dwmac4_set_umac_addr,
791+
.get_umac_addr = dwmac4_get_umac_addr,
792+
.set_eee_mode = dwmac4_set_eee_mode,
793+
.reset_eee_mode = dwmac4_reset_eee_mode,
794+
.set_eee_timer = dwmac4_set_eee_timer,
795+
.set_eee_pls = dwmac4_set_eee_pls,
796+
.pcs_ctrl_ane = dwmac4_ctrl_ane,
797+
.pcs_rane = dwmac4_rane,
798+
.pcs_get_adv_lp = dwmac4_get_adv_lp,
799+
.debug = dwmac4_debug,
800+
.set_filter = dwmac4_set_filter,
801+
.safety_feat_config = dwmac5_safety_feat_config,
802+
.safety_feat_irq_status = dwmac5_safety_feat_irq_status,
803+
.safety_feat_dump = dwmac5_safety_feat_dump,
804+
};
805+
771806
struct mac_device_info *dwmac4_setup(void __iomem *ioaddr, int mcbins,
772807
int perfect_uc_entries, int *synopsys_id)
773808
{
@@ -808,7 +843,9 @@ struct mac_device_info *dwmac4_setup(void __iomem *ioaddr, int mcbins,
808843
else
809844
mac->dma = &dwmac4_dma_ops;
810845

811-
if (*synopsys_id >= DWMAC_CORE_4_00)
846+
if (*synopsys_id >= DWMAC_CORE_5_10)
847+
mac->mac = &dwmac510_ops;
848+
else if (*synopsys_id >= DWMAC_CORE_4_00)
812849
mac->mac = &dwmac410_ops;
813850
else
814851
mac->mac = &dwmac4_ops;

drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ static void dwmac4_get_hw_feature(void __iomem *ioaddr,
373373

374374
/* IEEE 1588-2002 */
375375
dma_cap->time_stamp = 0;
376+
377+
/* MAC HW feature3 */
378+
hw_cap = readl(ioaddr + GMAC_HW_FEATURE3);
379+
380+
/* 5.10 Features */
381+
dma_cap->asp = (hw_cap & GMAC_HW_FEAT_ASP) >> 28;
376382
}
377383

378384
/* Enable/disable TSO feature and set MSS */

0 commit comments

Comments
 (0)