1*1802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2b5dcee22SMauro Carvalho Chehab /* 3b5dcee22SMauro Carvalho Chehab * include/media/i2c/lm3560.h 4b5dcee22SMauro Carvalho Chehab * 5b5dcee22SMauro Carvalho Chehab * Copyright (C) 2013 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 __LM3560_H__ 12b5dcee22SMauro Carvalho Chehab #define __LM3560_H__ 13b5dcee22SMauro Carvalho Chehab 14b5dcee22SMauro Carvalho Chehab #include <media/v4l2-subdev.h> 15b5dcee22SMauro Carvalho Chehab 16653d500cSPavel Machek #define LM3559_NAME "lm3559" 17b5dcee22SMauro Carvalho Chehab #define LM3560_NAME "lm3560" 18b5dcee22SMauro Carvalho Chehab #define LM3560_I2C_ADDR (0x53) 19b5dcee22SMauro Carvalho Chehab 20b5dcee22SMauro Carvalho Chehab /* FLASH Brightness 21b5dcee22SMauro Carvalho Chehab * min 62500uA, step 62500uA, max 1000000uA 22b5dcee22SMauro Carvalho Chehab */ 23b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_BRT_MIN 62500 24b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_BRT_STEP 62500 25b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_BRT_MAX 1000000 26b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_BRT_uA_TO_REG(a) \ 27b5dcee22SMauro Carvalho Chehab ((a) < LM3560_FLASH_BRT_MIN ? 0 : \ 28b5dcee22SMauro Carvalho Chehab (((a) - LM3560_FLASH_BRT_MIN) / LM3560_FLASH_BRT_STEP)) 29b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_BRT_REG_TO_uA(a) \ 30b5dcee22SMauro Carvalho Chehab ((a) * LM3560_FLASH_BRT_STEP + LM3560_FLASH_BRT_MIN) 31b5dcee22SMauro Carvalho Chehab 32b5dcee22SMauro Carvalho Chehab /* FLASH TIMEOUT DURATION 33b5dcee22SMauro Carvalho Chehab * min 32ms, step 32ms, max 1024ms 34b5dcee22SMauro Carvalho Chehab */ 35b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_TOUT_MIN 32 36b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_TOUT_STEP 32 37b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_TOUT_MAX 1024 38b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_TOUT_ms_TO_REG(a) \ 39b5dcee22SMauro Carvalho Chehab ((a) < LM3560_FLASH_TOUT_MIN ? 0 : \ 40b5dcee22SMauro Carvalho Chehab (((a) - LM3560_FLASH_TOUT_MIN) / LM3560_FLASH_TOUT_STEP)) 41b5dcee22SMauro Carvalho Chehab #define LM3560_FLASH_TOUT_REG_TO_ms(a) \ 42b5dcee22SMauro Carvalho Chehab ((a) * LM3560_FLASH_TOUT_STEP + LM3560_FLASH_TOUT_MIN) 43b5dcee22SMauro Carvalho Chehab 44b5dcee22SMauro Carvalho Chehab /* TORCH BRT 45b5dcee22SMauro Carvalho Chehab * min 31250uA, step 31250uA, max 250000uA 46b5dcee22SMauro Carvalho Chehab */ 47b5dcee22SMauro Carvalho Chehab #define LM3560_TORCH_BRT_MIN 31250 48b5dcee22SMauro Carvalho Chehab #define LM3560_TORCH_BRT_STEP 31250 49b5dcee22SMauro Carvalho Chehab #define LM3560_TORCH_BRT_MAX 250000 50b5dcee22SMauro Carvalho Chehab #define LM3560_TORCH_BRT_uA_TO_REG(a) \ 51b5dcee22SMauro Carvalho Chehab ((a) < LM3560_TORCH_BRT_MIN ? 0 : \ 52b5dcee22SMauro Carvalho Chehab (((a) - LM3560_TORCH_BRT_MIN) / LM3560_TORCH_BRT_STEP)) 53b5dcee22SMauro Carvalho Chehab #define LM3560_TORCH_BRT_REG_TO_uA(a) \ 54b5dcee22SMauro Carvalho Chehab ((a) * LM3560_TORCH_BRT_STEP + LM3560_TORCH_BRT_MIN) 55b5dcee22SMauro Carvalho Chehab 56b5dcee22SMauro Carvalho Chehab enum lm3560_led_id { 57b5dcee22SMauro Carvalho Chehab LM3560_LED0 = 0, 58b5dcee22SMauro Carvalho Chehab LM3560_LED1, 59b5dcee22SMauro Carvalho Chehab LM3560_LED_MAX 60b5dcee22SMauro Carvalho Chehab }; 61b5dcee22SMauro Carvalho Chehab 62b5dcee22SMauro Carvalho Chehab enum lm3560_peak_current { 63b5dcee22SMauro Carvalho Chehab LM3560_PEAK_1600mA = 0x00, 64b5dcee22SMauro Carvalho Chehab LM3560_PEAK_2300mA = 0x20, 65b5dcee22SMauro Carvalho Chehab LM3560_PEAK_3000mA = 0x40, 66b5dcee22SMauro Carvalho Chehab LM3560_PEAK_3600mA = 0x60 67b5dcee22SMauro Carvalho Chehab }; 68b5dcee22SMauro Carvalho Chehab 69b5dcee22SMauro Carvalho Chehab /* struct lm3560_platform_data 70b5dcee22SMauro Carvalho Chehab * 71b5dcee22SMauro Carvalho Chehab * @peak : peak current 72b5dcee22SMauro Carvalho Chehab * @max_flash_timeout: flash timeout 73b5dcee22SMauro Carvalho Chehab * @max_flash_brt: flash mode led brightness 74b5dcee22SMauro Carvalho Chehab * @max_torch_brt: torch mode led brightness 75b5dcee22SMauro Carvalho Chehab */ 76b5dcee22SMauro Carvalho Chehab struct lm3560_platform_data { 77b5dcee22SMauro Carvalho Chehab enum lm3560_peak_current peak; 78b5dcee22SMauro Carvalho Chehab 79b5dcee22SMauro Carvalho Chehab u32 max_flash_timeout; 80b5dcee22SMauro Carvalho Chehab u32 max_flash_brt[LM3560_LED_MAX]; 81b5dcee22SMauro Carvalho Chehab u32 max_torch_brt[LM3560_LED_MAX]; 82b5dcee22SMauro Carvalho Chehab }; 83b5dcee22SMauro Carvalho Chehab 84b5dcee22SMauro Carvalho Chehab #endif /* __LM3560_H__ */ 85