blob: 71af3d6ebe9d1ba1957285d8332a364f4237c724 [file] [log] [blame]
Mark Brown0c42e0b2008-10-10 15:58:04 +01001/*
2 * gpio.h -- GPIO Driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_WM8350_GPIO_H_
14#define __LINUX_MFD_WM8350_GPIO_H_
15
Mark Brownadd41cb2008-10-13 15:45:22 +010016#include <linux/platform_device.h>
17
Mark Brown0c42e0b2008-10-10 15:58:04 +010018/*
19 * GPIO Registers.
20 */
21#define WM8350_GPIO_DEBOUNCE 0x80
22#define WM8350_GPIO_PIN_PULL_UP_CONTROL 0x81
23#define WM8350_GPIO_PULL_DOWN_CONTROL 0x82
24#define WM8350_GPIO_INT_MODE 0x83
25#define WM8350_GPIO_CONTROL 0x85
26#define WM8350_GPIO_CONFIGURATION_I_O 0x86
27#define WM8350_GPIO_PIN_POLARITY_TYPE 0x87
28#define WM8350_GPIO_FUNCTION_SELECT_1 0x8C
29#define WM8350_GPIO_FUNCTION_SELECT_2 0x8D
30#define WM8350_GPIO_FUNCTION_SELECT_3 0x8E
31#define WM8350_GPIO_FUNCTION_SELECT_4 0x8F
32
33/*
34 * GPIO Functions
35 */
36#define WM8350_GPIO0_GPIO_IN 0x0
37#define WM8350_GPIO0_GPIO_OUT 0x0
38#define WM8350_GPIO0_PWR_ON_IN 0x1
39#define WM8350_GPIO0_PWR_ON_OUT 0x1
40#define WM8350_GPIO0_LDO_EN_IN 0x2
41#define WM8350_GPIO0_VRTC_OUT 0x2
42#define WM8350_GPIO0_LPWR1_IN 0x3
43#define WM8350_GPIO0_POR_B_OUT 0x3
44
45#define WM8350_GPIO1_GPIO_IN 0x0
46#define WM8350_GPIO1_GPIO_OUT 0x0
47#define WM8350_GPIO1_PWR_ON_IN 0x1
48#define WM8350_GPIO1_DO_CONF_OUT 0x1
49#define WM8350_GPIO1_LDO_EN_IN 0x2
50#define WM8350_GPIO1_RESET_OUT 0x2
51#define WM8350_GPIO1_LPWR2_IN 0x3
52#define WM8350_GPIO1_MEMRST_OUT 0x3
53
54#define WM8350_GPIO2_GPIO_IN 0x0
55#define WM8350_GPIO2_GPIO_OUT 0x0
56#define WM8350_GPIO2_PWR_ON_IN 0x1
57#define WM8350_GPIO2_PWR_ON_OUT 0x1
58#define WM8350_GPIO2_WAKE_UP_IN 0x2
59#define WM8350_GPIO2_VRTC_OUT 0x2
60#define WM8350_GPIO2_32KHZ_IN 0x3
61#define WM8350_GPIO2_32KHZ_OUT 0x3
62
63#define WM8350_GPIO3_GPIO_IN 0x0
64#define WM8350_GPIO3_GPIO_OUT 0x0
65#define WM8350_GPIO3_PWR_ON_IN 0x1
66#define WM8350_GPIO3_P_CLK_OUT 0x1
67#define WM8350_GPIO3_LDO_EN_IN 0x2
68#define WM8350_GPIO3_VRTC_OUT 0x2
69#define WM8350_GPIO3_PWR_OFF_IN 0x3
70#define WM8350_GPIO3_32KHZ_OUT 0x3
71
72#define WM8350_GPIO4_GPIO_IN 0x0
73#define WM8350_GPIO4_GPIO_OUT 0x0
74#define WM8350_GPIO4_MR_IN 0x1
75#define WM8350_GPIO4_MEM_RST_OUT 0x1
76#define WM8350_GPIO4_FLASH_IN 0x2
77#define WM8350_GPIO4_ADA_OUT 0x2
78#define WM8350_GPIO4_HIBERNATE_IN 0x3
79#define WM8350_GPIO4_FLASH_OUT 0x3
80#define WM8350_GPIO4_MICDET_OUT 0x4
81#define WM8350_GPIO4_MICSHT_OUT 0x5
82
83#define WM8350_GPIO5_GPIO_IN 0x0
84#define WM8350_GPIO5_GPIO_OUT 0x0
85#define WM8350_GPIO5_LPWR1_IN 0x1
86#define WM8350_GPIO5_P_CLK_OUT 0x1
87#define WM8350_GPIO5_ADCLRCLK_IN 0x2
88#define WM8350_GPIO5_ADCLRCLK_OUT 0x2
89#define WM8350_GPIO5_HIBERNATE_IN 0x3
90#define WM8350_GPIO5_32KHZ_OUT 0x3
91#define WM8350_GPIO5_MICDET_OUT 0x4
92#define WM8350_GPIO5_MICSHT_OUT 0x5
93#define WM8350_GPIO5_ADA_OUT 0x6
94#define WM8350_GPIO5_OPCLK_OUT 0x7
95
96#define WM8350_GPIO6_GPIO_IN 0x0
97#define WM8350_GPIO6_GPIO_OUT 0x0
98#define WM8350_GPIO6_LPWR2_IN 0x1
99#define WM8350_GPIO6_MEMRST_OUT 0x1
100#define WM8350_GPIO6_FLASH_IN 0x2
101#define WM8350_GPIO6_ADA_OUT 0x2
102#define WM8350_GPIO6_HIBERNATE_IN 0x3
103#define WM8350_GPIO6_RTC_OUT 0x3
104#define WM8350_GPIO6_MICDET_OUT 0x4
105#define WM8350_GPIO6_MICSHT_OUT 0x5
106#define WM8350_GPIO6_ADCLRCLKB_OUT 0x6
107#define WM8350_GPIO6_SDOUT_OUT 0x7
108
109#define WM8350_GPIO7_GPIO_IN 0x0
110#define WM8350_GPIO7_GPIO_OUT 0x0
111#define WM8350_GPIO7_LPWR3_IN 0x1
112#define WM8350_GPIO7_P_CLK_OUT 0x1
113#define WM8350_GPIO7_MASK_IN 0x2
114#define WM8350_GPIO7_VCC_FAULT_OUT 0x2
115#define WM8350_GPIO7_HIBERNATE_IN 0x3
116#define WM8350_GPIO7_BATT_FAULT_OUT 0x3
117#define WM8350_GPIO7_MICDET_OUT 0x4
118#define WM8350_GPIO7_MICSHT_OUT 0x5
119#define WM8350_GPIO7_ADA_OUT 0x6
120#define WM8350_GPIO7_CSB_IN 0x7
121
122#define WM8350_GPIO8_GPIO_IN 0x0
123#define WM8350_GPIO8_GPIO_OUT 0x0
124#define WM8350_GPIO8_MR_IN 0x1
125#define WM8350_GPIO8_VCC_FAULT_OUT 0x1
126#define WM8350_GPIO8_ADCBCLK_IN 0x2
127#define WM8350_GPIO8_ADCBCLK_OUT 0x2
128#define WM8350_GPIO8_PWR_OFF_IN 0x3
129#define WM8350_GPIO8_BATT_FAULT_OUT 0x3
130#define WM8350_GPIO8_ALTSCL_IN 0xf
131
132#define WM8350_GPIO9_GPIO_IN 0x0
133#define WM8350_GPIO9_GPIO_OUT 0x0
134#define WM8350_GPIO9_HEARTBEAT_IN 0x1
135#define WM8350_GPIO9_VCC_FAULT_OUT 0x1
136#define WM8350_GPIO9_MASK_IN 0x2
137#define WM8350_GPIO9_LINE_GT_BATT_OUT 0x2
138#define WM8350_GPIO9_PWR_OFF_IN 0x3
139#define WM8350_GPIO9_BATT_FAULT_OUT 0x3
140#define WM8350_GPIO9_ALTSDA_OUT 0xf
141
142#define WM8350_GPIO10_GPIO_IN 0x0
143#define WM8350_GPIO10_GPIO_OUT 0x0
144#define WM8350_GPIO10_ISINKC_OUT 0x1
145#define WM8350_GPIO10_PWR_OFF_IN 0x2
146#define WM8350_GPIO10_LINE_GT_BATT_OUT 0x2
147#define WM8350_GPIO10_CHD_IND_IN 0x3
148
149#define WM8350_GPIO11_GPIO_IN 0x0
150#define WM8350_GPIO11_GPIO_OUT 0x0
151#define WM8350_GPIO11_ISINKD_OUT 0x1
152#define WM8350_GPIO11_WAKEUP_IN 0x2
153#define WM8350_GPIO11_LINE_GT_BATT_OUT 0x2
154#define WM8350_GPIO11_CHD_IND_IN 0x3
155
156#define WM8350_GPIO12_GPIO_IN 0x0
157#define WM8350_GPIO12_GPIO_OUT 0x0
158#define WM8350_GPIO12_ISINKE_OUT 0x1
159#define WM8350_GPIO12_LINE_GT_BATT_OUT 0x2
160#define WM8350_GPIO12_LINE_EN_OUT 0x3
161#define WM8350_GPIO12_32KHZ_OUT 0x4
162
163#define WM8350_GPIO_DIR_IN 0
164#define WM8350_GPIO_DIR_OUT 1
165#define WM8350_GPIO_ACTIVE_LOW 0
166#define WM8350_GPIO_ACTIVE_HIGH 1
167#define WM8350_GPIO_PULL_NONE 0
168#define WM8350_GPIO_PULL_UP 1
169#define WM8350_GPIO_PULL_DOWN 2
170#define WM8350_GPIO_INVERT_OFF 0
171#define WM8350_GPIO_INVERT_ON 1
172#define WM8350_GPIO_DEBOUNCE_OFF 0
173#define WM8350_GPIO_DEBOUNCE_ON 1
174
175/*
Mark Brown0c7229f2009-10-12 16:15:10 +0100176 * R30 (0x1E) - GPIO Interrupt Status
177 */
178#define WM8350_GP12_EINT 0x1000
179#define WM8350_GP11_EINT 0x0800
180#define WM8350_GP10_EINT 0x0400
181#define WM8350_GP9_EINT 0x0200
182#define WM8350_GP8_EINT 0x0100
183#define WM8350_GP7_EINT 0x0080
184#define WM8350_GP6_EINT 0x0040
185#define WM8350_GP5_EINT 0x0020
186#define WM8350_GP4_EINT 0x0010
187#define WM8350_GP3_EINT 0x0008
188#define WM8350_GP2_EINT 0x0004
189#define WM8350_GP1_EINT 0x0002
190#define WM8350_GP0_EINT 0x0001
191
192
193/*
Mark Brown0c42e0b2008-10-10 15:58:04 +0100194 * R128 (0x80) - GPIO Debounce
195 */
196#define WM8350_GP12_DB 0x1000
197#define WM8350_GP11_DB 0x0800
198#define WM8350_GP10_DB 0x0400
199#define WM8350_GP9_DB 0x0200
200#define WM8350_GP8_DB 0x0100
201#define WM8350_GP7_DB 0x0080
202#define WM8350_GP6_DB 0x0040
203#define WM8350_GP5_DB 0x0020
204#define WM8350_GP4_DB 0x0010
205#define WM8350_GP3_DB 0x0008
206#define WM8350_GP2_DB 0x0004
207#define WM8350_GP1_DB 0x0002
208#define WM8350_GP0_DB 0x0001
209
210/*
211 * R129 (0x81) - GPIO Pin pull up Control
212 */
213#define WM8350_GP12_PU 0x1000
214#define WM8350_GP11_PU 0x0800
215#define WM8350_GP10_PU 0x0400
216#define WM8350_GP9_PU 0x0200
217#define WM8350_GP8_PU 0x0100
218#define WM8350_GP7_PU 0x0080
219#define WM8350_GP6_PU 0x0040
220#define WM8350_GP5_PU 0x0020
221#define WM8350_GP4_PU 0x0010
222#define WM8350_GP3_PU 0x0008
223#define WM8350_GP2_PU 0x0004
224#define WM8350_GP1_PU 0x0002
225#define WM8350_GP0_PU 0x0001
226
227/*
228 * R130 (0x82) - GPIO Pull down Control
229 */
230#define WM8350_GP12_PD 0x1000
231#define WM8350_GP11_PD 0x0800
232#define WM8350_GP10_PD 0x0400
233#define WM8350_GP9_PD 0x0200
234#define WM8350_GP8_PD 0x0100
235#define WM8350_GP7_PD 0x0080
236#define WM8350_GP6_PD 0x0040
237#define WM8350_GP5_PD 0x0020
238#define WM8350_GP4_PD 0x0010
239#define WM8350_GP3_PD 0x0008
240#define WM8350_GP2_PD 0x0004
241#define WM8350_GP1_PD 0x0002
242#define WM8350_GP0_PD 0x0001
243
244/*
245 * R131 (0x83) - GPIO Interrupt Mode
246 */
247#define WM8350_GP12_INTMODE 0x1000
248#define WM8350_GP11_INTMODE 0x0800
249#define WM8350_GP10_INTMODE 0x0400
250#define WM8350_GP9_INTMODE 0x0200
251#define WM8350_GP8_INTMODE 0x0100
252#define WM8350_GP7_INTMODE 0x0080
253#define WM8350_GP6_INTMODE 0x0040
254#define WM8350_GP5_INTMODE 0x0020
255#define WM8350_GP4_INTMODE 0x0010
256#define WM8350_GP3_INTMODE 0x0008
257#define WM8350_GP2_INTMODE 0x0004
258#define WM8350_GP1_INTMODE 0x0002
259#define WM8350_GP0_INTMODE 0x0001
260
261/*
262 * R133 (0x85) - GPIO Control
263 */
264#define WM8350_GP_DBTIME_MASK 0x00C0
265
266/*
267 * R134 (0x86) - GPIO Configuration (i/o)
268 */
269#define WM8350_GP12_DIR 0x1000
270#define WM8350_GP11_DIR 0x0800
271#define WM8350_GP10_DIR 0x0400
272#define WM8350_GP9_DIR 0x0200
273#define WM8350_GP8_DIR 0x0100
274#define WM8350_GP7_DIR 0x0080
275#define WM8350_GP6_DIR 0x0040
276#define WM8350_GP5_DIR 0x0020
277#define WM8350_GP4_DIR 0x0010
278#define WM8350_GP3_DIR 0x0008
279#define WM8350_GP2_DIR 0x0004
280#define WM8350_GP1_DIR 0x0002
281#define WM8350_GP0_DIR 0x0001
282
283/*
284 * R135 (0x87) - GPIO Pin Polarity / Type
285 */
286#define WM8350_GP12_CFG 0x1000
287#define WM8350_GP11_CFG 0x0800
288#define WM8350_GP10_CFG 0x0400
289#define WM8350_GP9_CFG 0x0200
290#define WM8350_GP8_CFG 0x0100
291#define WM8350_GP7_CFG 0x0080
292#define WM8350_GP6_CFG 0x0040
293#define WM8350_GP5_CFG 0x0020
294#define WM8350_GP4_CFG 0x0010
295#define WM8350_GP3_CFG 0x0008
296#define WM8350_GP2_CFG 0x0004
297#define WM8350_GP1_CFG 0x0002
298#define WM8350_GP0_CFG 0x0001
299
300/*
301 * R140 (0x8C) - GPIO Function Select 1
302 */
303#define WM8350_GP3_FN_MASK 0xF000
304#define WM8350_GP2_FN_MASK 0x0F00
305#define WM8350_GP1_FN_MASK 0x00F0
306#define WM8350_GP0_FN_MASK 0x000F
307
308/*
309 * R141 (0x8D) - GPIO Function Select 2
310 */
311#define WM8350_GP7_FN_MASK 0xF000
312#define WM8350_GP6_FN_MASK 0x0F00
313#define WM8350_GP5_FN_MASK 0x00F0
314#define WM8350_GP4_FN_MASK 0x000F
315
316/*
317 * R142 (0x8E) - GPIO Function Select 3
318 */
319#define WM8350_GP11_FN_MASK 0xF000
320#define WM8350_GP10_FN_MASK 0x0F00
321#define WM8350_GP9_FN_MASK 0x00F0
322#define WM8350_GP8_FN_MASK 0x000F
323
324/*
325 * R143 (0x8F) - GPIO Function Select 4
326 */
327#define WM8350_GP12_FN_MASK 0x000F
328
329/*
330 * R230 (0xE6) - GPIO Pin Status
331 */
332#define WM8350_GP12_LVL 0x1000
333#define WM8350_GP11_LVL 0x0800
334#define WM8350_GP10_LVL 0x0400
335#define WM8350_GP9_LVL 0x0200
336#define WM8350_GP8_LVL 0x0100
337#define WM8350_GP7_LVL 0x0080
338#define WM8350_GP6_LVL 0x0040
339#define WM8350_GP5_LVL 0x0020
340#define WM8350_GP4_LVL 0x0010
341#define WM8350_GP3_LVL 0x0008
342#define WM8350_GP2_LVL 0x0004
343#define WM8350_GP1_LVL 0x0002
344#define WM8350_GP0_LVL 0x0001
345
Mark Brown0e720392008-10-10 15:58:12 +0100346struct wm8350;
347
348int wm8350_gpio_config(struct wm8350 *wm8350, int gpio, int dir, int func,
349 int pol, int pull, int invert, int debounce);
350
Mark Brownadd41cb2008-10-13 15:45:22 +0100351struct wm8350_gpio {
352 struct platform_device *pdev;
353};
354
Mark Brown0e720392008-10-10 15:58:12 +0100355/*
356 * GPIO Interrupts
357 */
358#define WM8350_IRQ_GPIO(x) (50 + x)
359
Mark Brown0c42e0b2008-10-10 15:58:04 +0100360#endif