1 /* SPDX-License-Identifier: GPL-2.0-only */ << 2 /* 1 /* 3 * include/media/i2c/adp1653.h 2 * include/media/i2c/adp1653.h 4 * 3 * 5 * Copyright (C) 2008--2011 Nokia Corporation 4 * Copyright (C) 2008--2011 Nokia Corporation 6 * 5 * 7 * Contact: Sakari Ailus <sakari.ailus@iki.fi> 6 * Contact: Sakari Ailus <sakari.ailus@iki.fi> 8 * 7 * 9 * Contributors: 8 * Contributors: 10 * Sakari Ailus <sakari.ailus@iki.fi> 9 * Sakari Ailus <sakari.ailus@iki.fi> 11 * Tuukka Toivonen <tuukkat76@gmail.com> 10 * Tuukka Toivonen <tuukkat76@gmail.com> >> 11 * >> 12 * This program is free software; you can redistribute it and/or >> 13 * modify it under the terms of the GNU General Public License >> 14 * version 2 as published by the Free Software Foundation. >> 15 * >> 16 * This program is distributed in the hope that it will be useful, but >> 17 * WITHOUT ANY WARRANTY; without even the implied warranty of >> 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> 19 * General Public License for more details. >> 20 * >> 21 * You should have received a copy of the GNU General Public License >> 22 * along with this program; if not, write to the Free Software >> 23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA >> 24 * 02110-1301 USA >> 25 * 12 */ 26 */ 13 27 14 #ifndef ADP1653_H 28 #ifndef ADP1653_H 15 #define ADP1653_H 29 #define ADP1653_H 16 30 17 #include <linux/i2c.h> 31 #include <linux/i2c.h> 18 #include <linux/mutex.h> 32 #include <linux/mutex.h> 19 #include <linux/videodev2.h> 33 #include <linux/videodev2.h> 20 #include <media/v4l2-ctrls.h> 34 #include <media/v4l2-ctrls.h> 21 #include <media/v4l2-subdev.h> 35 #include <media/v4l2-subdev.h> 22 36 23 #define ADP1653_NAME 37 #define ADP1653_NAME "adp1653" 24 #define ADP1653_I2C_ADDR 38 #define ADP1653_I2C_ADDR (0x60 >> 1) 25 39 26 /* Register definitions */ 40 /* Register definitions */ 27 #define ADP1653_REG_OUT_SEL 41 #define ADP1653_REG_OUT_SEL 0x00 28 #define ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN 42 #define ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN 0x01 29 #define ADP1653_REG_OUT_SEL_HPLED_TORCH_MAX 43 #define ADP1653_REG_OUT_SEL_HPLED_TORCH_MAX 0x0b 30 #define ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN 44 #define ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN 0x0c 31 #define ADP1653_REG_OUT_SEL_HPLED_FLASH_MAX 45 #define ADP1653_REG_OUT_SEL_HPLED_FLASH_MAX 0x1f 32 #define ADP1653_REG_OUT_SEL_HPLED_SHIFT 46 #define ADP1653_REG_OUT_SEL_HPLED_SHIFT 3 33 #define ADP1653_REG_OUT_SEL_ILED_MAX 47 #define ADP1653_REG_OUT_SEL_ILED_MAX 0x07 34 #define ADP1653_REG_OUT_SEL_ILED_SHIFT 48 #define ADP1653_REG_OUT_SEL_ILED_SHIFT 0 35 49 36 #define ADP1653_REG_CONFIG 50 #define ADP1653_REG_CONFIG 0x01 37 #define ADP1653_REG_CONFIG_TMR_CFG 51 #define ADP1653_REG_CONFIG_TMR_CFG (1 << 4) 38 #define ADP1653_REG_CONFIG_TMR_SET_MAX 52 #define ADP1653_REG_CONFIG_TMR_SET_MAX 0x0f 39 #define ADP1653_REG_CONFIG_TMR_SET_SHIFT 53 #define ADP1653_REG_CONFIG_TMR_SET_SHIFT 0 40 54 41 #define ADP1653_REG_SW_STROBE 55 #define ADP1653_REG_SW_STROBE 0x02 42 #define ADP1653_REG_SW_STROBE_SW_STROBE 56 #define ADP1653_REG_SW_STROBE_SW_STROBE (1 << 0) 43 57 44 #define ADP1653_REG_FAULT 58 #define ADP1653_REG_FAULT 0x03 45 #define ADP1653_REG_FAULT_FLT_SCP 59 #define ADP1653_REG_FAULT_FLT_SCP (1 << 3) 46 #define ADP1653_REG_FAULT_FLT_OT 60 #define ADP1653_REG_FAULT_FLT_OT (1 << 2) 47 #define ADP1653_REG_FAULT_FLT_TMR 61 #define ADP1653_REG_FAULT_FLT_TMR (1 << 1) 48 #define ADP1653_REG_FAULT_FLT_OV 62 #define ADP1653_REG_FAULT_FLT_OV (1 << 0) 49 63 50 #define ADP1653_INDICATOR_INTENSITY_MIN 64 #define ADP1653_INDICATOR_INTENSITY_MIN 0 51 #define ADP1653_INDICATOR_INTENSITY_STEP 65 #define ADP1653_INDICATOR_INTENSITY_STEP 2500 52 #define ADP1653_INDICATOR_INTENSITY_MAX 66 #define ADP1653_INDICATOR_INTENSITY_MAX \ 53 (ADP1653_REG_OUT_SEL_ILED_MAX * ADP165 67 (ADP1653_REG_OUT_SEL_ILED_MAX * ADP1653_INDICATOR_INTENSITY_STEP) 54 #define ADP1653_INDICATOR_INTENSITY_uA_TO_REG( 68 #define ADP1653_INDICATOR_INTENSITY_uA_TO_REG(a) \ 55 ((a) / ADP1653_INDICATOR_INTENSITY_STE 69 ((a) / ADP1653_INDICATOR_INTENSITY_STEP) 56 #define ADP1653_INDICATOR_INTENSITY_REG_TO_uA( 70 #define ADP1653_INDICATOR_INTENSITY_REG_TO_uA(a) \ 57 ((a) * ADP1653_INDICATOR_INTENSITY_STE 71 ((a) * ADP1653_INDICATOR_INTENSITY_STEP) 58 72 59 #define ADP1653_FLASH_INTENSITY_BASE 73 #define ADP1653_FLASH_INTENSITY_BASE 35 60 #define ADP1653_FLASH_INTENSITY_STEP 74 #define ADP1653_FLASH_INTENSITY_STEP 15 61 #define ADP1653_FLASH_INTENSITY_MIN 75 #define ADP1653_FLASH_INTENSITY_MIN \ 62 (ADP1653_FLASH_INTENSITY_BASE 76 (ADP1653_FLASH_INTENSITY_BASE \ 63 + ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN 77 + ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN * ADP1653_FLASH_INTENSITY_STEP) 64 #define ADP1653_FLASH_INTENSITY_MAX 78 #define ADP1653_FLASH_INTENSITY_MAX \ 65 (ADP1653_FLASH_INTENSITY_MIN + 79 (ADP1653_FLASH_INTENSITY_MIN + \ 66 (ADP1653_REG_OUT_SEL_HPLED_FLASH_MAX 80 (ADP1653_REG_OUT_SEL_HPLED_FLASH_MAX - \ 67 ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN 81 ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN + 1) * \ 68 ADP1653_FLASH_INTENSITY_STEP) 82 ADP1653_FLASH_INTENSITY_STEP) 69 83 70 #define ADP1653_FLASH_INTENSITY_mA_TO_REG(a) 84 #define ADP1653_FLASH_INTENSITY_mA_TO_REG(a) \ 71 ((a) < ADP1653_FLASH_INTENSITY_BASE ? 85 ((a) < ADP1653_FLASH_INTENSITY_BASE ? 0 : \ 72 (((a) - ADP1653_FLASH_INTENSITY_BASE) 86 (((a) - ADP1653_FLASH_INTENSITY_BASE) / ADP1653_FLASH_INTENSITY_STEP)) 73 #define ADP1653_FLASH_INTENSITY_REG_TO_mA(a) 87 #define ADP1653_FLASH_INTENSITY_REG_TO_mA(a) \ 74 ((a) * ADP1653_FLASH_INTENSITY_STEP + 88 ((a) * ADP1653_FLASH_INTENSITY_STEP + ADP1653_FLASH_INTENSITY_BASE) 75 89 76 #define ADP1653_TORCH_INTENSITY_MIN 90 #define ADP1653_TORCH_INTENSITY_MIN \ 77 (ADP1653_FLASH_INTENSITY_BASE 91 (ADP1653_FLASH_INTENSITY_BASE \ 78 + ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN 92 + ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN * ADP1653_FLASH_INTENSITY_STEP) 79 #define ADP1653_TORCH_INTENSITY_MAX 93 #define ADP1653_TORCH_INTENSITY_MAX \ 80 (ADP1653_TORCH_INTENSITY_MIN + 94 (ADP1653_TORCH_INTENSITY_MIN + \ 81 (ADP1653_REG_OUT_SEL_HPLED_TORCH_MAX 95 (ADP1653_REG_OUT_SEL_HPLED_TORCH_MAX - \ 82 ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN 96 ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN + 1) * \ 83 ADP1653_FLASH_INTENSITY_STEP) 97 ADP1653_FLASH_INTENSITY_STEP) 84 98 85 struct adp1653_platform_data { 99 struct adp1653_platform_data { 86 int (*power)(struct v4l2_subdev *sd, i 100 int (*power)(struct v4l2_subdev *sd, int on); 87 101 88 u32 max_flash_timeout; /* fla 102 u32 max_flash_timeout; /* flash light timeout in us */ 89 u32 max_flash_intensity; /* led 103 u32 max_flash_intensity; /* led intensity, flash mode, mA */ 90 u32 max_torch_intensity; /* led 104 u32 max_torch_intensity; /* led intensity, torch mode, mA */ 91 u32 max_indicator_intensity; /* ind 105 u32 max_indicator_intensity; /* indicator led intensity, uA */ 92 106 93 struct gpio_desc *enable_gpio; /* for 107 struct gpio_desc *enable_gpio; /* for device-tree based boot */ 94 }; 108 }; 95 109 96 #define to_adp1653_flash(sd) container_of(s 110 #define to_adp1653_flash(sd) container_of(sd, struct adp1653_flash, subdev) 97 111 98 struct adp1653_flash { 112 struct adp1653_flash { 99 struct v4l2_subdev subdev; 113 struct v4l2_subdev subdev; 100 struct adp1653_platform_data *platform 114 struct adp1653_platform_data *platform_data; 101 115 102 struct v4l2_ctrl_handler ctrls; 116 struct v4l2_ctrl_handler ctrls; 103 struct v4l2_ctrl *led_mode; 117 struct v4l2_ctrl *led_mode; 104 struct v4l2_ctrl *flash_timeout; 118 struct v4l2_ctrl *flash_timeout; 105 struct v4l2_ctrl *flash_intensity; 119 struct v4l2_ctrl *flash_intensity; 106 struct v4l2_ctrl *torch_intensity; 120 struct v4l2_ctrl *torch_intensity; 107 struct v4l2_ctrl *indicator_intensity; 121 struct v4l2_ctrl *indicator_intensity; 108 122 109 struct mutex power_lock; 123 struct mutex power_lock; 110 int power_count; 124 int power_count; 111 int fault; 125 int fault; 112 }; 126 }; 113 127 114 #endif /* ADP1653_H */ 128 #endif /* ADP1653_H */ 115 129
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.