1 /* 2 * linux/include/linux/mfd/aat2870.h 3 * 4 * Copyright (c) 2011, NVIDIA Corporation. 5 * Author: Jin Park <jinyoungp@nvidia.com> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * version 2 as published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 19 * 02110-1301 USA 20 */ 21 22 #ifndef __LINUX_MFD_AAT2870_H 23 #define __LINUX_MFD_AAT2870_H 24 25 #include <linux/debugfs.h> 26 #include <linux/i2c.h> 27 28 /* Register offsets */ 29 #define AAT2870_BL_CH_EN 0x00 30 #define AAT2870_BLM 0x01 31 #define AAT2870_BLS 0x02 32 #define AAT2870_BL1 0x03 33 #define AAT2870_BL2 0x04 34 #define AAT2870_BL3 0x05 35 #define AAT2870_BL4 0x06 36 #define AAT2870_BL5 0x07 37 #define AAT2870_BL6 0x08 38 #define AAT2870_BL7 0x09 39 #define AAT2870_BL8 0x0A 40 #define AAT2870_FLR 0x0B 41 #define AAT2870_FM 0x0C 42 #define AAT2870_FS 0x0D 43 #define AAT2870_ALS_CFG0 0x0E 44 #define AAT2870_ALS_CFG1 0x0F 45 #define AAT2870_ALS_CFG2 0x10 46 #define AAT2870_AMB 0x11 47 #define AAT2870_ALS0 0x12 48 #define AAT2870_ALS1 0x13 49 #define AAT2870_ALS2 0x14 50 #define AAT2870_ALS3 0x15 51 #define AAT2870_ALS4 0x16 52 #define AAT2870_ALS5 0x17 53 #define AAT2870_ALS6 0x18 54 #define AAT2870_ALS7 0x19 55 #define AAT2870_ALS8 0x1A 56 #define AAT2870_ALS9 0x1B 57 #define AAT2870_ALSA 0x1C 58 #define AAT2870_ALSB 0x1D 59 #define AAT2870_ALSC 0x1E 60 #define AAT2870_ALSD 0x1F 61 #define AAT2870_ALSE 0x20 62 #define AAT2870_ALSF 0x21 63 #define AAT2870_SUB_SET 0x22 64 #define AAT2870_SUB_CTRL 0x23 65 #define AAT2870_LDO_AB 0x24 66 #define AAT2870_LDO_CD 0x25 67 #define AAT2870_LDO_EN 0x26 68 #define AAT2870_REG_NUM 0x27 69 70 /* Device IDs */ 71 enum aat2870_id { 72 AAT2870_ID_BL, 73 AAT2870_ID_LDOA, 74 AAT2870_ID_LDOB, 75 AAT2870_ID_LDOC, 76 AAT2870_ID_LDOD 77 }; 78 79 /* Backlight channels */ 80 #define AAT2870_BL_CH1 0x01 81 #define AAT2870_BL_CH2 0x02 82 #define AAT2870_BL_CH3 0x04 83 #define AAT2870_BL_CH4 0x08 84 #define AAT2870_BL_CH5 0x10 85 #define AAT2870_BL_CH6 0x20 86 #define AAT2870_BL_CH7 0x40 87 #define AAT2870_BL_CH8 0x80 88 #define AAT2870_BL_CH_ALL 0xFF 89 90 /* Backlight current magnitude (mA) */ 91 enum aat2870_current { 92 AAT2870_CURRENT_0_45 = 1, 93 AAT2870_CURRENT_0_90, 94 AAT2870_CURRENT_1_80, 95 AAT2870_CURRENT_2_70, 96 AAT2870_CURRENT_3_60, 97 AAT2870_CURRENT_4_50, 98 AAT2870_CURRENT_5_40, 99 AAT2870_CURRENT_6_30, 100 AAT2870_CURRENT_7_20, 101 AAT2870_CURRENT_8_10, 102 AAT2870_CURRENT_9_00, 103 AAT2870_CURRENT_9_90, 104 AAT2870_CURRENT_10_8, 105 AAT2870_CURRENT_11_7, 106 AAT2870_CURRENT_12_6, 107 AAT2870_CURRENT_13_5, 108 AAT2870_CURRENT_14_4, 109 AAT2870_CURRENT_15_3, 110 AAT2870_CURRENT_16_2, 111 AAT2870_CURRENT_17_1, 112 AAT2870_CURRENT_18_0, 113 AAT2870_CURRENT_18_9, 114 AAT2870_CURRENT_19_8, 115 AAT2870_CURRENT_20_7, 116 AAT2870_CURRENT_21_6, 117 AAT2870_CURRENT_22_5, 118 AAT2870_CURRENT_23_4, 119 AAT2870_CURRENT_24_3, 120 AAT2870_CURRENT_25_2, 121 AAT2870_CURRENT_26_1, 122 AAT2870_CURRENT_27_0, 123 AAT2870_CURRENT_27_9 124 }; 125 126 struct aat2870_register { 127 bool readable; 128 bool writeable; 129 u8 value; 130 }; 131 132 struct aat2870_data { 133 struct device *dev; 134 struct i2c_client *client; 135 136 struct mutex io_lock; 137 struct aat2870_register *reg_cache; /* register cache */ 138 int en_pin; /* enable GPIO pin (if < 0, ignore this value) */ 139 bool is_enable; 140 141 /* init and uninit for platform specified */ 142 int (*init)(struct aat2870_data *aat2870); 143 void (*uninit)(struct aat2870_data *aat2870); 144 145 /* i2c io funcntions */ 146 int (*read)(struct aat2870_data *aat2870, u8 addr, u8 *val); 147 int (*write)(struct aat2870_data *aat2870, u8 addr, u8 val); 148 int (*update)(struct aat2870_data *aat2870, u8 addr, u8 mask, u8 val); 149 150 /* for debugfs */ 151 struct dentry *dentry_root; 152 struct dentry *dentry_reg; 153 }; 154 155 struct aat2870_subdev_info { 156 int id; 157 const char *name; 158 void *platform_data; 159 }; 160 161 struct aat2870_platform_data { 162 int en_pin; /* enable GPIO pin (if < 0, ignore this value) */ 163 164 struct aat2870_subdev_info *subdevs; 165 int num_subdevs; 166 167 /* init and uninit for platform specified */ 168 int (*init)(struct aat2870_data *aat2870); 169 void (*uninit)(struct aat2870_data *aat2870); 170 }; 171 172 struct aat2870_bl_platform_data { 173 /* backlight channels, default is AAT2870_BL_CH_ALL */ 174 int channels; 175 /* backlight current magnitude, default is AAT2870_CURRENT_27_9 */ 176 int max_current; 177 /* maximum brightness, default is 255 */ 178 int max_brightness; 179 }; 180 181 #endif /* __LINUX_MFD_AAT2870_H */ 182