1 /*
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 
14 struct mc13xxx;
15 
16 void mc13xxx_lock(struct mc13xxx *mc13xxx);
17 void mc13xxx_unlock(struct mc13xxx *mc13xxx);
18 
19 int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val);
20 int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val);
21 int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset,
22 		u32 mask, u32 val);
23 
24 int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
25 
26 int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq,
27 		irq_handler_t handler, const char *name, void *dev);
28 int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq,
29 		irq_handler_t handler, const char *name, void *dev);
30 int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev);
31 
32 int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq);
33 int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
34 int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq,
35 		int *enabled, int *pending);
36 int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq);
37 
38 int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
39 
40 #define MC13XXX_IRQ_ADCDONE	0
41 #define MC13XXX_IRQ_ADCBISDONE	1
42 #define MC13XXX_IRQ_TS		2
43 #define MC13XXX_IRQ_CHGDET	6
44 #define MC13XXX_IRQ_CHGREV	8
45 #define MC13XXX_IRQ_CHGSHORT	9
46 #define MC13XXX_IRQ_CCCV	10
47 #define MC13XXX_IRQ_CHGCURR	11
48 #define MC13XXX_IRQ_BPON	12
49 #define MC13XXX_IRQ_LOBATL	13
50 #define MC13XXX_IRQ_LOBATH	14
51 #define MC13XXX_IRQ_1HZ		24
52 #define MC13XXX_IRQ_TODA	25
53 #define MC13XXX_IRQ_SYSRST	30
54 #define MC13XXX_IRQ_RTCRST	31
55 #define MC13XXX_IRQ_PC		32
56 #define MC13XXX_IRQ_WARM	33
57 #define MC13XXX_IRQ_MEMHLD	34
58 #define MC13XXX_IRQ_THWARNL	36
59 #define MC13XXX_IRQ_THWARNH	37
60 #define MC13XXX_IRQ_CLK		38
61 
62 #define MC13XXX_NUM_IRQ		46
63 
64 struct regulator_init_data;
65 
66 struct mc13xxx_regulator_init_data {
67 	int id;
68 	struct regulator_init_data *init_data;
69 };
70 
71 struct mc13xxx_regulator_platform_data {
72 	int num_regulators;
73 	struct mc13xxx_regulator_init_data *regulators;
74 };
75 
76 struct mc13xxx_led_platform_data {
77 #define MC13783_LED_MD		0
78 #define MC13783_LED_AD		1
79 #define MC13783_LED_KP		2
80 #define MC13783_LED_R1		3
81 #define MC13783_LED_G1		4
82 #define MC13783_LED_B1		5
83 #define MC13783_LED_R2		6
84 #define MC13783_LED_G2		7
85 #define MC13783_LED_B2		8
86 #define MC13783_LED_R3		9
87 #define MC13783_LED_G3		10
88 #define MC13783_LED_B3		11
89 #define MC13783_LED_MAX MC13783_LED_B3
90 	int id;
91 	const char *name;
92 	const char *default_trigger;
93 
94 /* Three or two bits current selection depending on the led */
95 	char max_current;
96 };
97 
98 struct mc13xxx_leds_platform_data {
99 	int num_leds;
100 	struct mc13xxx_led_platform_data *led;
101 
102 #define MC13783_LED_TRIODE_MD	(1 << 0)
103 #define MC13783_LED_TRIODE_AD	(1 << 1)
104 #define MC13783_LED_TRIODE_KP	(1 << 2)
105 #define MC13783_LED_BOOST_EN	(1 << 3)
106 #define MC13783_LED_TC1HALF	(1 << 4)
107 #define MC13783_LED_SLEWLIMTC	(1 << 5)
108 #define MC13783_LED_SLEWLIMBL	(1 << 6)
109 #define MC13783_LED_TRIODE_TC1	(1 << 7)
110 #define MC13783_LED_TRIODE_TC2	(1 << 8)
111 #define MC13783_LED_TRIODE_TC3	(1 << 9)
112 	int flags;
113 
114 #define MC13783_LED_AB_DISABLED		0
115 #define MC13783_LED_AB_MD1		1
116 #define MC13783_LED_AB_MD12		2
117 #define MC13783_LED_AB_MD123		3
118 #define MC13783_LED_AB_MD1234		4
119 #define MC13783_LED_AB_MD1234_AD1	5
120 #define MC13783_LED_AB_MD1234_AD12	6
121 #define MC13783_LED_AB_MD1_AD		7
122 	char abmode;
123 
124 #define MC13783_LED_ABREF_200MV	0
125 #define MC13783_LED_ABREF_400MV	1
126 #define MC13783_LED_ABREF_600MV	2
127 #define MC13783_LED_ABREF_800MV	3
128 	char abref;
129 
130 #define MC13783_LED_PERIOD_10MS		0
131 #define MC13783_LED_PERIOD_100MS	1
132 #define MC13783_LED_PERIOD_500MS	2
133 #define MC13783_LED_PERIOD_2S		3
134 	char bl_period;
135 	char tc1_period;
136 	char tc2_period;
137 	char tc3_period;
138 };
139 
140 struct mc13xxx_platform_data {
141 #define MC13XXX_USE_TOUCHSCREEN (1 << 0)
142 #define MC13XXX_USE_CODEC	(1 << 1)
143 #define MC13XXX_USE_ADC		(1 << 2)
144 #define MC13XXX_USE_RTC		(1 << 3)
145 #define MC13XXX_USE_REGULATOR	(1 << 4)
146 #define MC13XXX_USE_LED		(1 << 5)
147 	unsigned int flags;
148 
149 	struct mc13xxx_regulator_platform_data regulators;
150 	struct mc13xxx_leds_platform_data *leds;
151 };
152 
153 #endif /* ifndef __LINUX_MFD_MC13XXX_H */
154