.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Atmel MACB Ethernet Controller driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2004-2006 Atmel Corporation |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | */ |
---|
10 | 7 | #ifndef _MACB_H |
---|
11 | 8 | #define _MACB_H |
---|
12 | 9 | |
---|
13 | | -#include <linux/phy.h> |
---|
| 10 | +#include <linux/clk.h> |
---|
| 11 | +#include <linux/phylink.h> |
---|
14 | 12 | #include <linux/ptp_clock_kernel.h> |
---|
15 | 13 | #include <linux/net_tstamp.h> |
---|
16 | 14 | #include <linux/interrupt.h> |
---|
.. | .. |
---|
93 | 91 | #define GEM_SA3T 0x009C /* Specific3 Top */ |
---|
94 | 92 | #define GEM_SA4B 0x00A0 /* Specific4 Bottom */ |
---|
95 | 93 | #define GEM_SA4T 0x00A4 /* Specific4 Top */ |
---|
| 94 | +#define GEM_WOL 0x00b8 /* Wake on LAN */ |
---|
96 | 95 | #define GEM_EFTSH 0x00e8 /* PTP Event Frame Transmitted Seconds Register 47:32 */ |
---|
97 | 96 | #define GEM_EFRSH 0x00ec /* PTP Event Frame Received Seconds Register 47:32 */ |
---|
98 | 97 | #define GEM_PEFTSH 0x00f0 /* PTP Peer Event Frame Transmitted Seconds Register 47:32 */ |
---|
.. | .. |
---|
367 | 366 | #define MACB_ISR_RLE_SIZE 1 |
---|
368 | 367 | #define MACB_TXERR_OFFSET 6 /* EN TX frame corrupt from error interrupt */ |
---|
369 | 368 | #define MACB_TXERR_SIZE 1 |
---|
| 369 | +#define MACB_RM9200_TBRE_OFFSET 6 /* EN may send new frame interrupt (RM9200) */ |
---|
| 370 | +#define MACB_RM9200_TBRE_SIZE 1 |
---|
370 | 371 | #define MACB_TCOMP_OFFSET 7 /* Enable transmit complete interrupt */ |
---|
371 | 372 | #define MACB_TCOMP_SIZE 1 |
---|
372 | 373 | #define MACB_ISR_LINK_OFFSET 9 /* Enable link change interrupt */ |
---|
.. | .. |
---|
399 | 400 | #define MACB_PDRSFT_SIZE 1 |
---|
400 | 401 | #define MACB_SRI_OFFSET 26 /* TSU Seconds Register Increment */ |
---|
401 | 402 | #define MACB_SRI_SIZE 1 |
---|
| 403 | +#define GEM_WOL_OFFSET 28 /* Enable wake-on-lan interrupt */ |
---|
| 404 | +#define GEM_WOL_SIZE 1 |
---|
402 | 405 | |
---|
403 | 406 | /* Timer increment fields */ |
---|
404 | 407 | #define MACB_TI_CNS_OFFSET 0 |
---|
.. | .. |
---|
633 | 636 | #define GEM_CLK_DIV96 5 |
---|
634 | 637 | |
---|
635 | 638 | /* Constants for MAN register */ |
---|
636 | | -#define MACB_MAN_SOF 1 |
---|
637 | | -#define MACB_MAN_WRITE 1 |
---|
638 | | -#define MACB_MAN_READ 2 |
---|
639 | | -#define MACB_MAN_CODE 2 |
---|
| 639 | +#define MACB_MAN_C22_SOF 1 |
---|
| 640 | +#define MACB_MAN_C22_WRITE 1 |
---|
| 641 | +#define MACB_MAN_C22_READ 2 |
---|
| 642 | +#define MACB_MAN_C22_CODE 2 |
---|
| 643 | + |
---|
| 644 | +#define MACB_MAN_C45_SOF 0 |
---|
| 645 | +#define MACB_MAN_C45_ADDR 0 |
---|
| 646 | +#define MACB_MAN_C45_WRITE 1 |
---|
| 647 | +#define MACB_MAN_C45_POST_READ_INCR 2 |
---|
| 648 | +#define MACB_MAN_C45_READ 3 |
---|
| 649 | +#define MACB_MAN_C45_CODE 2 |
---|
640 | 650 | |
---|
641 | 651 | /* Capability mask bits */ |
---|
642 | 652 | #define MACB_CAPS_ISR_CLEAR_ON_WRITE 0x00000001 |
---|
.. | .. |
---|
648 | 658 | #define MACB_CAPS_GEM_HAS_PTP 0x00000040 |
---|
649 | 659 | #define MACB_CAPS_BD_RD_PREFETCH 0x00000080 |
---|
650 | 660 | #define MACB_CAPS_NEEDS_RSTONUBR 0x00000100 |
---|
| 661 | +#define MACB_CAPS_MACB_IS_EMAC 0x08000000 |
---|
651 | 662 | #define MACB_CAPS_FIFO_MODE 0x10000000 |
---|
652 | 663 | #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000 |
---|
653 | 664 | #define MACB_CAPS_SG_DISABLED 0x40000000 |
---|
.. | .. |
---|
718 | 729 | __v = macb_readl((__bp), __reg); \ |
---|
719 | 730 | __v; \ |
---|
720 | 731 | }) |
---|
| 732 | + |
---|
| 733 | +#define MACB_READ_NSR(bp) macb_readl(bp, NSR) |
---|
721 | 734 | |
---|
722 | 735 | /* struct macb_dma_desc - Hardware DMA descriptor |
---|
723 | 736 | * @addr: DMA address of data buffer |
---|
.. | .. |
---|
838 | 851 | |
---|
839 | 852 | /* limit RX checksum offload to TCP and UDP packets */ |
---|
840 | 853 | #define GEM_RX_CSUM_CHECKED_MASK 2 |
---|
| 854 | + |
---|
| 855 | +/* Scaled PPM fraction */ |
---|
| 856 | +#define PPM_FRACTION 16 |
---|
841 | 857 | |
---|
842 | 858 | /* struct macb_tx_skb - data about an skb which is being transmitted |
---|
843 | 859 | * @skb: skb currently being transmitted, only set for the last buffer |
---|
.. | .. |
---|
1065 | 1081 | int (*mog_alloc_rx_buffers)(struct macb *bp); |
---|
1066 | 1082 | void (*mog_free_rx_buffers)(struct macb *bp); |
---|
1067 | 1083 | void (*mog_init_rings)(struct macb *bp); |
---|
1068 | | - int (*mog_rx)(struct macb_queue *queue, int budget); |
---|
| 1084 | + int (*mog_rx)(struct macb_queue *queue, struct napi_struct *napi, |
---|
| 1085 | + int budget); |
---|
1069 | 1086 | }; |
---|
1070 | 1087 | |
---|
1071 | 1088 | /* MACB-PTP interface: adapt to platform needs. */ |
---|
.. | .. |
---|
1082 | 1099 | struct ifreq *ifr, int cmd); |
---|
1083 | 1100 | }; |
---|
1084 | 1101 | |
---|
| 1102 | +struct macb_pm_data { |
---|
| 1103 | + u32 scrt2; |
---|
| 1104 | + u32 usrio; |
---|
| 1105 | +}; |
---|
| 1106 | + |
---|
1085 | 1107 | struct macb_config { |
---|
1086 | 1108 | u32 caps; |
---|
1087 | 1109 | unsigned int dma_burst_length; |
---|
1088 | 1110 | int (*clk_init)(struct platform_device *pdev, struct clk **pclk, |
---|
1089 | 1111 | struct clk **hclk, struct clk **tx_clk, |
---|
1090 | | - struct clk **rx_clk); |
---|
| 1112 | + struct clk **rx_clk, struct clk **tsu_clk); |
---|
1091 | 1113 | int (*init)(struct platform_device *pdev); |
---|
1092 | 1114 | int jumbo_max_len; |
---|
1093 | 1115 | }; |
---|
.. | .. |
---|
1167 | 1189 | struct clk *hclk; |
---|
1168 | 1190 | struct clk *tx_clk; |
---|
1169 | 1191 | struct clk *rx_clk; |
---|
| 1192 | + struct clk *tsu_clk; |
---|
1170 | 1193 | struct net_device *dev; |
---|
1171 | 1194 | union { |
---|
1172 | 1195 | struct macb_stats macb; |
---|
.. | .. |
---|
1176 | 1199 | struct macb_or_gem_ops macbgem_ops; |
---|
1177 | 1200 | |
---|
1178 | 1201 | struct mii_bus *mii_bus; |
---|
1179 | | - struct device_node *phy_node; |
---|
1180 | | - int link; |
---|
1181 | | - int speed; |
---|
1182 | | - int duplex; |
---|
| 1202 | + struct phylink *phylink; |
---|
| 1203 | + struct phylink_config phylink_config; |
---|
1183 | 1204 | |
---|
1184 | 1205 | u32 caps; |
---|
1185 | 1206 | unsigned int dma_burst_length; |
---|
1186 | 1207 | |
---|
1187 | 1208 | phy_interface_t phy_interface; |
---|
1188 | 1209 | |
---|
1189 | | - /* AT91RM9200 transmit */ |
---|
1190 | | - struct sk_buff *skb; /* holds skb until xmit interrupt completes */ |
---|
1191 | | - dma_addr_t skb_physaddr; /* phys addr from pci_map_single */ |
---|
1192 | | - int skb_length; /* saved skb length for pci_unmap_single */ |
---|
| 1210 | + /* AT91RM9200 transmit queue (1 on wire + 1 queued) */ |
---|
| 1211 | + struct macb_tx_skb rm9200_txq[2]; |
---|
| 1212 | + unsigned int rm9200_tx_tail; |
---|
| 1213 | + unsigned int rm9200_tx_len; |
---|
1193 | 1214 | unsigned int max_tx_length; |
---|
1194 | 1215 | |
---|
1195 | 1216 | u64 ethtool_stats[GEM_STATS_LEN + QUEUE_STATS_LEN * MACB_MAX_QUEUES]; |
---|
.. | .. |
---|
1221 | 1242 | int tx_bd_rd_prefetch; |
---|
1222 | 1243 | |
---|
1223 | 1244 | u32 rx_intr_mask; |
---|
| 1245 | + |
---|
| 1246 | + struct macb_pm_data pm_data; |
---|
1224 | 1247 | }; |
---|
1225 | 1248 | |
---|
1226 | 1249 | #ifdef CONFIG_MACB_USE_HWSTAMP |
---|
.. | .. |
---|
1278 | 1301 | return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP); |
---|
1279 | 1302 | } |
---|
1280 | 1303 | |
---|
| 1304 | +/** |
---|
| 1305 | + * struct macb_platform_data - platform data for MACB Ethernet used for PCI registration |
---|
| 1306 | + * @pclk: platform clock |
---|
| 1307 | + * @hclk: AHB clock |
---|
| 1308 | + */ |
---|
| 1309 | +struct macb_platform_data { |
---|
| 1310 | + struct clk *pclk; |
---|
| 1311 | + struct clk *hclk; |
---|
| 1312 | +}; |
---|
| 1313 | + |
---|
1281 | 1314 | #endif /* _MACB_H */ |
---|