Krzysztof Kozlowski | d7d8d7a | 2018-08-07 18:11:23 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
MyungJoo Ham | 527e7e9 | 2011-03-04 15:50:26 +0900 | [diff] [blame] | 2 | /* |
| 3 | * max8997.h - Driver for the Maxim 8997/8966 |
| 4 | * |
| 5 | * Copyright (C) 2009-2010 Samsung Electrnoics |
| 6 | * MyungJoo Ham <myungjoo.ham@samsung.com> |
| 7 | * |
MyungJoo Ham | 527e7e9 | 2011-03-04 15:50:26 +0900 | [diff] [blame] | 8 | * This driver is based on max8998.h |
| 9 | * |
| 10 | * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices. |
| 11 | * Except Fuel Gauge, every device shares the same I2C bus and included in |
| 12 | * this mfd driver. Although the fuel gauge is included in the chip, it is |
| 13 | * excluded from the driver because a) it has a different I2C bus from |
| 14 | * others and b) it can be enabled simply by using MAX17042 driver. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __LINUX_MFD_MAX8998_H |
| 18 | #define __LINUX_MFD_MAX8998_H |
| 19 | |
| 20 | #include <linux/regulator/consumer.h> |
| 21 | |
| 22 | /* MAX8997/8966 regulator IDs */ |
| 23 | enum max8998_regulators { |
| 24 | MAX8997_LDO1 = 0, |
| 25 | MAX8997_LDO2, |
| 26 | MAX8997_LDO3, |
| 27 | MAX8997_LDO4, |
| 28 | MAX8997_LDO5, |
| 29 | MAX8997_LDO6, |
| 30 | MAX8997_LDO7, |
| 31 | MAX8997_LDO8, |
| 32 | MAX8997_LDO9, |
| 33 | MAX8997_LDO10, |
| 34 | MAX8997_LDO11, |
| 35 | MAX8997_LDO12, |
| 36 | MAX8997_LDO13, |
| 37 | MAX8997_LDO14, |
| 38 | MAX8997_LDO15, |
| 39 | MAX8997_LDO16, |
| 40 | MAX8997_LDO17, |
| 41 | MAX8997_LDO18, |
| 42 | MAX8997_LDO21, |
| 43 | MAX8997_BUCK1, |
| 44 | MAX8997_BUCK2, |
| 45 | MAX8997_BUCK3, |
| 46 | MAX8997_BUCK4, |
| 47 | MAX8997_BUCK5, |
| 48 | MAX8997_BUCK6, |
| 49 | MAX8997_BUCK7, |
| 50 | MAX8997_EN32KHZ_AP, |
| 51 | MAX8997_EN32KHZ_CP, |
| 52 | MAX8997_ENVICHG, |
| 53 | MAX8997_ESAFEOUT1, |
| 54 | MAX8997_ESAFEOUT2, |
| 55 | MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */ |
| 56 | MAX8997_CHARGER, /* charger current, MBCCTRL4 */ |
| 57 | MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */ |
MyungJoo Ham | bd6ca2c | 2011-03-11 11:34:44 +0900 | [diff] [blame] | 58 | |
| 59 | MAX8997_REG_MAX, |
MyungJoo Ham | 527e7e9 | 2011-03-04 15:50:26 +0900 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | struct max8997_regulator_data { |
| 63 | int id; |
| 64 | struct regulator_init_data *initdata; |
Thomas Abraham | 77b71b3 | 2012-11-27 14:04:32 +0530 | [diff] [blame] | 65 | struct device_node *reg_node; |
MyungJoo Ham | 527e7e9 | 2011-03-04 15:50:26 +0900 | [diff] [blame] | 66 | }; |
| 67 | |
Donggeun Kim | 2439d97 | 2011-11-24 18:12:17 +0900 | [diff] [blame] | 68 | struct max8997_muic_reg_data { |
| 69 | u8 addr; |
| 70 | u8 data; |
| 71 | }; |
| 72 | |
| 73 | /** |
| 74 | * struct max8997_muic_platform_data |
Donggeun Kim | 2439d97 | 2011-11-24 18:12:17 +0900 | [diff] [blame] | 75 | * @init_data: array of max8997_muic_reg_data |
| 76 | * used for initializing registers of MAX8997 MUIC device |
| 77 | * @num_init_data: array size of init_data |
| 78 | */ |
| 79 | struct max8997_muic_platform_data { |
Donggeun Kim | 2439d97 | 2011-11-24 18:12:17 +0900 | [diff] [blame] | 80 | struct max8997_muic_reg_data *init_data; |
| 81 | int num_init_data; |
Chanwoo Choi | 685dc9a | 2013-02-13 15:04:15 +0900 | [diff] [blame] | 82 | |
Chanwoo Choi | af5eb1a | 2013-02-13 15:10:00 +0900 | [diff] [blame] | 83 | /* Check cable state after certain delay */ |
| 84 | int detcable_delay_ms; |
| 85 | |
Chanwoo Choi | 685dc9a | 2013-02-13 15:04:15 +0900 | [diff] [blame] | 86 | /* |
| 87 | * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB |
| 88 | * h/w path of COMP2/COMN1 on CONTROL1 register. |
| 89 | */ |
| 90 | int path_usb; |
| 91 | int path_uart; |
Donggeun Kim | 2439d97 | 2011-11-24 18:12:17 +0900 | [diff] [blame] | 92 | }; |
| 93 | |
Donggeun Kim | 104594b0 | 2012-03-16 12:28:22 -0700 | [diff] [blame] | 94 | enum max8997_haptic_motor_type { |
| 95 | MAX8997_HAPTIC_ERM, |
| 96 | MAX8997_HAPTIC_LRA, |
| 97 | }; |
| 98 | |
| 99 | enum max8997_haptic_pulse_mode { |
| 100 | MAX8997_EXTERNAL_MODE, |
| 101 | MAX8997_INTERNAL_MODE, |
| 102 | }; |
| 103 | |
| 104 | enum max8997_haptic_pwm_divisor { |
| 105 | MAX8997_PWM_DIVISOR_32, |
| 106 | MAX8997_PWM_DIVISOR_64, |
| 107 | MAX8997_PWM_DIVISOR_128, |
| 108 | MAX8997_PWM_DIVISOR_256, |
| 109 | }; |
| 110 | |
| 111 | /** |
| 112 | * max8997_haptic_platform_data |
| 113 | * @pwm_channel_id: channel number of PWM device |
| 114 | * valid for MAX8997_EXTERNAL_MODE |
| 115 | * @pwm_period: period in nano second for PWM device |
| 116 | * valid for MAX8997_EXTERNAL_MODE |
| 117 | * @type: motor type |
| 118 | * @mode: pulse mode |
| 119 | * MAX8997_EXTERNAL_MODE: external PWM device is used to control motor |
| 120 | * MAX8997_INTERNAL_MODE: internal pulse generator is used to control motor |
| 121 | * @pwm_divisor: divisor for external PWM device |
| 122 | * @internal_mode_pattern: internal mode pattern for internal mode |
| 123 | * [0 - 3]: valid pattern number |
| 124 | * @pattern_cycle: the number of cycles of the waveform |
| 125 | * for the internal mode pattern |
| 126 | * [0 - 15]: available cycles |
| 127 | * @pattern_signal_period: period of the waveform for the internal mode pattern |
| 128 | * [0 - 255]: available period |
| 129 | */ |
| 130 | struct max8997_haptic_platform_data { |
| 131 | unsigned int pwm_channel_id; |
| 132 | unsigned int pwm_period; |
| 133 | |
| 134 | enum max8997_haptic_motor_type type; |
| 135 | enum max8997_haptic_pulse_mode mode; |
| 136 | enum max8997_haptic_pwm_divisor pwm_divisor; |
| 137 | |
| 138 | unsigned int internal_mode_pattern; |
| 139 | unsigned int pattern_cycle; |
| 140 | unsigned int pattern_signal_period; |
| 141 | }; |
| 142 | |
Donggeun Kim | f6dd2db | 2011-12-14 18:23:55 +0900 | [diff] [blame] | 143 | enum max8997_led_mode { |
| 144 | MAX8997_NONE, |
| 145 | MAX8997_FLASH_MODE, |
| 146 | MAX8997_MOVIE_MODE, |
| 147 | MAX8997_FLASH_PIN_CONTROL_MODE, |
| 148 | MAX8997_MOVIE_PIN_CONTROL_MODE, |
| 149 | }; |
| 150 | |
| 151 | /** |
| 152 | * struct max8997_led_platform_data |
| 153 | * The number of LED devices for MAX8997 is two |
| 154 | * @mode: LED mode for each LED device |
| 155 | * @brightness: initial brightness for each LED device |
| 156 | * range: |
| 157 | * [0 - 31]: MAX8997_FLASH_MODE and MAX8997_FLASH_PIN_CONTROL_MODE |
| 158 | * [0 - 15]: MAX8997_MOVIE_MODE and MAX8997_MOVIE_PIN_CONTROL_MODE |
| 159 | */ |
| 160 | struct max8997_led_platform_data { |
| 161 | enum max8997_led_mode mode[2]; |
| 162 | u8 brightness[2]; |
| 163 | }; |
| 164 | |
MyungJoo Ham | 527e7e9 | 2011-03-04 15:50:26 +0900 | [diff] [blame] | 165 | struct max8997_platform_data { |
MyungJoo Ham | 8de6bc7 | 2011-03-24 15:54:45 +0900 | [diff] [blame] | 166 | /* IRQ */ |
MyungJoo Ham | 8de6bc7 | 2011-03-24 15:54:45 +0900 | [diff] [blame] | 167 | int ono; |
MyungJoo Ham | 8de6bc7 | 2011-03-24 15:54:45 +0900 | [diff] [blame] | 168 | |
MyungJoo Ham | bd6ca2c | 2011-03-11 11:34:44 +0900 | [diff] [blame] | 169 | /* ---- PMIC ---- */ |
| 170 | struct max8997_regulator_data *regulators; |
| 171 | int num_regulators; |
| 172 | |
| 173 | /* |
| 174 | * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore, |
| 175 | * With buckx_gpiodvs enabled, the buckx cannot be controlled |
| 176 | * independently. To control buckx (of 1, 2, and 5) independently, |
| 177 | * disable buckx_gpiodvs and control with BUCKxDVS1 register. |
| 178 | * |
| 179 | * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage |
| 180 | * on buckx will change the voltage of bucky at the same time. |
| 181 | * |
| 182 | */ |
| 183 | bool ignore_gpiodvs_side_effect; |
| 184 | int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */ |
| 185 | int buck125_default_idx; /* Default value of SET1, 2, 3 */ |
| 186 | unsigned int buck1_voltage[8]; /* buckx_voltage in uV */ |
| 187 | bool buck1_gpiodvs; |
| 188 | unsigned int buck2_voltage[8]; |
| 189 | bool buck2_gpiodvs; |
| 190 | unsigned int buck5_voltage[8]; |
| 191 | bool buck5_gpiodvs; |
| 192 | |
Donggeun Kim | 149c077 | 2011-06-22 19:40:06 +0900 | [diff] [blame] | 193 | /* ---- Charger control ---- */ |
| 194 | /* eoc stands for 'end of charge' */ |
| 195 | int eoc_mA; /* 50 ~ 200mA by 10mA step */ |
| 196 | /* charge Full Timeout */ |
| 197 | int timeout; /* 0 (no timeout), 5, 6, 7 hours */ |
| 198 | |
Donggeun Kim | 2439d97 | 2011-11-24 18:12:17 +0900 | [diff] [blame] | 199 | /* ---- MUIC ---- */ |
| 200 | struct max8997_muic_platform_data *muic_pdata; |
| 201 | |
Donggeun Kim | 104594b0 | 2012-03-16 12:28:22 -0700 | [diff] [blame] | 202 | /* ---- HAPTIC ---- */ |
| 203 | struct max8997_haptic_platform_data *haptic_pdata; |
| 204 | |
MyungJoo Ham | 527e7e9 | 2011-03-04 15:50:26 +0900 | [diff] [blame] | 205 | /* RTC: Not implemented */ |
Donggeun Kim | f6dd2db | 2011-12-14 18:23:55 +0900 | [diff] [blame] | 206 | /* ---- LED ---- */ |
| 207 | struct max8997_led_platform_data *led_pdata; |
MyungJoo Ham | 527e7e9 | 2011-03-04 15:50:26 +0900 | [diff] [blame] | 208 | }; |
| 209 | |
| 210 | #endif /* __LINUX_MFD_MAX8998_H */ |