blob: a326c850f0468ad415ad6ab014a470db452b5b03 [file] [log] [blame]
Uwe Kleine-König8e005932010-09-28 16:37:20 +02001/*
2 * Copyright 2009-2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#ifndef __LINUX_MFD_MC13XXX_H
10#define __LINUX_MFD_MC13XXX_H
11
12#include <linux/interrupt.h>
13
14struct mc13xxx;
15
16void mc13xxx_lock(struct mc13xxx *mc13xxx);
17void mc13xxx_unlock(struct mc13xxx *mc13xxx);
18
19int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val);
20int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val);
21int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset,
22 u32 mask, u32 val);
23
Uwe Kleine-König8e005932010-09-28 16:37:20 +020024int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq,
25 irq_handler_t handler, const char *name, void *dev);
26int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq,
27 irq_handler_t handler, const char *name, void *dev);
28int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev);
29
30int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq);
31int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
32int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq,
33 int *enabled, int *pending);
34int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq);
35
36int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
37
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +020038int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
Michael Thalmeier1039d762012-02-20 12:18:13 +010039 unsigned int mode, unsigned int channel,
40 u8 ato, bool atox, unsigned int *sample);
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +020041
Mark Brownfd792f82013-09-23 19:14:32 +010042#define MC13783_AUDIO_RX0 36
43#define MC13783_AUDIO_RX1 37
44#define MC13783_AUDIO_TX 38
45#define MC13783_SSI_NETWORK 39
46#define MC13783_AUDIO_CODEC 40
47#define MC13783_AUDIO_DAC 41
48
Uwe Kleine-König8e005932010-09-28 16:37:20 +020049#define MC13XXX_IRQ_ADCDONE 0
50#define MC13XXX_IRQ_ADCBISDONE 1
51#define MC13XXX_IRQ_TS 2
52#define MC13XXX_IRQ_CHGDET 6
53#define MC13XXX_IRQ_CHGREV 8
54#define MC13XXX_IRQ_CHGSHORT 9
55#define MC13XXX_IRQ_CCCV 10
56#define MC13XXX_IRQ_CHGCURR 11
57#define MC13XXX_IRQ_BPON 12
58#define MC13XXX_IRQ_LOBATL 13
59#define MC13XXX_IRQ_LOBATH 14
60#define MC13XXX_IRQ_1HZ 24
61#define MC13XXX_IRQ_TODA 25
62#define MC13XXX_IRQ_SYSRST 30
63#define MC13XXX_IRQ_RTCRST 31
64#define MC13XXX_IRQ_PC 32
65#define MC13XXX_IRQ_WARM 33
66#define MC13XXX_IRQ_MEMHLD 34
67#define MC13XXX_IRQ_THWARNL 36
68#define MC13XXX_IRQ_THWARNH 37
69#define MC13XXX_IRQ_CLK 38
70
71#define MC13XXX_NUM_IRQ 46
72
73struct regulator_init_data;
74
75struct mc13xxx_regulator_init_data {
76 int id;
77 struct regulator_init_data *init_data;
Shawn Guo93bcb232011-12-21 23:00:46 +080078 struct device_node *node;
Uwe Kleine-König8e005932010-09-28 16:37:20 +020079};
80
81struct mc13xxx_regulator_platform_data {
82 int num_regulators;
83 struct mc13xxx_regulator_init_data *regulators;
84};
85
Alexander Shiyan9d2638132013-06-10 09:59:30 -070086enum {
87 /* MC13783 LED IDs */
88 MC13783_LED_MD,
89 MC13783_LED_AD,
90 MC13783_LED_KP,
91 MC13783_LED_R1,
92 MC13783_LED_G1,
93 MC13783_LED_B1,
94 MC13783_LED_R2,
95 MC13783_LED_G2,
96 MC13783_LED_B2,
97 MC13783_LED_R3,
98 MC13783_LED_G3,
99 MC13783_LED_B3,
Alexander Shiyanae6cdb02013-06-10 09:59:31 -0700100 /* MC13892 LED IDs */
101 MC13892_LED_MD,
102 MC13892_LED_AD,
103 MC13892_LED_KP,
104 MC13892_LED_R,
105 MC13892_LED_G,
106 MC13892_LED_B,
Alexander Shiyana59ce652014-01-31 22:36:28 -0800107 /* MC34708 LED IDs */
108 MC34708_LED_R,
109 MC34708_LED_G,
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700110};
111
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200112struct mc13xxx_led_platform_data {
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200113 int id;
114 const char *name;
115 const char *default_trigger;
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200116};
117
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700118#define MAX_LED_CONTROL_REGS 6
119
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200120struct mc13xxx_leds_platform_data {
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200121 struct mc13xxx_led_platform_data *led;
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700122 int num_leds;
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200123
Alexander Shiyan01a7a062013-12-06 22:22:18 -0800124/* MC13783 LED Control 0 */
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700125#define MC13783_LED_C0_ENABLE (1 << 0)
126#define MC13783_LED_C0_TRIODE_MD (1 << 7)
127#define MC13783_LED_C0_TRIODE_AD (1 << 8)
128#define MC13783_LED_C0_TRIODE_KP (1 << 9)
129#define MC13783_LED_C0_BOOST (1 << 10)
130#define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11)
131#define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14)
Alexander Shiyan01a7a062013-12-06 22:22:18 -0800132/* MC13783 LED Control 1 */
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700133#define MC13783_LED_C1_TC1HALF (1 << 18)
134#define MC13783_LED_C1_SLEWLIM (1 << 23)
Alexander Shiyan01a7a062013-12-06 22:22:18 -0800135/* MC13783 LED Control 2 */
136#define MC13783_LED_C2_CURRENT_MD(x) (((x) & 0x7) << 0)
137#define MC13783_LED_C2_CURRENT_AD(x) (((x) & 0x7) << 3)
138#define MC13783_LED_C2_CURRENT_KP(x) (((x) & 0x7) << 6)
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700139#define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21)
140#define MC13783_LED_C2_SLEWLIM (1 << 23)
Alexander Shiyan01a7a062013-12-06 22:22:18 -0800141/* MC13783 LED Control 3 */
142#define MC13783_LED_C3_CURRENT_R1(x) (((x) & 0x3) << 0)
143#define MC13783_LED_C3_CURRENT_G1(x) (((x) & 0x3) << 2)
144#define MC13783_LED_C3_CURRENT_B1(x) (((x) & 0x3) << 4)
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700145#define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21)
146#define MC13783_LED_C3_TRIODE_TC1 (1 << 23)
Alexander Shiyan01a7a062013-12-06 22:22:18 -0800147/* MC13783 LED Control 4 */
148#define MC13783_LED_C4_CURRENT_R2(x) (((x) & 0x3) << 0)
149#define MC13783_LED_C4_CURRENT_G2(x) (((x) & 0x3) << 2)
150#define MC13783_LED_C4_CURRENT_B2(x) (((x) & 0x3) << 4)
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700151#define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21)
152#define MC13783_LED_C4_TRIODE_TC2 (1 << 23)
Alexander Shiyan01a7a062013-12-06 22:22:18 -0800153/* MC13783 LED Control 5 */
154#define MC13783_LED_C5_CURRENT_R3(x) (((x) & 0x3) << 0)
155#define MC13783_LED_C5_CURRENT_G3(x) (((x) & 0x3) << 2)
156#define MC13783_LED_C5_CURRENT_B3(x) (((x) & 0x3) << 4)
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700157#define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21)
158#define MC13783_LED_C5_TRIODE_TC3 (1 << 23)
Alexander Shiyan01a7a062013-12-06 22:22:18 -0800159/* MC13892 LED Control 0 */
160#define MC13892_LED_C0_CURRENT_MD(x) (((x) & 0x7) << 9)
161#define MC13892_LED_C0_CURRENT_AD(x) (((x) & 0x7) << 21)
162/* MC13892 LED Control 1 */
163#define MC13892_LED_C1_CURRENT_KP(x) (((x) & 0x7) << 9)
164/* MC13892 LED Control 2 */
165#define MC13892_LED_C2_CURRENT_R(x) (((x) & 0x7) << 9)
166#define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21)
167/* MC13892 LED Control 3 */
168#define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9)
Alexander Shiyana59ce652014-01-31 22:36:28 -0800169/* MC34708 LED Control 0 */
170#define MC34708_LED_C0_CURRENT_R(x) (((x) & 0x3) << 9)
171#define MC34708_LED_C0_CURRENT_G(x) (((x) & 0x3) << 21)
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700172 u32 led_control[MAX_LED_CONTROL_REGS];
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200173};
174
Philippe Rétornaz30fc7ac2011-09-18 18:10:53 +0200175struct mc13xxx_buttons_platform_data {
176#define MC13783_BUTTON_DBNC_0MS 0
177#define MC13783_BUTTON_DBNC_30MS 1
178#define MC13783_BUTTON_DBNC_150MS 2
179#define MC13783_BUTTON_DBNC_750MS 3
180#define MC13783_BUTTON_ENABLE (1 << 2)
181#define MC13783_BUTTON_POL_INVERT (1 << 3)
182#define MC13783_BUTTON_RESET_EN (1 << 4)
183 int b1on_flags;
184 unsigned short b1on_key;
185 int b2on_flags;
186 unsigned short b2on_key;
187 int b3on_flags;
188 unsigned short b3on_key;
189};
190
Michael Thalmeier1039d762012-02-20 12:18:13 +0100191struct mc13xxx_ts_platform_data {
192 /* Delay between Touchscreen polarization and ADC Conversion.
193 * Given in clock ticks of a 32 kHz clock which gives a granularity of
194 * about 30.5ms */
195 u8 ato;
196
197#define MC13783_TS_ATO_FIRST false
198#define MC13783_TS_ATO_EACH true
199 /* Use the ATO delay only for the first conversion or for each one */
200 bool atox;
201};
202
Philippe Rétornaze3a08712012-05-15 13:53:49 +0200203enum mc13783_ssi_port {
204 MC13783_SSI1_PORT,
205 MC13783_SSI2_PORT,
206};
207
208struct mc13xxx_codec_platform_data {
209 enum mc13783_ssi_port adc_ssi_port;
210 enum mc13783_ssi_port dac_ssi_port;
211};
212
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200213struct mc13xxx_platform_data {
214#define MC13XXX_USE_TOUCHSCREEN (1 << 0)
215#define MC13XXX_USE_CODEC (1 << 1)
216#define MC13XXX_USE_ADC (1 << 2)
217#define MC13XXX_USE_RTC (1 << 3)
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200218 unsigned int flags;
219
Andres Salomon4ec1b542011-02-17 19:07:23 -0800220 struct mc13xxx_regulator_platform_data regulators;
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200221 struct mc13xxx_leds_platform_data *leds;
Philippe Rétornaz30fc7ac2011-09-18 18:10:53 +0200222 struct mc13xxx_buttons_platform_data *buttons;
Michael Thalmeier1039d762012-02-20 12:18:13 +0100223 struct mc13xxx_ts_platform_data touch;
Philippe Rétornaze3a08712012-05-15 13:53:49 +0200224 struct mc13xxx_codec_platform_data *codec;
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200225};
226
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +0200227#define MC13XXX_ADC_MODE_TS 1
228#define MC13XXX_ADC_MODE_SINGLE_CHAN 2
229#define MC13XXX_ADC_MODE_MULT_CHAN 3
230
231#define MC13XXX_ADC0 43
Robin van der Gracht21618912011-11-29 12:09:03 +0100232#define MC13XXX_ADC0_LICELLCON (1 << 0)
233#define MC13XXX_ADC0_CHRGICON (1 << 1)
234#define MC13XXX_ADC0_BATICON (1 << 2)
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +0200235#define MC13XXX_ADC0_ADREFEN (1 << 10)
236#define MC13XXX_ADC0_TSMOD0 (1 << 12)
237#define MC13XXX_ADC0_TSMOD1 (1 << 13)
238#define MC13XXX_ADC0_TSMOD2 (1 << 14)
239#define MC13XXX_ADC0_ADINC1 (1 << 16)
240#define MC13XXX_ADC0_ADINC2 (1 << 17)
241
242#define MC13XXX_ADC0_TSMOD_MASK (MC13XXX_ADC0_TSMOD0 | \
243 MC13XXX_ADC0_TSMOD1 | \
244 MC13XXX_ADC0_TSMOD2)
245
Robin van der Gracht21618912011-11-29 12:09:03 +0100246#define MC13XXX_ADC0_CONFIG_MASK (MC13XXX_ADC0_TSMOD_MASK | \
247 MC13XXX_ADC0_LICELLCON | \
248 MC13XXX_ADC0_CHRGICON | \
249 MC13XXX_ADC0_BATICON)
250
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200251#endif /* ifndef __LINUX_MFD_MC13XXX_H */