18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * include/media/i2c/lm3646.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2014 Texas Instruments
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Contact: Daniel Jeong <gshark.jeong@gmail.com>
88c2ecf20Sopenharmony_ci *			Ldd-Mlp <ldd-mlp@list.ti.com>
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef __LM3646_H__
128c2ecf20Sopenharmony_ci#define __LM3646_H__
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <media/v4l2-subdev.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define LM3646_NAME	"lm3646"
178c2ecf20Sopenharmony_ci#define LM3646_I2C_ADDR_REV1	(0x67)
188c2ecf20Sopenharmony_ci#define LM3646_I2C_ADDR_REV0	(0x63)
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/*  TOTAL FLASH Brightness Max
218c2ecf20Sopenharmony_ci *	min 93350uA, step 93750uA, max 1499600uA
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#define LM3646_TOTAL_FLASH_BRT_MIN 93350
248c2ecf20Sopenharmony_ci#define LM3646_TOTAL_FLASH_BRT_STEP 93750
258c2ecf20Sopenharmony_ci#define LM3646_TOTAL_FLASH_BRT_MAX 1499600
268c2ecf20Sopenharmony_ci#define LM3646_TOTAL_FLASH_BRT_uA_TO_REG(a)	\
278c2ecf20Sopenharmony_ci	((a) < LM3646_TOTAL_FLASH_BRT_MIN ? 0 :	\
288c2ecf20Sopenharmony_ci	 ((((a) - LM3646_TOTAL_FLASH_BRT_MIN) / LM3646_TOTAL_FLASH_BRT_STEP)))
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/*  TOTAL TORCH Brightness Max
318c2ecf20Sopenharmony_ci *	min 23040uA, step 23430uA, max 187100uA
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci#define LM3646_TOTAL_TORCH_BRT_MIN 23040
348c2ecf20Sopenharmony_ci#define LM3646_TOTAL_TORCH_BRT_STEP 23430
358c2ecf20Sopenharmony_ci#define LM3646_TOTAL_TORCH_BRT_MAX 187100
368c2ecf20Sopenharmony_ci#define LM3646_TOTAL_TORCH_BRT_uA_TO_REG(a)	\
378c2ecf20Sopenharmony_ci	((a) < LM3646_TOTAL_TORCH_BRT_MIN ? 0 :	\
388c2ecf20Sopenharmony_ci	 ((((a) - LM3646_TOTAL_TORCH_BRT_MIN) / LM3646_TOTAL_TORCH_BRT_STEP)))
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/*  LED1 FLASH Brightness
418c2ecf20Sopenharmony_ci *	min 23040uA, step 11718uA, max 1499600uA
428c2ecf20Sopenharmony_ci */
438c2ecf20Sopenharmony_ci#define LM3646_LED1_FLASH_BRT_MIN 23040
448c2ecf20Sopenharmony_ci#define LM3646_LED1_FLASH_BRT_STEP 11718
458c2ecf20Sopenharmony_ci#define LM3646_LED1_FLASH_BRT_MAX 1499600
468c2ecf20Sopenharmony_ci#define LM3646_LED1_FLASH_BRT_uA_TO_REG(a)	\
478c2ecf20Sopenharmony_ci	((a) <= LM3646_LED1_FLASH_BRT_MIN ? 0 :	\
488c2ecf20Sopenharmony_ci	 ((((a) - LM3646_LED1_FLASH_BRT_MIN) / LM3646_LED1_FLASH_BRT_STEP))+1)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/*  LED1 TORCH Brightness
518c2ecf20Sopenharmony_ci *	min 2530uA, step 1460uA, max 187100uA
528c2ecf20Sopenharmony_ci */
538c2ecf20Sopenharmony_ci#define LM3646_LED1_TORCH_BRT_MIN 2530
548c2ecf20Sopenharmony_ci#define LM3646_LED1_TORCH_BRT_STEP 1460
558c2ecf20Sopenharmony_ci#define LM3646_LED1_TORCH_BRT_MAX 187100
568c2ecf20Sopenharmony_ci#define LM3646_LED1_TORCH_BRT_uA_TO_REG(a)	\
578c2ecf20Sopenharmony_ci	((a) <= LM3646_LED1_TORCH_BRT_MIN ? 0 :	\
588c2ecf20Sopenharmony_ci	 ((((a) - LM3646_LED1_TORCH_BRT_MIN) / LM3646_LED1_TORCH_BRT_STEP))+1)
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/*  FLASH TIMEOUT DURATION
618c2ecf20Sopenharmony_ci *	min 50ms, step 50ms, max 400ms
628c2ecf20Sopenharmony_ci */
638c2ecf20Sopenharmony_ci#define LM3646_FLASH_TOUT_MIN 50
648c2ecf20Sopenharmony_ci#define LM3646_FLASH_TOUT_STEP 50
658c2ecf20Sopenharmony_ci#define LM3646_FLASH_TOUT_MAX 400
668c2ecf20Sopenharmony_ci#define LM3646_FLASH_TOUT_ms_TO_REG(a)	\
678c2ecf20Sopenharmony_ci	((a) <= LM3646_FLASH_TOUT_MIN ? 0 :	\
688c2ecf20Sopenharmony_ci	 (((a) - LM3646_FLASH_TOUT_MIN) / LM3646_FLASH_TOUT_STEP))
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/* struct lm3646_platform_data
718c2ecf20Sopenharmony_ci *
728c2ecf20Sopenharmony_ci * @flash_timeout: flash timeout
738c2ecf20Sopenharmony_ci * @led1_flash_brt: led1 flash mode brightness, uA
748c2ecf20Sopenharmony_ci * @led1_torch_brt: led1 torch mode brightness, uA
758c2ecf20Sopenharmony_ci */
768c2ecf20Sopenharmony_cistruct lm3646_platform_data {
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	u32 flash_timeout;
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	u32 led1_flash_brt;
818c2ecf20Sopenharmony_ci	u32 led1_torch_brt;
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#endif /* __LM3646_H__ */
85