blob: 2523f99d41d6ea0364e2059db4667499013dfb3f [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010, 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 __PMIC8058_PWM_H__
14#define __PMIC8058_PWM_H__
15
16/* The MAX value is computation limit. Hardware limit is 393 seconds. */
17#define PM_PWM_PERIOD_MAX (274 * USEC_PER_SEC)
18/* The MIN value is hardware limit. */
19#define PM_PWM_PERIOD_MIN 7 /* micro seconds */
20
21struct pm8058_pwm_pdata {
22 int (*config)(struct pwm_device *pwm, int ch, int on);
23 int (*enable)(struct pwm_device *pwm, int ch, int on);
24};
25
26#define PM_PWM_LUT_SIZE 64
27#define PM_PWM_LUT_DUTY_TIME_MAX 512 /* ms */
28#define PM_PWM_LUT_PAUSE_MAX (7000 * PM_PWM_LUT_DUTY_TIME_MAX)
29
30/* Flags for Look Up Table */
31#define PM_PWM_LUT_LOOP 0x01
32#define PM_PWM_LUT_RAMP_UP 0x02
33#define PM_PWM_LUT_REVERSE 0x04
34#define PM_PWM_LUT_PAUSE_HI_EN 0x10
35#define PM_PWM_LUT_PAUSE_LO_EN 0x20
36
37#define PM_PWM_LUT_NO_TABLE 0x100
38
39/* PWM LED ID */
40#define PM_PWM_LED_0 0
41#define PM_PWM_LED_1 1
42#define PM_PWM_LED_2 2
43#define PM_PWM_LED_KPD 3
44#define PM_PWM_LED_FLASH 4
45#define PM_PWM_LED_FLASH1 5
46
47/* PWM LED configuration mode */
48#define PM_PWM_CONF_NONE 0x0
49#define PM_PWM_CONF_PWM1 0x1
50#define PM_PWM_CONF_PWM2 0x2
51#define PM_PWM_CONF_PWM3 0x3
52#define PM_PWM_CONF_DTEST1 0x4
53#define PM_PWM_CONF_DTEST2 0x5
54#define PM_PWM_CONF_DTEST3 0x6
55#define PM_PWM_CONF_DTEST4 0x7
56
57/*
58 * pm8058_pwm_lut_config - change a PWM device configuration to use LUT
59 *
60 * @pwm: the PWM device
61 * @period_us: period in micro second
62 * @duty_pct: arrary of duty cycles in percent, like 20, 50.
63 * @duty_time_ms: time for each duty cycle in millisecond
64 * @start_idx: start index in lookup table from 0 to MAX-1
65 * @idx_len: number of index
66 * @pause_lo: pause time in millisecond at low index
67 * @pause_hi: pause time in millisecond at high index
68 * @flags: control flags
69 *
70 */
71int pm8058_pwm_lut_config(struct pwm_device *pwm, int period_us,
72 int duty_pct[], int duty_time_ms, int start_idx,
73 int len, int pause_lo, int pause_hi, int flags);
74
75/*
76 * pm8058_pwm_lut_enable - control a PWM device to start/stop LUT ramp
77 *
78 * @pwm: the PWM device
79 * @start: to start (1), or stop (0)
80 */
81int pm8058_pwm_lut_enable(struct pwm_device *pwm, int start);
82
83int pm8058_pwm_set_dtest(struct pwm_device *pwm, int enable);
84
85int pm8058_pwm_config_led(struct pwm_device *pwm, int id,
86 int mode, int max_current);
87
88#endif /* __PMIC8058_PWM_H__ */