Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Internal header file for UCC FAST unit routines.
0004  *
0005  * Copyright (C) 2006 Freescale Semiconductor, Inc. All rights reserved.
0006  *
0007  * Authors:     Shlomi Gridish <gridish@freescale.com>
0008  *      Li Yang <leoli@freescale.com>
0009  */
0010 #ifndef __UCC_FAST_H__
0011 #define __UCC_FAST_H__
0012 
0013 #include <linux/types.h>
0014 
0015 #include <soc/fsl/qe/immap_qe.h>
0016 #include <soc/fsl/qe/qe.h>
0017 
0018 #include <soc/fsl/qe/ucc.h>
0019 
0020 /* Receive BD's status and length*/
0021 #define R_E 0x80000000  /* buffer empty */
0022 #define R_W 0x20000000  /* wrap bit */
0023 #define R_I 0x10000000  /* interrupt on reception */
0024 #define R_L 0x08000000  /* last */
0025 #define R_F 0x04000000  /* first */
0026 
0027 /* transmit BD's status and length*/
0028 #define T_R 0x80000000  /* ready bit */
0029 #define T_W 0x20000000  /* wrap bit */
0030 #define T_I 0x10000000  /* interrupt on completion */
0031 #define T_L 0x08000000  /* last */
0032 
0033 /* Receive BD's status */
0034 #define R_E_S   0x8000  /* buffer empty */
0035 #define R_W_S   0x2000  /* wrap bit */
0036 #define R_I_S   0x1000  /* interrupt on reception */
0037 #define R_L_S   0x0800  /* last */
0038 #define R_F_S   0x0400  /* first */
0039 #define R_CM_S  0x0200  /* continuous mode */
0040 #define R_LG_S  0x0020  /* frame length */
0041 #define R_NO_S  0x0010  /* nonoctet */
0042 #define R_AB_S  0x0008  /* abort */
0043 #define R_CR_S  0x0004  /* crc */
0044 #define R_OV_S  0x0002  /* overrun */
0045 #define R_CD_S  0x0001  /* carrier detect */
0046 
0047 /* transmit BD's status */
0048 #define T_R_S   0x8000  /* ready bit */
0049 #define T_W_S   0x2000  /* wrap bit */
0050 #define T_I_S   0x1000  /* interrupt on completion */
0051 #define T_L_S   0x0800  /* last */
0052 #define T_TC_S  0x0400  /* crc */
0053 #define T_TM_S  0x0200  /* continuous mode */
0054 #define T_UN_S  0x0002  /* hdlc underrun */
0055 #define T_CT_S  0x0001  /* hdlc carrier lost */
0056 
0057 /* Rx Data buffer must be 4 bytes aligned in most cases */
0058 #define UCC_FAST_RX_ALIGN           4
0059 #define UCC_FAST_MRBLR_ALIGNMENT        4
0060 #define UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT   8
0061 
0062 /* Sizes */
0063 #define UCC_FAST_URFS_MIN_VAL               0x88
0064 #define UCC_FAST_RECEIVE_VIRTUAL_FIFO_SIZE_FUDGE_FACTOR 8
0065 
0066 /* ucc_fast_channel_protocol_mode - UCC FAST mode */
0067 enum ucc_fast_channel_protocol_mode {
0068     UCC_FAST_PROTOCOL_MODE_HDLC = 0x00000000,
0069     UCC_FAST_PROTOCOL_MODE_RESERVED01 = 0x00000001,
0070     UCC_FAST_PROTOCOL_MODE_RESERVED_QMC = 0x00000002,
0071     UCC_FAST_PROTOCOL_MODE_RESERVED02 = 0x00000003,
0072     UCC_FAST_PROTOCOL_MODE_RESERVED_UART = 0x00000004,
0073     UCC_FAST_PROTOCOL_MODE_RESERVED03 = 0x00000005,
0074     UCC_FAST_PROTOCOL_MODE_RESERVED_EX_MAC_1 = 0x00000006,
0075     UCC_FAST_PROTOCOL_MODE_RESERVED_EX_MAC_2 = 0x00000007,
0076     UCC_FAST_PROTOCOL_MODE_RESERVED_BISYNC = 0x00000008,
0077     UCC_FAST_PROTOCOL_MODE_RESERVED04 = 0x00000009,
0078     UCC_FAST_PROTOCOL_MODE_ATM = 0x0000000A,
0079     UCC_FAST_PROTOCOL_MODE_RESERVED05 = 0x0000000B,
0080     UCC_FAST_PROTOCOL_MODE_ETHERNET = 0x0000000C,
0081     UCC_FAST_PROTOCOL_MODE_RESERVED06 = 0x0000000D,
0082     UCC_FAST_PROTOCOL_MODE_POS = 0x0000000E,
0083     UCC_FAST_PROTOCOL_MODE_RESERVED07 = 0x0000000F
0084 };
0085 
0086 /* ucc_fast_transparent_txrx - UCC Fast Transparent TX & RX */
0087 enum ucc_fast_transparent_txrx {
0088     UCC_FAST_GUMR_TRANSPARENT_TTX_TRX_NORMAL = 0x00000000,
0089     UCC_FAST_GUMR_TRANSPARENT_TTX_TRX_TRANSPARENT = 0x18000000
0090 };
0091 
0092 /* UCC fast diagnostic mode */
0093 enum ucc_fast_diag_mode {
0094     UCC_FAST_DIAGNOSTIC_NORMAL = 0x0,
0095     UCC_FAST_DIAGNOSTIC_LOCAL_LOOP_BACK = 0x40000000,
0096     UCC_FAST_DIAGNOSTIC_AUTO_ECHO = 0x80000000,
0097     UCC_FAST_DIAGNOSTIC_LOOP_BACK_AND_ECHO = 0xC0000000
0098 };
0099 
0100 /* UCC fast Sync length (transparent mode only) */
0101 enum ucc_fast_sync_len {
0102     UCC_FAST_SYNC_LEN_NOT_USED = 0x0,
0103     UCC_FAST_SYNC_LEN_AUTOMATIC = 0x00004000,
0104     UCC_FAST_SYNC_LEN_8_BIT = 0x00008000,
0105     UCC_FAST_SYNC_LEN_16_BIT = 0x0000C000
0106 };
0107 
0108 /* UCC fast RTS mode */
0109 enum ucc_fast_ready_to_send {
0110     UCC_FAST_SEND_IDLES_BETWEEN_FRAMES = 0x00000000,
0111     UCC_FAST_SEND_FLAGS_BETWEEN_FRAMES = 0x00002000
0112 };
0113 
0114 /* UCC fast receiver decoding mode */
0115 enum ucc_fast_rx_decoding_method {
0116     UCC_FAST_RX_ENCODING_NRZ = 0x00000000,
0117     UCC_FAST_RX_ENCODING_NRZI = 0x00000800,
0118     UCC_FAST_RX_ENCODING_RESERVED0 = 0x00001000,
0119     UCC_FAST_RX_ENCODING_RESERVED1 = 0x00001800
0120 };
0121 
0122 /* UCC fast transmitter encoding mode */
0123 enum ucc_fast_tx_encoding_method {
0124     UCC_FAST_TX_ENCODING_NRZ = 0x00000000,
0125     UCC_FAST_TX_ENCODING_NRZI = 0x00000100,
0126     UCC_FAST_TX_ENCODING_RESERVED0 = 0x00000200,
0127     UCC_FAST_TX_ENCODING_RESERVED1 = 0x00000300
0128 };
0129 
0130 /* UCC fast CRC length */
0131 enum ucc_fast_transparent_tcrc {
0132     UCC_FAST_16_BIT_CRC = 0x00000000,
0133     UCC_FAST_CRC_RESERVED0 = 0x00000040,
0134     UCC_FAST_32_BIT_CRC = 0x00000080,
0135     UCC_FAST_CRC_RESERVED1 = 0x000000C0
0136 };
0137 
0138 /* Fast UCC initialization structure */
0139 struct ucc_fast_info {
0140     int ucc_num;
0141     int tdm_num;
0142     enum qe_clock rx_clock;
0143     enum qe_clock tx_clock;
0144     enum qe_clock rx_sync;
0145     enum qe_clock tx_sync;
0146     resource_size_t regs;
0147     int irq;
0148     u32 uccm_mask;
0149     int brkpt_support;
0150     int grant_support;
0151     int tsa;
0152     int cdp;
0153     int cds;
0154     int ctsp;
0155     int ctss;
0156     int tci;
0157     int txsy;
0158     int rtsm;
0159     int revd;
0160     int rsyn;
0161     u16 max_rx_buf_length;
0162     u16 urfs;
0163     u16 urfet;
0164     u16 urfset;
0165     u16 utfs;
0166     u16 utfet;
0167     u16 utftt;
0168     u16 ufpt;
0169     enum ucc_fast_channel_protocol_mode mode;
0170     enum ucc_fast_transparent_txrx ttx_trx;
0171     enum ucc_fast_tx_encoding_method tenc;
0172     enum ucc_fast_rx_decoding_method renc;
0173     enum ucc_fast_transparent_tcrc tcrc;
0174     enum ucc_fast_sync_len synl;
0175 };
0176 
0177 struct ucc_fast_private {
0178     struct ucc_fast_info *uf_info;
0179     struct ucc_fast __iomem *uf_regs; /* a pointer to the UCC regs. */
0180     __be32 __iomem *p_ucce; /* a pointer to the event register in memory. */
0181     __be32 __iomem *p_uccm; /* a pointer to the mask register in memory. */
0182 #ifdef CONFIG_UGETH_TX_ON_DEMAND
0183     __be16 __iomem *p_utodr;/* pointer to the transmit on demand register */
0184 #endif
0185     int enabled_tx;     /* Whether channel is enabled for Tx (ENT) */
0186     int enabled_rx;     /* Whether channel is enabled for Rx (ENR) */
0187     int stopped_tx;     /* Whether channel has been stopped for Tx
0188                    (STOP_TX, etc.) */
0189     int stopped_rx;     /* Whether channel has been stopped for Rx */
0190     s32 ucc_fast_tx_virtual_fifo_base_offset;/* pointer to base of Tx
0191                             virtual fifo */
0192     s32 ucc_fast_rx_virtual_fifo_base_offset;/* pointer to base of Rx
0193                             virtual fifo */
0194 #ifdef STATISTICS
0195     u32 tx_frames;      /* Transmitted frames counter. */
0196     u32 rx_frames;      /* Received frames counter (only frames
0197                    passed to application). */
0198     u32 tx_discarded;   /* Discarded tx frames counter (frames that
0199                    were discarded by the driver due to errors).
0200                    */
0201     u32 rx_discarded;   /* Discarded rx frames counter (frames that
0202                    were discarded by the driver due to errors).
0203                    */
0204 #endif              /* STATISTICS */
0205     u16 mrblr;      /* maximum receive buffer length */
0206 };
0207 
0208 /* ucc_fast_init
0209  * Initializes Fast UCC according to user provided parameters.
0210  *
0211  * uf_info  - (In) pointer to the fast UCC info structure.
0212  * uccf_ret - (Out) pointer to the fast UCC structure.
0213  */
0214 int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** uccf_ret);
0215 
0216 /* ucc_fast_free
0217  * Frees all resources for fast UCC.
0218  *
0219  * uccf - (In) pointer to the fast UCC structure.
0220  */
0221 void ucc_fast_free(struct ucc_fast_private * uccf);
0222 
0223 /* ucc_fast_enable
0224  * Enables a fast UCC port.
0225  * This routine enables Tx and/or Rx through the General UCC Mode Register.
0226  *
0227  * uccf - (In) pointer to the fast UCC structure.
0228  * mode - (In) TX, RX, or both.
0229  */
0230 void ucc_fast_enable(struct ucc_fast_private * uccf, enum comm_dir mode);
0231 
0232 /* ucc_fast_disable
0233  * Disables a fast UCC port.
0234  * This routine disables Tx and/or Rx through the General UCC Mode Register.
0235  *
0236  * uccf - (In) pointer to the fast UCC structure.
0237  * mode - (In) TX, RX, or both.
0238  */
0239 void ucc_fast_disable(struct ucc_fast_private * uccf, enum comm_dir mode);
0240 
0241 /* ucc_fast_irq
0242  * Handles interrupts on fast UCC.
0243  * Called from the general interrupt routine to handle interrupts on fast UCC.
0244  *
0245  * uccf - (In) pointer to the fast UCC structure.
0246  */
0247 void ucc_fast_irq(struct ucc_fast_private * uccf);
0248 
0249 /* ucc_fast_transmit_on_demand
0250  * Immediately forces a poll of the transmitter for data to be sent.
0251  * Typically, the hardware performs a periodic poll for data that the
0252  * transmit routine has set up to be transmitted. In cases where
0253  * this polling cycle is not soon enough, this optional routine can
0254  * be invoked to force a poll right away, instead. Proper use for
0255  * each transmission for which this functionality is desired is to
0256  * call the transmit routine and then this routine right after.
0257  *
0258  * uccf - (In) pointer to the fast UCC structure.
0259  */
0260 void ucc_fast_transmit_on_demand(struct ucc_fast_private * uccf);
0261 
0262 u32 ucc_fast_get_qe_cr_subblock(int uccf_num);
0263 
0264 void ucc_fast_dump_regs(struct ucc_fast_private * uccf);
0265 
0266 #endif              /* __UCC_FAST_H__ */