flintman | 22a2056 | 2014-06-07 07:37:52 -0400 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/i2c_lm8502_led.h |
| 3 | * |
| 4 | * Copyright (C) 2008 Palm Inc, |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
| 11 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 12 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * |
| 14 | * Authors: Kevin McCray (kevin.mccray@palm.com) |
| 15 | * Brian Xiong (brian.xiong@palm.com) |
| 16 | * Amon Xie(amon.xie@palm.com) |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #ifndef _LM8502_H |
| 21 | #define _LM8502_H |
| 22 | |
| 23 | #include <linux/i2c.h> |
| 24 | #include <linux/leds.h> |
| 25 | |
| 26 | #define LED_OFF 0 |
| 27 | #define LED_ON 1 |
| 28 | #define MISC_POWER_SAVE_ON (1 << 5) |
| 29 | #define MISC_POWER_SAVE_OFF (0 << 5) |
| 30 | |
| 31 | #define LM8502_I2C_DEVICE "LM8502" |
| 32 | #define LM8502_I2C_DRIVER "LM8502" |
| 33 | #define LM8502_I2C_ADDR 0x33 |
| 34 | |
| 35 | /*ioctl codes */ |
| 36 | #define LM8502_DOWNLOAD_MICROCODE 1 |
| 37 | #define LM8502_START_ENGINE 9 |
| 38 | #define LM8502_STOP_ENGINE 3 |
| 39 | #define LM8502_WAIT_FOR_INTERRUPT 4 |
| 40 | #define LM8502_CONFIGURE_MEMORY 5 |
| 41 | #define LM8502_STOP_ENGINE_AFTER_INTERRUPT 6 |
| 42 | #define LM8502_READ_PWM 7 |
| 43 | #define LM8502_WAIT_FOR_ENGINE_STOPPED 8 |
| 44 | #define LM8502_CONFIG_MAX_CURRENT 10 |
| 45 | |
| 46 | /* lm8502 LED platform data structure */ |
| 47 | enum { |
| 48 | LED_GRP_1 = 0, |
| 49 | LED_GRP_2, |
| 50 | LED_GRP_3, |
| 51 | LED_GRP_4, |
| 52 | LED_GRP_5, |
| 53 | LED_GRP_6, |
| 54 | LED_GRP_7, |
| 55 | LED_GRP_8, |
| 56 | LED_GRP_9, |
| 57 | LED_GRP_10, |
| 58 | }; |
| 59 | |
| 60 | enum { |
| 61 | LED_HW_GRP_NONE = 0, |
| 62 | LED_HW_GRP_1, |
| 63 | LED_HW_GRP_2, |
| 64 | LED_HW_GRP_3, |
| 65 | }; |
| 66 | |
| 67 | enum { |
| 68 | LED_NONE = 0, |
| 69 | LED_RED, |
| 70 | LED_GREEN, |
| 71 | LED_BLUE, |
| 72 | LED_WHITE, |
| 73 | }; |
| 74 | |
| 75 | struct lm8502_read_pwm { |
| 76 | u8 led; |
| 77 | u8 value; |
| 78 | }; |
| 79 | |
| 80 | struct led_cfg { |
| 81 | int type; |
| 82 | u8 current_addr; |
| 83 | u8 control_addr; |
| 84 | }; |
| 85 | |
| 86 | |
| 87 | struct lm8502_memory_config { |
| 88 | int eng1_startpage; |
| 89 | int eng1_endpage; |
| 90 | int eng2_startpage; |
| 91 | int eng2_endpage; |
| 92 | }; |
| 93 | |
| 94 | struct lm8502_led_config { |
| 95 | struct led_classdev cdev; |
| 96 | struct i2c_client *client; |
| 97 | struct led_cfg *led_list; |
| 98 | struct work_struct brightness_work; |
| 99 | int nleds; |
| 100 | int brightness; |
| 101 | int group_id; |
| 102 | int hw_group; |
| 103 | u8 default_max_current; |
| 104 | int default_brightness; |
| 105 | int default_state; |
| 106 | }; |
| 107 | |
| 108 | struct lm8502_platform_data { |
| 109 | int enable_gpio; |
| 110 | int interrupt_gpio; |
| 111 | int strobe_gpio; |
| 112 | u8 vib_default_duty_cycle; |
| 113 | u8 vib_default_direction; |
| 114 | u8 vib_invert_direction; |
| 115 | u16 flash_default_duration; |
| 116 | u16 flash_default_current; |
| 117 | u16 torch_default_current; |
| 118 | void (*select_flash) (struct i2c_client* client); |
| 119 | void (*select_vibrator) (struct i2c_client* client); |
| 120 | struct lm8502_led_config *leds; |
| 121 | struct lm8502_memory_config *memcfg; |
| 122 | int nleds; |
| 123 | u8 power_mode; |
| 124 | char *dev_name; |
| 125 | }; |
| 126 | |
| 127 | int lm8502_set_current(uint8_t is_flash_mode, uint32_t mA); |
| 128 | #endif // _LM8502_H |