blob: 41ed59276c002fc77b598ed60fb5fc68501e72c6 [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
24int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
25
26int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq,
27 irq_handler_t handler, const char *name, void *dev);
28int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq,
29 irq_handler_t handler, const char *name, void *dev);
30int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev);
31
32int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq);
33int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
34int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq,
35 int *enabled, int *pending);
36int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq);
37
38int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
39
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +020040int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
Michael Thalmeier1039d762012-02-20 12:18:13 +010041 unsigned int mode, unsigned int channel,
42 u8 ato, bool atox, unsigned int *sample);
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +020043
Uwe Kleine-König8e005932010-09-28 16:37:20 +020044#define MC13XXX_IRQ_ADCDONE 0
45#define MC13XXX_IRQ_ADCBISDONE 1
46#define MC13XXX_IRQ_TS 2
47#define MC13XXX_IRQ_CHGDET 6
48#define MC13XXX_IRQ_CHGREV 8
49#define MC13XXX_IRQ_CHGSHORT 9
50#define MC13XXX_IRQ_CCCV 10
51#define MC13XXX_IRQ_CHGCURR 11
52#define MC13XXX_IRQ_BPON 12
53#define MC13XXX_IRQ_LOBATL 13
54#define MC13XXX_IRQ_LOBATH 14
55#define MC13XXX_IRQ_1HZ 24
56#define MC13XXX_IRQ_TODA 25
57#define MC13XXX_IRQ_SYSRST 30
58#define MC13XXX_IRQ_RTCRST 31
59#define MC13XXX_IRQ_PC 32
60#define MC13XXX_IRQ_WARM 33
61#define MC13XXX_IRQ_MEMHLD 34
62#define MC13XXX_IRQ_THWARNL 36
63#define MC13XXX_IRQ_THWARNH 37
64#define MC13XXX_IRQ_CLK 38
65
66#define MC13XXX_NUM_IRQ 46
67
68struct regulator_init_data;
69
70struct mc13xxx_regulator_init_data {
71 int id;
72 struct regulator_init_data *init_data;
Shawn Guo93bcb232011-12-21 23:00:46 +080073 struct device_node *node;
Uwe Kleine-König8e005932010-09-28 16:37:20 +020074};
75
76struct mc13xxx_regulator_platform_data {
77 int num_regulators;
78 struct mc13xxx_regulator_init_data *regulators;
79};
80
Alexander Shiyan9d2638132013-06-10 09:59:30 -070081enum {
82 /* MC13783 LED IDs */
83 MC13783_LED_MD,
84 MC13783_LED_AD,
85 MC13783_LED_KP,
86 MC13783_LED_R1,
87 MC13783_LED_G1,
88 MC13783_LED_B1,
89 MC13783_LED_R2,
90 MC13783_LED_G2,
91 MC13783_LED_B2,
92 MC13783_LED_R3,
93 MC13783_LED_G3,
94 MC13783_LED_B3,
Alexander Shiyanae6cdb02013-06-10 09:59:31 -070095 /* MC13892 LED IDs */
96 MC13892_LED_MD,
97 MC13892_LED_AD,
98 MC13892_LED_KP,
99 MC13892_LED_R,
100 MC13892_LED_G,
101 MC13892_LED_B,
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700102};
103
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200104struct mc13xxx_led_platform_data {
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200105 int id;
106 const char *name;
107 const char *default_trigger;
108
109/* Three or two bits current selection depending on the led */
110 char max_current;
111};
112
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700113#define MAX_LED_CONTROL_REGS 6
114
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200115struct mc13xxx_leds_platform_data {
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200116 struct mc13xxx_led_platform_data *led;
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700117 int num_leds;
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200118
Alexander Shiyan9d2638132013-06-10 09:59:30 -0700119/* LED Control 0 */
120#define MC13783_LED_C0_ENABLE (1 << 0)
121#define MC13783_LED_C0_TRIODE_MD (1 << 7)
122#define MC13783_LED_C0_TRIODE_AD (1 << 8)
123#define MC13783_LED_C0_TRIODE_KP (1 << 9)
124#define MC13783_LED_C0_BOOST (1 << 10)
125#define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11)
126#define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14)
127/* LED Control 1 */
128#define MC13783_LED_C1_TC1HALF (1 << 18)
129#define MC13783_LED_C1_SLEWLIM (1 << 23)
130/* LED Control 2 */
131#define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21)
132#define MC13783_LED_C2_SLEWLIM (1 << 23)
133/* LED Control 3 */
134#define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21)
135#define MC13783_LED_C3_TRIODE_TC1 (1 << 23)
136/* LED Control 4 */
137#define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21)
138#define MC13783_LED_C4_TRIODE_TC2 (1 << 23)
139/* LED Control 5 */
140#define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21)
141#define MC13783_LED_C5_TRIODE_TC3 (1 << 23)
142 u32 led_control[MAX_LED_CONTROL_REGS];
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200143};
144
Philippe Rétornaz30fc7ac2011-09-18 18:10:53 +0200145struct mc13xxx_buttons_platform_data {
146#define MC13783_BUTTON_DBNC_0MS 0
147#define MC13783_BUTTON_DBNC_30MS 1
148#define MC13783_BUTTON_DBNC_150MS 2
149#define MC13783_BUTTON_DBNC_750MS 3
150#define MC13783_BUTTON_ENABLE (1 << 2)
151#define MC13783_BUTTON_POL_INVERT (1 << 3)
152#define MC13783_BUTTON_RESET_EN (1 << 4)
153 int b1on_flags;
154 unsigned short b1on_key;
155 int b2on_flags;
156 unsigned short b2on_key;
157 int b3on_flags;
158 unsigned short b3on_key;
159};
160
Michael Thalmeier1039d762012-02-20 12:18:13 +0100161struct mc13xxx_ts_platform_data {
162 /* Delay between Touchscreen polarization and ADC Conversion.
163 * Given in clock ticks of a 32 kHz clock which gives a granularity of
164 * about 30.5ms */
165 u8 ato;
166
167#define MC13783_TS_ATO_FIRST false
168#define MC13783_TS_ATO_EACH true
169 /* Use the ATO delay only for the first conversion or for each one */
170 bool atox;
171};
172
Philippe Rétornaze3a08712012-05-15 13:53:49 +0200173enum mc13783_ssi_port {
174 MC13783_SSI1_PORT,
175 MC13783_SSI2_PORT,
176};
177
178struct mc13xxx_codec_platform_data {
179 enum mc13783_ssi_port adc_ssi_port;
180 enum mc13783_ssi_port dac_ssi_port;
181};
182
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200183struct mc13xxx_platform_data {
184#define MC13XXX_USE_TOUCHSCREEN (1 << 0)
185#define MC13XXX_USE_CODEC (1 << 1)
186#define MC13XXX_USE_ADC (1 << 2)
187#define MC13XXX_USE_RTC (1 << 3)
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200188 unsigned int flags;
189
Andres Salomon4ec1b542011-02-17 19:07:23 -0800190 struct mc13xxx_regulator_platform_data regulators;
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200191 struct mc13xxx_leds_platform_data *leds;
Philippe Rétornaz30fc7ac2011-09-18 18:10:53 +0200192 struct mc13xxx_buttons_platform_data *buttons;
Michael Thalmeier1039d762012-02-20 12:18:13 +0100193 struct mc13xxx_ts_platform_data touch;
Philippe Rétornaze3a08712012-05-15 13:53:49 +0200194 struct mc13xxx_codec_platform_data *codec;
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200195};
196
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +0200197#define MC13XXX_ADC_MODE_TS 1
198#define MC13XXX_ADC_MODE_SINGLE_CHAN 2
199#define MC13XXX_ADC_MODE_MULT_CHAN 3
200
201#define MC13XXX_ADC0 43
Robin van der Gracht21618912011-11-29 12:09:03 +0100202#define MC13XXX_ADC0_LICELLCON (1 << 0)
203#define MC13XXX_ADC0_CHRGICON (1 << 1)
204#define MC13XXX_ADC0_BATICON (1 << 2)
Uwe Kleine-Königfec316d2011-08-24 15:28:21 +0200205#define MC13XXX_ADC0_ADREFEN (1 << 10)
206#define MC13XXX_ADC0_TSMOD0 (1 << 12)
207#define MC13XXX_ADC0_TSMOD1 (1 << 13)
208#define MC13XXX_ADC0_TSMOD2 (1 << 14)
209#define MC13XXX_ADC0_ADINC1 (1 << 16)
210#define MC13XXX_ADC0_ADINC2 (1 << 17)
211
212#define MC13XXX_ADC0_TSMOD_MASK (MC13XXX_ADC0_TSMOD0 | \
213 MC13XXX_ADC0_TSMOD1 | \
214 MC13XXX_ADC0_TSMOD2)
215
Robin van der Gracht21618912011-11-29 12:09:03 +0100216#define MC13XXX_ADC0_CONFIG_MASK (MC13XXX_ADC0_TSMOD_MASK | \
217 MC13XXX_ADC0_LICELLCON | \
218 MC13XXX_ADC0_CHRGICON | \
219 MC13XXX_ADC0_BATICON)
220
Uwe Kleine-König8e005932010-09-28 16:37:20 +0200221#endif /* ifndef __LINUX_MFD_MC13XXX_H */