blob: 5f6aff55eeb75d676199b6d214e570b732f1505a [file] [log] [blame]
Sascha Hauer8238add2009-08-19 01:40:28 +02001/*
Uwe Kleine-König9e272672009-11-30 00:53:17 +01002 * Copyright 2009 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Sascha Hauer8238add2009-08-19 01:40:28 +02004 *
Uwe Kleine-König9e272672009-11-30 00:53:17 +01005 * 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.
Sascha Hauer8238add2009-08-19 01:40:28 +02008 */
Uwe Kleine-König9e272672009-11-30 00:53:17 +01009#ifndef __LINUX_MFD_MC13783_H
10#define __LINUX_MFD_MC13783_H
Sascha Hauer8238add2009-08-19 01:40:28 +020011
Uwe Kleine-König9e272672009-11-30 00:53:17 +010012#include <linux/interrupt.h>
Sascha Hauer8238add2009-08-19 01:40:28 +020013
14struct mc13783;
Uwe Kleine-König9e272672009-11-30 00:53:17 +010015
16void mc13783_lock(struct mc13783 *mc13783);
17void mc13783_unlock(struct mc13783 *mc13783);
18
19int mc13783_reg_read(struct mc13783 *mc13783, unsigned int offset, u32 *val);
20int mc13783_reg_write(struct mc13783 *mc13783, unsigned int offset, u32 val);
21int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset,
22 u32 mask, u32 val);
23
Uwe Kleine-König3b16bb52010-08-02 11:14:17 +020024int mc13783_get_flags(struct mc13783 *mc13783);
25
Uwe Kleine-König9e272672009-11-30 00:53:17 +010026int mc13783_irq_request(struct mc13783 *mc13783, int irq,
27 irq_handler_t handler, const char *name, void *dev);
28int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq,
29 irq_handler_t handler, const char *name, void *dev);
30int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev);
Uwe Kleine-König9e272672009-11-30 00:53:17 +010031
Uwe Kleine-König57205022010-03-05 13:44:25 -080032int mc13783_irq_mask(struct mc13783 *mc13783, int irq);
33int mc13783_irq_unmask(struct mc13783 *mc13783, int irq);
Uwe Kleine-König86c34002010-03-05 13:44:29 -080034int mc13783_irq_status(struct mc13783 *mc13783, int irq,
35 int *enabled, int *pending);
Uwe Kleine-König57205022010-03-05 13:44:25 -080036int mc13783_irq_ack(struct mc13783 *mc13783, int irq);
37
Uwe Kleine-König9e272672009-11-30 00:53:17 +010038#define MC13783_ADC0 43
39#define MC13783_ADC0_ADREFEN (1 << 10)
40#define MC13783_ADC0_ADREFMODE (1 << 11)
41#define MC13783_ADC0_TSMOD0 (1 << 12)
42#define MC13783_ADC0_TSMOD1 (1 << 13)
43#define MC13783_ADC0_TSMOD2 (1 << 14)
44#define MC13783_ADC0_ADINC1 (1 << 16)
45#define MC13783_ADC0_ADINC2 (1 << 17)
46
47#define MC13783_ADC0_TSMOD_MASK (MC13783_ADC0_TSMOD0 | \
48 MC13783_ADC0_TSMOD1 | \
49 MC13783_ADC0_TSMOD2)
50
Philippe Rétornaz7fdcef82010-05-19 09:24:31 +020051struct mc13783_led_platform_data {
52#define MC13783_LED_MD 0
53#define MC13783_LED_AD 1
54#define MC13783_LED_KP 2
55#define MC13783_LED_R1 3
56#define MC13783_LED_G1 4
57#define MC13783_LED_B1 5
58#define MC13783_LED_R2 6
59#define MC13783_LED_G2 7
60#define MC13783_LED_B2 8
61#define MC13783_LED_R3 9
62#define MC13783_LED_G3 10
63#define MC13783_LED_B3 11
64#define MC13783_LED_MAX MC13783_LED_B3
65 int id;
66 const char *name;
67 const char *default_trigger;
68
69/* Three or two bits current selection depending on the led */
70 char max_current;
71};
72
73struct mc13783_leds_platform_data {
74 int num_leds;
75 struct mc13783_led_platform_data *led;
76
77#define MC13783_LED_TRIODE_MD (1 << 0)
78#define MC13783_LED_TRIODE_AD (1 << 1)
79#define MC13783_LED_TRIODE_KP (1 << 2)
80#define MC13783_LED_BOOST_EN (1 << 3)
81#define MC13783_LED_TC1HALF (1 << 4)
82#define MC13783_LED_SLEWLIMTC (1 << 5)
83#define MC13783_LED_SLEWLIMBL (1 << 6)
84#define MC13783_LED_TRIODE_TC1 (1 << 7)
85#define MC13783_LED_TRIODE_TC2 (1 << 8)
86#define MC13783_LED_TRIODE_TC3 (1 << 9)
87 int flags;
88
89#define MC13783_LED_AB_DISABLED 0
90#define MC13783_LED_AB_MD1 1
91#define MC13783_LED_AB_MD12 2
92#define MC13783_LED_AB_MD123 3
93#define MC13783_LED_AB_MD1234 4
94#define MC13783_LED_AB_MD1234_AD1 5
95#define MC13783_LED_AB_MD1234_AD12 6
96#define MC13783_LED_AB_MD1_AD 7
97 char abmode;
98
99#define MC13783_LED_ABREF_200MV 0
100#define MC13783_LED_ABREF_400MV 1
101#define MC13783_LED_ABREF_600MV 2
102#define MC13783_LED_ABREF_800MV 3
103 char abref;
104
105#define MC13783_LED_PERIOD_10MS 0
106#define MC13783_LED_PERIOD_100MS 1
107#define MC13783_LED_PERIOD_500MS 2
108#define MC13783_LED_PERIOD_2S 3
109 char bl_period;
110 char tc1_period;
111 char tc2_period;
112 char tc3_period;
113};
114
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100115/* to be cleaned up */
Sascha Hauer8238add2009-08-19 01:40:28 +0200116struct regulator_init_data;
117
118struct mc13783_regulator_init_data {
119 int id;
120 struct regulator_init_data *init_data;
121};
122
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100123struct mc13783_regulator_platform_data {
Sascha Hauer8238add2009-08-19 01:40:28 +0200124 int num_regulators;
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100125 struct mc13783_regulator_init_data *regulators;
Sascha Hauer8238add2009-08-19 01:40:28 +0200126};
127
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100128struct mc13783_platform_data {
129 int num_regulators;
130 struct mc13783_regulator_init_data *regulators;
Philippe Rétornaz7fdcef82010-05-19 09:24:31 +0200131 struct mc13783_leds_platform_data *leds;
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100132
Sascha Hauer8238add2009-08-19 01:40:28 +0200133#define MC13783_USE_TOUCHSCREEN (1 << 0)
134#define MC13783_USE_CODEC (1 << 1)
135#define MC13783_USE_ADC (1 << 2)
136#define MC13783_USE_RTC (1 << 3)
137#define MC13783_USE_REGULATOR (1 << 4)
Philippe Rétornaz7fdcef82010-05-19 09:24:31 +0200138#define MC13783_USE_LED (1 << 5)
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100139 unsigned int flags;
140};
141
142#define MC13783_ADC_MODE_TS 1
143#define MC13783_ADC_MODE_SINGLE_CHAN 2
144#define MC13783_ADC_MODE_MULT_CHAN 3
Sascha Hauer8238add2009-08-19 01:40:28 +0200145
146int mc13783_adc_do_conversion(struct mc13783 *mc13783, unsigned int mode,
147 unsigned int channel, unsigned int *sample);
148
Sascha Hauer8238add2009-08-19 01:40:28 +0200149
150#define MC13783_SW_SW1A 0
151#define MC13783_SW_SW1B 1
152#define MC13783_SW_SW2A 2
153#define MC13783_SW_SW2B 3
154#define MC13783_SW_SW3 4
155#define MC13783_SW_PLL 5
156#define MC13783_REGU_VAUDIO 6
157#define MC13783_REGU_VIOHI 7
158#define MC13783_REGU_VIOLO 8
159#define MC13783_REGU_VDIG 9
160#define MC13783_REGU_VGEN 10
161#define MC13783_REGU_VRFDIG 11
162#define MC13783_REGU_VRFREF 12
163#define MC13783_REGU_VRFCP 13
164#define MC13783_REGU_VSIM 14
165#define MC13783_REGU_VESIM 15
166#define MC13783_REGU_VCAM 16
167#define MC13783_REGU_VRFBG 17
168#define MC13783_REGU_VVIB 18
169#define MC13783_REGU_VRF1 19
170#define MC13783_REGU_VRF2 20
171#define MC13783_REGU_VMMC1 21
172#define MC13783_REGU_VMMC2 22
173#define MC13783_REGU_GPO1 23
174#define MC13783_REGU_GPO2 24
175#define MC13783_REGU_GPO3 25
176#define MC13783_REGU_GPO4 26
177#define MC13783_REGU_V1 27
178#define MC13783_REGU_V2 28
179#define MC13783_REGU_V3 29
180#define MC13783_REGU_V4 30
Alberto Panizzof4b97b32010-01-19 12:48:54 +0100181#define MC13783_REGU_PWGT1SPI 31
182#define MC13783_REGU_PWGT2SPI 32
Sascha Hauer8238add2009-08-19 01:40:28 +0200183
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100184#define MC13783_IRQ_ADCDONE 0
185#define MC13783_IRQ_ADCBISDONE 1
186#define MC13783_IRQ_TS 2
187#define MC13783_IRQ_WHIGH 3
188#define MC13783_IRQ_WLOW 4
189#define MC13783_IRQ_CHGDET 6
190#define MC13783_IRQ_CHGOV 7
191#define MC13783_IRQ_CHGREV 8
192#define MC13783_IRQ_CHGSHORT 9
193#define MC13783_IRQ_CCCV 10
194#define MC13783_IRQ_CHGCURR 11
195#define MC13783_IRQ_BPON 12
196#define MC13783_IRQ_LOBATL 13
197#define MC13783_IRQ_LOBATH 14
198#define MC13783_IRQ_UDP 15
199#define MC13783_IRQ_USB 16
200#define MC13783_IRQ_ID 19
201#define MC13783_IRQ_SE1 21
202#define MC13783_IRQ_CKDET 22
203#define MC13783_IRQ_UDM 23
204#define MC13783_IRQ_1HZ 24
205#define MC13783_IRQ_TODA 25
206#define MC13783_IRQ_ONOFD1 27
207#define MC13783_IRQ_ONOFD2 28
208#define MC13783_IRQ_ONOFD3 29
209#define MC13783_IRQ_SYSRST 30
210#define MC13783_IRQ_RTCRST 31
211#define MC13783_IRQ_PC 32
212#define MC13783_IRQ_WARM 33
213#define MC13783_IRQ_MEMHLD 34
214#define MC13783_IRQ_PWRRDY 35
215#define MC13783_IRQ_THWARNL 36
216#define MC13783_IRQ_THWARNH 37
217#define MC13783_IRQ_CLK 38
218#define MC13783_IRQ_SEMAF 39
219#define MC13783_IRQ_MC2B 41
220#define MC13783_IRQ_HSDET 42
221#define MC13783_IRQ_HSL 43
222#define MC13783_IRQ_ALSPTH 44
223#define MC13783_IRQ_AHSSHORT 45
224#define MC13783_NUM_IRQ 46
Sascha Hauer8238add2009-08-19 01:40:28 +0200225
Uwe Kleine-König9e272672009-11-30 00:53:17 +0100226#endif /* __LINUX_MFD_MC13783_H */