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