18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * include/media/i2c/lm3560.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2013 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 __LM3560_H__ 128c2ecf20Sopenharmony_ci#define __LM3560_H__ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <media/v4l2-subdev.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define LM3559_NAME "lm3559" 178c2ecf20Sopenharmony_ci#define LM3560_NAME "lm3560" 188c2ecf20Sopenharmony_ci#define LM3560_I2C_ADDR (0x53) 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* FLASH Brightness 218c2ecf20Sopenharmony_ci * min 62500uA, step 62500uA, max 1000000uA 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#define LM3560_FLASH_BRT_MIN 62500 248c2ecf20Sopenharmony_ci#define LM3560_FLASH_BRT_STEP 62500 258c2ecf20Sopenharmony_ci#define LM3560_FLASH_BRT_MAX 1000000 268c2ecf20Sopenharmony_ci#define LM3560_FLASH_BRT_uA_TO_REG(a) \ 278c2ecf20Sopenharmony_ci ((a) < LM3560_FLASH_BRT_MIN ? 0 : \ 288c2ecf20Sopenharmony_ci (((a) - LM3560_FLASH_BRT_MIN) / LM3560_FLASH_BRT_STEP)) 298c2ecf20Sopenharmony_ci#define LM3560_FLASH_BRT_REG_TO_uA(a) \ 308c2ecf20Sopenharmony_ci ((a) * LM3560_FLASH_BRT_STEP + LM3560_FLASH_BRT_MIN) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* FLASH TIMEOUT DURATION 338c2ecf20Sopenharmony_ci * min 32ms, step 32ms, max 1024ms 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci#define LM3560_FLASH_TOUT_MIN 32 368c2ecf20Sopenharmony_ci#define LM3560_FLASH_TOUT_STEP 32 378c2ecf20Sopenharmony_ci#define LM3560_FLASH_TOUT_MAX 1024 388c2ecf20Sopenharmony_ci#define LM3560_FLASH_TOUT_ms_TO_REG(a) \ 398c2ecf20Sopenharmony_ci ((a) < LM3560_FLASH_TOUT_MIN ? 0 : \ 408c2ecf20Sopenharmony_ci (((a) - LM3560_FLASH_TOUT_MIN) / LM3560_FLASH_TOUT_STEP)) 418c2ecf20Sopenharmony_ci#define LM3560_FLASH_TOUT_REG_TO_ms(a) \ 428c2ecf20Sopenharmony_ci ((a) * LM3560_FLASH_TOUT_STEP + LM3560_FLASH_TOUT_MIN) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* TORCH BRT 458c2ecf20Sopenharmony_ci * min 31250uA, step 31250uA, max 250000uA 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ci#define LM3560_TORCH_BRT_MIN 31250 488c2ecf20Sopenharmony_ci#define LM3560_TORCH_BRT_STEP 31250 498c2ecf20Sopenharmony_ci#define LM3560_TORCH_BRT_MAX 250000 508c2ecf20Sopenharmony_ci#define LM3560_TORCH_BRT_uA_TO_REG(a) \ 518c2ecf20Sopenharmony_ci ((a) < LM3560_TORCH_BRT_MIN ? 0 : \ 528c2ecf20Sopenharmony_ci (((a) - LM3560_TORCH_BRT_MIN) / LM3560_TORCH_BRT_STEP)) 538c2ecf20Sopenharmony_ci#define LM3560_TORCH_BRT_REG_TO_uA(a) \ 548c2ecf20Sopenharmony_ci ((a) * LM3560_TORCH_BRT_STEP + LM3560_TORCH_BRT_MIN) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cienum lm3560_led_id { 578c2ecf20Sopenharmony_ci LM3560_LED0 = 0, 588c2ecf20Sopenharmony_ci LM3560_LED1, 598c2ecf20Sopenharmony_ci LM3560_LED_MAX 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cienum lm3560_peak_current { 638c2ecf20Sopenharmony_ci LM3560_PEAK_1600mA = 0x00, 648c2ecf20Sopenharmony_ci LM3560_PEAK_2300mA = 0x20, 658c2ecf20Sopenharmony_ci LM3560_PEAK_3000mA = 0x40, 668c2ecf20Sopenharmony_ci LM3560_PEAK_3600mA = 0x60 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* struct lm3560_platform_data 708c2ecf20Sopenharmony_ci * 718c2ecf20Sopenharmony_ci * @peak : peak current 728c2ecf20Sopenharmony_ci * @max_flash_timeout: flash timeout 738c2ecf20Sopenharmony_ci * @max_flash_brt: flash mode led brightness 748c2ecf20Sopenharmony_ci * @max_torch_brt: torch mode led brightness 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_cistruct lm3560_platform_data { 778c2ecf20Sopenharmony_ci enum lm3560_peak_current peak; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci u32 max_flash_timeout; 808c2ecf20Sopenharmony_ci u32 max_flash_brt[LM3560_LED_MAX]; 818c2ecf20Sopenharmony_ci u32 max_torch_brt[LM3560_LED_MAX]; 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#endif /* __LM3560_H__ */ 85