blob: f9546853def273017fa905951531901e8ed0e3a5 [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;
Ethan Chenae4f0322013-09-03 12:13:46 -070071 int blink_duty_per_2sec;
Flemmard0fd9b762013-04-26 01:11:12 -070072 int function_flags;
73 int duties[64];
74 int pwm_coefficient;
75 void (*gpio_status_switch)(bool);
Ethan Chenae4f0322013-09-03 12:13:46 -070076 int (*lpm_power)(int on);
Flemmard0fd9b762013-04-26 01:11:12 -070077};
78
79struct pm8xxx_led_platform_data {
80 int num_leds;
81 struct pm8xxx_led_configure *leds;
82};
83
84struct pm8xxx_led_data {
85 struct led_classdev cdev;
86 struct pwm_device *pwm_led;
87 int id;
88 int bank;
89 int function_flags;
90 int period_us;
91 int duty_time_ms;
92 int start_index;
93 int duites_size;
94 int lut_flag;
95 int out_current;
Ethan Chenae4f0322013-09-03 12:13:46 -070096 int blink_duty_per_2sec;
Flemmard0fd9b762013-04-26 01:11:12 -070097 int *duties;
98 int led_sync;
99 int pwm_coefficient;
100 u8 reg;
101 struct device *dev;
102 struct delayed_work blink_delayed_work;
103 struct delayed_work fade_delayed_work;
104 struct work_struct led_work;
Flemmarde7777262014-01-07 00:09:06 -0800105 struct work_struct led_on_work;
106 struct work_struct led_blink_work;
Flemmard0fd9b762013-04-26 01:11:12 -0700107 struct alarm led_alarm;
108 void (*gpio_status_switch)(bool);
Ethan Chenae4f0322013-09-03 12:13:46 -0700109 int (*lpm_power)(int on);
Flemmarde7777262014-01-07 00:09:06 -0800110 int brightness;
111 int mode;
Flemmard0fd9b762013-04-26 01:11:12 -0700112};
113void pm8xxx_led_current_set_for_key(int brightness_key);
114
115#endif