Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 1 | /* Copyright (c) 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 __PM8XXX_PWM_H__ |
| 14 | #define __PM8XXX_PWM_H__ |
| 15 | |
| 16 | #include <linux/pwm.h> |
| 17 | |
| 18 | #define PM8XXX_PWM_DEV_NAME "pm8xxx-pwm" |
| 19 | |
| 20 | #define PM8XXX_PWM_PERIOD_MAX (327 * USEC_PER_SEC) |
| 21 | #define PM8XXX_PWM_PERIOD_MIN 7 /* micro seconds */ |
| 22 | |
| 23 | #define PM_PWM_LUT_SIZE 64 |
| 24 | #define PM_PWM_LUT_DUTY_TIME_MAX 512 /* ms */ |
| 25 | #define PM_PWM_LUT_PAUSE_MAX (7000 * PM_PWM_LUT_DUTY_TIME_MAX) |
| 26 | |
| 27 | /* Flags for Look Up Table */ |
| 28 | #define PM_PWM_LUT_LOOP 0x01 |
| 29 | #define PM_PWM_LUT_RAMP_UP 0x02 |
| 30 | #define PM_PWM_LUT_REVERSE 0x04 |
| 31 | #define PM_PWM_LUT_PAUSE_HI_EN 0x10 |
| 32 | #define PM_PWM_LUT_PAUSE_LO_EN 0x20 |
| 33 | |
| 34 | #define PM_PWM_LUT_NO_TABLE 0x100 |
| 35 | |
| 36 | /** |
| 37 | * pm8xxx_pwm_lut_config - change a PWM device configuration to use LUT |
| 38 | * @pwm: the PWM device |
| 39 | * @period_us: period in micro second |
| 40 | * @duty_pct: arrary of duty cycles in percent, like 20, 50. |
| 41 | * @duty_time_ms: time for each duty cycle in millisecond |
| 42 | * @start_idx: start index in lookup table from 0 to MAX-1 |
| 43 | * @idx_len: number of index |
| 44 | * @pause_lo: pause time in millisecond at low index |
| 45 | * @pause_hi: pause time in millisecond at high index |
| 46 | * @flags: control flags |
| 47 | */ |
| 48 | int pm8xxx_pwm_lut_config(struct pwm_device *pwm, int period_us, |
| 49 | int duty_pct[], int duty_time_ms, int start_idx, |
| 50 | int len, int pause_lo, int pause_hi, int flags); |
| 51 | |
| 52 | /** |
| 53 | * pm8xxx_pwm_lut_enable - control a PWM device to start/stop LUT ramp |
| 54 | * @pwm: the PWM device |
| 55 | * @start: to start (1), or stop (0) |
| 56 | */ |
| 57 | int pm8xxx_pwm_lut_enable(struct pwm_device *pwm, int start); |
| 58 | |
| 59 | /* Standard APIs supported */ |
| 60 | /** |
| 61 | * pwm_request - request a PWM device |
| 62 | * @pwm_id: PWM id or channel |
| 63 | * @label: the label to identify the user |
| 64 | */ |
| 65 | |
| 66 | /** |
| 67 | * pwm_free - free a PWM device |
| 68 | * @pwm: the PWM device |
| 69 | */ |
| 70 | |
| 71 | /** |
| 72 | * pwm_config - change a PWM device configuration |
| 73 | * @pwm: the PWM device |
| 74 | * @period_us: period in microsecond |
| 75 | * @duty_us: duty cycle in microsecond |
| 76 | */ |
| 77 | |
| 78 | /** |
| 79 | * pwm_enable - start a PWM output toggling |
| 80 | * @pwm: the PWM device |
| 81 | */ |
| 82 | |
| 83 | /** |
| 84 | * pwm_disable - stop a PWM output toggling |
| 85 | * @pwm: the PWM device |
| 86 | */ |
| 87 | |
| 88 | #endif /* __PM8XXX_PWM_H__ */ |