1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2b5dcee22SMauro Carvalho Chehab /* 3b5dcee22SMauro Carvalho Chehab * include/media/i2c/lm3646.h 4b5dcee22SMauro Carvalho Chehab * 5b5dcee22SMauro Carvalho Chehab * Copyright (C) 2014 Texas Instruments 6b5dcee22SMauro Carvalho Chehab * 7b5dcee22SMauro Carvalho Chehab * Contact: Daniel Jeong <gshark.jeong@gmail.com> 8b5dcee22SMauro Carvalho Chehab * Ldd-Mlp <ldd-mlp@list.ti.com> 9b5dcee22SMauro Carvalho Chehab */ 10b5dcee22SMauro Carvalho Chehab 11b5dcee22SMauro Carvalho Chehab #ifndef __LM3646_H__ 12b5dcee22SMauro Carvalho Chehab #define __LM3646_H__ 13b5dcee22SMauro Carvalho Chehab 14b5dcee22SMauro Carvalho Chehab #include <media/v4l2-subdev.h> 15b5dcee22SMauro Carvalho Chehab 16b5dcee22SMauro Carvalho Chehab #define LM3646_NAME "lm3646" 17b5dcee22SMauro Carvalho Chehab #define LM3646_I2C_ADDR_REV1 (0x67) 18b5dcee22SMauro Carvalho Chehab #define LM3646_I2C_ADDR_REV0 (0x63) 19b5dcee22SMauro Carvalho Chehab 20b5dcee22SMauro Carvalho Chehab /* TOTAL FLASH Brightness Max 21b5dcee22SMauro Carvalho Chehab * min 93350uA, step 93750uA, max 1499600uA 22b5dcee22SMauro Carvalho Chehab */ 23b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_FLASH_BRT_MIN 93350 24b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_FLASH_BRT_STEP 93750 25b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_FLASH_BRT_MAX 1499600 26b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_FLASH_BRT_uA_TO_REG(a) \ 27b5dcee22SMauro Carvalho Chehab ((a) < LM3646_TOTAL_FLASH_BRT_MIN ? 0 : \ 28b5dcee22SMauro Carvalho Chehab ((((a) - LM3646_TOTAL_FLASH_BRT_MIN) / LM3646_TOTAL_FLASH_BRT_STEP))) 29b5dcee22SMauro Carvalho Chehab 30b5dcee22SMauro Carvalho Chehab /* TOTAL TORCH Brightness Max 31b5dcee22SMauro Carvalho Chehab * min 23040uA, step 23430uA, max 187100uA 32b5dcee22SMauro Carvalho Chehab */ 33b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_TORCH_BRT_MIN 23040 34b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_TORCH_BRT_STEP 23430 35b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_TORCH_BRT_MAX 187100 36b5dcee22SMauro Carvalho Chehab #define LM3646_TOTAL_TORCH_BRT_uA_TO_REG(a) \ 37b5dcee22SMauro Carvalho Chehab ((a) < LM3646_TOTAL_TORCH_BRT_MIN ? 0 : \ 38b5dcee22SMauro Carvalho Chehab ((((a) - LM3646_TOTAL_TORCH_BRT_MIN) / LM3646_TOTAL_TORCH_BRT_STEP))) 39b5dcee22SMauro Carvalho Chehab 40b5dcee22SMauro Carvalho Chehab /* LED1 FLASH Brightness 41b5dcee22SMauro Carvalho Chehab * min 23040uA, step 11718uA, max 1499600uA 42b5dcee22SMauro Carvalho Chehab */ 43b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_FLASH_BRT_MIN 23040 44b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_FLASH_BRT_STEP 11718 45b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_FLASH_BRT_MAX 1499600 46b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_FLASH_BRT_uA_TO_REG(a) \ 47b5dcee22SMauro Carvalho Chehab ((a) <= LM3646_LED1_FLASH_BRT_MIN ? 0 : \ 48b5dcee22SMauro Carvalho Chehab ((((a) - LM3646_LED1_FLASH_BRT_MIN) / LM3646_LED1_FLASH_BRT_STEP))+1) 49b5dcee22SMauro Carvalho Chehab 50b5dcee22SMauro Carvalho Chehab /* LED1 TORCH Brightness 51b5dcee22SMauro Carvalho Chehab * min 2530uA, step 1460uA, max 187100uA 52b5dcee22SMauro Carvalho Chehab */ 53b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_TORCH_BRT_MIN 2530 54b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_TORCH_BRT_STEP 1460 55b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_TORCH_BRT_MAX 187100 56b5dcee22SMauro Carvalho Chehab #define LM3646_LED1_TORCH_BRT_uA_TO_REG(a) \ 57b5dcee22SMauro Carvalho Chehab ((a) <= LM3646_LED1_TORCH_BRT_MIN ? 0 : \ 58b5dcee22SMauro Carvalho Chehab ((((a) - LM3646_LED1_TORCH_BRT_MIN) / LM3646_LED1_TORCH_BRT_STEP))+1) 59b5dcee22SMauro Carvalho Chehab 60b5dcee22SMauro Carvalho Chehab /* FLASH TIMEOUT DURATION 61b5dcee22SMauro Carvalho Chehab * min 50ms, step 50ms, max 400ms 62b5dcee22SMauro Carvalho Chehab */ 63b5dcee22SMauro Carvalho Chehab #define LM3646_FLASH_TOUT_MIN 50 64b5dcee22SMauro Carvalho Chehab #define LM3646_FLASH_TOUT_STEP 50 65b5dcee22SMauro Carvalho Chehab #define LM3646_FLASH_TOUT_MAX 400 66b5dcee22SMauro Carvalho Chehab #define LM3646_FLASH_TOUT_ms_TO_REG(a) \ 67b5dcee22SMauro Carvalho Chehab ((a) <= LM3646_FLASH_TOUT_MIN ? 0 : \ 68b5dcee22SMauro Carvalho Chehab (((a) - LM3646_FLASH_TOUT_MIN) / LM3646_FLASH_TOUT_STEP)) 69b5dcee22SMauro Carvalho Chehab 70b5dcee22SMauro Carvalho Chehab /* struct lm3646_platform_data 71b5dcee22SMauro Carvalho Chehab * 72b5dcee22SMauro Carvalho Chehab * @flash_timeout: flash timeout 73b5dcee22SMauro Carvalho Chehab * @led1_flash_brt: led1 flash mode brightness, uA 74b5dcee22SMauro Carvalho Chehab * @led1_torch_brt: led1 torch mode brightness, uA 75b5dcee22SMauro Carvalho Chehab */ 76b5dcee22SMauro Carvalho Chehab struct lm3646_platform_data { 77b5dcee22SMauro Carvalho Chehab 78b5dcee22SMauro Carvalho Chehab u32 flash_timeout; 79b5dcee22SMauro Carvalho Chehab 80b5dcee22SMauro Carvalho Chehab u32 led1_flash_brt; 81b5dcee22SMauro Carvalho Chehab u32 led1_torch_brt; 82b5dcee22SMauro Carvalho Chehab }; 83b5dcee22SMauro Carvalho Chehab 84b5dcee22SMauro Carvalho Chehab #endif /* __LM3646_H__ */ 85