Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
18#include <linux/mutex.h>
19#include <linux/interrupt.h>
20#include <linux/regmap.h>
21
22#include <linux/mfd/wm8994/pdata.h>
23
24enum wm8994_type {
25 WM8994 = 0,
26 WM8958 = 1,
27 WM1811 = 2,
28};
29
30struct regulator_dev;
31struct regulator_bulk_data;
32
33#define WM8994_NUM_GPIO_REGS 11
34#define WM8994_NUM_LDO_REGS 2
35#define WM8994_NUM_IRQ_REGS 2
36
37#define WM8994_IRQ_TEMP_SHUT 0
38#define WM8994_IRQ_MIC1_DET 1
39#define WM8994_IRQ_MIC1_SHRT 2
40#define WM8994_IRQ_MIC2_DET 3
41#define WM8994_IRQ_MIC2_SHRT 4
42#define WM8994_IRQ_FLL1_LOCK 5
43#define WM8994_IRQ_FLL2_LOCK 6
44#define WM8994_IRQ_SRC1_LOCK 7
45#define WM8994_IRQ_SRC2_LOCK 8
46#define WM8994_IRQ_AIF1DRC1_SIG_DET 9
47#define WM8994_IRQ_AIF1DRC2_SIG_DET 10
48#define WM8994_IRQ_AIF2DRC_SIG_DET 11
49#define WM8994_IRQ_FIFOS_ERR 12
50#define WM8994_IRQ_WSEQ_DONE 13
51#define WM8994_IRQ_DCS_DONE 14
52#define WM8994_IRQ_TEMP_WARN 15
53
54/* GPIOs in the chip are numbered from 1-11 */
55#define WM8994_IRQ_GPIO(x) (x + WM8994_IRQ_TEMP_WARN)
56
57struct wm8994 {
58 struct mutex irq_lock;
59
60 struct wm8994_pdata pdata;
61
62 enum wm8994_type type;
63 int revision;
64 int cust_id;
65
66 struct device *dev;
67 struct regmap *regmap;
68
69 bool ldo_ena_always_driven;
70
71 int gpio_base;
72 int irq_base;
73
74 int irq;
75 struct regmap_irq_chip_data *irq_data;
76
77 /* Used over suspend/resume */
78 bool suspended;
79
80 struct regulator_dev *dbvdd;
81 int num_supplies;
82 struct regulator_bulk_data *supplies;
83};
84
85/* Device I/O API */
86int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg);
87int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
88 unsigned short val);
89int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
90 unsigned short mask, unsigned short val);
91int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
92 int count, u16 *buf);
93int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
94 int count, const u16 *buf);
95
96
97/* Helper to save on boilerplate */
98static inline int wm8994_request_irq(struct wm8994 *wm8994, int irq,
99 irq_handler_t handler, const char *name,
100 void *data)
101{
102 if (!wm8994->irq_data)
103 return -EINVAL;
104 return request_threaded_irq(regmap_irq_get_virq(wm8994->irq_data, irq),
105 NULL, handler, IRQF_TRIGGER_RISING, name,
106 data);
107}
108static inline void wm8994_free_irq(struct wm8994 *wm8994, int irq, void *data)
109{
110 if (!wm8994->irq_data)
111 return;
112 free_irq(regmap_irq_get_virq(wm8994->irq_data, irq), data);
113}
114
115int wm8994_irq_init(struct wm8994 *wm8994);
116void wm8994_irq_exit(struct wm8994 *wm8994);
117
118#endif