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