1515#include <linux/phy/phy.h>
1616#include <linux/workqueue.h>
1717
18- #if defined(CONFIG_ARCH_DMA_ADDR_T_64BIT ) || defined(CONFIG_MACB_USE_HWSTAMP )
19- #define MACB_EXT_DESC
20- #endif
21-
2218#define MACB_GREGS_NBR 16
2319#define MACB_GREGS_VERSION 2
2420#define MACB_MAX_QUEUES 8
756752#define MACB_MAN_C45_CODE 2
757753
758754/* Capability mask bits */
759- #define MACB_CAPS_ISR_CLEAR_ON_WRITE 0x00000001
760- #define MACB_CAPS_USRIO_HAS_CLKEN 0x00000002
761- #define MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII 0x00000004
762- #define MACB_CAPS_NO_GIGABIT_HALF 0x00000008
763- #define MACB_CAPS_USRIO_DISABLED 0x00000010
764- #define MACB_CAPS_JUMBO 0x00000020
765- #define MACB_CAPS_GEM_HAS_PTP 0x00000040
766- #define MACB_CAPS_BD_RD_PREFETCH 0x00000080
767- #define MACB_CAPS_NEEDS_RSTONUBR 0x00000100
768- #define MACB_CAPS_MIIONRGMII 0x00000200
769- #define MACB_CAPS_NEED_TSUCLK 0x00000400
770- #define MACB_CAPS_QUEUE_DISABLE 0x00000800
771- #define MACB_CAPS_QBV 0x00001000
772- #define MACB_CAPS_PCS 0x01000000
773- #define MACB_CAPS_HIGH_SPEED 0x02000000
774- #define MACB_CAPS_CLK_HW_CHG 0x04000000
775- #define MACB_CAPS_MACB_IS_EMAC 0x08000000
776- #define MACB_CAPS_FIFO_MODE 0x10000000
777- #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
778- #define MACB_CAPS_SG_DISABLED 0x40000000
779- #define MACB_CAPS_MACB_IS_GEM 0x80000000
755+ #define MACB_CAPS_ISR_CLEAR_ON_WRITE BIT(0)
756+ #define MACB_CAPS_USRIO_HAS_CLKEN BIT(1)
757+ #define MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII BIT(2)
758+ #define MACB_CAPS_NO_GIGABIT_HALF BIT(3)
759+ #define MACB_CAPS_USRIO_DISABLED BIT(4)
760+ #define MACB_CAPS_JUMBO BIT(5)
761+ #define MACB_CAPS_GEM_HAS_PTP BIT(6)
762+ #define MACB_CAPS_BD_RD_PREFETCH BIT(7)
763+ #define MACB_CAPS_NEEDS_RSTONUBR BIT(8)
764+ #define MACB_CAPS_MIIONRGMII BIT(9)
765+ #define MACB_CAPS_NEED_TSUCLK BIT(10)
766+ #define MACB_CAPS_QUEUE_DISABLE BIT(11)
767+ #define MACB_CAPS_QBV BIT(12)
768+ #define MACB_CAPS_PCS BIT(13)
769+ #define MACB_CAPS_HIGH_SPEED BIT(14)
770+ #define MACB_CAPS_CLK_HW_CHG BIT(15)
771+ #define MACB_CAPS_MACB_IS_EMAC BIT(16)
772+ #define MACB_CAPS_FIFO_MODE BIT(17)
773+ #define MACB_CAPS_GIGABIT_MODE_AVAILABLE BIT(18)
774+ #define MACB_CAPS_SG_DISABLED BIT(19)
775+ #define MACB_CAPS_MACB_IS_GEM BIT(20)
776+ #define MACB_CAPS_DMA_64B BIT(21)
777+ #define MACB_CAPS_DMA_PTP BIT(22)
780778
781779/* LSO settings */
782780#define MACB_LSO_UFO_ENABLE 0x01
@@ -853,12 +851,6 @@ struct macb_dma_desc {
853851 u32 ctrl ;
854852};
855853
856- #ifdef MACB_EXT_DESC
857- #define HW_DMA_CAP_32B 0
858- #define HW_DMA_CAP_64B (1 << 0)
859- #define HW_DMA_CAP_PTP (1 << 1)
860- #define HW_DMA_CAP_64B_PTP (HW_DMA_CAP_64B | HW_DMA_CAP_PTP)
861-
862854struct macb_dma_desc_64 {
863855 u32 addrh ;
864856 u32 resvd ;
@@ -868,7 +860,6 @@ struct macb_dma_desc_ptp {
868860 u32 ts_1 ;
869861 u32 ts_2 ;
870862};
871- #endif
872863
873864/* DMA descriptor bitfields */
874865#define MACB_RX_USED_OFFSET 0
@@ -1299,7 +1290,6 @@ struct macb {
12991290 unsigned int tx_ring_size ;
13001291
13011292 unsigned int num_queues ;
1302- unsigned int queue_mask ;
13031293 struct macb_queue queues [MACB_MAX_QUEUES ];
13041294
13051295 spinlock_t lock ;
@@ -1349,9 +1339,6 @@ struct macb {
13491339
13501340 struct phy * sgmii_phy ; /* for ZynqMP SGMII mode */
13511341
1352- #ifdef MACB_EXT_DESC
1353- uint8_t hw_dma_cap ;
1354- #endif
13551342 spinlock_t tsu_clk_lock ; /* gem tsu clock locking */
13561343 unsigned int tsu_rate ;
13571344 struct ptp_clock * ptp_clock ;
@@ -1443,6 +1430,18 @@ static inline u64 enst_max_hw_interval(u32 speed_mbps)
14431430 ENST_TIME_GRANULARITY_NS * 1000 , (speed_mbps ));
14441431}
14451432
1433+ static inline bool macb_dma64 (struct macb * bp )
1434+ {
1435+ return IS_ENABLED (CONFIG_ARCH_DMA_ADDR_T_64BIT ) &&
1436+ bp -> caps & MACB_CAPS_DMA_64B ;
1437+ }
1438+
1439+ static inline bool macb_dma_ptp (struct macb * bp )
1440+ {
1441+ return IS_ENABLED (CONFIG_MACB_USE_HWSTAMP ) &&
1442+ bp -> caps & MACB_CAPS_DMA_PTP ;
1443+ }
1444+
14461445/**
14471446 * struct macb_platform_data - platform data for MACB Ethernet used for PCI registration
14481447 * @pclk: platform clock
0 commit comments