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