Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lp8788.h
Go to the documentation of this file.
1 /*
2  * TI LP8788 MFD Device
3  *
4  * Copyright 2012 Texas Instruments
5  *
6  * Author: Milo(Woogyom) Kim <[email protected]>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  *
12  */
13 
14 #ifndef __MFD_LP8788_H__
15 #define __MFD_LP8788_H__
16 
17 #include <linux/gpio.h>
18 #include <linux/irqdomain.h>
19 #include <linux/regmap.h>
20 
21 #define LP8788_DEV_BUCK "lp8788-buck"
22 #define LP8788_DEV_DLDO "lp8788-dldo"
23 #define LP8788_DEV_ALDO "lp8788-aldo"
24 #define LP8788_DEV_CHARGER "lp8788-charger"
25 #define LP8788_DEV_RTC "lp8788-rtc"
26 #define LP8788_DEV_BACKLIGHT "lp8788-backlight"
27 #define LP8788_DEV_VIBRATOR "lp8788-vibrator"
28 #define LP8788_DEV_KEYLED "lp8788-keyled"
29 #define LP8788_DEV_ADC "lp8788-adc"
30 
31 #define LP8788_NUM_BUCKS 4
32 #define LP8788_NUM_DLDOS 12
33 #define LP8788_NUM_ALDOS 10
34 #define LP8788_NUM_BUCK2_DVS 2
35 
36 #define LP8788_CHG_IRQ "CHG_IRQ"
37 #define LP8788_PRSW_IRQ "PRSW_IRQ"
38 #define LP8788_BATT_IRQ "BATT_IRQ"
39 #define LP8788_ALM_IRQ "ALARM_IRQ"
40 
42  /* interrup register 1 : Addr 00h */
51 
52  /* interrupt register 2 : Addr 01h */
60 
61  /* interrupt register 3 : Addr 02h */
68 
70 };
71 
77 };
78 
87 };
88 
92 };
93 
96  LP8788_BL_COMB_PWM_BASED, /* PWM + I2C, changed by PWM input */
97  LP8788_BL_COMB_REGISTER_BASED, /* PWM + I2C, changed by I2C */
98 };
99 
103 };
104 
114 };
115 
125 };
126 
130 };
131 
135 };
136 
141 };
142 
147 };
148 
164 };
165 
166 struct lp8788;
167 
168 /*
169  * lp8788_buck1_dvs
170  * @gpio : gpio pin number for dvs control
171  * @vsel : dvs selector for buck v1 register
172  */
174  int gpio;
176 };
177 
178 /*
179  * lp8788_buck2_dvs
180  * @gpio : two gpio pin numbers are used for dvs
181  * @vsel : dvs selector for buck v2 register
182  */
186 };
187 
188 /*
189  * struct lp8788_ldo_enable_pin
190  *
191  * Basically, all LDOs are enabled through the I2C commands.
192  * But ALDO 1 ~ 5, 7, DLDO 7, 9, 11 can be enabled by external gpio pins.
193  *
194  * @gpio : gpio number which is used for enabling ldos
195  * @init_state : initial gpio state (ex. GPIOF_OUT_INIT_LOW)
196  */
198  int gpio;
200 };
201 
202 /*
203  * struct lp8788_chg_param
204  * @addr : charging control register address (range : 0x11 ~ 0x1C)
205  * @val : charging parameter value
206  */
210 };
211 
212 /*
213  * struct lp8788_charger_platform_data
214  * @vbatt_adc : adc selection id for battery voltage
215  * @batt_temp_adc : adc selection id for battery temperature
216  * @max_vbatt_mv : used for calculating battery capacity
217  * @chg_params : initial charging parameters
218  * @num_chg_params : numbers of charging parameters
219  * @charger_event : the charger event can be reported to the platform side
220  */
224  unsigned int max_vbatt_mv;
229 };
230 
231 /*
232  * struct lp8788_bl_pwm_data
233  * @pwm_set_intensity : set duty of pwm
234  * @pwm_get_intensity : get current duty of pwm
235  */
237  void (*pwm_set_intensity) (int brightness, int max_brightness);
238  int (*pwm_get_intensity) (int max_brightness);
239 };
240 
241 /*
242  * struct lp8788_backlight_platform_data
243  * @name : backlight driver name. (default: "lcd-backlight")
244  * @initial_brightness : initial value of backlight brightness
245  * @bl_mode : brightness control by pwm or lp8788 register
246  * @dim_mode : dimming mode selection
247  * @full_scale : full scale current setting
248  * @rise_time : brightness ramp up step time
249  * @fall_time : brightness ramp down step time
250  * @pwm_pol : pwm polarity setting when bl_mode is pwm based
251  * @pwm_data : platform specific pwm generation functions
252  * only valid when bl_mode is pwm based
253  */
255  char *name;
264 };
265 
266 /*
267  * struct lp8788_led_platform_data
268  * @name : led driver name. (default: "keyboard-backlight")
269  * @scale : current scale
270  * @num : current sink number
271  * @iout_code : current output value (Addr 9Ah ~ 9Bh)
272  */
274  char *name;
278 };
279 
280 /*
281  * struct lp8788_vib_platform_data
282  * @name : vibrator driver name
283  * @scale : current scale
284  * @num : current sink number
285  * @iout_code : current output value (Addr 9Ah ~ 9Bh)
286  * @pwm_code : PWM code value (Addr 9Ch ~ 9Eh)
287  */
289  char *name;
293  int pwm_code;
294 };
295 
296 /*
297  * struct lp8788_platform_data
298  * @init_func : used for initializing registers
299  * before mfd driver is registered
300  * @buck_data : regulator initial data for buck
301  * @dldo_data : regulator initial data for digital ldo
302  * @aldo_data : regulator initial data for analog ldo
303  * @buck1_dvs : gpio configurations for buck1 dvs
304  * @buck2_dvs : gpio configurations for buck2 dvs
305  * @ldo_pin : gpio configurations for enabling LDOs
306  * @chg_pdata : platform data for charger driver
307  * @alarm_sel : rtc alarm selection (1 or 2)
308  * @bl_pdata : configurable data for backlight driver
309  * @led_pdata : configurable data for led driver
310  * @vib_pdata : configurable data for vibrator driver
311  * @adc_pdata : iio map data for adc driver
312  */
314  /* general system information */
315  int (*init_func) (struct lp8788 *lp);
316 
317  /* regulators */
324 
325  /* charger */
327 
328  /* rtc alarm */
330 
331  /* backlight */
333 
334  /* current sinks */
337 
338  /* adc iio map data */
340 };
341 
342 /*
343  * struct lp8788
344  * @dev : parent device pointer
345  * @regmap : used for i2c communcation on accessing registers
346  * @irqdm : interrupt domain for handling nested interrupt
347  * @irq : pin number of IRQ_N
348  * @pdata : lp8788 platform specific data
349  */
350 struct lp8788 {
351  struct device *dev;
352  struct regmap *regmap;
353  struct irq_domain *irqdm;
354  int irq;
356 };
357 
358 int lp8788_irq_init(struct lp8788 *lp, int chip_irq);
359 void lp8788_irq_exit(struct lp8788 *lp);
360 int lp8788_read_byte(struct lp8788 *lp, u8 reg, u8 *data);
361 int lp8788_read_multi_bytes(struct lp8788 *lp, u8 reg, u8 *data, size_t count);
362 int lp8788_write_byte(struct lp8788 *lp, u8 reg, u8 data);
363 int lp8788_update_bits(struct lp8788 *lp, u8 reg, u8 mask, u8 data);
364 #endif