fsl_ucc_hdlc.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* Freescale QUICC Engine HDLC Device Driver
  2. *
  3. * Copyright 2014 Freescale Semiconductor Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #ifndef _UCC_HDLC_H_
  11. #define _UCC_HDLC_H_
  12. #include <linux/kernel.h>
  13. #include <linux/list.h>
  14. #include <soc/fsl/qe/immap_qe.h>
  15. #include <soc/fsl/qe/qe.h>
  16. #include <soc/fsl/qe/ucc.h>
  17. #include <soc/fsl/qe/ucc_fast.h>
  18. /* UCC HDLC event register */
  19. #define UCCE_HDLC_RX_EVENTS \
  20. (UCC_HDLC_UCCE_RXF | UCC_HDLC_UCCE_RXB | UCC_HDLC_UCCE_BSY)
  21. #define UCCE_HDLC_TX_EVENTS (UCC_HDLC_UCCE_TXB | UCC_HDLC_UCCE_TXE)
  22. struct ucc_hdlc_param {
  23. __be16 riptr;
  24. __be16 tiptr;
  25. __be16 res0;
  26. __be16 mrblr;
  27. __be32 rstate;
  28. __be32 rbase;
  29. __be16 rbdstat;
  30. __be16 rbdlen;
  31. __be32 rdptr;
  32. __be32 tstate;
  33. __be32 tbase;
  34. __be16 tbdstat;
  35. __be16 tbdlen;
  36. __be32 tdptr;
  37. __be32 rbptr;
  38. __be32 tbptr;
  39. __be32 rcrc;
  40. __be32 res1;
  41. __be32 tcrc;
  42. __be32 res2;
  43. __be32 res3;
  44. __be32 c_mask;
  45. __be32 c_pres;
  46. __be16 disfc;
  47. __be16 crcec;
  48. __be16 abtsc;
  49. __be16 nmarc;
  50. __be32 max_cnt;
  51. __be16 mflr;
  52. __be16 rfthr;
  53. __be16 rfcnt;
  54. __be16 hmask;
  55. __be16 haddr1;
  56. __be16 haddr2;
  57. __be16 haddr3;
  58. __be16 haddr4;
  59. __be16 ts_tmp;
  60. __be16 tmp_mb;
  61. };
  62. struct ucc_hdlc_private {
  63. struct ucc_tdm *utdm;
  64. struct ucc_tdm_info *ut_info;
  65. struct ucc_fast_private *uccf;
  66. struct device *dev;
  67. struct net_device *ndev;
  68. struct napi_struct napi;
  69. struct ucc_fast __iomem *uf_regs; /* UCC Fast registers */
  70. struct ucc_hdlc_param __iomem *ucc_pram;
  71. u16 tsa;
  72. bool hdlc_busy;
  73. bool loopback;
  74. u8 *tx_buffer;
  75. u8 *rx_buffer;
  76. dma_addr_t dma_tx_addr;
  77. dma_addr_t dma_rx_addr;
  78. struct qe_bd *tx_bd_base;
  79. struct qe_bd *rx_bd_base;
  80. dma_addr_t dma_tx_bd;
  81. dma_addr_t dma_rx_bd;
  82. struct qe_bd *curtx_bd;
  83. struct qe_bd *currx_bd;
  84. struct qe_bd *dirty_tx;
  85. u16 currx_bdnum;
  86. struct sk_buff **tx_skbuff;
  87. struct sk_buff **rx_skbuff;
  88. u16 skb_curtx;
  89. u16 skb_currx;
  90. unsigned short skb_dirtytx;
  91. unsigned short tx_ring_size;
  92. unsigned short rx_ring_size;
  93. u32 ucc_pram_offset;
  94. unsigned short encoding;
  95. unsigned short parity;
  96. u32 clocking;
  97. spinlock_t lock; /* lock for Tx BD and Tx buffer */
  98. #ifdef CONFIG_PM
  99. struct ucc_hdlc_param *ucc_pram_bak;
  100. u32 gumr;
  101. u8 guemr;
  102. u32 cmxsi1cr_l, cmxsi1cr_h;
  103. u32 cmxsi1syr;
  104. u32 cmxucr[4];
  105. #endif
  106. };
  107. #define TX_BD_RING_LEN 0x10
  108. #define RX_BD_RING_LEN 0x20
  109. #define RX_CLEAN_MAX 0x10
  110. #define NUM_OF_BUF 4
  111. #define MAX_RX_BUF_LENGTH (48 * 0x20)
  112. #define MAX_FRAME_LENGTH (MAX_RX_BUF_LENGTH + 8)
  113. #define ALIGNMENT_OF_UCC_HDLC_PRAM 64
  114. #define SI_BANK_SIZE 128
  115. #define MAX_HDLC_NUM 4
  116. #define HDLC_HEAD_LEN 2
  117. #define HDLC_CRC_SIZE 2
  118. #define TX_RING_MOD_MASK(size) (size - 1)
  119. #define RX_RING_MOD_MASK(size) (size - 1)
  120. #define HDLC_HEAD_MASK 0x0000
  121. #define DEFAULT_HDLC_HEAD 0xff44
  122. #define DEFAULT_ADDR_MASK 0x00ff
  123. #define DEFAULT_HDLC_ADDR 0x00ff
  124. #define BMR_GBL 0x20000000
  125. #define BMR_BIG_ENDIAN 0x10000000
  126. #define CRC_16BIT_MASK 0x0000F0B8
  127. #define CRC_16BIT_PRES 0x0000FFFF
  128. #define DEFAULT_RFTHR 1
  129. #define DEFAULT_PPP_HEAD 0xff03
  130. #endif