blob: 594bc591f256e4e213af3a4ece9a8da6a1746a3b [file] [log] [blame]
Johan Hovold16c5c022012-05-03 12:26:36 +02001/*
2 * lm3533.h -- LM3533 interface
3 *
4 * Copyright (C) 2011-2012 Texas Instruments
5 *
6 * Author: Johan Hovold <jhovold@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#ifndef __LINUX_MFD_LM3533_H
15#define __LINUX_MFD_LM3533_H
16
17#define LM3533_ATTR_RO(_name) \
18 DEVICE_ATTR(_name, S_IRUGO, show_##_name, NULL)
19#define LM3533_ATTR_RW(_name) \
20 DEVICE_ATTR(_name, S_IRUGO | S_IWUSR , show_##_name, store_##_name)
21
22struct device;
23struct regmap;
24
25struct lm3533 {
26 struct device *dev;
27
28 struct regmap *regmap;
29
30 int gpio_hwen;
31 int irq;
32
33 unsigned have_als:1;
34 unsigned have_backlights:1;
35 unsigned have_leds:1;
36};
37
38struct lm3533_ctrlbank {
39 struct lm3533 *lm3533;
40 struct device *dev;
41 int id;
42};
43
44struct lm3533_als_platform_data {
45 unsigned pwm_mode:1; /* PWM input mode (default analog) */
Johan Hovold730a3d02012-05-18 20:22:45 +020046 u8 r_select; /* 1 - 127 (ignored in PWM-mode) */
Johan Hovold16c5c022012-05-03 12:26:36 +020047};
48
49struct lm3533_bl_platform_data {
50 char *name;
Johan Hovold6fa4b9d2012-05-10 19:18:29 +020051 u16 max_current; /* 5000 - 29800 uA (800 uA step) */
Johan Hovold16c5c022012-05-03 12:26:36 +020052 u8 default_brightness; /* 0 - 255 */
Johan Hovold16c5c022012-05-03 12:26:36 +020053 u8 pwm; /* 0 - 0x3f */
54};
55
56struct lm3533_led_platform_data {
57 char *name;
58 const char *default_trigger;
Johan Hovold6fa4b9d2012-05-10 19:18:29 +020059 u16 max_current; /* 5000 - 29800 uA (800 uA step) */
Johan Hovold16c5c022012-05-03 12:26:36 +020060 u8 pwm; /* 0 - 0x3f */
61};
62
Johan Hovoldd9055dc2012-05-10 14:11:28 +020063enum lm3533_boost_freq {
64 LM3533_BOOST_FREQ_500KHZ,
65 LM3533_BOOST_FREQ_1000KHZ,
66};
67
68enum lm3533_boost_ovp {
69 LM3533_BOOST_OVP_16V,
70 LM3533_BOOST_OVP_24V,
71 LM3533_BOOST_OVP_32V,
72 LM3533_BOOST_OVP_40V,
73};
74
Johan Hovold16c5c022012-05-03 12:26:36 +020075struct lm3533_platform_data {
76 int gpio_hwen;
77
Johan Hovoldd9055dc2012-05-10 14:11:28 +020078 enum lm3533_boost_ovp boost_ovp;
79 enum lm3533_boost_freq boost_freq;
80
Johan Hovold16c5c022012-05-03 12:26:36 +020081 struct lm3533_als_platform_data *als;
82
83 struct lm3533_bl_platform_data *backlights;
84 int num_backlights;
85
86 struct lm3533_led_platform_data *leds;
87 int num_leds;
88};
89
90extern int lm3533_ctrlbank_enable(struct lm3533_ctrlbank *cb);
91extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb);
92
93extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val);
94extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val);
Johan Hovold6fa4b9d2012-05-10 19:18:29 +020095extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb,
96 u16 imax);
Johan Hovold16c5c022012-05-03 12:26:36 +020097extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val);
98extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val);
99
100extern int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val);
101extern int lm3533_write(struct lm3533 *lm3533, u8 reg, u8 val);
102extern int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask);
103
104#endif /* __LINUX_MFD_LM3533_H */