blob: e91258533cbbaf2afcbb9870e0479d1812c73179 [file] [log] [blame]
Amy Malochee7d7ef32013-01-30 16:16:35 -08001/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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
Jay Chokshi8994e392011-09-14 18:20:39 -070016#include <linux/kernel.h>
Jay Chokshi868312e2011-09-16 13:57:13 -070017#include <linux/mfd/pm8xxx/pwm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018
19#define PM8XXX_LEDS_DEV_NAME "pm8xxx-led"
20
Amy Malochee7d7ef32013-01-30 16:16:35 -080021#define WLED_FIRST_STRING (1 << 2)
22#define WLED_SECOND_STRING (1 << 1)
23#define WLED_THIRD_STRING (1 << 0)
24
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025/**
26 * enum pm8xxx_leds - PMIC8XXX supported led ids
27 * @PM8XXX_ID_LED_KB_LIGHT - keyboard backlight led
28 * @PM8XXX_ID_LED_0 - First low current led
29 * @PM8XXX_ID_LED_1 - Second low current led
30 * @PM8XXX_ID_LED_2 - Third low current led
31 * @PM8XXX_ID_FLASH_LED_0 - First flash led
32 * @PM8XXX_ID_FLASH_LED_0 - Second flash led
33 */
34enum pm8xxx_leds {
35 PM8XXX_ID_LED_KB_LIGHT = 1,
36 PM8XXX_ID_LED_0,
37 PM8XXX_ID_LED_1,
38 PM8XXX_ID_LED_2,
39 PM8XXX_ID_FLASH_LED_0,
40 PM8XXX_ID_FLASH_LED_1,
Mohan Pallaka53fe1a12011-12-15 16:56:37 +053041 PM8XXX_ID_WLED,
Amy Malochec17c3732012-02-27 18:34:07 -080042 PM8XXX_ID_RGB_LED_RED,
43 PM8XXX_ID_RGB_LED_GREEN,
44 PM8XXX_ID_RGB_LED_BLUE,
Mohan Pallaka53fe1a12011-12-15 16:56:37 +053045 PM8XXX_ID_MAX,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046};
47
Jay Chokshi12e49bf2011-07-22 16:24:39 -070048/**
49 * pm8xxx_led_modes - Operating modes of LEDs
50 */
51enum pm8xxx_led_modes {
52 PM8XXX_LED_MODE_MANUAL,
53 PM8XXX_LED_MODE_PWM1,
54 PM8XXX_LED_MODE_PWM2,
55 PM8XXX_LED_MODE_PWM3,
56 PM8XXX_LED_MODE_DTEST1,
57 PM8XXX_LED_MODE_DTEST2,
58 PM8XXX_LED_MODE_DTEST3,
59 PM8XXX_LED_MODE_DTEST4
60};
61
Mohan Pallaka53fe1a12011-12-15 16:56:37 +053062/* current boost limit */
63enum wled_current_bost_limit {
64 WLED_CURR_LIMIT_105mA,
65 WLED_CURR_LIMIT_385mA,
66 WLED_CURR_LIMIT_525mA,
67 WLED_CURR_LIMIT_805mA,
68 WLED_CURR_LIMIT_980mA,
69 WLED_CURR_LIMIT_1260mA,
70 WLED_CURR_LIMIT_1400mA,
71 WLED_CURR_LIMIT_1680mA,
72};
73
74/* over voltage protection threshold */
75enum wled_ovp_threshold {
76 WLED_OVP_35V,
77 WLED_OVP_32V,
78 WLED_OVP_29V,
79 WLED_OVP_37V,
80};
81
82/**
83 * wled_config_data - wled configuration data
Amy Malochee7d7ef32013-01-30 16:16:35 -080084 * @strings - strings supported
Mohan Pallaka53fe1a12011-12-15 16:56:37 +053085 * @ovp_val - over voltage protection threshold
86 * @boost_curr_lim - boot current limit
87 * @cp_select - high pole capacitance
88 * @ctrl_delay_us - delay in activation of led
89 * @dig_mod_gen_en - digital module generator
90 * @cs_out_en - current sink output enable
91 * @op_fdbck - selection of output as feedback for the boost
Amy Malochec366d5b2012-08-28 11:06:40 -070092 * @cabc_en - enable cabc for backlight pwm control
Amy Malochee7d7ef32013-01-30 16:16:35 -080093 *
Mohan Pallaka53fe1a12011-12-15 16:56:37 +053094 */
95struct wled_config_data {
Amy Malochee7d7ef32013-01-30 16:16:35 -080096 u8 strings;
Mohan Pallaka53fe1a12011-12-15 16:56:37 +053097 u8 ovp_val;
98 u8 boost_curr_lim;
99 u8 cp_select;
100 u8 ctrl_delay_us;
101 bool dig_mod_gen_en;
102 bool cs_out_en;
103 bool op_fdbck;
Amy Malochec366d5b2012-08-28 11:06:40 -0700104 bool cabc_en;
Amy Maloche59cf8182012-11-30 12:27:40 -0800105 bool sstart_en;
106 bool max_current_ind;
107 u8 max_three;
108 u8 max_two;
109 u8 max_one;
Mohan Pallaka53fe1a12011-12-15 16:56:37 +0530110};
111
Jay Chokshi8994e392011-09-14 18:20:39 -0700112/**
113 * pm8xxx_led_config - led configuration parameters
Jay Chokshi868312e2011-09-16 13:57:13 -0700114 * @id - LED id
115 * @mode - LED mode
116 * @max_current - maximum current that LED can sustain
117 * @pwm_channel - PWM channel ID the LED is driven to
118 * @pwm_period_us - PWM period value in micro seconds
Mohan Pallaka53fe1a12011-12-15 16:56:37 +0530119 * @default_state - default state of the led
Jay Chokshi868312e2011-09-16 13:57:13 -0700120 * @pwm_duty_cycles - PWM duty cycle information
Jay Chokshi8994e392011-09-14 18:20:39 -0700121 */
122struct pm8xxx_led_config {
123 u8 id;
124 u8 mode;
125 u16 max_current;
Jay Chokshi868312e2011-09-16 13:57:13 -0700126 int pwm_channel;
127 u32 pwm_period_us;
Mohan Pallaka53fe1a12011-12-15 16:56:37 +0530128 bool default_state;
Jay Chokshi868312e2011-09-16 13:57:13 -0700129 struct pm8xxx_pwm_duty_cycles *pwm_duty_cycles;
Mohan Pallaka53fe1a12011-12-15 16:56:37 +0530130 struct wled_config_data *wled_cfg;
Jay Chokshi8994e392011-09-14 18:20:39 -0700131};
132
133/**
134 * pm8xxx_led_platform_data - platform data for LED
Jay Chokshi868312e2011-09-16 13:57:13 -0700135 * @led_core - array of LEDs. Each datum in array contains
Jay Chokshi8994e392011-09-14 18:20:39 -0700136 * core data for the LED
Jay Chokshi868312e2011-09-16 13:57:13 -0700137 * @configs - array of platform configuration parameters
Jay Chokshi8994e392011-09-14 18:20:39 -0700138 * for each LED. It maps one-to-one with
139 * array of LEDs
Jay Chokshi868312e2011-09-16 13:57:13 -0700140 * @num_configs - count of members of configs array
Jay Chokshi8994e392011-09-14 18:20:39 -0700141 */
142struct pm8xxx_led_platform_data {
143 struct led_platform_data *led_core;
144 struct pm8xxx_led_config *configs;
145 u32 num_configs;
146};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700147#endif /* __LEDS_PM8XXX_H__ */