mfd: Don't suspend WM8994 if the CODEC is not suspended
[deliverable/linux.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
559e0df6
MB
20enum wm8994_type {
21 WM8994 = 0,
22 WM8958 = 1,
23};
24
9e501086
MB
25struct regulator_dev;
26struct regulator_bulk_data;
27
28#define WM8994_NUM_GPIO_REGS 11
c9fbf7e0
MB
29#define WM8994_NUM_LDO_REGS 2
30#define WM8994_NUM_IRQ_REGS 2
31
32#define WM8994_IRQ_TEMP_SHUT 0
33#define WM8994_IRQ_MIC1_DET 1
34#define WM8994_IRQ_MIC1_SHRT 2
35#define WM8994_IRQ_MIC2_DET 3
36#define WM8994_IRQ_MIC2_SHRT 4
37#define WM8994_IRQ_FLL1_LOCK 5
38#define WM8994_IRQ_FLL2_LOCK 6
39#define WM8994_IRQ_SRC1_LOCK 7
40#define WM8994_IRQ_SRC2_LOCK 8
41#define WM8994_IRQ_AIF1DRC1_SIG_DET 9
42#define WM8994_IRQ_AIF1DRC2_SIG_DET 10
43#define WM8994_IRQ_AIF2DRC_SIG_DET 11
44#define WM8994_IRQ_FIFOS_ERR 12
45#define WM8994_IRQ_WSEQ_DONE 13
46#define WM8994_IRQ_DCS_DONE 14
47#define WM8994_IRQ_TEMP_WARN 15
48
49/* GPIOs in the chip are numbered from 1-11 */
50#define WM8994_IRQ_GPIO(x) (x + WM8994_IRQ_TEMP_WARN)
9e501086
MB
51
52struct wm8994 {
53 struct mutex io_lock;
c9fbf7e0 54 struct mutex irq_lock;
9e501086 55
559e0df6
MB
56 enum wm8994_type type;
57
9e501086
MB
58 struct device *dev;
59 int (*read_dev)(struct wm8994 *wm8994, unsigned short reg,
60 int bytes, void *dest);
61 int (*write_dev)(struct wm8994 *wm8994, unsigned short reg,
62 int bytes, void *src);
63
64 void *control_data;
65
66 int gpio_base;
c9fbf7e0
MB
67 int irq_base;
68
69 int irq;
70 u16 irq_masks_cur[WM8994_NUM_IRQ_REGS];
71 u16 irq_masks_cache[WM8994_NUM_IRQ_REGS];
9e501086
MB
72
73 /* Used over suspend/resume */
77bd70e9 74 bool suspended;
9e501086
MB
75 u16 ldo_regs[WM8994_NUM_LDO_REGS];
76 u16 gpio_regs[WM8994_NUM_GPIO_REGS];
77
78 struct regulator_dev *dbvdd;
559e0df6 79 int num_supplies;
9e501086
MB
80 struct regulator_bulk_data *supplies;
81};
82
83/* Device I/O API */
84int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg);
85int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
86 unsigned short val);
87int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
88 unsigned short mask, unsigned short val);
89int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
90 int count, u16 *buf);
91
c9fbf7e0
MB
92
93/* Helper to save on boilerplate */
94static inline int wm8994_request_irq(struct wm8994 *wm8994, int irq,
95 irq_handler_t handler, const char *name,
96 void *data)
97{
98 if (!wm8994->irq_base)
99 return -EINVAL;
100 return request_threaded_irq(wm8994->irq_base + irq, NULL, handler,
101 IRQF_TRIGGER_RISING, name,
102 data);
103}
104static inline void wm8994_free_irq(struct wm8994 *wm8994, int irq, void *data)
105{
106 if (!wm8994->irq_base)
107 return;
108 free_irq(wm8994->irq_base + irq, data);
109}
110
111int wm8994_irq_init(struct wm8994 *wm8994);
112void wm8994_irq_exit(struct wm8994 *wm8994);
113
9e501086 114#endif
This page took 0.075627 seconds and 5 git commands to generate.