Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * linux/include/linux/mfd/aat2870.h
0004  *
0005  * Copyright (c) 2011, NVIDIA Corporation.
0006  * Author: Jin Park <jinyoungp@nvidia.com>
0007  */
0008 
0009 #ifndef __LINUX_MFD_AAT2870_H
0010 #define __LINUX_MFD_AAT2870_H
0011 
0012 #include <linux/debugfs.h>
0013 #include <linux/i2c.h>
0014 
0015 /* Register offsets */
0016 #define AAT2870_BL_CH_EN    0x00
0017 #define AAT2870_BLM     0x01
0018 #define AAT2870_BLS     0x02
0019 #define AAT2870_BL1     0x03
0020 #define AAT2870_BL2     0x04
0021 #define AAT2870_BL3     0x05
0022 #define AAT2870_BL4     0x06
0023 #define AAT2870_BL5     0x07
0024 #define AAT2870_BL6     0x08
0025 #define AAT2870_BL7     0x09
0026 #define AAT2870_BL8     0x0A
0027 #define AAT2870_FLR     0x0B
0028 #define AAT2870_FM      0x0C
0029 #define AAT2870_FS      0x0D
0030 #define AAT2870_ALS_CFG0    0x0E
0031 #define AAT2870_ALS_CFG1    0x0F
0032 #define AAT2870_ALS_CFG2    0x10
0033 #define AAT2870_AMB     0x11
0034 #define AAT2870_ALS0        0x12
0035 #define AAT2870_ALS1        0x13
0036 #define AAT2870_ALS2        0x14
0037 #define AAT2870_ALS3        0x15
0038 #define AAT2870_ALS4        0x16
0039 #define AAT2870_ALS5        0x17
0040 #define AAT2870_ALS6        0x18
0041 #define AAT2870_ALS7        0x19
0042 #define AAT2870_ALS8        0x1A
0043 #define AAT2870_ALS9        0x1B
0044 #define AAT2870_ALSA        0x1C
0045 #define AAT2870_ALSB        0x1D
0046 #define AAT2870_ALSC        0x1E
0047 #define AAT2870_ALSD        0x1F
0048 #define AAT2870_ALSE        0x20
0049 #define AAT2870_ALSF        0x21
0050 #define AAT2870_SUB_SET     0x22
0051 #define AAT2870_SUB_CTRL    0x23
0052 #define AAT2870_LDO_AB      0x24
0053 #define AAT2870_LDO_CD      0x25
0054 #define AAT2870_LDO_EN      0x26
0055 #define AAT2870_REG_NUM     0x27
0056 
0057 /* Device IDs */
0058 enum aat2870_id {
0059     AAT2870_ID_BL,
0060     AAT2870_ID_LDOA,
0061     AAT2870_ID_LDOB,
0062     AAT2870_ID_LDOC,
0063     AAT2870_ID_LDOD
0064 };
0065 
0066 /* Backlight channels */
0067 #define AAT2870_BL_CH1      0x01
0068 #define AAT2870_BL_CH2      0x02
0069 #define AAT2870_BL_CH3      0x04
0070 #define AAT2870_BL_CH4      0x08
0071 #define AAT2870_BL_CH5      0x10
0072 #define AAT2870_BL_CH6      0x20
0073 #define AAT2870_BL_CH7      0x40
0074 #define AAT2870_BL_CH8      0x80
0075 #define AAT2870_BL_CH_ALL   0xFF
0076 
0077 /* Backlight current magnitude (mA) */
0078 enum aat2870_current {
0079     AAT2870_CURRENT_0_45 = 1,
0080     AAT2870_CURRENT_0_90,
0081     AAT2870_CURRENT_1_80,
0082     AAT2870_CURRENT_2_70,
0083     AAT2870_CURRENT_3_60,
0084     AAT2870_CURRENT_4_50,
0085     AAT2870_CURRENT_5_40,
0086     AAT2870_CURRENT_6_30,
0087     AAT2870_CURRENT_7_20,
0088     AAT2870_CURRENT_8_10,
0089     AAT2870_CURRENT_9_00,
0090     AAT2870_CURRENT_9_90,
0091     AAT2870_CURRENT_10_8,
0092     AAT2870_CURRENT_11_7,
0093     AAT2870_CURRENT_12_6,
0094     AAT2870_CURRENT_13_5,
0095     AAT2870_CURRENT_14_4,
0096     AAT2870_CURRENT_15_3,
0097     AAT2870_CURRENT_16_2,
0098     AAT2870_CURRENT_17_1,
0099     AAT2870_CURRENT_18_0,
0100     AAT2870_CURRENT_18_9,
0101     AAT2870_CURRENT_19_8,
0102     AAT2870_CURRENT_20_7,
0103     AAT2870_CURRENT_21_6,
0104     AAT2870_CURRENT_22_5,
0105     AAT2870_CURRENT_23_4,
0106     AAT2870_CURRENT_24_3,
0107     AAT2870_CURRENT_25_2,
0108     AAT2870_CURRENT_26_1,
0109     AAT2870_CURRENT_27_0,
0110     AAT2870_CURRENT_27_9
0111 };
0112 
0113 struct aat2870_register {
0114     bool readable;
0115     bool writeable;
0116     u8 value;
0117 };
0118 
0119 struct aat2870_data {
0120     struct device *dev;
0121     struct i2c_client *client;
0122 
0123     struct mutex io_lock;
0124     struct aat2870_register *reg_cache; /* register cache */
0125     int en_pin; /* enable GPIO pin (if < 0, ignore this value) */
0126     bool is_enable;
0127 
0128     /* init and uninit for platform specified */
0129     int (*init)(struct aat2870_data *aat2870);
0130     void (*uninit)(struct aat2870_data *aat2870);
0131 
0132     /* i2c io funcntions */
0133     int (*read)(struct aat2870_data *aat2870, u8 addr, u8 *val);
0134     int (*write)(struct aat2870_data *aat2870, u8 addr, u8 val);
0135     int (*update)(struct aat2870_data *aat2870, u8 addr, u8 mask, u8 val);
0136 
0137     /* for debugfs */
0138     struct dentry *dentry_root;
0139 };
0140 
0141 struct aat2870_subdev_info {
0142     int id;
0143     const char *name;
0144     void *platform_data;
0145 };
0146 
0147 struct aat2870_platform_data {
0148     int en_pin; /* enable GPIO pin (if < 0, ignore this value) */
0149 
0150     struct aat2870_subdev_info *subdevs;
0151     int num_subdevs;
0152 
0153     /* init and uninit for platform specified */
0154     int (*init)(struct aat2870_data *aat2870);
0155     void (*uninit)(struct aat2870_data *aat2870);
0156 };
0157 
0158 struct aat2870_bl_platform_data {
0159     /* backlight channels, default is AAT2870_BL_CH_ALL */
0160     int channels;
0161     /* backlight current magnitude, default is AAT2870_CURRENT_27_9 */
0162     int max_current;
0163     /* maximum brightness, default is 255 */
0164     int max_brightness;
0165 };
0166 
0167 #endif /* __LINUX_MFD_AAT2870_H */