blob: ff0b72f0857db4681efacaa92ac1b5a75ef533b2 [file] [log] [blame]
Flemmard0fd9b762013-04-26 01:11:12 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __LEDS_PM8XXX_H__
14#define __LEDS_PM8XXX_H__
15
16
17#define PM8XXX_LEDS_DEV_NAME "pm8xxx-led"
18
19#include <linux/android_alarm.h>
20#include <linux/leds.h>
21
22enum pm8xxx_blink_type {
23 BLINK_STOP = -1,
24 BLINK_UNCHANGE = 0,
25 BLINK_64MS_PER_2SEC,
26 BLINK_64MS_ON_310MS_PER_2SEC,
27 BLINK_64MS_ON_2SEC_PER_2SEC,
28 BLINK_1SEC_PER_2SEC,
29};
30
31enum pm8xxx_leds {
32 PM8XXX_ID_GPIO24 = 0,
33 PM8XXX_ID_GPIO25,
34 PM8XXX_ID_GPIO26,
35 PM8XXX_ID_LED_KB_LIGHT,
36 PM8XXX_ID_LED_2,
37 PM8XXX_ID_LED_1,
38 PM8XXX_ID_LED_0,
39 PM8XXX_ID_FLASH_LED_0,
40 PM8XXX_ID_FLASH_LED_1,
41};
42
43enum pm8xxx_led_modes {
44 PM8XXX_LED_MODE_MANUAL = 0,
45 PM8XXX_LED_MODE_PWM1,
46 PM8XXX_LED_MODE_PWM2,
47 PM8XXX_LED_MODE_PWM3,
48 PM8XXX_LED_MODE_DTEST1,
49 PM8XXX_LED_MODE_DTEST2,
50 PM8XXX_LED_MODE_DTEST3,
51 PM8XXX_LED_MODE_DTEST4
52};
53
54int pm8xxx_led_config(enum pm8xxx_leds led_id,
55 enum pm8xxx_led_modes led_mode, int max_current);
56
57#define LED_PWM_FUNCTION (1 << 0)
58#define LED_BLINK_FUNCTION (1 << 1)
59#define LED_BRETH_FUNCTION (1 << 2)
60
61struct pm8xxx_led_configure {
62 const char *name;
63 int flags;
64 int period_us;
65 int start_index;
66 int duites_size;
67 int duty_time_ms;
68 int lut_flag;
69 int led_sync;
70 int out_current;
71 int function_flags;
72 int duties[64];
73 int pwm_coefficient;
74 void (*gpio_status_switch)(bool);
75};
76
77struct pm8xxx_led_platform_data {
78 int num_leds;
79 struct pm8xxx_led_configure *leds;
80};
81
82struct pm8xxx_led_data {
83 struct led_classdev cdev;
84 struct pwm_device *pwm_led;
85 int id;
86 int bank;
87 int function_flags;
88 int period_us;
89 int duty_time_ms;
90 int start_index;
91 int duites_size;
92 int lut_flag;
93 int out_current;
94 int *duties;
95 int led_sync;
96 int pwm_coefficient;
97 u8 reg;
98 struct device *dev;
99 struct delayed_work blink_delayed_work;
100 struct delayed_work fade_delayed_work;
101 struct work_struct led_work;
102 struct alarm led_alarm;
103 void (*gpio_status_switch)(bool);
104};
105void pm8xxx_led_current_set_for_key(int brightness_key);
106
107#endif