stmmac.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*******************************************************************************
  3. Header file for stmmac platform data
  4. Copyright (C) 2009 STMicroelectronics Ltd
  5. Author: Giuseppe Cavallaro <[email protected]>
  6. *******************************************************************************/
  7. #ifndef __STMMAC_PLATFORM_DATA
  8. #define __STMMAC_PLATFORM_DATA
  9. #include <linux/platform_device.h>
  10. #include <linux/phy.h>
  11. #include <linux/netdevice.h>
  12. #define MTL_MAX_RX_QUEUES 8
  13. #define MTL_MAX_TX_QUEUES 8
  14. #define STMMAC_CH_MAX 8
  15. #define STMMAC_RX_COE_NONE 0
  16. #define STMMAC_RX_COE_TYPE1 1
  17. #define STMMAC_RX_COE_TYPE2 2
  18. /* Define the macros for CSR clock range parameters to be passed by
  19. * platform code.
  20. * This could also be configured at run time using CPU freq framework. */
  21. /* MDC Clock Selection define*/
  22. #define STMMAC_CSR_60_100M 0x0 /* MDC = clk_scr_i/42 */
  23. #define STMMAC_CSR_100_150M 0x1 /* MDC = clk_scr_i/62 */
  24. #define STMMAC_CSR_20_35M 0x2 /* MDC = clk_scr_i/16 */
  25. #define STMMAC_CSR_35_60M 0x3 /* MDC = clk_scr_i/26 */
  26. #define STMMAC_CSR_150_250M 0x4 /* MDC = clk_scr_i/102 */
  27. #define STMMAC_CSR_250_300M 0x5 /* MDC = clk_scr_i/122 */
  28. /* MTL algorithms identifiers */
  29. #define MTL_TX_ALGORITHM_WRR 0x0
  30. #define MTL_TX_ALGORITHM_WFQ 0x1
  31. #define MTL_TX_ALGORITHM_DWRR 0x2
  32. #define MTL_TX_ALGORITHM_SP 0x3
  33. #define MTL_RX_ALGORITHM_SP 0x4
  34. #define MTL_RX_ALGORITHM_WSP 0x5
  35. /* RX/TX Queue Mode */
  36. #define MTL_QUEUE_AVB 0x0
  37. #define MTL_QUEUE_DCB 0x1
  38. /* The MDC clock could be set higher than the IEEE 802.3
  39. * specified frequency limit 0f 2.5 MHz, by programming a clock divider
  40. * of value different than the above defined values. The resultant MDIO
  41. * clock frequency of 12.5 MHz is applicable for the interfacing chips
  42. * supporting higher MDC clocks.
  43. * The MDC clock selection macros need to be defined for MDC clock rate
  44. * of 12.5 MHz, corresponding to the following selection.
  45. */
  46. #define STMMAC_CSR_I_4 0x8 /* clk_csr_i/4 */
  47. #define STMMAC_CSR_I_6 0x9 /* clk_csr_i/6 */
  48. #define STMMAC_CSR_I_8 0xA /* clk_csr_i/8 */
  49. #define STMMAC_CSR_I_10 0xB /* clk_csr_i/10 */
  50. #define STMMAC_CSR_I_12 0xC /* clk_csr_i/12 */
  51. #define STMMAC_CSR_I_14 0xD /* clk_csr_i/14 */
  52. #define STMMAC_CSR_I_16 0xE /* clk_csr_i/16 */
  53. #define STMMAC_CSR_I_18 0xF /* clk_csr_i/18 */
  54. /* AXI DMA Burst length supported */
  55. #define DMA_AXI_BLEN_4 (1 << 1)
  56. #define DMA_AXI_BLEN_8 (1 << 2)
  57. #define DMA_AXI_BLEN_16 (1 << 3)
  58. #define DMA_AXI_BLEN_32 (1 << 4)
  59. #define DMA_AXI_BLEN_64 (1 << 5)
  60. #define DMA_AXI_BLEN_128 (1 << 6)
  61. #define DMA_AXI_BLEN_256 (1 << 7)
  62. #define DMA_AXI_BLEN_ALL (DMA_AXI_BLEN_4 | DMA_AXI_BLEN_8 | DMA_AXI_BLEN_16 \
  63. | DMA_AXI_BLEN_32 | DMA_AXI_BLEN_64 \
  64. | DMA_AXI_BLEN_128 | DMA_AXI_BLEN_256)
  65. /* Platfrom data for platform device structure's platform_data field */
  66. struct stmmac_mdio_bus_data {
  67. unsigned int phy_mask;
  68. unsigned int has_xpcs;
  69. unsigned int xpcs_an_inband;
  70. int *irqs;
  71. int probed_phy_irq;
  72. bool needs_reset;
  73. };
  74. struct stmmac_dma_cfg {
  75. int pbl;
  76. int txpbl;
  77. int rxpbl;
  78. bool pblx8;
  79. int fixed_burst;
  80. int mixed_burst;
  81. bool aal;
  82. bool eame;
  83. bool multi_msi_en;
  84. bool dche;
  85. };
  86. #define AXI_BLEN 7
  87. struct stmmac_axi {
  88. bool axi_lpi_en;
  89. bool axi_xit_frm;
  90. u32 axi_wr_osr_lmt;
  91. u32 axi_rd_osr_lmt;
  92. bool axi_kbbe;
  93. u32 axi_blen[AXI_BLEN];
  94. bool axi_fb;
  95. bool axi_mb;
  96. bool axi_rb;
  97. };
  98. #define EST_GCL 1024
  99. struct stmmac_est {
  100. struct mutex lock;
  101. int enable;
  102. u32 btr_reserve[2];
  103. u32 btr_offset[2];
  104. u32 btr[2];
  105. u32 ctr[2];
  106. u32 ter;
  107. u32 gcl_unaligned[EST_GCL];
  108. u32 gcl[EST_GCL];
  109. u32 gcl_size;
  110. };
  111. struct stmmac_rxq_cfg {
  112. u8 mode_to_use;
  113. u32 chan;
  114. u8 pkt_route;
  115. bool use_prio;
  116. u32 prio;
  117. };
  118. struct stmmac_txq_cfg {
  119. u32 weight;
  120. u8 mode_to_use;
  121. /* Credit Base Shaper parameters */
  122. u32 send_slope;
  123. u32 idle_slope;
  124. u32 high_credit;
  125. u32 low_credit;
  126. bool use_prio;
  127. u32 prio;
  128. int tbs_en;
  129. };
  130. /* FPE link state */
  131. enum stmmac_fpe_state {
  132. FPE_STATE_OFF = 0,
  133. FPE_STATE_CAPABLE = 1,
  134. FPE_STATE_ENTERING_ON = 2,
  135. FPE_STATE_ON = 3,
  136. };
  137. /* FPE link-partner hand-shaking mPacket type */
  138. enum stmmac_mpacket_type {
  139. MPACKET_VERIFY = 0,
  140. MPACKET_RESPONSE = 1,
  141. };
  142. enum stmmac_fpe_task_state_t {
  143. __FPE_REMOVING,
  144. __FPE_TASK_SCHED,
  145. };
  146. struct stmmac_fpe_cfg {
  147. bool enable; /* FPE enable */
  148. bool hs_enable; /* FPE handshake enable */
  149. enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */
  150. enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */
  151. u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */
  152. };
  153. struct stmmac_safety_feature_cfg {
  154. u32 tsoee;
  155. u32 mrxpee;
  156. u32 mestee;
  157. u32 mrxee;
  158. u32 mtxee;
  159. u32 epsi;
  160. u32 edpp;
  161. u32 prtyen;
  162. u32 tmouten;
  163. };
  164. struct emac_emb_smmu_cb_ctx {
  165. bool valid;
  166. struct platform_device *pdev_master;
  167. struct platform_device *smmu_pdev;
  168. struct dma_iommu_mapping *mapping;
  169. struct iommu_domain *iommu_domain;
  170. u32 va_start;
  171. u32 va_size;
  172. u32 va_end;
  173. int ret;
  174. };
  175. struct plat_stmmacenet_data {
  176. int bus_id;
  177. int phy_addr;
  178. int interface;
  179. phy_interface_t phy_interface;
  180. struct stmmac_mdio_bus_data *mdio_bus_data;
  181. struct device_node *phy_node;
  182. struct device_node *phylink_node;
  183. struct device_node *mdio_node;
  184. struct stmmac_dma_cfg *dma_cfg;
  185. struct stmmac_est *est;
  186. struct stmmac_fpe_cfg *fpe_cfg;
  187. struct stmmac_safety_feature_cfg *safety_feat_cfg;
  188. int clk_csr;
  189. int has_gmac;
  190. int enh_desc;
  191. int tx_coe;
  192. int rx_coe;
  193. int bugged_jumbo;
  194. int pmt;
  195. int force_sf_dma_mode;
  196. int force_thresh_dma_mode;
  197. int riwt_off;
  198. int max_speed;
  199. int maxmtu;
  200. int multicast_filter_bins;
  201. int unicast_filter_entries;
  202. int tx_fifo_size;
  203. int rx_fifo_size;
  204. u32 host_dma_width;
  205. u32 rx_queues_to_use;
  206. u32 tx_queues_to_use;
  207. u8 rx_sched_algorithm;
  208. u8 tx_sched_algorithm;
  209. struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
  210. struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
  211. void (*fix_mac_speed)(void *priv, unsigned int speed);
  212. void (*serdes_loopback_v3_1)(struct plat_stmmacenet_data *plat, bool on);
  213. int (*serdes_powerup)(struct net_device *ndev, void *priv);
  214. void (*serdes_powerdown)(struct net_device *ndev, void *priv);
  215. void (*speed_mode_2500)(struct net_device *ndev, void *priv);
  216. void (*ptp_clk_freq_config)(void *priv);
  217. int (*init)(struct platform_device *pdev, void *priv);
  218. void (*exit)(struct platform_device *pdev, void *priv);
  219. struct mac_device_info *(*setup)(void *priv);
  220. int (*clks_config)(void *priv, bool enabled);
  221. int (*crosststamp)(ktime_t *device, struct system_counterval_t *system,
  222. void *ctx);
  223. void (*dump_debug_regs)(void *priv);
  224. void *bsp_priv;
  225. struct clk *stmmac_clk;
  226. struct clk *pclk;
  227. struct clk *clk_ptp_ref;
  228. unsigned int clk_ptp_rate;
  229. unsigned int clk_ptp_req_rate;
  230. unsigned int clk_ref_rate;
  231. unsigned int mult_fact_100ns;
  232. s32 ptp_max_adj;
  233. u32 cdc_error_adj;
  234. struct reset_control *stmmac_rst;
  235. struct reset_control *stmmac_ahb_rst;
  236. struct stmmac_axi *axi;
  237. int has_gmac4;
  238. bool has_sun8i;
  239. bool tso_en;
  240. int rss_en;
  241. int mac_port_sel_speed;
  242. bool en_tx_lpi_clockgating;
  243. bool rx_clk_runs_in_lpi;
  244. int has_xgmac;
  245. unsigned int (*get_plat_tx_coal_frames)
  246. (struct sk_buff *skb);
  247. u16 (*tx_select_queue)
  248. (struct net_device *dev, struct sk_buff *skb,
  249. struct net_device *sb_dev);
  250. bool vlan_fail_q_en;
  251. u8 vlan_fail_q;
  252. unsigned int eee_usecs_rate;
  253. struct pci_dev *pdev;
  254. int int_snapshot_num;
  255. int ext_snapshot_num;
  256. bool int_snapshot_en;
  257. bool ext_snapshot_en;
  258. bool multi_msi_en;
  259. int msi_mac_vec;
  260. int msi_wol_vec;
  261. int msi_lpi_vec;
  262. int msi_sfty_ce_vec;
  263. int msi_sfty_ue_vec;
  264. int msi_rx_base_vec;
  265. int msi_tx_base_vec;
  266. bool use_phy_wol;
  267. bool sph_disable;
  268. struct emac_emb_smmu_cb_ctx stmmac_emb_smmu_ctx;
  269. bool phy_intr_en_extn_stm;
  270. int has_c22_mdio_probe_capability;
  271. int (*handle_prv_ioctl)(struct net_device *dev, struct ifreq *ifr,
  272. int cmd);
  273. void (*request_phy_wol)(void *plat);
  274. int (*init_pps)(void *priv);
  275. bool pcs_v3;
  276. void (*phy_irq_enable)(void *priv);
  277. void (*phy_irq_disable)(void *priv);
  278. bool early_eth;
  279. };
  280. #endif