1
2 #ifndef __PMAC_PFUNC_H__
3 #define __PMAC_PFUNC_H__
4
5 #include <linux/types.h>
6 #include <linux/list.h>
7
8
9 #define PMF_FLAGS_ON_INIT 0x80000000u
10 #define PMF_FLGAS_ON_TERM 0x40000000u
11 #define PMF_FLAGS_ON_SLEEP 0x20000000u
12 #define PMF_FLAGS_ON_WAKE 0x10000000u
13 #define PMF_FLAGS_ON_DEMAND 0x08000000u
14 #define PMF_FLAGS_INT_GEN 0x04000000u
15 #define PMF_FLAGS_HIGH_SPEED 0x02000000u
16 #define PMF_FLAGS_LOW_SPEED 0x01000000u
17 #define PMF_FLAGS_SIDE_EFFECTS 0x00800000u
18
19
20
21
22
23
24 struct pmf_args {
25 union {
26 u32 v;
27 u32 *p;
28 } u[4];
29 unsigned int count;
30 };
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 #define PMF_STD_ARGS struct pmf_function *func, void *instdata, \
53 struct pmf_args *args
54
55 struct pmf_function;
56
57 struct pmf_handlers {
58 void * (*begin)(struct pmf_function *func, struct pmf_args *args);
59 void (*end)(struct pmf_function *func, void *instdata);
60
61 int (*irq_enable)(struct pmf_function *func);
62 int (*irq_disable)(struct pmf_function *func);
63
64 int (*write_gpio)(PMF_STD_ARGS, u8 value, u8 mask);
65 int (*read_gpio)(PMF_STD_ARGS, u8 mask, int rshift, u8 xor);
66
67 int (*write_reg32)(PMF_STD_ARGS, u32 offset, u32 value, u32 mask);
68 int (*read_reg32)(PMF_STD_ARGS, u32 offset);
69 int (*write_reg16)(PMF_STD_ARGS, u32 offset, u16 value, u16 mask);
70 int (*read_reg16)(PMF_STD_ARGS, u32 offset);
71 int (*write_reg8)(PMF_STD_ARGS, u32 offset, u8 value, u8 mask);
72 int (*read_reg8)(PMF_STD_ARGS, u32 offset);
73
74 int (*delay)(PMF_STD_ARGS, u32 duration);
75
76 int (*wait_reg32)(PMF_STD_ARGS, u32 offset, u32 value, u32 mask);
77 int (*wait_reg16)(PMF_STD_ARGS, u32 offset, u16 value, u16 mask);
78 int (*wait_reg8)(PMF_STD_ARGS, u32 offset, u8 value, u8 mask);
79
80 int (*read_i2c)(PMF_STD_ARGS, u32 len);
81 int (*write_i2c)(PMF_STD_ARGS, u32 len, const u8 *data);
82 int (*rmw_i2c)(PMF_STD_ARGS, u32 masklen, u32 valuelen, u32 totallen,
83 const u8 *maskdata, const u8 *valuedata);
84
85 int (*read_cfg)(PMF_STD_ARGS, u32 offset, u32 len);
86 int (*write_cfg)(PMF_STD_ARGS, u32 offset, u32 len, const u8 *data);
87 int (*rmw_cfg)(PMF_STD_ARGS, u32 offset, u32 masklen, u32 valuelen,
88 u32 totallen, const u8 *maskdata, const u8 *valuedata);
89
90 int (*read_i2c_sub)(PMF_STD_ARGS, u8 subaddr, u32 len);
91 int (*write_i2c_sub)(PMF_STD_ARGS, u8 subaddr, u32 len, const u8 *data);
92 int (*set_i2c_mode)(PMF_STD_ARGS, int mode);
93 int (*rmw_i2c_sub)(PMF_STD_ARGS, u8 subaddr, u32 masklen, u32 valuelen,
94 u32 totallen, const u8 *maskdata,
95 const u8 *valuedata);
96
97 int (*read_reg32_msrx)(PMF_STD_ARGS, u32 offset, u32 mask, u32 shift,
98 u32 xor);
99 int (*read_reg16_msrx)(PMF_STD_ARGS, u32 offset, u32 mask, u32 shift,
100 u32 xor);
101 int (*read_reg8_msrx)(PMF_STD_ARGS, u32 offset, u32 mask, u32 shift,
102 u32 xor);
103
104 int (*write_reg32_slm)(PMF_STD_ARGS, u32 offset, u32 shift, u32 mask);
105 int (*write_reg16_slm)(PMF_STD_ARGS, u32 offset, u32 shift, u32 mask);
106 int (*write_reg8_slm)(PMF_STD_ARGS, u32 offset, u32 shift, u32 mask);
107
108 int (*mask_and_compare)(PMF_STD_ARGS, u32 len, const u8 *maskdata,
109 const u8 *valuedata);
110
111 struct module *owner;
112 };
113
114
115
116
117
118
119
120
121
122 struct pmf_device;
123
124 struct pmf_function {
125
126 struct list_head link;
127
128
129 struct device_node *node;
130 void *driver_data;
131
132
133 struct pmf_device *dev;
134
135
136
137
138
139
140 const char *name;
141 u32 phandle;
142
143
144
145
146 u32 flags;
147
148
149 const void *data;
150 unsigned int length;
151
152
153 struct list_head irq_clients;
154
155
156 struct kref ref;
157 };
158
159
160
161
162
163
164
165
166 struct pmf_irq_client {
167 void (*handler)(void *data);
168 void *data;
169 struct module *owner;
170 struct list_head link;
171 struct pmf_function *func;
172 };
173
174
175
176
177
178 extern int pmf_register_driver(struct device_node *np,
179 struct pmf_handlers *handlers,
180 void *driverdata);
181
182 extern void pmf_unregister_driver(struct device_node *np);
183
184
185
186
187
188 extern int pmf_register_irq_client(struct device_node *np,
189 const char *name,
190 struct pmf_irq_client *client);
191
192 extern void pmf_unregister_irq_client(struct pmf_irq_client *client);
193
194
195
196
197 extern void pmf_do_irq(struct pmf_function *func);
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217 extern int pmf_do_functions(struct device_node *np, const char *name,
218 u32 phandle, u32 flags, struct pmf_args *args);
219
220
221
222
223
224
225
226
227
228
229
230
231 extern int pmf_call_function(struct device_node *target, const char *name,
232 struct pmf_args *args);
233
234
235
236
237
238
239
240 extern struct pmf_function *pmf_find_function(struct device_node *target,
241 const char *name);
242
243 extern struct pmf_function * pmf_get_function(struct pmf_function *func);
244 extern void pmf_put_function(struct pmf_function *func);
245
246 extern int pmf_call_one(struct pmf_function *func, struct pmf_args *args);
247
248 int pmac_pfunc_base_install(void);
249
250
251 extern void pmac_pfunc_base_suspend(void);
252 extern void pmac_pfunc_base_resume(void);
253
254 #endif