1
2
3
4
5
6
7
8
9#ifndef DRIVERS_FSI_MASTER_H
10#define DRIVERS_FSI_MASTER_H
11
12#include <linux/device.h>
13#include <linux/mutex.h>
14
15
16
17
18
19
20
21
22
23#define FSI_MMODE 0x0
24#define FSI_MDLYR 0x4
25#define FSI_MCRSP 0x8
26#define FSI_MENP0 0x10
27#define FSI_MLEVP0 0x18
28#define FSI_MSENP0 0x18
29#define FSI_MCENP0 0x20
30#define FSI_MAEB 0x70
31#define FSI_MVER 0x74
32#define FSI_MSTAP0 0xd0
33#define FSI_MRESP0 0xd0
34#define FSI_MESRB0 0x1d0
35#define FSI_MRESB0 0x1d0
36#define FSI_MSCSB0 0x1d4
37#define FSI_MATRB0 0x1d8
38#define FSI_MDTRB0 0x1dc
39#define FSI_MECTRL 0x2e0
40
41
42#define FSI_MMODE_EIP 0x80000000
43#define FSI_MMODE_ECRC 0x40000000
44#define FSI_MMODE_RELA 0x20000000
45#define FSI_MMODE_EPC 0x10000000
46#define FSI_MMODE_P8_TO_LSB 0x00000010
47
48
49#define FSI_MMODE_CRS0SHFT 18
50#define FSI_MMODE_CRS0MASK 0x3ff
51#define FSI_MMODE_CRS1SHFT 8
52#define FSI_MMODE_CRS1MASK 0x3ff
53
54
55#define FSI_MRESB_RST_GEN 0x80000000
56#define FSI_MRESB_RST_ERR 0x40000000
57
58
59#define FSI_MRESP_RST_ALL_MASTER 0x20000000
60#define FSI_MRESP_RST_ALL_LINK 0x10000000
61#define FSI_MRESP_RST_MCR 0x08000000
62#define FSI_MRESP_RST_PYE 0x04000000
63#define FSI_MRESP_RST_ALL 0xfc000000
64
65
66#define FSI_MECTRL_EOAE 0x8000
67
68#define FSI_MECTRL_P8_AUTO_TERM 0x4000
69
70#define FSI_HUB_LINK_OFFSET 0x80000
71#define FSI_HUB_LINK_SIZE 0x80000
72#define FSI_HUB_MASTER_MAX_LINKS 8
73
74
75
76
77
78
79
80
81#define FSI_ECHO_DELAY_CLOCKS 16
82#define FSI_SEND_DELAY_CLOCKS 16
83#define FSI_PRE_BREAK_CLOCKS 50
84#define FSI_BREAK_CLOCKS 256
85#define FSI_POST_BREAK_CLOCKS 16000
86#define FSI_INIT_CLOCKS 5000
87#define FSI_MASTER_DPOLL_CLOCKS 50
88#define FSI_MASTER_EPOLL_CLOCKS 50
89
90
91#define FSI_CRC_ERR_RETRIES 10
92#define FSI_MASTER_MAX_BUSY 200
93#define FSI_MASTER_MTOE_COUNT 1000
94
95
96#define FSI_CMD_DPOLL 0x2
97#define FSI_CMD_EPOLL 0x3
98#define FSI_CMD_TERM 0x3f
99#define FSI_CMD_ABS_AR 0x4
100#define FSI_CMD_REL_AR 0x5
101#define FSI_CMD_SAME_AR 0x3
102
103
104#define FSI_RESP_ACK 0
105#define FSI_RESP_BUSY 1
106#define FSI_RESP_ERRA 2
107#define FSI_RESP_ERRC 3
108
109
110#define FSI_CRC_SIZE 4
111
112
113#define FSI_MASTER_FLAG_SWCLOCK 0x1
114
115
116
117
118
119
120
121struct fsi_master {
122 struct device dev;
123 int idx;
124 int n_links;
125 int flags;
126 struct mutex scan_lock;
127 int (*read)(struct fsi_master *, int link, uint8_t id,
128 uint32_t addr, void *val, size_t size);
129 int (*write)(struct fsi_master *, int link, uint8_t id,
130 uint32_t addr, const void *val, size_t size);
131 int (*term)(struct fsi_master *, int link, uint8_t id);
132 int (*send_break)(struct fsi_master *, int link);
133 int (*link_enable)(struct fsi_master *, int link,
134 bool enable);
135 int (*link_config)(struct fsi_master *, int link,
136 u8 t_send_delay, u8 t_echo_delay);
137};
138
139#define dev_to_fsi_master(d) container_of(d, struct fsi_master, dev)
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156extern int fsi_master_register(struct fsi_master *master);
157extern void fsi_master_unregister(struct fsi_master *master);
158
159extern int fsi_master_rescan(struct fsi_master *master);
160
161#endif
162