xref: /openbmc/linux/include/soc/fsl/qe/qe_tdm.h (revision 76426e23)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Internal header file for QE TDM mode routines.
4  *
5  * Copyright (C) 2016 Freescale Semiconductor, Inc. All rights reserved.
6  *
7  * Authors:	Zhao Qiang <qiang.zhao@nxp.com>
8  */
9 
10 #ifndef _QE_TDM_H_
11 #define _QE_TDM_H_
12 
13 #include <linux/kernel.h>
14 #include <linux/list.h>
15 
16 #include <soc/fsl/qe/immap_qe.h>
17 #include <soc/fsl/qe/qe.h>
18 
19 #include <soc/fsl/qe/ucc.h>
20 #include <soc/fsl/qe/ucc_fast.h>
21 
22 /* SI RAM entries */
23 #define SIR_LAST	0x0001
24 #define SIR_BYTE	0x0002
25 #define SIR_CNT(x)	((x) << 2)
26 #define SIR_CSEL(x)	((x) << 5)
27 #define SIR_SGS		0x0200
28 #define SIR_SWTR	0x4000
29 #define SIR_MCC		0x8000
30 #define SIR_IDLE	0
31 
32 /* SIxMR fields */
33 #define SIMR_SAD(x) ((x) << 12)
34 #define SIMR_SDM_NORMAL	0x0000
35 #define SIMR_SDM_INTERNAL_LOOPBACK	0x0800
36 #define SIMR_SDM_MASK	0x0c00
37 #define SIMR_CRT	0x0040
38 #define SIMR_SL		0x0020
39 #define SIMR_CE		0x0010
40 #define SIMR_FE		0x0008
41 #define SIMR_GM		0x0004
42 #define SIMR_TFSD(n)	(n)
43 #define SIMR_RFSD(n)	((n) << 8)
44 
45 enum tdm_ts_t {
46 	TDM_TX_TS,
47 	TDM_RX_TS
48 };
49 
50 enum tdm_framer_t {
51 	TDM_FRAMER_T1,
52 	TDM_FRAMER_E1
53 };
54 
55 enum tdm_mode_t {
56 	TDM_INTERNAL_LOOPBACK,
57 	TDM_NORMAL
58 };
59 
60 struct si_mode_info {
61 	u8 simr_rfsd;
62 	u8 simr_tfsd;
63 	u8 simr_crt;
64 	u8 simr_sl;
65 	u8 simr_ce;
66 	u8 simr_fe;
67 	u8 simr_gm;
68 };
69 
70 struct ucc_tdm_info {
71 	struct ucc_fast_info uf_info;
72 	struct si_mode_info si_info;
73 };
74 
75 struct ucc_tdm {
76 	u16 tdm_port;		/* port for this tdm:TDMA,TDMB */
77 	u32 siram_entry_id;
78 	u16 __iomem *siram;
79 	struct si1 __iomem *si_regs;
80 	enum tdm_framer_t tdm_framer_type;
81 	enum tdm_mode_t tdm_mode;
82 	u8 num_of_ts;		/* the number of timeslots in this tdm frame */
83 	u32 tx_ts_mask;		/* tx time slot mask */
84 	u32 rx_ts_mask;		/* rx time slot mask */
85 };
86 
87 int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm,
88 		     struct ucc_tdm_info *ut_info);
89 void ucc_tdm_init(struct ucc_tdm *utdm, struct ucc_tdm_info *ut_info);
90 #endif
91