0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __LINUX_MFD_ADP5520_H
0011 #define __LINUX_MFD_ADP5520_H
0012
0013 #define ID_ADP5520 5520
0014 #define ID_ADP5501 5501
0015
0016
0017
0018
0019
0020 #define ADP5520_MODE_STATUS 0x00
0021 #define ADP5520_INTERRUPT_ENABLE 0x01
0022 #define ADP5520_BL_CONTROL 0x02
0023 #define ADP5520_BL_TIME 0x03
0024 #define ADP5520_BL_FADE 0x04
0025 #define ADP5520_DAYLIGHT_MAX 0x05
0026 #define ADP5520_DAYLIGHT_DIM 0x06
0027 #define ADP5520_OFFICE_MAX 0x07
0028 #define ADP5520_OFFICE_DIM 0x08
0029 #define ADP5520_DARK_MAX 0x09
0030 #define ADP5520_DARK_DIM 0x0A
0031 #define ADP5520_BL_VALUE 0x0B
0032 #define ADP5520_ALS_CMPR_CFG 0x0C
0033 #define ADP5520_L2_TRIP 0x0D
0034 #define ADP5520_L2_HYS 0x0E
0035 #define ADP5520_L3_TRIP 0x0F
0036 #define ADP5520_L3_HYS 0x10
0037 #define ADP5520_LED_CONTROL 0x11
0038 #define ADP5520_LED_TIME 0x12
0039 #define ADP5520_LED_FADE 0x13
0040 #define ADP5520_LED1_CURRENT 0x14
0041 #define ADP5520_LED2_CURRENT 0x15
0042 #define ADP5520_LED3_CURRENT 0x16
0043
0044
0045
0046
0047
0048 #define ADP5520_GPIO_CFG_1 0x17
0049 #define ADP5520_GPIO_CFG_2 0x18
0050 #define ADP5520_GPIO_IN 0x19
0051 #define ADP5520_GPIO_OUT 0x1A
0052 #define ADP5520_GPIO_INT_EN 0x1B
0053 #define ADP5520_GPIO_INT_STAT 0x1C
0054 #define ADP5520_GPIO_INT_LVL 0x1D
0055 #define ADP5520_GPIO_DEBOUNCE 0x1E
0056 #define ADP5520_GPIO_PULLUP 0x1F
0057 #define ADP5520_KP_INT_STAT_1 0x20
0058 #define ADP5520_KP_INT_STAT_2 0x21
0059 #define ADP5520_KR_INT_STAT_1 0x22
0060 #define ADP5520_KR_INT_STAT_2 0x23
0061 #define ADP5520_KEY_STAT_1 0x24
0062 #define ADP5520_KEY_STAT_2 0x25
0063
0064
0065
0066
0067
0068 #define ADP5520_nSTNBY (1 << 7)
0069 #define ADP5520_BL_EN (1 << 6)
0070 #define ADP5520_DIM_EN (1 << 5)
0071 #define ADP5520_OVP_INT (1 << 4)
0072 #define ADP5520_CMPR_INT (1 << 3)
0073 #define ADP5520_GPI_INT (1 << 2)
0074 #define ADP5520_KR_INT (1 << 1)
0075 #define ADP5520_KP_INT (1 << 0)
0076
0077
0078
0079
0080
0081 #define ADP5520_AUTO_LD_EN (1 << 4)
0082 #define ADP5520_CMPR_IEN (1 << 3)
0083 #define ADP5520_OVP_IEN (1 << 2)
0084 #define ADP5520_KR_IEN (1 << 1)
0085 #define ADP5520_KP_IEN (1 << 0)
0086
0087
0088
0089
0090
0091 #define ADP5520_BL_LVL ((x) << 5)
0092 #define ADP5520_BL_LAW ((x) << 4)
0093 #define ADP5520_BL_AUTO_ADJ (1 << 3)
0094 #define ADP5520_OVP_EN (1 << 2)
0095 #define ADP5520_FOVR (1 << 1)
0096 #define ADP5520_KP_BL_EN (1 << 0)
0097
0098
0099
0100
0101
0102 #define ADP5520_L3_OUT (1 << 3)
0103 #define ADP5520_L2_OUT (1 << 2)
0104 #define ADP5520_L3_EN (1 << 1)
0105
0106 #define ADP5020_MAX_BRIGHTNESS 0x7F
0107
0108 #define FADE_VAL(in, out) ((0xF & (in)) | ((0xF & (out)) << 4))
0109 #define BL_CTRL_VAL(law, auto) (((1 & (auto)) << 3) | ((0x3 & (law)) << 4))
0110 #define ALS_CMPR_CFG_VAL(filt, l3_en) (((0x7 & filt) << 5) | l3_en)
0111
0112
0113
0114
0115
0116 #define ADP5520_01_MAXLEDS 3
0117
0118 #define ADP5520_FLAG_LED_MASK 0x3
0119 #define ADP5520_FLAG_OFFT_SHIFT 8
0120 #define ADP5520_FLAG_OFFT_MASK 0x3
0121
0122 #define ADP5520_R3_MODE (1 << 5)
0123 #define ADP5520_C3_MODE (1 << 4)
0124 #define ADP5520_LED_LAW (1 << 3)
0125 #define ADP5520_LED3_EN (1 << 2)
0126 #define ADP5520_LED2_EN (1 << 1)
0127 #define ADP5520_LED1_EN (1 << 0)
0128
0129
0130
0131
0132
0133 #define ADP5520_MAXGPIOS 8
0134
0135 #define ADP5520_GPIO_C3 (1 << 7)
0136 #define ADP5520_GPIO_C2 (1 << 6)
0137 #define ADP5520_GPIO_C1 (1 << 5)
0138 #define ADP5520_GPIO_C0 (1 << 4)
0139 #define ADP5520_GPIO_R3 (1 << 3)
0140 #define ADP5520_GPIO_R2 (1 << 2)
0141 #define ADP5520_GPIO_R1 (1 << 1)
0142 #define ADP5520_GPIO_R0 (1 << 0)
0143
0144 struct adp5520_gpio_platform_data {
0145 unsigned gpio_start;
0146 u8 gpio_en_mask;
0147 u8 gpio_pullup_mask;
0148 };
0149
0150
0151
0152
0153
0154 #define ADP5520_MAXKEYS 16
0155
0156 #define ADP5520_COL_C3 (1 << 7)
0157 #define ADP5520_COL_C2 (1 << 6)
0158 #define ADP5520_COL_C1 (1 << 5)
0159 #define ADP5520_COL_C0 (1 << 4)
0160 #define ADP5520_ROW_R3 (1 << 3)
0161 #define ADP5520_ROW_R2 (1 << 2)
0162 #define ADP5520_ROW_R1 (1 << 1)
0163 #define ADP5520_ROW_R0 (1 << 0)
0164
0165 #define ADP5520_KEY(row, col) (col + row * 4)
0166 #define ADP5520_KEYMAPSIZE ADP5520_MAXKEYS
0167
0168 struct adp5520_keys_platform_data {
0169 int rows_en_mask;
0170 int cols_en_mask;
0171 const unsigned short *keymap;
0172 unsigned short keymapsize;
0173 unsigned repeat:1;
0174 };
0175
0176
0177
0178
0179
0180
0181 #define FLAG_ID_ADP5520_LED1_ADP5501_LED0 1
0182 #define FLAG_ID_ADP5520_LED2_ADP5501_LED1 2
0183 #define FLAG_ID_ADP5520_LED3_ADP5501_LED2 3
0184
0185 #define ADP5520_LED_DIS_BLINK (0 << ADP5520_FLAG_OFFT_SHIFT)
0186 #define ADP5520_LED_OFFT_600ms (1 << ADP5520_FLAG_OFFT_SHIFT)
0187 #define ADP5520_LED_OFFT_800ms (2 << ADP5520_FLAG_OFFT_SHIFT)
0188 #define ADP5520_LED_OFFT_1200ms (3 << ADP5520_FLAG_OFFT_SHIFT)
0189
0190 #define ADP5520_LED_ONT_200ms 0
0191 #define ADP5520_LED_ONT_600ms 1
0192 #define ADP5520_LED_ONT_800ms 2
0193 #define ADP5520_LED_ONT_1200ms 3
0194
0195 struct adp5520_leds_platform_data {
0196 int num_leds;
0197 struct led_info *leds;
0198 u8 fade_in;
0199 u8 fade_out;
0200 u8 led_on_time;
0201 };
0202
0203
0204
0205
0206
0207 #define ADP5520_FADE_T_DIS 0
0208 #define ADP5520_FADE_T_300ms 1
0209 #define ADP5520_FADE_T_600ms 2
0210 #define ADP5520_FADE_T_900ms 3
0211 #define ADP5520_FADE_T_1200ms 4
0212 #define ADP5520_FADE_T_1500ms 5
0213 #define ADP5520_FADE_T_1800ms 6
0214 #define ADP5520_FADE_T_2100ms 7
0215 #define ADP5520_FADE_T_2400ms 8
0216 #define ADP5520_FADE_T_2700ms 9
0217 #define ADP5520_FADE_T_3000ms 10
0218 #define ADP5520_FADE_T_3500ms 11
0219 #define ADP5520_FADE_T_4000ms 12
0220 #define ADP5520_FADE_T_4500ms 13
0221 #define ADP5520_FADE_T_5000ms 14
0222 #define ADP5520_FADE_T_5500ms 15
0223
0224 #define ADP5520_BL_LAW_LINEAR 0
0225 #define ADP5520_BL_LAW_SQUARE 1
0226 #define ADP5520_BL_LAW_CUBIC1 2
0227 #define ADP5520_BL_LAW_CUBIC2 3
0228
0229 #define ADP5520_BL_AMBL_FILT_80ms 0
0230 #define ADP5520_BL_AMBL_FILT_160ms 1
0231 #define ADP5520_BL_AMBL_FILT_320ms 2
0232 #define ADP5520_BL_AMBL_FILT_640ms 3
0233 #define ADP5520_BL_AMBL_FILT_1280ms 4
0234 #define ADP5520_BL_AMBL_FILT_2560ms 5
0235 #define ADP5520_BL_AMBL_FILT_5120ms 6
0236 #define ADP5520_BL_AMBL_FILT_10240ms 7
0237
0238
0239
0240
0241 #define ADP5520_BL_CUR_mA(I) ((I * 127) / 30)
0242
0243
0244
0245
0246 #define ADP5520_L2_COMP_CURR_uA(I) ((I * 255) / 1000)
0247
0248
0249
0250
0251 #define ADP5520_L3_COMP_CURR_uA(I) ((I * 255) / 127)
0252
0253 struct adp5520_backlight_platform_data {
0254 u8 fade_in;
0255 u8 fade_out;
0256 u8 fade_led_law;
0257
0258 u8 en_ambl_sens;
0259 u8 abml_filt;
0260 u8 l1_daylight_max;
0261 u8 l1_daylight_dim;
0262 u8 l2_office_max;
0263 u8 l2_office_dim;
0264 u8 l3_dark_max;
0265 u8 l3_dark_dim;
0266 u8 l2_trip;
0267 u8 l2_hyst;
0268 u8 l3_trip;
0269 u8 l3_hyst;
0270 };
0271
0272
0273
0274
0275
0276 struct adp5520_platform_data {
0277 struct adp5520_keys_platform_data *keys;
0278 struct adp5520_gpio_platform_data *gpio;
0279 struct adp5520_leds_platform_data *leds;
0280 struct adp5520_backlight_platform_data *backlight;
0281 };
0282
0283
0284
0285
0286
0287 extern int adp5520_read(struct device *dev, int reg, uint8_t *val);
0288 extern int adp5520_write(struct device *dev, int reg, u8 val);
0289 extern int adp5520_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
0290 extern int adp5520_set_bits(struct device *dev, int reg, uint8_t bit_mask);
0291
0292 extern int adp5520_register_notifier(struct device *dev,
0293 struct notifier_block *nb, unsigned int events);
0294
0295 extern int adp5520_unregister_notifier(struct device *dev,
0296 struct notifier_block *nb, unsigned int events);
0297
0298 #endif