]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/mfd/wm8994/core.h
mfd: Add WM8994 interrupt controller support
[net-next-2.6.git] / include / linux / mfd / wm8994 / core.h
CommitLineData
9e501086
MB
1/*
2 * include/linux/mfd/wm8994/core.h -- Core interface for WM8994
3 *
4 * Copyright 2009 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.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
15#ifndef __MFD_WM8994_CORE_H__
16#define __MFD_WM8994_CORE_H__
17
c9fbf7e0
MB
18#include <linux/interrupt.h>
19
9e501086
MB
20struct regulator_dev;
21struct regulator_bulk_data;
22
23#define WM8994_NUM_GPIO_REGS 11
c9fbf7e0
MB
24#define WM8994_NUM_LDO_REGS 2
25#define WM8994_NUM_IRQ_REGS 2
26
27#define WM8994_IRQ_TEMP_SHUT 0
28#define WM8994_IRQ_MIC1_DET 1
29#define WM8994_IRQ_MIC1_SHRT 2
30#define WM8994_IRQ_MIC2_DET 3
31#define WM8994_IRQ_MIC2_SHRT 4
32#define WM8994_IRQ_FLL1_LOCK 5
33#define WM8994_IRQ_FLL2_LOCK 6
34#define WM8994_IRQ_SRC1_LOCK 7
35#define WM8994_IRQ_SRC2_LOCK 8
36#define WM8994_IRQ_AIF1DRC1_SIG_DET 9
37#define WM8994_IRQ_AIF1DRC2_SIG_DET 10
38#define WM8994_IRQ_AIF2DRC_SIG_DET 11
39#define WM8994_IRQ_FIFOS_ERR 12
40#define WM8994_IRQ_WSEQ_DONE 13
41#define WM8994_IRQ_DCS_DONE 14
42#define WM8994_IRQ_TEMP_WARN 15
43
44/* GPIOs in the chip are numbered from 1-11 */
45#define WM8994_IRQ_GPIO(x) (x + WM8994_IRQ_TEMP_WARN)
9e501086
MB
46
47struct wm8994 {
48 struct mutex io_lock;
c9fbf7e0 49 struct mutex irq_lock;
9e501086
MB
50
51 struct device *dev;
52 int (*read_dev)(struct wm8994 *wm8994, unsigned short reg,
53 int bytes, void *dest);
54 int (*write_dev)(struct wm8994 *wm8994, unsigned short reg,
55 int bytes, void *src);
56
57 void *control_data;
58
59 int gpio_base;
c9fbf7e0
MB
60 int irq_base;
61
62 int irq;
63 u16 irq_masks_cur[WM8994_NUM_IRQ_REGS];
64 u16 irq_masks_cache[WM8994_NUM_IRQ_REGS];
9e501086
MB
65
66 /* Used over suspend/resume */
67 u16 ldo_regs[WM8994_NUM_LDO_REGS];
68 u16 gpio_regs[WM8994_NUM_GPIO_REGS];
69
70 struct regulator_dev *dbvdd;
71 struct regulator_bulk_data *supplies;
72};
73
74/* Device I/O API */
75int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg);
76int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
77 unsigned short val);
78int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
79 unsigned short mask, unsigned short val);
80int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
81 int count, u16 *buf);
82
c9fbf7e0
MB
83
84/* Helper to save on boilerplate */
85static inline int wm8994_request_irq(struct wm8994 *wm8994, int irq,
86 irq_handler_t handler, const char *name,
87 void *data)
88{
89 if (!wm8994->irq_base)
90 return -EINVAL;
91 return request_threaded_irq(wm8994->irq_base + irq, NULL, handler,
92 IRQF_TRIGGER_RISING, name,
93 data);
94}
95static inline void wm8994_free_irq(struct wm8994 *wm8994, int irq, void *data)
96{
97 if (!wm8994->irq_base)
98 return;
99 free_irq(wm8994->irq_base + irq, data);
100}
101
102int wm8994_irq_init(struct wm8994 *wm8994);
103void wm8994_irq_exit(struct wm8994 *wm8994);
104
9e501086 105#endif