1 /* 2 * LED driver for TI lp3952 controller 3 * 4 * Copyright (C) 2016, DAQRI, LLC. 5 * Author: Tony Makkiel <tony.makkiel@daqri.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 * 11 */ 12 13 #ifndef LEDS_LP3952_H_ 14 #define LEDS_LP3952_H_ 15 16 #define LP3952_NAME "lp3952" 17 #define LP3952_CMD_REG_COUNT 8 18 #define LP3952_BRIGHT_MAX 4 19 #define LP3952_LABEL_MAX_LEN 15 20 21 #define LP3952_REG_LED_CTRL 0x00 22 #define LP3952_REG_R1_BLNK_TIME_CTRL 0x01 23 #define LP3952_REG_R1_BLNK_CYCLE_CTRL 0x02 24 #define LP3952_REG_G1_BLNK_TIME_CTRL 0x03 25 #define LP3952_REG_G1_BLNK_CYCLE_CTRL 0x04 26 #define LP3952_REG_B1_BLNK_TIME_CTRL 0x05 27 #define LP3952_REG_B1_BLNK_CYCLE_CTRL 0x06 28 #define LP3952_REG_ENABLES 0x0B 29 #define LP3952_REG_PAT_GEN_CTRL 0x11 30 #define LP3952_REG_RGB1_MAX_I_CTRL 0x12 31 #define LP3952_REG_RGB2_MAX_I_CTRL 0x13 32 #define LP3952_REG_CMD_0 0x50 33 #define LP3952_REG_RESET 0x60 34 #define REG_MAX LP3952_REG_RESET 35 36 #define LP3952_PATRN_LOOP BIT(1) 37 #define LP3952_PATRN_GEN_EN BIT(2) 38 #define LP3952_INT_B00ST_LDR BIT(2) 39 #define LP3952_ACTIVE_MODE BIT(6) 40 #define LP3952_LED_MASK_ALL 0x3f 41 42 /* Transition Time in ms */ 43 enum lp3952_tt { 44 TT0, 45 TT55, 46 TT110, 47 TT221, 48 TT422, 49 TT885, 50 TT1770, 51 TT3539 52 }; 53 54 /* Command Execution Time in ms */ 55 enum lp3952_cet { 56 CET197, 57 CET393, 58 CET590, 59 CET786, 60 CET1180, 61 CET1376, 62 CET1573, 63 CET1769, 64 CET1966, 65 CET2163, 66 CET2359, 67 CET2556, 68 CET2763, 69 CET2949, 70 CET3146 71 }; 72 73 /* Max Current in % */ 74 enum lp3952_colour_I_log_0 { 75 I0, 76 I7, 77 I14, 78 I21, 79 I32, 80 I46, 81 I71, 82 I100 83 }; 84 85 enum lp3952_leds { 86 LP3952_BLUE_2, 87 LP3952_GREEN_2, 88 LP3952_RED_2, 89 LP3952_BLUE_1, 90 LP3952_GREEN_1, 91 LP3952_RED_1, 92 LP3952_LED_ALL 93 }; 94 95 struct lp3952_ctrl_hdl { 96 struct led_classdev cdev; 97 char name[LP3952_LABEL_MAX_LEN]; 98 enum lp3952_leds channel; 99 void *priv; 100 }; 101 102 struct ptrn_gen_cmd { 103 union { 104 struct { 105 u16 tt:3; 106 u16 b:3; 107 u16 cet:4; 108 u16 g:3; 109 u16 r:3; 110 }; 111 struct { 112 u8 lsb; 113 u8 msb; 114 } bytes; 115 }; 116 } __packed; 117 118 struct lp3952_led_array { 119 struct regmap *regmap; 120 struct i2c_client *client; 121 struct gpio_desc *enable_gpio; 122 struct lp3952_ctrl_hdl leds[LP3952_LED_ALL]; 123 }; 124 125 #endif /* LEDS_LP3952_H_ */ 126