aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/regulator/max8973-regulator.txt6
-rw-r--r--drivers/extcon/extcon-max77693.c94
-rw-r--r--drivers/extcon/extcon-max77843.c66
-rw-r--r--drivers/input/misc/Kconfig18
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/max77693-haptic.c92
-rw-r--r--drivers/input/misc/max77843-haptic.c358
-rw-r--r--drivers/leds/leds-max77693.c1
-rw-r--r--drivers/mfd/max77693.c31
-rw-r--r--drivers/mfd/max77843.c20
-rw-r--r--drivers/power/max77693_charger.c1
-rw-r--r--drivers/regulator/Kconfig16
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/lp872x.c16
-rw-r--r--drivers/regulator/ltc3589.c3
-rw-r--r--drivers/regulator/max77693.c173
-rw-r--r--drivers/regulator/max77843.c201
-rw-r--r--drivers/regulator/max8973-regulator.c80
-rw-r--r--include/linux/mfd/max77693-common.h49
-rw-r--r--include/linux/mfd/max77693-private.h134
-rw-r--r--include/linux/mfd/max77843-private.h174
21 files changed, 622 insertions, 913 deletions
diff --git a/Documentation/devicetree/bindings/regulator/max8973-regulator.txt b/Documentation/devicetree/bindings/regulator/max8973-regulator.txt
index 55efb24e5683..f80ea2fe27e6 100644
--- a/Documentation/devicetree/bindings/regulator/max8973-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/max8973-regulator.txt
@@ -25,6 +25,12 @@ Optional properties:
25-maxim,enable-frequency-shift: boolean, enable 9% frequency shift. 25-maxim,enable-frequency-shift: boolean, enable 9% frequency shift.
26-maxim,enable-bias-control: boolean, enable bias control. By enabling this 26-maxim,enable-bias-control: boolean, enable bias control. By enabling this
27 startup delay can be reduce to 20us from 220us. 27 startup delay can be reduce to 20us from 220us.
28-maxim,enable-etr: boolean, enable Enhanced Transient Response.
29-maxim,enable-high-etr-sensitivity: boolean, Enhanced transient response
30 circuit is enabled and set for high sensitivity. If this
31 property is available then etr will be enable default.
32
33Enhanced transient response (ETR) will affect the configuration of CKADV.
28 34
29Example: 35Example:
30 36
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index f4f3b3d53928..35b9e118b2fb 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -24,6 +24,7 @@
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/mfd/max77693.h> 26#include <linux/mfd/max77693.h>
27#include <linux/mfd/max77693-common.h>
27#include <linux/mfd/max77693-private.h> 28#include <linux/mfd/max77693-private.h>
28#include <linux/extcon.h> 29#include <linux/extcon.h>
29#include <linux/regmap.h> 30#include <linux/regmap.h>
@@ -42,7 +43,7 @@ static struct max77693_reg_data default_init_data[] = {
42 { 43 {
43 /* STATUS2 - [3]ChgDetRun */ 44 /* STATUS2 - [3]ChgDetRun */
44 .addr = MAX77693_MUIC_REG_STATUS2, 45 .addr = MAX77693_MUIC_REG_STATUS2,
45 .data = STATUS2_CHGDETRUN_MASK, 46 .data = MAX77693_STATUS2_CHGDETRUN_MASK,
46 }, { 47 }, {
47 /* INTMASK1 - Unmask [3]ADC1KM,[0]ADCM */ 48 /* INTMASK1 - Unmask [3]ADC1KM,[0]ADCM */
48 .addr = MAX77693_MUIC_REG_INTMASK1, 49 .addr = MAX77693_MUIC_REG_INTMASK1,
@@ -235,7 +236,7 @@ static int max77693_muic_set_debounce_time(struct max77693_muic_info *info,
235 */ 236 */
236 ret = regmap_write(info->max77693->regmap_muic, 237 ret = regmap_write(info->max77693->regmap_muic,
237 MAX77693_MUIC_REG_CTRL3, 238 MAX77693_MUIC_REG_CTRL3,
238 time << CONTROL3_ADCDBSET_SHIFT); 239 time << MAX77693_CONTROL3_ADCDBSET_SHIFT);
239 if (ret) { 240 if (ret) {
240 dev_err(info->dev, "failed to set ADC debounce time\n"); 241 dev_err(info->dev, "failed to set ADC debounce time\n");
241 return ret; 242 return ret;
@@ -268,7 +269,7 @@ static int max77693_muic_set_path(struct max77693_muic_info *info,
268 if (attached) 269 if (attached)
269 ctrl1 = val; 270 ctrl1 = val;
270 else 271 else
271 ctrl1 = CONTROL1_SW_OPEN; 272 ctrl1 = MAX77693_CONTROL1_SW_OPEN;
272 273
273 ret = regmap_update_bits(info->max77693->regmap_muic, 274 ret = regmap_update_bits(info->max77693->regmap_muic,
274 MAX77693_MUIC_REG_CTRL1, COMP_SW_MASK, ctrl1); 275 MAX77693_MUIC_REG_CTRL1, COMP_SW_MASK, ctrl1);
@@ -278,13 +279,14 @@ static int max77693_muic_set_path(struct max77693_muic_info *info,
278 } 279 }
279 280
280 if (attached) 281 if (attached)
281 ctrl2 |= CONTROL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */ 282 ctrl2 |= MAX77693_CONTROL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */
282 else 283 else
283 ctrl2 |= CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */ 284 ctrl2 |= MAX77693_CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */
284 285
285 ret = regmap_update_bits(info->max77693->regmap_muic, 286 ret = regmap_update_bits(info->max77693->regmap_muic,
286 MAX77693_MUIC_REG_CTRL2, 287 MAX77693_MUIC_REG_CTRL2,
287 CONTROL2_LOWPWR_MASK | CONTROL2_CPEN_MASK, ctrl2); 288 MAX77693_CONTROL2_LOWPWR_MASK | MAX77693_CONTROL2_CPEN_MASK,
289 ctrl2);
288 if (ret < 0) { 290 if (ret < 0) {
289 dev_err(info->dev, "failed to update MUIC register\n"); 291 dev_err(info->dev, "failed to update MUIC register\n");
290 return ret; 292 return ret;
@@ -326,8 +328,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
326 * Read ADC value to check cable type and decide cable state 328 * Read ADC value to check cable type and decide cable state
327 * according to cable type 329 * according to cable type
328 */ 330 */
329 adc = info->status[0] & STATUS1_ADC_MASK; 331 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
330 adc >>= STATUS1_ADC_SHIFT; 332 adc >>= MAX77693_STATUS1_ADC_SHIFT;
331 333
332 /* 334 /*
333 * Check current cable state/cable type and store cable type 335 * Check current cable state/cable type and store cable type
@@ -350,8 +352,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
350 * Read ADC value to check cable type and decide cable state 352 * Read ADC value to check cable type and decide cable state
351 * according to cable type 353 * according to cable type
352 */ 354 */
353 adc = info->status[0] & STATUS1_ADC_MASK; 355 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
354 adc >>= STATUS1_ADC_SHIFT; 356 adc >>= MAX77693_STATUS1_ADC_SHIFT;
355 357
356 /* 358 /*
357 * Check current cable state/cable type and store cable type 359 * Check current cable state/cable type and store cable type
@@ -366,13 +368,13 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
366 } else { 368 } else {
367 *attached = true; 369 *attached = true;
368 370
369 adclow = info->status[0] & STATUS1_ADCLOW_MASK; 371 adclow = info->status[0] & MAX77693_STATUS1_ADCLOW_MASK;
370 adclow >>= STATUS1_ADCLOW_SHIFT; 372 adclow >>= MAX77693_STATUS1_ADCLOW_SHIFT;
371 adc1k = info->status[0] & STATUS1_ADC1K_MASK; 373 adc1k = info->status[0] & MAX77693_STATUS1_ADC1K_MASK;
372 adc1k >>= STATUS1_ADC1K_SHIFT; 374 adc1k >>= MAX77693_STATUS1_ADC1K_SHIFT;
373 375
374 vbvolt = info->status[1] & STATUS2_VBVOLT_MASK; 376 vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK;
375 vbvolt >>= STATUS2_VBVOLT_SHIFT; 377 vbvolt >>= MAX77693_STATUS2_VBVOLT_SHIFT;
376 378
377 /** 379 /**
378 * [0x1|VBVolt|ADCLow|ADC1K] 380 * [0x1|VBVolt|ADCLow|ADC1K]
@@ -397,8 +399,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
397 * Read charger type to check cable type and decide cable state 399 * Read charger type to check cable type and decide cable state
398 * according to type of charger cable. 400 * according to type of charger cable.
399 */ 401 */
400 chg_type = info->status[1] & STATUS2_CHGTYP_MASK; 402 chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK;
401 chg_type >>= STATUS2_CHGTYP_SHIFT; 403 chg_type >>= MAX77693_STATUS2_CHGTYP_SHIFT;
402 404
403 if (chg_type == MAX77693_CHARGER_TYPE_NONE) { 405 if (chg_type == MAX77693_CHARGER_TYPE_NONE) {
404 *attached = false; 406 *attached = false;
@@ -422,10 +424,10 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
422 * Read ADC value to check cable type and decide cable state 424 * Read ADC value to check cable type and decide cable state
423 * according to cable type 425 * according to cable type
424 */ 426 */
425 adc = info->status[0] & STATUS1_ADC_MASK; 427 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
426 adc >>= STATUS1_ADC_SHIFT; 428 adc >>= MAX77693_STATUS1_ADC_SHIFT;
427 chg_type = info->status[1] & STATUS2_CHGTYP_MASK; 429 chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK;
428 chg_type >>= STATUS2_CHGTYP_SHIFT; 430 chg_type >>= MAX77693_STATUS2_CHGTYP_SHIFT;
429 431
430 if (adc == MAX77693_MUIC_ADC_OPEN 432 if (adc == MAX77693_MUIC_ADC_OPEN
431 && chg_type == MAX77693_CHARGER_TYPE_NONE) 433 && chg_type == MAX77693_CHARGER_TYPE_NONE)
@@ -437,8 +439,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
437 * Read vbvolt field, if vbvolt is 1, 439 * Read vbvolt field, if vbvolt is 1,
438 * this cable is used for charging. 440 * this cable is used for charging.
439 */ 441 */
440 vbvolt = info->status[1] & STATUS2_VBVOLT_MASK; 442 vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK;
441 vbvolt >>= STATUS2_VBVOLT_SHIFT; 443 vbvolt >>= MAX77693_STATUS2_VBVOLT_SHIFT;
442 444
443 cable_type = vbvolt; 445 cable_type = vbvolt;
444 break; 446 break;
@@ -520,7 +522,8 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
520 } 522 }
521 523
522 /* Dock-Car/Desk/Audio, PATH:AUDIO */ 524 /* Dock-Car/Desk/Audio, PATH:AUDIO */
523 ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); 525 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO,
526 attached);
524 if (ret < 0) 527 if (ret < 0)
525 return ret; 528 return ret;
526 extcon_set_cable_state_(info->edev, dock_id, attached); 529 extcon_set_cable_state_(info->edev, dock_id, attached);
@@ -585,14 +588,16 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
585 case MAX77693_MUIC_GND_USB_HOST: 588 case MAX77693_MUIC_GND_USB_HOST:
586 case MAX77693_MUIC_GND_USB_HOST_VB: 589 case MAX77693_MUIC_GND_USB_HOST_VB:
587 /* USB_HOST, PATH: AP_USB */ 590 /* USB_HOST, PATH: AP_USB */
588 ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); 591 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_USB,
592 attached);
589 if (ret < 0) 593 if (ret < 0)
590 return ret; 594 return ret;
591 extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, attached); 595 extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, attached);
592 break; 596 break;
593 case MAX77693_MUIC_GND_AV_CABLE_LOAD: 597 case MAX77693_MUIC_GND_AV_CABLE_LOAD:
594 /* Audio Video Cable with load, PATH:AUDIO */ 598 /* Audio Video Cable with load, PATH:AUDIO */
595 ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); 599 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO,
600 attached);
596 if (ret < 0) 601 if (ret < 0)
597 return ret; 602 return ret;
598 extcon_set_cable_state_(info->edev, EXTCON_USB, attached); 603 extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
@@ -615,7 +620,7 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info,
615 int cable_type, bool attached) 620 int cable_type, bool attached)
616{ 621{
617 int ret = 0; 622 int ret = 0;
618 u8 path = CONTROL1_SW_OPEN; 623 u8 path = MAX77693_CONTROL1_SW_OPEN;
619 624
620 dev_info(info->dev, 625 dev_info(info->dev,
621 "external connector is %s (adc:0x%02x)\n", 626 "external connector is %s (adc:0x%02x)\n",
@@ -625,12 +630,12 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info,
625 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */ 630 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */
626 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */ 631 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */
627 /* PATH:AP_USB */ 632 /* PATH:AP_USB */
628 path = CONTROL1_SW_USB; 633 path = MAX77693_CONTROL1_SW_USB;
629 break; 634 break;
630 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */ 635 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */
631 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* ADC_JIG_UART_ON */ 636 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* ADC_JIG_UART_ON */
632 /* PATH:AP_UART */ 637 /* PATH:AP_UART */
633 path = CONTROL1_SW_UART; 638 path = MAX77693_CONTROL1_SW_UART;
634 break; 639 break;
635 default: 640 default:
636 dev_err(info->dev, "failed to detect %s jig cable\n", 641 dev_err(info->dev, "failed to detect %s jig cable\n",
@@ -1077,7 +1082,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
1077 dev_dbg(&pdev->dev, "allocate register map\n"); 1082 dev_dbg(&pdev->dev, "allocate register map\n");
1078 } else { 1083 } else {
1079 info->max77693->regmap_muic = devm_regmap_init_i2c( 1084 info->max77693->regmap_muic = devm_regmap_init_i2c(
1080 info->max77693->muic, 1085 info->max77693->i2c_muic,
1081 &max77693_muic_regmap_config); 1086 &max77693_muic_regmap_config);
1082 if (IS_ERR(info->max77693->regmap_muic)) { 1087 if (IS_ERR(info->max77693->regmap_muic)) {
1083 ret = PTR_ERR(info->max77693->regmap_muic); 1088 ret = PTR_ERR(info->max77693->regmap_muic);
@@ -1164,28 +1169,9 @@ static int max77693_muic_probe(struct platform_device *pdev)
1164 } 1169 }
1165 1170
1166 for (i = 0; i < num_init_data; i++) { 1171 for (i = 0; i < num_init_data; i++) {
1167 enum max77693_irq_source irq_src
1168 = MAX77693_IRQ_GROUP_NR;
1169
1170 regmap_write(info->max77693->regmap_muic, 1172 regmap_write(info->max77693->regmap_muic,
1171 init_data[i].addr, 1173 init_data[i].addr,
1172 init_data[i].data); 1174 init_data[i].data);
1173
1174 switch (init_data[i].addr) {
1175 case MAX77693_MUIC_REG_INTMASK1:
1176 irq_src = MUIC_INT1;
1177 break;
1178 case MAX77693_MUIC_REG_INTMASK2:
1179 irq_src = MUIC_INT2;
1180 break;
1181 case MAX77693_MUIC_REG_INTMASK3:
1182 irq_src = MUIC_INT3;
1183 break;
1184 }
1185
1186 if (irq_src < MAX77693_IRQ_GROUP_NR)
1187 info->max77693->irq_masks_cur[irq_src]
1188 = init_data[i].data;
1189 } 1175 }
1190 1176
1191 if (pdata && pdata->muic_data) { 1177 if (pdata && pdata->muic_data) {
@@ -1199,12 +1185,12 @@ static int max77693_muic_probe(struct platform_device *pdev)
1199 if (muic_pdata->path_uart) 1185 if (muic_pdata->path_uart)
1200 info->path_uart = muic_pdata->path_uart; 1186 info->path_uart = muic_pdata->path_uart;
1201 else 1187 else
1202 info->path_uart = CONTROL1_SW_UART; 1188 info->path_uart = MAX77693_CONTROL1_SW_UART;
1203 1189
1204 if (muic_pdata->path_usb) 1190 if (muic_pdata->path_usb)
1205 info->path_usb = muic_pdata->path_usb; 1191 info->path_usb = muic_pdata->path_usb;
1206 else 1192 else
1207 info->path_usb = CONTROL1_SW_USB; 1193 info->path_usb = MAX77693_CONTROL1_SW_USB;
1208 1194
1209 /* 1195 /*
1210 * Default delay time for detecting cable state 1196 * Default delay time for detecting cable state
@@ -1216,8 +1202,8 @@ static int max77693_muic_probe(struct platform_device *pdev)
1216 else 1202 else
1217 delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); 1203 delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
1218 } else { 1204 } else {
1219 info->path_usb = CONTROL1_SW_USB; 1205 info->path_usb = MAX77693_CONTROL1_SW_USB;
1220 info->path_uart = CONTROL1_SW_UART; 1206 info->path_uart = MAX77693_CONTROL1_SW_UART;
1221 delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); 1207 delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
1222 } 1208 }
1223 1209
diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index fac2f1417a79..f652c4199870 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -15,6 +15,7 @@
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/mfd/max77693-common.h>
18#include <linux/mfd/max77843-private.h> 19#include <linux/mfd/max77843-private.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
@@ -32,7 +33,7 @@ enum max77843_muic_status {
32 33
33struct max77843_muic_info { 34struct max77843_muic_info {
34 struct device *dev; 35 struct device *dev;
35 struct max77843 *max77843; 36 struct max77693_dev *max77843;
36 struct extcon_dev *edev; 37 struct extcon_dev *edev;
37 38
38 struct mutex mutex; 39 struct mutex mutex;
@@ -198,18 +199,18 @@ static const struct regmap_irq_chip max77843_muic_irq_chip = {
198static int max77843_muic_set_path(struct max77843_muic_info *info, 199static int max77843_muic_set_path(struct max77843_muic_info *info,
199 u8 val, bool attached) 200 u8 val, bool attached)
200{ 201{
201 struct max77843 *max77843 = info->max77843; 202 struct max77693_dev *max77843 = info->max77843;
202 int ret = 0; 203 int ret = 0;
203 unsigned int ctrl1, ctrl2; 204 unsigned int ctrl1, ctrl2;
204 205
205 if (attached) 206 if (attached)
206 ctrl1 = val; 207 ctrl1 = val;
207 else 208 else
208 ctrl1 = CONTROL1_SW_OPEN; 209 ctrl1 = MAX77843_MUIC_CONTROL1_SW_OPEN;
209 210
210 ret = regmap_update_bits(max77843->regmap_muic, 211 ret = regmap_update_bits(max77843->regmap_muic,
211 MAX77843_MUIC_REG_CONTROL1, 212 MAX77843_MUIC_REG_CONTROL1,
212 CONTROL1_COM_SW, ctrl1); 213 MAX77843_MUIC_CONTROL1_COM_SW, ctrl1);
213 if (ret < 0) { 214 if (ret < 0) {
214 dev_err(info->dev, "Cannot switch MUIC port\n"); 215 dev_err(info->dev, "Cannot switch MUIC port\n");
215 return ret; 216 return ret;
@@ -243,7 +244,7 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
243 244
244 adc = info->status[MAX77843_MUIC_STATUS1] & 245 adc = info->status[MAX77843_MUIC_STATUS1] &
245 MAX77843_MUIC_STATUS1_ADC_MASK; 246 MAX77843_MUIC_STATUS1_ADC_MASK;
246 adc >>= STATUS1_ADC_SHIFT; 247 adc >>= MAX77843_MUIC_STATUS1_ADC_SHIFT;
247 248
248 switch (group) { 249 switch (group) {
249 case MAX77843_CABLE_GROUP_ADC: 250 case MAX77843_CABLE_GROUP_ADC:
@@ -309,7 +310,7 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
309 /* Get VBVolt register bit */ 310 /* Get VBVolt register bit */
310 gnd_type |= (info->status[MAX77843_MUIC_STATUS2] & 311 gnd_type |= (info->status[MAX77843_MUIC_STATUS2] &
311 MAX77843_MUIC_STATUS2_VBVOLT_MASK); 312 MAX77843_MUIC_STATUS2_VBVOLT_MASK);
312 gnd_type >>= STATUS2_VBVOLT_SHIFT; 313 gnd_type >>= MAX77843_MUIC_STATUS2_VBVOLT_SHIFT;
313 314
314 /* Offset of GND cable */ 315 /* Offset of GND cable */
315 gnd_type |= MAX77843_MUIC_GND_USB_HOST; 316 gnd_type |= MAX77843_MUIC_GND_USB_HOST;
@@ -338,7 +339,9 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info)
338 switch (gnd_cable_type) { 339 switch (gnd_cable_type) {
339 case MAX77843_MUIC_GND_USB_HOST: 340 case MAX77843_MUIC_GND_USB_HOST:
340 case MAX77843_MUIC_GND_USB_HOST_VB: 341 case MAX77843_MUIC_GND_USB_HOST_VB:
341 ret = max77843_muic_set_path(info, CONTROL1_SW_USB, attached); 342 ret = max77843_muic_set_path(info,
343 MAX77843_MUIC_CONTROL1_SW_USB,
344 attached);
342 if (ret < 0) 345 if (ret < 0)
343 return ret; 346 return ret;
344 347
@@ -346,7 +349,9 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info)
346 break; 349 break;
347 case MAX77843_MUIC_GND_MHL_VB: 350 case MAX77843_MUIC_GND_MHL_VB:
348 case MAX77843_MUIC_GND_MHL: 351 case MAX77843_MUIC_GND_MHL:
349 ret = max77843_muic_set_path(info, CONTROL1_SW_OPEN, attached); 352 ret = max77843_muic_set_path(info,
353 MAX77843_MUIC_CONTROL1_SW_OPEN,
354 attached);
350 if (ret < 0) 355 if (ret < 0)
351 return ret; 356 return ret;
352 357
@@ -365,7 +370,7 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info,
365 int cable_type, bool attached) 370 int cable_type, bool attached)
366{ 371{
367 int ret; 372 int ret;
368 u8 path = CONTROL1_SW_OPEN; 373 u8 path = MAX77843_MUIC_CONTROL1_SW_OPEN;
369 374
370 dev_dbg(info->dev, "external connector is %s (adc:0x%02x)\n", 375 dev_dbg(info->dev, "external connector is %s (adc:0x%02x)\n",
371 attached ? "attached" : "detached", cable_type); 376 attached ? "attached" : "detached", cable_type);
@@ -373,10 +378,10 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info,
373 switch (cable_type) { 378 switch (cable_type) {
374 case MAX77843_MUIC_ADC_FACTORY_MODE_USB_OFF: 379 case MAX77843_MUIC_ADC_FACTORY_MODE_USB_OFF:
375 case MAX77843_MUIC_ADC_FACTORY_MODE_USB_ON: 380 case MAX77843_MUIC_ADC_FACTORY_MODE_USB_ON:
376 path = CONTROL1_SW_USB; 381 path = MAX77843_MUIC_CONTROL1_SW_USB;
377 break; 382 break;
378 case MAX77843_MUIC_ADC_FACTORY_MODE_UART_OFF: 383 case MAX77843_MUIC_ADC_FACTORY_MODE_UART_OFF:
379 path = CONTROL1_SW_UART; 384 path = MAX77843_MUIC_CONTROL1_SW_UART;
380 break; 385 break;
381 default: 386 default:
382 return -EINVAL; 387 return -EINVAL;
@@ -474,14 +479,18 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
474 479
475 switch (chg_type) { 480 switch (chg_type) {
476 case MAX77843_MUIC_CHG_USB: 481 case MAX77843_MUIC_CHG_USB:
477 ret = max77843_muic_set_path(info, CONTROL1_SW_USB, attached); 482 ret = max77843_muic_set_path(info,
483 MAX77843_MUIC_CONTROL1_SW_USB,
484 attached);
478 if (ret < 0) 485 if (ret < 0)
479 return ret; 486 return ret;
480 487
481 extcon_set_cable_state_(info->edev, EXTCON_USB, attached); 488 extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
482 break; 489 break;
483 case MAX77843_MUIC_CHG_DOWNSTREAM: 490 case MAX77843_MUIC_CHG_DOWNSTREAM:
484 ret = max77843_muic_set_path(info, CONTROL1_SW_OPEN, attached); 491 ret = max77843_muic_set_path(info,
492 MAX77843_MUIC_CONTROL1_SW_OPEN,
493 attached);
485 if (ret < 0) 494 if (ret < 0)
486 return ret; 495 return ret;
487 496
@@ -489,14 +498,18 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
489 attached); 498 attached);
490 break; 499 break;
491 case MAX77843_MUIC_CHG_DEDICATED: 500 case MAX77843_MUIC_CHG_DEDICATED:
492 ret = max77843_muic_set_path(info, CONTROL1_SW_OPEN, attached); 501 ret = max77843_muic_set_path(info,
502 MAX77843_MUIC_CONTROL1_SW_OPEN,
503 attached);
493 if (ret < 0) 504 if (ret < 0)
494 return ret; 505 return ret;
495 506
496 extcon_set_cable_state_(info->edev, EXTCON_TA, attached); 507 extcon_set_cable_state_(info->edev, EXTCON_TA, attached);
497 break; 508 break;
498 case MAX77843_MUIC_CHG_SPECIAL_500MA: 509 case MAX77843_MUIC_CHG_SPECIAL_500MA:
499 ret = max77843_muic_set_path(info, CONTROL1_SW_OPEN, attached); 510 ret = max77843_muic_set_path(info,
511 MAX77843_MUIC_CONTROL1_SW_OPEN,
512 attached);
500 if (ret < 0) 513 if (ret < 0)
501 return ret; 514 return ret;
502 515
@@ -504,7 +517,9 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
504 attached); 517 attached);
505 break; 518 break;
506 case MAX77843_MUIC_CHG_SPECIAL_1A: 519 case MAX77843_MUIC_CHG_SPECIAL_1A:
507 ret = max77843_muic_set_path(info, CONTROL1_SW_OPEN, attached); 520 ret = max77843_muic_set_path(info,
521 MAX77843_MUIC_CONTROL1_SW_OPEN,
522 attached);
508 if (ret < 0) 523 if (ret < 0)
509 return ret; 524 return ret;
510 525
@@ -528,7 +543,8 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
528 "failed to detect %s accessory (chg_type:0x%x)\n", 543 "failed to detect %s accessory (chg_type:0x%x)\n",
529 attached ? "attached" : "detached", chg_type); 544 attached ? "attached" : "detached", chg_type);
530 545
531 max77843_muic_set_path(info, CONTROL1_SW_OPEN, attached); 546 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN,
547 attached);
532 return -EINVAL; 548 return -EINVAL;
533 } 549 }
534 550
@@ -539,7 +555,7 @@ static void max77843_muic_irq_work(struct work_struct *work)
539{ 555{
540 struct max77843_muic_info *info = container_of(work, 556 struct max77843_muic_info *info = container_of(work,
541 struct max77843_muic_info, irq_work); 557 struct max77843_muic_info, irq_work);
542 struct max77843 *max77843 = info->max77843; 558 struct max77693_dev *max77843 = info->max77843;
543 int ret = 0; 559 int ret = 0;
544 560
545 mutex_lock(&info->mutex); 561 mutex_lock(&info->mutex);
@@ -615,7 +631,7 @@ static void max77843_muic_detect_cable_wq(struct work_struct *work)
615{ 631{
616 struct max77843_muic_info *info = container_of(to_delayed_work(work), 632 struct max77843_muic_info *info = container_of(to_delayed_work(work),
617 struct max77843_muic_info, wq_detcable); 633 struct max77843_muic_info, wq_detcable);
618 struct max77843 *max77843 = info->max77843; 634 struct max77693_dev *max77843 = info->max77843;
619 int chg_type, adc, ret; 635 int chg_type, adc, ret;
620 bool attached; 636 bool attached;
621 637
@@ -656,7 +672,7 @@ err_cable_wq:
656static int max77843_muic_set_debounce_time(struct max77843_muic_info *info, 672static int max77843_muic_set_debounce_time(struct max77843_muic_info *info,
657 enum max77843_muic_adc_debounce_time time) 673 enum max77843_muic_adc_debounce_time time)
658{ 674{
659 struct max77843 *max77843 = info->max77843; 675 struct max77693_dev *max77843 = info->max77843;
660 int ret; 676 int ret;
661 677
662 switch (time) { 678 switch (time) {
@@ -667,7 +683,7 @@ static int max77843_muic_set_debounce_time(struct max77843_muic_info *info,
667 ret = regmap_update_bits(max77843->regmap_muic, 683 ret = regmap_update_bits(max77843->regmap_muic,
668 MAX77843_MUIC_REG_CONTROL4, 684 MAX77843_MUIC_REG_CONTROL4,
669 MAX77843_MUIC_CONTROL4_ADCDBSET_MASK, 685 MAX77843_MUIC_CONTROL4_ADCDBSET_MASK,
670 time << CONTROL4_ADCDBSET_SHIFT); 686 time << MAX77843_MUIC_CONTROL4_ADCDBSET_SHIFT);
671 if (ret < 0) { 687 if (ret < 0) {
672 dev_err(info->dev, "Cannot write MUIC regmap\n"); 688 dev_err(info->dev, "Cannot write MUIC regmap\n");
673 return ret; 689 return ret;
@@ -681,7 +697,7 @@ static int max77843_muic_set_debounce_time(struct max77843_muic_info *info,
681 return 0; 697 return 0;
682} 698}
683 699
684static int max77843_init_muic_regmap(struct max77843 *max77843) 700static int max77843_init_muic_regmap(struct max77693_dev *max77843)
685{ 701{
686 int ret; 702 int ret;
687 703
@@ -720,7 +736,7 @@ err_muic_i2c:
720 736
721static int max77843_muic_probe(struct platform_device *pdev) 737static int max77843_muic_probe(struct platform_device *pdev)
722{ 738{
723 struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent); 739 struct max77693_dev *max77843 = dev_get_drvdata(pdev->dev.parent);
724 struct max77843_muic_info *info; 740 struct max77843_muic_info *info;
725 unsigned int id; 741 unsigned int id;
726 int i, ret; 742 int i, ret;
@@ -768,7 +784,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
768 max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); 784 max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS);
769 785
770 /* Set initial path for UART */ 786 /* Set initial path for UART */
771 max77843_muic_set_path(info, CONTROL1_SW_UART, true); 787 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true);
772 788
773 /* Check revision number of MUIC device */ 789 /* Check revision number of MUIC device */
774 ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id); 790 ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id);
@@ -821,7 +837,7 @@ err_muic_irq:
821static int max77843_muic_remove(struct platform_device *pdev) 837static int max77843_muic_remove(struct platform_device *pdev)
822{ 838{
823 struct max77843_muic_info *info = platform_get_drvdata(pdev); 839 struct max77843_muic_info *info = platform_get_drvdata(pdev);
824 struct max77843 *max77843 = info->max77843; 840 struct max77693_dev *max77843 = info->max77843;
825 841
826 cancel_work_sync(&info->irq_work); 842 cancel_work_sync(&info->irq_work);
827 regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic); 843 regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic);
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index d4f0a817e858..c41dec819cdf 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -167,28 +167,16 @@ config INPUT_M68K_BEEP
167 depends on M68K 167 depends on M68K
168 168
169config INPUT_MAX77693_HAPTIC 169config INPUT_MAX77693_HAPTIC
170 tristate "MAXIM MAX77693 haptic controller support" 170 tristate "MAXIM MAX77693/MAX77843 haptic controller support"
171 depends on MFD_MAX77693 && PWM 171 depends on (MFD_MAX77693 || MFD_MAX77843) && PWM
172 select INPUT_FF_MEMLESS 172 select INPUT_FF_MEMLESS
173 help 173 help
174 This option enables support for the haptic controller on 174 This option enables support for the haptic controller on
175 MAXIM MAX77693 chip. 175 MAXIM MAX77693 and MAX77843 chips.
176 176
177 To compile this driver as module, choose M here: the 177 To compile this driver as module, choose M here: the
178 module will be called max77693-haptic. 178 module will be called max77693-haptic.
179 179
180config INPUT_MAX77843_HAPTIC
181 tristate "MAXIM MAX77843 haptic controller support"
182 depends on MFD_MAX77843 && REGULATOR
183 select INPUT_FF_MEMLESS
184 help
185 This option enables support for the haptic controller on
186 MAXIM MAX77843 chip. The driver supports ff-memless interface
187 from input framework.
188
189 To compile this driver as module, choose M here: the
190 module will be called max77843-haptic.
191
192config INPUT_MAX8925_ONKEY 180config INPUT_MAX8925_ONKEY
193 tristate "MAX8925 ONKEY support" 181 tristate "MAX8925 ONKEY support"
194 depends on MFD_MAX8925 182 depends on MFD_MAX8925
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 53df07dcc23c..0357a088c6a9 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -41,7 +41,6 @@ obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o
41obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o 41obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o
42obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o 42obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o
43obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o 43obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o
44obj-$(CONFIG_INPUT_MAX77843_HAPTIC) += max77843-haptic.o
45obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o 44obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o
46obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o 45obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o
47obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o 46obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o
diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
index 39e930c10ebb..6d96bff32a0e 100644
--- a/drivers/input/misc/max77693-haptic.c
+++ b/drivers/input/misc/max77693-haptic.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * MAXIM MAX77693 Haptic device driver 2 * MAXIM MAX77693/MAX77843 Haptic device driver
3 * 3 *
4 * Copyright (C) 2014 Samsung Electronics 4 * Copyright (C) 2014,2015 Samsung Electronics
5 * Jaewon Kim <jaewon02.kim@samsung.com> 5 * Jaewon Kim <jaewon02.kim@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski@samsung.com>
6 * 7 *
7 * This program is not provided / owned by Maxim Integrated Products. 8 * This program is not provided / owned by Maxim Integrated Products.
8 * 9 *
@@ -24,7 +25,9 @@
24#include <linux/workqueue.h> 25#include <linux/workqueue.h>
25#include <linux/regulator/consumer.h> 26#include <linux/regulator/consumer.h>
26#include <linux/mfd/max77693.h> 27#include <linux/mfd/max77693.h>
28#include <linux/mfd/max77693-common.h>
27#include <linux/mfd/max77693-private.h> 29#include <linux/mfd/max77693-private.h>
30#include <linux/mfd/max77843-private.h>
28 31
29#define MAX_MAGNITUDE_SHIFT 16 32#define MAX_MAGNITUDE_SHIFT 16
30 33
@@ -46,6 +49,8 @@ enum max77693_haptic_pwm_divisor {
46}; 49};
47 50
48struct max77693_haptic { 51struct max77693_haptic {
52 enum max77693_types dev_type;
53
49 struct regmap *regmap_pmic; 54 struct regmap *regmap_pmic;
50 struct regmap *regmap_haptic; 55 struct regmap *regmap_haptic;
51 struct device *dev; 56 struct device *dev;
@@ -59,7 +64,6 @@ struct max77693_haptic {
59 unsigned int pwm_duty; 64 unsigned int pwm_duty;
60 enum max77693_haptic_motor_type type; 65 enum max77693_haptic_motor_type type;
61 enum max77693_haptic_pulse_mode mode; 66 enum max77693_haptic_pulse_mode mode;
62 enum max77693_haptic_pwm_divisor pwm_divisor;
63 67
64 struct work_struct work; 68 struct work_struct work;
65}; 69};
@@ -78,19 +82,52 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic)
78 return 0; 82 return 0;
79} 83}
80 84
85static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on)
86{
87 int error;
88
89 if (haptic->dev_type != TYPE_MAX77843)
90 return 0;
91
92 error = regmap_update_bits(haptic->regmap_haptic,
93 MAX77843_SYS_REG_MAINCTRL1,
94 MAX77843_MAINCTRL1_BIASEN_MASK,
95 on << MAINCTRL1_BIASEN_SHIFT);
96 if (error) {
97 dev_err(haptic->dev, "failed to %s bias: %d\n",
98 on ? "enable" : "disable", error);
99 return error;
100 }
101
102 return 0;
103}
104
81static int max77693_haptic_configure(struct max77693_haptic *haptic, 105static int max77693_haptic_configure(struct max77693_haptic *haptic,
82 bool enable) 106 bool enable)
83{ 107{
84 unsigned int value; 108 unsigned int value, config_reg;
85 int error; 109 int error;
86 110
87 value = ((haptic->type << MAX77693_CONFIG2_MODE) | 111 switch (haptic->dev_type) {
88 (enable << MAX77693_CONFIG2_MEN) | 112 case TYPE_MAX77693:
89 (haptic->mode << MAX77693_CONFIG2_HTYP) | 113 value = ((haptic->type << MAX77693_CONFIG2_MODE) |
90 (haptic->pwm_divisor)); 114 (enable << MAX77693_CONFIG2_MEN) |
115 (haptic->mode << MAX77693_CONFIG2_HTYP) |
116 MAX77693_HAPTIC_PWM_DIVISOR_128);
117 config_reg = MAX77693_HAPTIC_REG_CONFIG2;
118 break;
119 case TYPE_MAX77843:
120 value = (haptic->type << MCONFIG_MODE_SHIFT) |
121 (enable << MCONFIG_MEN_SHIFT) |
122 MAX77693_HAPTIC_PWM_DIVISOR_128;
123 config_reg = MAX77843_HAP_REG_MCONFIG;
124 break;
125 default:
126 return -EINVAL;
127 }
91 128
92 error = regmap_write(haptic->regmap_haptic, 129 error = regmap_write(haptic->regmap_haptic,
93 MAX77693_HAPTIC_REG_CONFIG2, value); 130 config_reg, value);
94 if (error) { 131 if (error) {
95 dev_err(haptic->dev, 132 dev_err(haptic->dev,
96 "failed to update haptic config: %d\n", error); 133 "failed to update haptic config: %d\n", error);
@@ -104,6 +141,9 @@ static int max77693_haptic_lowsys(struct max77693_haptic *haptic, bool enable)
104{ 141{
105 int error; 142 int error;
106 143
144 if (haptic->dev_type != TYPE_MAX77693)
145 return 0;
146
107 error = regmap_update_bits(haptic->regmap_pmic, 147 error = regmap_update_bits(haptic->regmap_pmic,
108 MAX77693_PMIC_REG_LSCNFG, 148 MAX77693_PMIC_REG_LSCNFG,
109 MAX77693_PMIC_LOW_SYS_MASK, 149 MAX77693_PMIC_LOW_SYS_MASK,
@@ -219,6 +259,10 @@ static int max77693_haptic_open(struct input_dev *dev)
219 struct max77693_haptic *haptic = input_get_drvdata(dev); 259 struct max77693_haptic *haptic = input_get_drvdata(dev);
220 int error; 260 int error;
221 261
262 error = max77843_haptic_bias(haptic, true);
263 if (error)
264 return error;
265
222 error = regulator_enable(haptic->motor_reg); 266 error = regulator_enable(haptic->motor_reg);
223 if (error) { 267 if (error) {
224 dev_err(haptic->dev, 268 dev_err(haptic->dev,
@@ -241,6 +285,8 @@ static void max77693_haptic_close(struct input_dev *dev)
241 if (error) 285 if (error)
242 dev_err(haptic->dev, 286 dev_err(haptic->dev,
243 "failed to disable regulator: %d\n", error); 287 "failed to disable regulator: %d\n", error);
288
289 max77843_haptic_bias(haptic, false);
244} 290}
245 291
246static int max77693_haptic_probe(struct platform_device *pdev) 292static int max77693_haptic_probe(struct platform_device *pdev)
@@ -254,13 +300,26 @@ static int max77693_haptic_probe(struct platform_device *pdev)
254 return -ENOMEM; 300 return -ENOMEM;
255 301
256 haptic->regmap_pmic = max77693->regmap; 302 haptic->regmap_pmic = max77693->regmap;
257 haptic->regmap_haptic = max77693->regmap_haptic;
258 haptic->dev = &pdev->dev; 303 haptic->dev = &pdev->dev;
259 haptic->type = MAX77693_HAPTIC_LRA; 304 haptic->type = MAX77693_HAPTIC_LRA;
260 haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE; 305 haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE;
261 haptic->pwm_divisor = MAX77693_HAPTIC_PWM_DIVISOR_128;
262 haptic->suspend_state = false; 306 haptic->suspend_state = false;
263 307
308 /* Variant-specific init */
309 haptic->dev_type = platform_get_device_id(pdev)->driver_data;
310 switch (haptic->dev_type) {
311 case TYPE_MAX77693:
312 haptic->regmap_haptic = max77693->regmap_haptic;
313 break;
314 case TYPE_MAX77843:
315 haptic->regmap_haptic = max77693->regmap;
316 break;
317 default:
318 dev_err(&pdev->dev, "unsupported device type: %u\n",
319 haptic->dev_type);
320 return -EINVAL;
321 }
322
264 INIT_WORK(&haptic->work, max77693_haptic_play_work); 323 INIT_WORK(&haptic->work, max77693_haptic_play_work);
265 324
266 /* Get pwm and regulatot for haptic device */ 325 /* Get pwm and regulatot for haptic device */
@@ -338,16 +397,25 @@ static int __maybe_unused max77693_haptic_resume(struct device *dev)
338static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, 397static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops,
339 max77693_haptic_suspend, max77693_haptic_resume); 398 max77693_haptic_suspend, max77693_haptic_resume);
340 399
400static const struct platform_device_id max77693_haptic_id[] = {
401 { "max77693-haptic", TYPE_MAX77693 },
402 { "max77843-haptic", TYPE_MAX77843 },
403 {},
404};
405MODULE_DEVICE_TABLE(platform, max77693_haptic_id);
406
341static struct platform_driver max77693_haptic_driver = { 407static struct platform_driver max77693_haptic_driver = {
342 .driver = { 408 .driver = {
343 .name = "max77693-haptic", 409 .name = "max77693-haptic",
344 .pm = &max77693_haptic_pm_ops, 410 .pm = &max77693_haptic_pm_ops,
345 }, 411 },
346 .probe = max77693_haptic_probe, 412 .probe = max77693_haptic_probe,
413 .id_table = max77693_haptic_id,
347}; 414};
348module_platform_driver(max77693_haptic_driver); 415module_platform_driver(max77693_haptic_driver);
349 416
350MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>"); 417MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
351MODULE_DESCRIPTION("MAXIM MAX77693 Haptic driver"); 418MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>");
419MODULE_DESCRIPTION("MAXIM 77693/77843 Haptic driver");
352MODULE_ALIAS("platform:max77693-haptic"); 420MODULE_ALIAS("platform:max77693-haptic");
353MODULE_LICENSE("GPL"); 421MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/max77843-haptic.c b/drivers/input/misc/max77843-haptic.c
deleted file mode 100644
index dccbb465a055..000000000000
--- a/drivers/input/misc/max77843-haptic.c
+++ /dev/null
@@ -1,358 +0,0 @@
1/*
2 * MAXIM MAX77693 Haptic device driver
3 *
4 * Copyright (C) 2015 Samsung Electronics
5 * Author: Jaewon Kim <jaewon02.kim@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#include <linux/err.h>
14#include <linux/i2c.h>
15#include <linux/init.h>
16#include <linux/input.h>
17#include <linux/mfd/max77843-private.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/pwm.h>
21#include <linux/regmap.h>
22#include <linux/regulator/consumer.h>
23#include <linux/slab.h>
24#include <linux/workqueue.h>
25
26#define MAX_MAGNITUDE_SHIFT 16
27
28enum max77843_haptic_motor_type {
29 MAX77843_HAPTIC_ERM = 0,
30 MAX77843_HAPTIC_LRA,
31};
32
33enum max77843_haptic_pwm_divisor {
34 MAX77843_HAPTIC_PWM_DIVISOR_32 = 0,
35 MAX77843_HAPTIC_PWM_DIVISOR_64,
36 MAX77843_HAPTIC_PWM_DIVISOR_128,
37 MAX77843_HAPTIC_PWM_DIVISOR_256,
38};
39
40struct max77843_haptic {
41 struct regmap *regmap_haptic;
42 struct device *dev;
43 struct input_dev *input_dev;
44 struct pwm_device *pwm_dev;
45 struct regulator *motor_reg;
46 struct work_struct work;
47 struct mutex mutex;
48
49 unsigned int magnitude;
50 unsigned int pwm_duty;
51
52 bool active;
53 bool suspended;
54
55 enum max77843_haptic_motor_type type;
56 enum max77843_haptic_pwm_divisor pwm_divisor;
57};
58
59static int max77843_haptic_set_duty_cycle(struct max77843_haptic *haptic)
60{
61 int delta = (haptic->pwm_dev->period + haptic->pwm_duty) / 2;
62 int error;
63
64 error = pwm_config(haptic->pwm_dev, delta, haptic->pwm_dev->period);
65 if (error) {
66 dev_err(haptic->dev, "failed to configure pwm: %d\n", error);
67 return error;
68 }
69
70 return 0;
71}
72
73static int max77843_haptic_bias(struct max77843_haptic *haptic, bool on)
74{
75 int error;
76
77 error = regmap_update_bits(haptic->regmap_haptic,
78 MAX77843_SYS_REG_MAINCTRL1,
79 MAX77843_MAINCTRL1_BIASEN_MASK,
80 on << MAINCTRL1_BIASEN_SHIFT);
81 if (error) {
82 dev_err(haptic->dev, "failed to %s bias: %d\n",
83 on ? "enable" : "disable", error);
84 return error;
85 }
86
87 return 0;
88}
89
90static int max77843_haptic_config(struct max77843_haptic *haptic, bool enable)
91{
92 unsigned int value;
93 int error;
94
95 value = (haptic->type << MCONFIG_MODE_SHIFT) |
96 (enable << MCONFIG_MEN_SHIFT) |
97 (haptic->pwm_divisor << MCONFIG_PDIV_SHIFT);
98
99 error = regmap_write(haptic->regmap_haptic,
100 MAX77843_HAP_REG_MCONFIG, value);
101 if (error) {
102 dev_err(haptic->dev,
103 "failed to update haptic config: %d\n", error);
104 return error;
105 }
106
107 return 0;
108}
109
110static int max77843_haptic_enable(struct max77843_haptic *haptic)
111{
112 int error;
113
114 if (haptic->active)
115 return 0;
116
117 error = pwm_enable(haptic->pwm_dev);
118 if (error) {
119 dev_err(haptic->dev,
120 "failed to enable pwm device: %d\n", error);
121 return error;
122 }
123
124 error = max77843_haptic_config(haptic, true);
125 if (error)
126 goto err_config;
127
128 haptic->active = true;
129
130 return 0;
131
132err_config:
133 pwm_disable(haptic->pwm_dev);
134
135 return error;
136}
137
138static int max77843_haptic_disable(struct max77843_haptic *haptic)
139{
140 int error;
141
142 if (!haptic->active)
143 return 0;
144
145 error = max77843_haptic_config(haptic, false);
146 if (error)
147 return error;
148
149 pwm_disable(haptic->pwm_dev);
150
151 haptic->active = false;
152
153 return 0;
154}
155
156static void max77843_haptic_play_work(struct work_struct *work)
157{
158 struct max77843_haptic *haptic =
159 container_of(work, struct max77843_haptic, work);
160 int error;
161
162 mutex_lock(&haptic->mutex);
163
164 if (haptic->suspended)
165 goto out_unlock;
166
167 if (haptic->magnitude) {
168 error = max77843_haptic_set_duty_cycle(haptic);
169 if (error) {
170 dev_err(haptic->dev,
171 "failed to set duty cycle: %d\n", error);
172 goto out_unlock;
173 }
174
175 error = max77843_haptic_enable(haptic);
176 if (error)
177 dev_err(haptic->dev,
178 "cannot enable haptic: %d\n", error);
179 } else {
180 error = max77843_haptic_disable(haptic);
181 if (error)
182 dev_err(haptic->dev,
183 "cannot disable haptic: %d\n", error);
184 }
185
186out_unlock:
187 mutex_unlock(&haptic->mutex);
188}
189
190static int max77843_haptic_play_effect(struct input_dev *dev, void *data,
191 struct ff_effect *effect)
192{
193 struct max77843_haptic *haptic = input_get_drvdata(dev);
194 u64 period_mag_multi;
195
196 haptic->magnitude = effect->u.rumble.strong_magnitude;
197 if (!haptic->magnitude)
198 haptic->magnitude = effect->u.rumble.weak_magnitude;
199
200 period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
201 haptic->pwm_duty = (unsigned int)(period_mag_multi >>
202 MAX_MAGNITUDE_SHIFT);
203
204 schedule_work(&haptic->work);
205
206 return 0;
207}
208
209static int max77843_haptic_open(struct input_dev *dev)
210{
211 struct max77843_haptic *haptic = input_get_drvdata(dev);
212 int error;
213
214 error = max77843_haptic_bias(haptic, true);
215 if (error)
216 return error;
217
218 error = regulator_enable(haptic->motor_reg);
219 if (error) {
220 dev_err(haptic->dev,
221 "failed to enable regulator: %d\n", error);
222 return error;
223 }
224
225 return 0;
226}
227
228static void max77843_haptic_close(struct input_dev *dev)
229{
230 struct max77843_haptic *haptic = input_get_drvdata(dev);
231 int error;
232
233 cancel_work_sync(&haptic->work);
234 max77843_haptic_disable(haptic);
235
236 error = regulator_disable(haptic->motor_reg);
237 if (error)
238 dev_err(haptic->dev,
239 "failed to disable regulator: %d\n", error);
240
241 max77843_haptic_bias(haptic, false);
242}
243
244static int max77843_haptic_probe(struct platform_device *pdev)
245{
246 struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
247 struct max77843_haptic *haptic;
248 int error;
249
250 haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL);
251 if (!haptic)
252 return -ENOMEM;
253
254 haptic->regmap_haptic = max77843->regmap;
255 haptic->dev = &pdev->dev;
256 haptic->type = MAX77843_HAPTIC_LRA;
257 haptic->pwm_divisor = MAX77843_HAPTIC_PWM_DIVISOR_128;
258
259 INIT_WORK(&haptic->work, max77843_haptic_play_work);
260 mutex_init(&haptic->mutex);
261
262 haptic->pwm_dev = devm_pwm_get(&pdev->dev, NULL);
263 if (IS_ERR(haptic->pwm_dev)) {
264 dev_err(&pdev->dev, "failed to get pwm device\n");
265 return PTR_ERR(haptic->pwm_dev);
266 }
267
268 haptic->motor_reg = devm_regulator_get_exclusive(&pdev->dev, "haptic");
269 if (IS_ERR(haptic->motor_reg)) {
270 dev_err(&pdev->dev, "failed to get regulator\n");
271 return PTR_ERR(haptic->motor_reg);
272 }
273
274 haptic->input_dev = devm_input_allocate_device(&pdev->dev);
275 if (!haptic->input_dev) {
276 dev_err(&pdev->dev, "failed to allocate input device\n");
277 return -ENOMEM;
278 }
279
280 haptic->input_dev->name = "max77843-haptic";
281 haptic->input_dev->id.version = 1;
282 haptic->input_dev->dev.parent = &pdev->dev;
283 haptic->input_dev->open = max77843_haptic_open;
284 haptic->input_dev->close = max77843_haptic_close;
285 input_set_drvdata(haptic->input_dev, haptic);
286 input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE);
287
288 error = input_ff_create_memless(haptic->input_dev, NULL,
289 max77843_haptic_play_effect);
290 if (error) {
291 dev_err(&pdev->dev, "failed to create force-feedback\n");
292 return error;
293 }
294
295 error = input_register_device(haptic->input_dev);
296 if (error) {
297 dev_err(&pdev->dev, "failed to register input device\n");
298 return error;
299 }
300
301 platform_set_drvdata(pdev, haptic);
302
303 return 0;
304}
305
306static int __maybe_unused max77843_haptic_suspend(struct device *dev)
307{
308 struct platform_device *pdev = to_platform_device(dev);
309 struct max77843_haptic *haptic = platform_get_drvdata(pdev);
310 int error;
311
312 error = mutex_lock_interruptible(&haptic->mutex);
313 if (error)
314 return error;
315
316 max77843_haptic_disable(haptic);
317
318 haptic->suspended = true;
319
320 mutex_unlock(&haptic->mutex);
321
322 return 0;
323}
324
325static int __maybe_unused max77843_haptic_resume(struct device *dev)
326{
327 struct platform_device *pdev = to_platform_device(dev);
328 struct max77843_haptic *haptic = platform_get_drvdata(pdev);
329 unsigned int magnitude;
330
331 mutex_lock(&haptic->mutex);
332
333 haptic->suspended = false;
334
335 magnitude = ACCESS_ONCE(haptic->magnitude);
336 if (magnitude)
337 max77843_haptic_enable(haptic);
338
339 mutex_unlock(&haptic->mutex);
340
341 return 0;
342}
343
344static SIMPLE_DEV_PM_OPS(max77843_haptic_pm_ops,
345 max77843_haptic_suspend, max77843_haptic_resume);
346
347static struct platform_driver max77843_haptic_driver = {
348 .driver = {
349 .name = "max77843-haptic",
350 .pm = &max77843_haptic_pm_ops,
351 },
352 .probe = max77843_haptic_probe,
353};
354module_platform_driver(max77843_haptic_driver);
355
356MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
357MODULE_DESCRIPTION("MAXIM MAX77843 Haptic driver");
358MODULE_LICENSE("GPL");
diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c
index b8b0eec7b540..df348a06d8c7 100644
--- a/drivers/leds/leds-max77693.c
+++ b/drivers/leds/leds-max77693.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/led-class-flash.h> 14#include <linux/led-class-flash.h>
15#include <linux/mfd/max77693.h> 15#include <linux/mfd/max77693.h>
16#include <linux/mfd/max77693-common.h>
16#include <linux/mfd/max77693-private.h> 17#include <linux/mfd/max77693-private.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index cb14afa97e6f..67bc53fdc389 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -33,6 +33,7 @@
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/mfd/core.h> 34#include <linux/mfd/core.h>
35#include <linux/mfd/max77693.h> 35#include <linux/mfd/max77693.h>
36#include <linux/mfd/max77693-common.h>
36#include <linux/mfd/max77693-private.h> 37#include <linux/mfd/max77693-private.h>
37#include <linux/regulator/machine.h> 38#include <linux/regulator/machine.h>
38#include <linux/regmap.h> 39#include <linux/regmap.h>
@@ -193,22 +194,22 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
193 } else 194 } else
194 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); 195 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);
195 196
196 max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); 197 max77693->i2c_muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
197 if (!max77693->muic) { 198 if (!max77693->i2c_muic) {
198 dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n"); 199 dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n");
199 return -ENODEV; 200 return -ENODEV;
200 } 201 }
201 i2c_set_clientdata(max77693->muic, max77693); 202 i2c_set_clientdata(max77693->i2c_muic, max77693);
202 203
203 max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); 204 max77693->i2c_haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
204 if (!max77693->haptic) { 205 if (!max77693->i2c_haptic) {
205 dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n"); 206 dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n");
206 ret = -ENODEV; 207 ret = -ENODEV;
207 goto err_i2c_haptic; 208 goto err_i2c_haptic;
208 } 209 }
209 i2c_set_clientdata(max77693->haptic, max77693); 210 i2c_set_clientdata(max77693->i2c_haptic, max77693);
210 211
211 max77693->regmap_haptic = devm_regmap_init_i2c(max77693->haptic, 212 max77693->regmap_haptic = devm_regmap_init_i2c(max77693->i2c_haptic,
212 &max77693_regmap_haptic_config); 213 &max77693_regmap_haptic_config);
213 if (IS_ERR(max77693->regmap_haptic)) { 214 if (IS_ERR(max77693->regmap_haptic)) {
214 ret = PTR_ERR(max77693->regmap_haptic); 215 ret = PTR_ERR(max77693->regmap_haptic);
@@ -222,7 +223,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
222 * instance of MUIC device when irq of max77693 is initialized 223 * instance of MUIC device when irq of max77693 is initialized
223 * before call max77693-muic probe() function. 224 * before call max77693-muic probe() function.
224 */ 225 */
225 max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic, 226 max77693->regmap_muic = devm_regmap_init_i2c(max77693->i2c_muic,
226 &max77693_regmap_muic_config); 227 &max77693_regmap_muic_config);
227 if (IS_ERR(max77693->regmap_muic)) { 228 if (IS_ERR(max77693->regmap_muic)) {
228 ret = PTR_ERR(max77693->regmap_muic); 229 ret = PTR_ERR(max77693->regmap_muic);
@@ -255,7 +256,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
255 IRQF_ONESHOT | IRQF_SHARED | 256 IRQF_ONESHOT | IRQF_SHARED |
256 IRQF_TRIGGER_FALLING, 0, 257 IRQF_TRIGGER_FALLING, 0,
257 &max77693_charger_irq_chip, 258 &max77693_charger_irq_chip,
258 &max77693->irq_data_charger); 259 &max77693->irq_data_chg);
259 if (ret) { 260 if (ret) {
260 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); 261 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
261 goto err_irq_charger; 262 goto err_irq_charger;
@@ -296,15 +297,15 @@ err_mfd:
296err_intsrc: 297err_intsrc:
297 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); 298 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic);
298err_irq_muic: 299err_irq_muic:
299 regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); 300 regmap_del_irq_chip(max77693->irq, max77693->irq_data_chg);
300err_irq_charger: 301err_irq_charger:
301 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); 302 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys);
302err_irq_topsys: 303err_irq_topsys:
303 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); 304 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led);
304err_regmap: 305err_regmap:
305 i2c_unregister_device(max77693->haptic); 306 i2c_unregister_device(max77693->i2c_haptic);
306err_i2c_haptic: 307err_i2c_haptic:
307 i2c_unregister_device(max77693->muic); 308 i2c_unregister_device(max77693->i2c_muic);
308 return ret; 309 return ret;
309} 310}
310 311
@@ -315,12 +316,12 @@ static int max77693_i2c_remove(struct i2c_client *i2c)
315 mfd_remove_devices(max77693->dev); 316 mfd_remove_devices(max77693->dev);
316 317
317 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); 318 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic);
318 regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); 319 regmap_del_irq_chip(max77693->irq, max77693->irq_data_chg);
319 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); 320 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys);
320 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); 321 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led);
321 322
322 i2c_unregister_device(max77693->muic); 323 i2c_unregister_device(max77693->i2c_muic);
323 i2c_unregister_device(max77693->haptic); 324 i2c_unregister_device(max77693->i2c_haptic);
324 325
325 return 0; 326 return 0;
326} 327}
diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c
index a354ac677ec7..c52162ea3d0a 100644
--- a/drivers/mfd/max77843.c
+++ b/drivers/mfd/max77843.c
@@ -17,6 +17,7 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
20#include <linux/mfd/max77693-common.h>
20#include <linux/mfd/max77843-private.h> 21#include <linux/mfd/max77843-private.h>
21#include <linux/of_device.h> 22#include <linux/of_device.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
@@ -71,7 +72,7 @@ static const struct regmap_irq_chip max77843_irq_chip = {
71}; 72};
72 73
73/* Charger and Charger regulator use same regmap. */ 74/* Charger and Charger regulator use same regmap. */
74static int max77843_chg_init(struct max77843 *max77843) 75static int max77843_chg_init(struct max77693_dev *max77843)
75{ 76{
76 int ret; 77 int ret;
77 78
@@ -101,7 +102,7 @@ err_chg_i2c:
101static int max77843_probe(struct i2c_client *i2c, 102static int max77843_probe(struct i2c_client *i2c,
102 const struct i2c_device_id *id) 103 const struct i2c_device_id *id)
103{ 104{
104 struct max77843 *max77843; 105 struct max77693_dev *max77843;
105 unsigned int reg_data; 106 unsigned int reg_data;
106 int ret; 107 int ret;
107 108
@@ -113,6 +114,7 @@ static int max77843_probe(struct i2c_client *i2c,
113 max77843->dev = &i2c->dev; 114 max77843->dev = &i2c->dev;
114 max77843->i2c = i2c; 115 max77843->i2c = i2c;
115 max77843->irq = i2c->irq; 116 max77843->irq = i2c->irq;
117 max77843->type = id->driver_data;
116 118
117 max77843->regmap = devm_regmap_init_i2c(i2c, 119 max77843->regmap = devm_regmap_init_i2c(i2c,
118 &max77843_regmap_config); 120 &max77843_regmap_config);
@@ -123,7 +125,7 @@ static int max77843_probe(struct i2c_client *i2c,
123 125
124 ret = regmap_add_irq_chip(max77843->regmap, max77843->irq, 126 ret = regmap_add_irq_chip(max77843->regmap, max77843->irq,
125 IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, 127 IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED,
126 0, &max77843_irq_chip, &max77843->irq_data); 128 0, &max77843_irq_chip, &max77843->irq_data_topsys);
127 if (ret) { 129 if (ret) {
128 dev_err(&i2c->dev, "Failed to add TOPSYS IRQ chip\n"); 130 dev_err(&i2c->dev, "Failed to add TOPSYS IRQ chip\n");
129 return ret; 131 return ret;
@@ -164,18 +166,18 @@ static int max77843_probe(struct i2c_client *i2c,
164 return 0; 166 return 0;
165 167
166err_pmic_id: 168err_pmic_id:
167 regmap_del_irq_chip(max77843->irq, max77843->irq_data); 169 regmap_del_irq_chip(max77843->irq, max77843->irq_data_topsys);
168 170
169 return ret; 171 return ret;
170} 172}
171 173
172static int max77843_remove(struct i2c_client *i2c) 174static int max77843_remove(struct i2c_client *i2c)
173{ 175{
174 struct max77843 *max77843 = i2c_get_clientdata(i2c); 176 struct max77693_dev *max77843 = i2c_get_clientdata(i2c);
175 177
176 mfd_remove_devices(max77843->dev); 178 mfd_remove_devices(max77843->dev);
177 179
178 regmap_del_irq_chip(max77843->irq, max77843->irq_data); 180 regmap_del_irq_chip(max77843->irq, max77843->irq_data_topsys);
179 181
180 i2c_unregister_device(max77843->i2c_chg); 182 i2c_unregister_device(max77843->i2c_chg);
181 183
@@ -188,7 +190,7 @@ static const struct of_device_id max77843_dt_match[] = {
188}; 190};
189 191
190static const struct i2c_device_id max77843_id[] = { 192static const struct i2c_device_id max77843_id[] = {
191 { "max77843", }, 193 { "max77843", TYPE_MAX77843, },
192 { }, 194 { },
193}; 195};
194MODULE_DEVICE_TABLE(i2c, max77843_id); 196MODULE_DEVICE_TABLE(i2c, max77843_id);
@@ -196,7 +198,7 @@ MODULE_DEVICE_TABLE(i2c, max77843_id);
196static int __maybe_unused max77843_suspend(struct device *dev) 198static int __maybe_unused max77843_suspend(struct device *dev)
197{ 199{
198 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); 200 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
199 struct max77843 *max77843 = i2c_get_clientdata(i2c); 201 struct max77693_dev *max77843 = i2c_get_clientdata(i2c);
200 202
201 disable_irq(max77843->irq); 203 disable_irq(max77843->irq);
202 if (device_may_wakeup(dev)) 204 if (device_may_wakeup(dev))
@@ -208,7 +210,7 @@ static int __maybe_unused max77843_suspend(struct device *dev)
208static int __maybe_unused max77843_resume(struct device *dev) 210static int __maybe_unused max77843_resume(struct device *dev)
209{ 211{
210 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); 212 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
211 struct max77843 *max77843 = i2c_get_clientdata(i2c); 213 struct max77693_dev *max77843 = i2c_get_clientdata(i2c);
212 214
213 if (device_may_wakeup(dev)) 215 if (device_may_wakeup(dev))
214 disable_irq_wake(max77843->irq); 216 disable_irq_wake(max77843->irq);
diff --git a/drivers/power/max77693_charger.c b/drivers/power/max77693_charger.c
index 754879eb59f6..060cab5ae3aa 100644
--- a/drivers/power/max77693_charger.c
+++ b/drivers/power/max77693_charger.c
@@ -20,6 +20,7 @@
20#include <linux/power_supply.h> 20#include <linux/power_supply.h>
21#include <linux/regmap.h> 21#include <linux/regmap.h>
22#include <linux/mfd/max77693.h> 22#include <linux/mfd/max77693.h>
23#include <linux/mfd/max77693-common.h>
23#include <linux/mfd/max77693-private.h> 24#include <linux/mfd/max77693-private.h>
24 25
25#define MAX77693_CHARGER_NAME "max77693-charger" 26#define MAX77693_CHARGER_NAME "max77693-charger"
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 23496da101de..a7b81f0185b5 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -407,13 +407,13 @@ config REGULATOR_MAX77686
407 Exynos-4 chips to control VARM and VINT voltages. 407 Exynos-4 chips to control VARM and VINT voltages.
408 408
409config REGULATOR_MAX77693 409config REGULATOR_MAX77693
410 tristate "Maxim MAX77693 regulator" 410 tristate "Maxim 77693/77843 regulator"
411 depends on MFD_MAX77693 411 depends on (MFD_MAX77693 || MFD_MAX77843)
412 help 412 help
413 This driver controls a Maxim 77693 regulator via I2C bus. 413 This driver controls a Maxim 77693/77843 regulators via I2C bus.
414 The regulators include two LDOs, 'SAFEOUT1', 'SAFEOUT2' 414 The regulators include two LDOs, 'SAFEOUT1', 'SAFEOUT2'
415 and one current regulator 'CHARGER'. This is suitable for 415 and one current regulator 'CHARGER'. This is suitable for
416 Exynos-4x12 chips. 416 Exynos-4x12 (MAX77693) or Exynos5433 (MAX77843) SoC chips.
417 417
418config REGULATOR_MAX77802 418config REGULATOR_MAX77802
419 tristate "Maxim 77802 regulator" 419 tristate "Maxim 77802 regulator"
@@ -424,14 +424,6 @@ config REGULATOR_MAX77802
424 Exynos5420/Exynos5800 SoCs to control various voltages. 424 Exynos5420/Exynos5800 SoCs to control various voltages.
425 It includes support for control of voltage and ramp speed. 425 It includes support for control of voltage and ramp speed.
426 426
427config REGULATOR_MAX77843
428 tristate "Maxim 77843 regulator"
429 depends on MFD_MAX77843
430 help
431 This driver controls a Maxim 77843 regulator.
432 The regulator include two 'SAFEOUT' for USB(Universal Serial Bus)
433 This is suitable for Exynos5433 SoC chips.
434
435config REGULATOR_MC13XXX_CORE 427config REGULATOR_MC13XXX_CORE
436 tristate 428 tristate
437 429
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 91bf76267404..6429e629dcb6 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -56,7 +56,6 @@ obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
56obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o 56obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o
57obj-$(CONFIG_REGULATOR_MAX77693) += max77693.o 57obj-$(CONFIG_REGULATOR_MAX77693) += max77693.o
58obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o 58obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o
59obj-$(CONFIG_REGULATOR_MAX77843) += max77843.o
60obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o 59obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
61obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o 60obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
62obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o 61obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 3de328ab41f3..8702e7384af7 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -849,7 +849,7 @@ static struct lp872x_platform_data
849 849
850 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 850 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
851 if (!pdata) 851 if (!pdata)
852 goto out; 852 return ERR_PTR(-ENOMEM);
853 853
854 of_property_read_u8(np, "ti,general-config", &pdata->general_config); 854 of_property_read_u8(np, "ti,general-config", &pdata->general_config);
855 if (of_find_property(np, "ti,update-config", NULL)) 855 if (of_find_property(np, "ti,update-config", NULL))
@@ -857,7 +857,7 @@ static struct lp872x_platform_data
857 857
858 pdata->dvs = devm_kzalloc(dev, sizeof(struct lp872x_dvs), GFP_KERNEL); 858 pdata->dvs = devm_kzalloc(dev, sizeof(struct lp872x_dvs), GFP_KERNEL);
859 if (!pdata->dvs) 859 if (!pdata->dvs)
860 goto out; 860 return ERR_PTR(-ENOMEM);
861 861
862 pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0); 862 pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0);
863 of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); 863 of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel);
@@ -903,15 +903,21 @@ static struct lp872x_platform_data
903static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) 903static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
904{ 904{
905 struct lp872x *lp; 905 struct lp872x *lp;
906 struct lp872x_platform_data *pdata;
906 int ret; 907 int ret;
907 const int lp872x_num_regulators[] = { 908 const int lp872x_num_regulators[] = {
908 [LP8720] = LP8720_NUM_REGULATORS, 909 [LP8720] = LP8720_NUM_REGULATORS,
909 [LP8725] = LP8725_NUM_REGULATORS, 910 [LP8725] = LP8725_NUM_REGULATORS,
910 }; 911 };
911 912
912 if (cl->dev.of_node) 913 if (cl->dev.of_node) {
913 cl->dev.platform_data = lp872x_populate_pdata_from_dt(&cl->dev, 914 pdata = lp872x_populate_pdata_from_dt(&cl->dev,
914 (enum lp872x_id)id->driver_data); 915 (enum lp872x_id)id->driver_data);
916 if (IS_ERR(pdata))
917 return PTR_ERR(pdata);
918 } else {
919 pdata = dev_get_platdata(&cl->dev);
920 }
915 921
916 lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); 922 lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL);
917 if (!lp) 923 if (!lp)
@@ -927,7 +933,7 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
927 } 933 }
928 934
929 lp->dev = &cl->dev; 935 lp->dev = &cl->dev;
930 lp->pdata = dev_get_platdata(&cl->dev); 936 lp->pdata = pdata;
931 lp->chipid = id->driver_data; 937 lp->chipid = id->driver_data;
932 i2c_set_clientdata(cl, lp); 938 i2c_set_clientdata(cl, lp);
933 939
diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c
index 0ce8e4e0fa73..cc22ac66c8fd 100644
--- a/drivers/regulator/ltc3589.c
+++ b/drivers/regulator/ltc3589.c
@@ -378,7 +378,7 @@ static bool ltc3589_volatile_reg(struct device *dev, unsigned int reg)
378 return false; 378 return false;
379} 379}
380 380
381static struct reg_default ltc3589_reg_defaults[] = { 381static const struct reg_default ltc3589_reg_defaults[] = {
382 { LTC3589_SCR1, 0x00 }, 382 { LTC3589_SCR1, 0x00 },
383 { LTC3589_OVEN, 0x00 }, 383 { LTC3589_OVEN, 0x00 },
384 { LTC3589_SCR2, 0x00 }, 384 { LTC3589_SCR2, 0x00 },
@@ -552,4 +552,3 @@ module_i2c_driver(ltc3589_driver);
552MODULE_AUTHOR("Philipp Zabel <p.zabel@pengutronix.de>"); 552MODULE_AUTHOR("Philipp Zabel <p.zabel@pengutronix.de>");
553MODULE_DESCRIPTION("Regulator driver for Linear Technology LTC3589(-1,2)"); 553MODULE_DESCRIPTION("Regulator driver for Linear Technology LTC3589(-1,2)");
554MODULE_LICENSE("GPL v2"); 554MODULE_LICENSE("GPL v2");
555MODULE_ALIAS("i2c:ltc3589");
diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c
index 38722c8311a5..de730fd3f8a5 100644
--- a/drivers/regulator/max77693.c
+++ b/drivers/regulator/max77693.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * max77693.c - Regulator driver for the Maxim 77693 2 * max77693.c - Regulator driver for the Maxim 77693 and 77843
3 * 3 *
4 * Copyright (C) 2013 Samsung Electronics 4 * Copyright (C) 2013-2015 Samsung Electronics
5 * Jonghwa Lee <jonghwa3.lee@samsung.com> 5 * Jonghwa Lee <jonghwa3.lee@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -29,38 +30,64 @@
29#include <linux/regulator/driver.h> 30#include <linux/regulator/driver.h>
30#include <linux/regulator/machine.h> 31#include <linux/regulator/machine.h>
31#include <linux/mfd/max77693.h> 32#include <linux/mfd/max77693.h>
33#include <linux/mfd/max77693-common.h>
32#include <linux/mfd/max77693-private.h> 34#include <linux/mfd/max77693-private.h>
35#include <linux/mfd/max77843-private.h>
33#include <linux/regulator/of_regulator.h> 36#include <linux/regulator/of_regulator.h>
34#include <linux/regmap.h> 37#include <linux/regmap.h>
35 38
36#define CHGIN_ILIM_STEP_20mA 20000 39/*
40 * ID for MAX77843 regulators.
41 * There is no need for such for MAX77693.
42 */
43enum max77843_regulator_type {
44 MAX77843_SAFEOUT1 = 0,
45 MAX77843_SAFEOUT2,
46 MAX77843_CHARGER,
47
48 MAX77843_NUM,
49};
50
51/* Register differences between chargers: MAX77693 and MAX77843 */
52struct chg_reg_data {
53 unsigned int linear_reg;
54 unsigned int linear_mask;
55 unsigned int uA_step;
56 unsigned int min_sel;
57};
37 58
38/* 59/*
39 * CHARGER regulator - Min : 20mA, Max : 2580mA, step : 20mA 60 * MAX77693 CHARGER regulator - Min : 20mA, Max : 2580mA, step : 20mA
40 * 0x00, 0x01, 0x2, 0x03 = 60 mA 61 * 0x00, 0x01, 0x2, 0x03 = 60 mA
41 * 0x04 ~ 0x7E = (60 + (X - 3) * 20) mA 62 * 0x04 ~ 0x7E = (60 + (X - 3) * 20) mA
63 * Actually for MAX77693 the driver manipulates the maximum input current,
64 * not the fast charge current (output). This should be fixed.
65 *
66 * On MAX77843 the calculation formula is the same (except values).
67 * Fortunately it properly manipulates the fast charge current.
42 */ 68 */
43static int max77693_chg_get_current_limit(struct regulator_dev *rdev) 69static int max77693_chg_get_current_limit(struct regulator_dev *rdev)
44{ 70{
71 const struct chg_reg_data *reg_data = rdev_get_drvdata(rdev);
45 unsigned int chg_min_uA = rdev->constraints->min_uA; 72 unsigned int chg_min_uA = rdev->constraints->min_uA;
46 unsigned int chg_max_uA = rdev->constraints->max_uA; 73 unsigned int chg_max_uA = rdev->constraints->max_uA;
47 unsigned int reg, sel; 74 unsigned int reg, sel;
48 unsigned int val; 75 unsigned int val;
49 int ret; 76 int ret;
50 77
51 ret = regmap_read(rdev->regmap, MAX77693_CHG_REG_CHG_CNFG_09, &reg); 78 ret = regmap_read(rdev->regmap, reg_data->linear_reg, &reg);
52 if (ret < 0) 79 if (ret < 0)
53 return ret; 80 return ret;
54 81
55 sel = reg & CHG_CNFG_09_CHGIN_ILIM_MASK; 82 sel = reg & reg_data->linear_mask;
56 83
57 /* the first four codes for charger current are all 60mA */ 84 /* the first four codes for charger current are all 60mA */
58 if (sel <= 3) 85 if (sel <= reg_data->min_sel)
59 sel = 0; 86 sel = 0;
60 else 87 else
61 sel -= 3; 88 sel -= reg_data->min_sel;
62 89
63 val = chg_min_uA + CHGIN_ILIM_STEP_20mA * sel; 90 val = chg_min_uA + reg_data->uA_step * sel;
64 if (val > chg_max_uA) 91 if (val > chg_max_uA)
65 return -EINVAL; 92 return -EINVAL;
66 93
@@ -70,23 +97,43 @@ static int max77693_chg_get_current_limit(struct regulator_dev *rdev)
70static int max77693_chg_set_current_limit(struct regulator_dev *rdev, 97static int max77693_chg_set_current_limit(struct regulator_dev *rdev,
71 int min_uA, int max_uA) 98 int min_uA, int max_uA)
72{ 99{
100 const struct chg_reg_data *reg_data = rdev_get_drvdata(rdev);
73 unsigned int chg_min_uA = rdev->constraints->min_uA; 101 unsigned int chg_min_uA = rdev->constraints->min_uA;
74 int sel = 0; 102 int sel = 0;
75 103
76 while (chg_min_uA + CHGIN_ILIM_STEP_20mA * sel < min_uA) 104 while (chg_min_uA + reg_data->uA_step * sel < min_uA)
77 sel++; 105 sel++;
78 106
79 if (chg_min_uA + CHGIN_ILIM_STEP_20mA * sel > max_uA) 107 if (chg_min_uA + reg_data->uA_step * sel > max_uA)
80 return -EINVAL; 108 return -EINVAL;
81 109
82 /* the first four codes for charger current are all 60mA */ 110 /* the first four codes for charger current are all 60mA */
83 sel += 3; 111 sel += reg_data->min_sel;
84 112
85 return regmap_write(rdev->regmap, 113 return regmap_write(rdev->regmap, reg_data->linear_reg, sel);
86 MAX77693_CHG_REG_CHG_CNFG_09, sel);
87} 114}
88/* end of CHARGER regulator ops */ 115/* end of CHARGER regulator ops */
89 116
117/* Returns regmap suitable for given regulator on chosen device */
118static struct regmap *max77693_get_regmap(enum max77693_types type,
119 struct max77693_dev *max77693,
120 int reg_id)
121{
122 if (type == TYPE_MAX77693)
123 return max77693->regmap;
124
125 /* Else: TYPE_MAX77843 */
126 switch (reg_id) {
127 case MAX77843_SAFEOUT1:
128 case MAX77843_SAFEOUT2:
129 return max77693->regmap;
130 case MAX77843_CHARGER:
131 return max77693->regmap_chg;
132 default:
133 return max77693->regmap;
134 }
135}
136
90static const unsigned int max77693_safeout_table[] = { 137static const unsigned int max77693_safeout_table[] = {
91 4850000, 138 4850000,
92 4900000, 139 4900000,
@@ -111,7 +158,7 @@ static struct regulator_ops max77693_charger_ops = {
111 .set_current_limit = max77693_chg_set_current_limit, 158 .set_current_limit = max77693_chg_set_current_limit,
112}; 159};
113 160
114#define regulator_desc_esafeout(_num) { \ 161#define max77693_regulator_desc_esafeout(_num) { \
115 .name = "ESAFEOUT"#_num, \ 162 .name = "ESAFEOUT"#_num, \
116 .id = MAX77693_ESAFEOUT##_num, \ 163 .id = MAX77693_ESAFEOUT##_num, \
117 .of_match = of_match_ptr("ESAFEOUT"#_num), \ 164 .of_match = of_match_ptr("ESAFEOUT"#_num), \
@@ -127,9 +174,9 @@ static struct regulator_ops max77693_charger_ops = {
127 .enable_mask = SAFEOUT_CTRL_ENSAFEOUT##_num##_MASK , \ 174 .enable_mask = SAFEOUT_CTRL_ENSAFEOUT##_num##_MASK , \
128} 175}
129 176
130static const struct regulator_desc regulators[] = { 177static const struct regulator_desc max77693_supported_regulators[] = {
131 regulator_desc_esafeout(1), 178 max77693_regulator_desc_esafeout(1),
132 regulator_desc_esafeout(2), 179 max77693_regulator_desc_esafeout(2),
133 { 180 {
134 .name = "CHARGER", 181 .name = "CHARGER",
135 .id = MAX77693_CHARGER, 182 .id = MAX77693_CHARGER,
@@ -145,18 +192,86 @@ static const struct regulator_desc regulators[] = {
145 }, 192 },
146}; 193};
147 194
195static const struct chg_reg_data max77693_chg_reg_data = {
196 .linear_reg = MAX77693_CHG_REG_CHG_CNFG_09,
197 .linear_mask = CHG_CNFG_09_CHGIN_ILIM_MASK,
198 .uA_step = 20000,
199 .min_sel = 3,
200};
201
202#define max77843_regulator_desc_esafeout(num) { \
203 .name = "SAFEOUT" # num, \
204 .id = MAX77843_SAFEOUT ## num, \
205 .ops = &max77693_safeout_ops, \
206 .of_match = of_match_ptr("SAFEOUT" # num), \
207 .regulators_node = of_match_ptr("regulators"), \
208 .type = REGULATOR_VOLTAGE, \
209 .owner = THIS_MODULE, \
210 .n_voltages = ARRAY_SIZE(max77693_safeout_table), \
211 .volt_table = max77693_safeout_table, \
212 .enable_reg = MAX77843_SYS_REG_SAFEOUTCTRL, \
213 .enable_mask = MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT ## num, \
214 .vsel_reg = MAX77843_SYS_REG_SAFEOUTCTRL, \
215 .vsel_mask = MAX77843_REG_SAFEOUTCTRL_SAFEOUT ## num ## _MASK, \
216}
217
218static const struct regulator_desc max77843_supported_regulators[] = {
219 [MAX77843_SAFEOUT1] = max77843_regulator_desc_esafeout(1),
220 [MAX77843_SAFEOUT2] = max77843_regulator_desc_esafeout(2),
221 [MAX77843_CHARGER] = {
222 .name = "CHARGER",
223 .id = MAX77843_CHARGER,
224 .ops = &max77693_charger_ops,
225 .of_match = of_match_ptr("CHARGER"),
226 .regulators_node = of_match_ptr("regulators"),
227 .type = REGULATOR_CURRENT,
228 .owner = THIS_MODULE,
229 .enable_reg = MAX77843_CHG_REG_CHG_CNFG_00,
230 .enable_mask = MAX77843_CHG_MASK,
231 .enable_val = MAX77843_CHG_MASK,
232 },
233};
234
235static const struct chg_reg_data max77843_chg_reg_data = {
236 .linear_reg = MAX77843_CHG_REG_CHG_CNFG_02,
237 .linear_mask = MAX77843_CHG_FAST_CHG_CURRENT_MASK,
238 .uA_step = MAX77843_CHG_FAST_CHG_CURRENT_STEP,
239 .min_sel = 2,
240};
241
148static int max77693_pmic_probe(struct platform_device *pdev) 242static int max77693_pmic_probe(struct platform_device *pdev)
149{ 243{
244 enum max77693_types type = platform_get_device_id(pdev)->driver_data;
150 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); 245 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);
246 const struct regulator_desc *regulators;
247 unsigned int regulators_size;
151 int i; 248 int i;
152 struct regulator_config config = { }; 249 struct regulator_config config = { };
153 250
154 config.dev = iodev->dev; 251 config.dev = iodev->dev;
155 config.regmap = iodev->regmap;
156 252
157 for (i = 0; i < ARRAY_SIZE(regulators); i++) { 253 switch (type) {
254 case TYPE_MAX77693:
255 regulators = max77693_supported_regulators;
256 regulators_size = ARRAY_SIZE(max77693_supported_regulators);
257 config.driver_data = (void *)&max77693_chg_reg_data;
258 break;
259 case TYPE_MAX77843:
260 regulators = max77843_supported_regulators;
261 regulators_size = ARRAY_SIZE(max77843_supported_regulators);
262 config.driver_data = (void *)&max77843_chg_reg_data;
263 break;
264 default:
265 dev_err(&pdev->dev, "Unsupported device type: %u\n", type);
266 return -ENODEV;
267 }
268
269 for (i = 0; i < regulators_size; i++) {
158 struct regulator_dev *rdev; 270 struct regulator_dev *rdev;
159 271
272 config.regmap = max77693_get_regmap(type, iodev,
273 regulators[i].id);
274
160 rdev = devm_regulator_register(&pdev->dev, 275 rdev = devm_regulator_register(&pdev->dev,
161 &regulators[i], &config); 276 &regulators[i], &config);
162 if (IS_ERR(rdev)) { 277 if (IS_ERR(rdev)) {
@@ -170,7 +285,8 @@ static int max77693_pmic_probe(struct platform_device *pdev)
170} 285}
171 286
172static const struct platform_device_id max77693_pmic_id[] = { 287static const struct platform_device_id max77693_pmic_id[] = {
173 {"max77693-pmic", 0}, 288 { "max77693-pmic", TYPE_MAX77693 },
289 { "max77843-regulator", TYPE_MAX77843 },
174 {}, 290 {},
175}; 291};
176 292
@@ -184,8 +300,19 @@ static struct platform_driver max77693_pmic_driver = {
184 .id_table = max77693_pmic_id, 300 .id_table = max77693_pmic_id,
185}; 301};
186 302
187module_platform_driver(max77693_pmic_driver); 303static int __init max77693_pmic_init(void)
304{
305 return platform_driver_register(&max77693_pmic_driver);
306}
307subsys_initcall(max77693_pmic_init);
308
309static void __exit max77693_pmic_cleanup(void)
310{
311 platform_driver_unregister(&max77693_pmic_driver);
312}
313module_exit(max77693_pmic_cleanup);
188 314
189MODULE_DESCRIPTION("MAXIM MAX77693 regulator driver"); 315MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver");
190MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>"); 316MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>");
317MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski.k@gmail.com>");
191MODULE_LICENSE("GPL"); 318MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/max77843.c b/drivers/regulator/max77843.c
deleted file mode 100644
index f4fd0d3cfa6e..000000000000
--- a/drivers/regulator/max77843.c
+++ /dev/null
@@ -1,201 +0,0 @@
1/*
2 * max77843.c - Regulator driver for the Maxim MAX77843
3 *
4 * Copyright (C) 2015 Samsung Electronics
5 * Author: Jaewon Kim <jaewon02.kim@samsung.com>
6 * Author: Beomho Seo <beomho.seo@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/module.h>
15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h>
18#include <linux/mfd/max77843-private.h>
19#include <linux/regulator/of_regulator.h>
20
21enum max77843_regulator_type {
22 MAX77843_SAFEOUT1 = 0,
23 MAX77843_SAFEOUT2,
24 MAX77843_CHARGER,
25
26 MAX77843_NUM,
27};
28
29static const unsigned int max77843_safeout_voltage_table[] = {
30 4850000,
31 4900000,
32 4950000,
33 3300000,
34};
35
36static int max77843_reg_get_current_limit(struct regulator_dev *rdev)
37{
38 struct regmap *regmap = rdev->regmap;
39 unsigned int chg_min_uA = rdev->constraints->min_uA;
40 unsigned int chg_max_uA = rdev->constraints->max_uA;
41 unsigned int val;
42 int ret;
43 unsigned int reg, sel;
44
45 ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_CNFG_02, &reg);
46 if (ret) {
47 dev_err(&rdev->dev, "Failed to read charger register\n");
48 return ret;
49 }
50
51 sel = reg & MAX77843_CHG_FAST_CHG_CURRENT_MASK;
52
53 if (sel < 0x03)
54 sel = 0;
55 else
56 sel -= 2;
57
58 val = chg_min_uA + MAX77843_CHG_FAST_CHG_CURRENT_STEP * sel;
59 if (val > chg_max_uA)
60 return -EINVAL;
61
62 return val;
63}
64
65static int max77843_reg_set_current_limit(struct regulator_dev *rdev,
66 int min_uA, int max_uA)
67{
68 struct regmap *regmap = rdev->regmap;
69 unsigned int chg_min_uA = rdev->constraints->min_uA;
70 int sel = 0;
71
72 while (chg_min_uA + MAX77843_CHG_FAST_CHG_CURRENT_STEP * sel < min_uA)
73 sel++;
74
75 if (chg_min_uA + MAX77843_CHG_FAST_CHG_CURRENT_STEP * sel > max_uA)
76 return -EINVAL;
77
78 sel += 2;
79
80 return regmap_write(regmap, MAX77843_CHG_REG_CHG_CNFG_02, sel);
81}
82
83static struct regulator_ops max77843_charger_ops = {
84 .is_enabled = regulator_is_enabled_regmap,
85 .enable = regulator_enable_regmap,
86 .disable = regulator_disable_regmap,
87 .get_current_limit = max77843_reg_get_current_limit,
88 .set_current_limit = max77843_reg_set_current_limit,
89};
90
91static struct regulator_ops max77843_regulator_ops = {
92 .is_enabled = regulator_is_enabled_regmap,
93 .enable = regulator_enable_regmap,
94 .disable = regulator_disable_regmap,
95 .list_voltage = regulator_list_voltage_table,
96 .get_voltage_sel = regulator_get_voltage_sel_regmap,
97 .set_voltage_sel = regulator_set_voltage_sel_regmap,
98};
99
100#define MAX77843_SAFEOUT(num) { \
101 .name = "SAFEOUT" # num, \
102 .id = MAX77843_SAFEOUT ## num, \
103 .ops = &max77843_regulator_ops, \
104 .of_match = of_match_ptr("SAFEOUT" # num), \
105 .regulators_node = of_match_ptr("regulators"), \
106 .type = REGULATOR_VOLTAGE, \
107 .owner = THIS_MODULE, \
108 .n_voltages = ARRAY_SIZE(max77843_safeout_voltage_table), \
109 .volt_table = max77843_safeout_voltage_table, \
110 .enable_reg = MAX77843_SYS_REG_SAFEOUTCTRL, \
111 .enable_mask = MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT ## num, \
112 .vsel_reg = MAX77843_SYS_REG_SAFEOUTCTRL, \
113 .vsel_mask = MAX77843_REG_SAFEOUTCTRL_SAFEOUT ## num ## _MASK, \
114}
115
116static const struct regulator_desc max77843_supported_regulators[] = {
117 [MAX77843_SAFEOUT1] = MAX77843_SAFEOUT(1),
118 [MAX77843_SAFEOUT2] = MAX77843_SAFEOUT(2),
119 [MAX77843_CHARGER] = {
120 .name = "CHARGER",
121 .id = MAX77843_CHARGER,
122 .ops = &max77843_charger_ops,
123 .of_match = of_match_ptr("CHARGER"),
124 .regulators_node = of_match_ptr("regulators"),
125 .type = REGULATOR_CURRENT,
126 .owner = THIS_MODULE,
127 .enable_reg = MAX77843_CHG_REG_CHG_CNFG_00,
128 .enable_mask = MAX77843_CHG_MASK | MAX77843_CHG_BUCK_MASK,
129 .enable_val = MAX77843_CHG_MASK | MAX77843_CHG_BUCK_MASK,
130 },
131};
132
133static struct regmap *max77843_get_regmap(struct max77843 *max77843, int reg_id)
134{
135 switch (reg_id) {
136 case MAX77843_SAFEOUT1:
137 case MAX77843_SAFEOUT2:
138 return max77843->regmap;
139 case MAX77843_CHARGER:
140 return max77843->regmap_chg;
141 default:
142 return max77843->regmap;
143 }
144}
145
146static int max77843_regulator_probe(struct platform_device *pdev)
147{
148 struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
149 struct regulator_config config = {};
150 int i;
151
152 config.dev = max77843->dev;
153 config.driver_data = max77843;
154
155 for (i = 0; i < ARRAY_SIZE(max77843_supported_regulators); i++) {
156 struct regulator_dev *regulator;
157
158 config.regmap = max77843_get_regmap(max77843,
159 max77843_supported_regulators[i].id);
160
161 regulator = devm_regulator_register(&pdev->dev,
162 &max77843_supported_regulators[i], &config);
163 if (IS_ERR(regulator)) {
164 dev_err(&pdev->dev,
165 "Failed to regiser regulator-%d\n", i);
166 return PTR_ERR(regulator);
167 }
168 }
169
170 return 0;
171}
172
173static const struct platform_device_id max77843_regulator_id[] = {
174 { "max77843-regulator", },
175 { /* sentinel */ },
176};
177
178static struct platform_driver max77843_regulator_driver = {
179 .driver = {
180 .name = "max77843-regulator",
181 },
182 .probe = max77843_regulator_probe,
183 .id_table = max77843_regulator_id,
184};
185
186static int __init max77843_regulator_init(void)
187{
188 return platform_driver_register(&max77843_regulator_driver);
189}
190subsys_initcall(max77843_regulator_init);
191
192static void __exit max77843_regulator_exit(void)
193{
194 platform_driver_unregister(&max77843_regulator_driver);
195}
196module_exit(max77843_regulator_exit);
197
198MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
199MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
200MODULE_DESCRIPTION("Maxim MAX77843 regulator driver");
201MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index e94ddcf97722..8857cc02d9a8 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -75,6 +75,7 @@
75#define MAX8973_DISCH_ENBABLE BIT(5) 75#define MAX8973_DISCH_ENBABLE BIT(5)
76#define MAX8973_FT_ENABLE BIT(4) 76#define MAX8973_FT_ENABLE BIT(4)
77 77
78#define MAX8973_CKKADV_TRIP_MASK 0xC
78#define MAX8973_CKKADV_TRIP_DISABLE 0xC 79#define MAX8973_CKKADV_TRIP_DISABLE 0xC
79#define MAX8973_CKKADV_TRIP_75mV_PER_US 0x0 80#define MAX8973_CKKADV_TRIP_75mV_PER_US 0x0
80#define MAX8973_CKKADV_TRIP_150mV_PER_US 0x4 81#define MAX8973_CKKADV_TRIP_150mV_PER_US 0x4
@@ -282,6 +283,55 @@ static int max8973_set_ramp_delay(struct regulator_dev *rdev,
282 return ret; 283 return ret;
283} 284}
284 285
286static int max8973_set_current_limit(struct regulator_dev *rdev,
287 int min_ua, int max_ua)
288{
289 struct max8973_chip *max = rdev_get_drvdata(rdev);
290 unsigned int val;
291 int ret;
292
293 if (max_ua <= 9000000)
294 val = MAX8973_CKKADV_TRIP_75mV_PER_US;
295 else if (max_ua <= 12000000)
296 val = MAX8973_CKKADV_TRIP_150mV_PER_US;
297 else
298 val = MAX8973_CKKADV_TRIP_DISABLE;
299
300 ret = regmap_update_bits(max->regmap, MAX8973_CONTROL2,
301 MAX8973_CKKADV_TRIP_MASK, val);
302 if (ret < 0) {
303 dev_err(max->dev, "register %d update failed: %d\n",
304 MAX8973_CONTROL2, ret);
305 return ret;
306 }
307 return 0;
308}
309
310static int max8973_get_current_limit(struct regulator_dev *rdev)
311{
312 struct max8973_chip *max = rdev_get_drvdata(rdev);
313 unsigned int control2;
314 int ret;
315
316 ret = regmap_read(max->regmap, MAX8973_CONTROL2, &control2);
317 if (ret < 0) {
318 dev_err(max->dev, "register %d read failed: %d\n",
319 MAX8973_CONTROL2, ret);
320 return ret;
321 }
322 switch (control2 & MAX8973_CKKADV_TRIP_MASK) {
323 case MAX8973_CKKADV_TRIP_DISABLE:
324 return 15000000;
325 case MAX8973_CKKADV_TRIP_150mV_PER_US:
326 return 12000000;
327 case MAX8973_CKKADV_TRIP_75mV_PER_US:
328 return 9000000;
329 default:
330 break;
331 }
332 return 9000000;
333}
334
285static const struct regulator_ops max8973_dcdc_ops = { 335static const struct regulator_ops max8973_dcdc_ops = {
286 .get_voltage_sel = max8973_dcdc_get_voltage_sel, 336 .get_voltage_sel = max8973_dcdc_get_voltage_sel,
287 .set_voltage_sel = max8973_dcdc_set_voltage_sel, 337 .set_voltage_sel = max8973_dcdc_set_voltage_sel,
@@ -421,6 +471,8 @@ static struct max8973_regulator_platform_data *max8973_parse_dt(
421 struct device_node *np = dev->of_node; 471 struct device_node *np = dev->of_node;
422 int ret; 472 int ret;
423 u32 pval; 473 u32 pval;
474 bool etr_enable;
475 bool etr_sensitivity_high;
424 476
425 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 477 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
426 if (!pdata) 478 if (!pdata)
@@ -452,6 +504,23 @@ static struct max8973_regulator_platform_data *max8973_parse_dt(
452 if (of_property_read_bool(np, "maxim,enable-bias-control")) 504 if (of_property_read_bool(np, "maxim,enable-bias-control"))
453 pdata->control_flags |= MAX8973_CONTROL_BIAS_ENABLE; 505 pdata->control_flags |= MAX8973_CONTROL_BIAS_ENABLE;
454 506
507 etr_enable = of_property_read_bool(np, "maxim,enable-etr");
508 etr_sensitivity_high = of_property_read_bool(np,
509 "maxim,enable-high-etr-sensitivity");
510 if (etr_sensitivity_high)
511 etr_enable = true;
512
513 if (etr_enable) {
514 if (etr_sensitivity_high)
515 pdata->control_flags |=
516 MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US;
517 else
518 pdata->control_flags |=
519 MAX8973_CONTROL_CLKADV_TRIP_150mV_PER_US;
520 } else {
521 pdata->control_flags |= MAX8973_CONTROL_CLKADV_TRIP_DISABLED;
522 }
523
455 return pdata; 524 return pdata;
456} 525}
457 526
@@ -568,6 +637,15 @@ static int max8973_probe(struct i2c_client *client,
568 max->lru_index[i] = i; 637 max->lru_index[i] = i;
569 max->lru_index[0] = max->curr_vout_reg; 638 max->lru_index[0] = max->curr_vout_reg;
570 max->lru_index[max->curr_vout_reg] = 0; 639 max->lru_index[max->curr_vout_reg] = 0;
640 } else {
641 /*
642 * If there is no DVS GPIO, the VOUT register
643 * address is fixed.
644 */
645 max->ops.set_voltage_sel = regulator_set_voltage_sel_regmap;
646 max->ops.get_voltage_sel = regulator_get_voltage_sel_regmap;
647 max->desc.vsel_reg = max->curr_vout_reg;
648 max->desc.vsel_mask = MAX8973_VOUT_MASK;
571 } 649 }
572 650
573 if (pdata_from_dt) 651 if (pdata_from_dt)
@@ -613,6 +691,8 @@ static int max8973_probe(struct i2c_client *client,
613 max->ops.enable = regulator_enable_regmap; 691 max->ops.enable = regulator_enable_regmap;
614 max->ops.disable = regulator_disable_regmap; 692 max->ops.disable = regulator_disable_regmap;
615 max->ops.is_enabled = regulator_is_enabled_regmap; 693 max->ops.is_enabled = regulator_is_enabled_regmap;
694 max->ops.set_current_limit = max8973_set_current_limit;
695 max->ops.get_current_limit = max8973_get_current_limit;
616 break; 696 break;
617 default: 697 default:
618 break; 698 break;
diff --git a/include/linux/mfd/max77693-common.h b/include/linux/mfd/max77693-common.h
new file mode 100644
index 000000000000..095b121aa725
--- /dev/null
+++ b/include/linux/mfd/max77693-common.h
@@ -0,0 +1,49 @@
1/*
2 * Common data shared between Maxim 77693 and 77843 drivers
3 *
4 * Copyright (C) 2015 Samsung Electronics
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __LINUX_MFD_MAX77693_COMMON_H
13#define __LINUX_MFD_MAX77693_COMMON_H
14
15enum max77693_types {
16 TYPE_MAX77693_UNKNOWN,
17 TYPE_MAX77693,
18 TYPE_MAX77843,
19
20 TYPE_MAX77693_NUM,
21};
22
23/*
24 * Shared also with max77843.
25 */
26struct max77693_dev {
27 struct device *dev;
28 struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */
29 struct i2c_client *i2c_muic; /* 0x4A , MUIC */
30 struct i2c_client *i2c_haptic; /* MAX77693: 0x90 , Haptic */
31 struct i2c_client *i2c_chg; /* MAX77843: 0xD2, Charger */
32
33 enum max77693_types type;
34
35 struct regmap *regmap;
36 struct regmap *regmap_muic;
37 struct regmap *regmap_haptic; /* Only MAX77693 */
38 struct regmap *regmap_chg; /* Only MAX77843 */
39
40 struct regmap_irq_chip_data *irq_data_led;
41 struct regmap_irq_chip_data *irq_data_topsys;
42 struct regmap_irq_chip_data *irq_data_chg; /* Only MAX77693 */
43 struct regmap_irq_chip_data *irq_data_muic;
44
45 int irq;
46};
47
48
49#endif /* __LINUX_MFD_MAX77693_COMMON_H */
diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h
index 51633ea6f910..3c7a63b98ad6 100644
--- a/include/linux/mfd/max77693-private.h
+++ b/include/linux/mfd/max77693-private.h
@@ -310,30 +310,30 @@ enum max77693_muic_reg {
310#define INTMASK2_CHGTYP_MASK (1 << INTMASK2_CHGTYP_SHIFT) 310#define INTMASK2_CHGTYP_MASK (1 << INTMASK2_CHGTYP_SHIFT)
311 311
312/* MAX77693 MUIC - STATUS1~3 Register */ 312/* MAX77693 MUIC - STATUS1~3 Register */
313#define STATUS1_ADC_SHIFT (0) 313#define MAX77693_STATUS1_ADC_SHIFT 0
314#define STATUS1_ADCLOW_SHIFT (5) 314#define MAX77693_STATUS1_ADCLOW_SHIFT 5
315#define STATUS1_ADCERR_SHIFT (6) 315#define MAX77693_STATUS1_ADCERR_SHIFT 6
316#define STATUS1_ADC1K_SHIFT (7) 316#define MAX77693_STATUS1_ADC1K_SHIFT 7
317#define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) 317#define MAX77693_STATUS1_ADC_MASK (0x1f << MAX77693_STATUS1_ADC_SHIFT)
318#define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT) 318#define MAX77693_STATUS1_ADCLOW_MASK BIT(MAX77693_STATUS1_ADCLOW_SHIFT)
319#define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT) 319#define MAX77693_STATUS1_ADCERR_MASK BIT(MAX77693_STATUS1_ADCERR_SHIFT)
320#define STATUS1_ADC1K_MASK (0x1 << STATUS1_ADC1K_SHIFT) 320#define MAX77693_STATUS1_ADC1K_MASK BIT(MAX77693_STATUS1_ADC1K_SHIFT)
321 321
322#define STATUS2_CHGTYP_SHIFT (0) 322#define MAX77693_STATUS2_CHGTYP_SHIFT 0
323#define STATUS2_CHGDETRUN_SHIFT (3) 323#define MAX77693_STATUS2_CHGDETRUN_SHIFT 3
324#define STATUS2_DCDTMR_SHIFT (4) 324#define MAX77693_STATUS2_DCDTMR_SHIFT 4
325#define STATUS2_DXOVP_SHIFT (5) 325#define MAX77693_STATUS2_DXOVP_SHIFT 5
326#define STATUS2_VBVOLT_SHIFT (6) 326#define MAX77693_STATUS2_VBVOLT_SHIFT 6
327#define STATUS2_VIDRM_SHIFT (7) 327#define MAX77693_STATUS2_VIDRM_SHIFT 7
328#define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) 328#define MAX77693_STATUS2_CHGTYP_MASK (0x7 << MAX77693_STATUS2_CHGTYP_SHIFT)
329#define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT) 329#define MAX77693_STATUS2_CHGDETRUN_MASK BIT(MAX77693_STATUS2_CHGDETRUN_SHIFT)
330#define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT) 330#define MAX77693_STATUS2_DCDTMR_MASK BIT(MAX77693_STATUS2_DCDTMR_SHIFT)
331#define STATUS2_DXOVP_MASK (0x1 << STATUS2_DXOVP_SHIFT) 331#define MAX77693_STATUS2_DXOVP_MASK BIT(MAX77693_STATUS2_DXOVP_SHIFT)
332#define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT) 332#define MAX77693_STATUS2_VBVOLT_MASK BIT(MAX77693_STATUS2_VBVOLT_SHIFT)
333#define STATUS2_VIDRM_MASK (0x1 << STATUS2_VIDRM_SHIFT) 333#define MAX77693_STATUS2_VIDRM_MASK BIT(MAX77693_STATUS2_VIDRM_SHIFT)
334 334
335#define STATUS3_OVP_SHIFT (2) 335#define MAX77693_STATUS3_OVP_SHIFT 2
336#define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT) 336#define MAX77693_STATUS3_OVP_MASK BIT(MAX77693_STATUS3_OVP_SHIFT)
337 337
338/* MAX77693 CDETCTRL1~2 register */ 338/* MAX77693 CDETCTRL1~2 register */
339#define CDETCTRL1_CHGDETEN_SHIFT (0) 339#define CDETCTRL1_CHGDETEN_SHIFT (0)
@@ -362,38 +362,38 @@ enum max77693_muic_reg {
362#define COMN1SW_MASK (0x7 << COMN1SW_SHIFT) 362#define COMN1SW_MASK (0x7 << COMN1SW_SHIFT)
363#define COMP2SW_MASK (0x7 << COMP2SW_SHIFT) 363#define COMP2SW_MASK (0x7 << COMP2SW_SHIFT)
364#define COMP_SW_MASK (COMP2SW_MASK | COMN1SW_MASK) 364#define COMP_SW_MASK (COMP2SW_MASK | COMN1SW_MASK)
365#define CONTROL1_SW_USB ((1 << COMP2SW_SHIFT) \ 365#define MAX77693_CONTROL1_SW_USB ((1 << COMP2SW_SHIFT) \
366 | (1 << COMN1SW_SHIFT)) 366 | (1 << COMN1SW_SHIFT))
367#define CONTROL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \ 367#define MAX77693_CONTROL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \
368 | (2 << COMN1SW_SHIFT)) 368 | (2 << COMN1SW_SHIFT))
369#define CONTROL1_SW_UART ((3 << COMP2SW_SHIFT) \ 369#define MAX77693_CONTROL1_SW_UART ((3 << COMP2SW_SHIFT) \
370 | (3 << COMN1SW_SHIFT)) 370 | (3 << COMN1SW_SHIFT))
371#define CONTROL1_SW_OPEN ((0 << COMP2SW_SHIFT) \ 371#define MAX77693_CONTROL1_SW_OPEN ((0 << COMP2SW_SHIFT) \
372 | (0 << COMN1SW_SHIFT)) 372 | (0 << COMN1SW_SHIFT))
373 373
374#define CONTROL2_LOWPWR_SHIFT (0) 374#define MAX77693_CONTROL2_LOWPWR_SHIFT 0
375#define CONTROL2_ADCEN_SHIFT (1) 375#define MAX77693_CONTROL2_ADCEN_SHIFT 1
376#define CONTROL2_CPEN_SHIFT (2) 376#define MAX77693_CONTROL2_CPEN_SHIFT 2
377#define CONTROL2_SFOUTASRT_SHIFT (3) 377#define MAX77693_CONTROL2_SFOUTASRT_SHIFT 3
378#define CONTROL2_SFOUTORD_SHIFT (4) 378#define MAX77693_CONTROL2_SFOUTORD_SHIFT 4
379#define CONTROL2_ACCDET_SHIFT (5) 379#define MAX77693_CONTROL2_ACCDET_SHIFT 5
380#define CONTROL2_USBCPINT_SHIFT (6) 380#define MAX77693_CONTROL2_USBCPINT_SHIFT 6
381#define CONTROL2_RCPS_SHIFT (7) 381#define MAX77693_CONTROL2_RCPS_SHIFT 7
382#define CONTROL2_LOWPWR_MASK (0x1 << CONTROL2_LOWPWR_SHIFT) 382#define MAX77693_CONTROL2_LOWPWR_MASK BIT(MAX77693_CONTROL2_LOWPWR_SHIFT)
383#define CONTROL2_ADCEN_MASK (0x1 << CONTROL2_ADCEN_SHIFT) 383#define MAX77693_CONTROL2_ADCEN_MASK BIT(MAX77693_CONTROL2_ADCEN_SHIFT)
384#define CONTROL2_CPEN_MASK (0x1 << CONTROL2_CPEN_SHIFT) 384#define MAX77693_CONTROL2_CPEN_MASK BIT(MAX77693_CONTROL2_CPEN_SHIFT)
385#define CONTROL2_SFOUTASRT_MASK (0x1 << CONTROL2_SFOUTASRT_SHIFT) 385#define MAX77693_CONTROL2_SFOUTASRT_MASK BIT(MAX77693_CONTROL2_SFOUTASRT_SHIFT)
386#define CONTROL2_SFOUTORD_MASK (0x1 << CONTROL2_SFOUTORD_SHIFT) 386#define MAX77693_CONTROL2_SFOUTORD_MASK BIT(MAX77693_CONTROL2_SFOUTORD_SHIFT)
387#define CONTROL2_ACCDET_MASK (0x1 << CONTROL2_ACCDET_SHIFT) 387#define MAX77693_CONTROL2_ACCDET_MASK BIT(MAX77693_CONTROL2_ACCDET_SHIFT)
388#define CONTROL2_USBCPINT_MASK (0x1 << CONTROL2_USBCPINT_SHIFT) 388#define MAX77693_CONTROL2_USBCPINT_MASK BIT(MAX77693_CONTROL2_USBCPINT_SHIFT)
389#define CONTROL2_RCPS_MASK (0x1 << CONTROL2_RCPS_SHIFT) 389#define MAX77693_CONTROL2_RCPS_MASK BIT(MAX77693_CONTROL2_RCPS_SHIFT)
390 390
391#define CONTROL3_JIGSET_SHIFT (0) 391#define MAX77693_CONTROL3_JIGSET_SHIFT 0
392#define CONTROL3_BTLDSET_SHIFT (2) 392#define MAX77693_CONTROL3_BTLDSET_SHIFT 2
393#define CONTROL3_ADCDBSET_SHIFT (4) 393#define MAX77693_CONTROL3_ADCDBSET_SHIFT 4
394#define CONTROL3_JIGSET_MASK (0x3 << CONTROL3_JIGSET_SHIFT) 394#define MAX77693_CONTROL3_JIGSET_MASK (0x3 << MAX77693_CONTROL3_JIGSET_SHIFT)
395#define CONTROL3_BTLDSET_MASK (0x3 << CONTROL3_BTLDSET_SHIFT) 395#define MAX77693_CONTROL3_BTLDSET_MASK (0x3 << MAX77693_CONTROL3_BTLDSET_SHIFT)
396#define CONTROL3_ADCDBSET_MASK (0x3 << CONTROL3_ADCDBSET_SHIFT) 396#define MAX77693_CONTROL3_ADCDBSET_MASK (0x3 << MAX77693_CONTROL3_ADCDBSET_SHIFT)
397 397
398/* Slave addr = 0x90: Haptic */ 398/* Slave addr = 0x90: Haptic */
399enum max77693_haptic_reg { 399enum max77693_haptic_reg {
@@ -529,36 +529,4 @@ enum max77693_irq_muic {
529 MAX77693_MUIC_IRQ_NR, 529 MAX77693_MUIC_IRQ_NR,
530}; 530};
531 531
532struct max77693_dev {
533 struct device *dev;
534 struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */
535 struct i2c_client *muic; /* 0x4A , MUIC */
536 struct i2c_client *haptic; /* 0x90 , Haptic */
537
538 int type;
539
540 struct regmap *regmap;
541 struct regmap *regmap_muic;
542 struct regmap *regmap_haptic;
543
544 struct regmap_irq_chip_data *irq_data_led;
545 struct regmap_irq_chip_data *irq_data_topsys;
546 struct regmap_irq_chip_data *irq_data_charger;
547 struct regmap_irq_chip_data *irq_data_muic;
548
549 int irq;
550 int irq_gpio;
551 struct mutex irqlock;
552 int irq_masks_cur[MAX77693_IRQ_GROUP_NR];
553 int irq_masks_cache[MAX77693_IRQ_GROUP_NR];
554};
555
556enum max77693_types {
557 TYPE_MAX77693,
558};
559
560extern int max77693_irq_init(struct max77693_dev *max77686);
561extern void max77693_irq_exit(struct max77693_dev *max77686);
562extern int max77693_irq_resume(struct max77693_dev *max77686);
563
564#endif /* __LINUX_MFD_MAX77693_PRIV_H */ 532#endif /* __LINUX_MFD_MAX77693_PRIV_H */
diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h
index 7178ace8379e..c19303b0ccfd 100644
--- a/include/linux/mfd/max77843-private.h
+++ b/include/linux/mfd/max77843-private.h
@@ -318,62 +318,62 @@ enum max77843_irq_muic {
318 MAX77843_INTSRCMASK_SYS_MASK | MAX77843_INTSRCMASK_CHGR_MASK) 318 MAX77843_INTSRCMASK_SYS_MASK | MAX77843_INTSRCMASK_CHGR_MASK)
319 319
320/* MAX77843 STATUS register*/ 320/* MAX77843 STATUS register*/
321#define STATUS1_ADC_SHIFT 0 321#define MAX77843_MUIC_STATUS1_ADC_SHIFT 0
322#define STATUS1_ADCERROR_SHIFT 6 322#define MAX77843_MUIC_STATUS1_ADCERROR_SHIFT 6
323#define STATUS1_ADC1K_SHIFT 7 323#define MAX77843_MUIC_STATUS1_ADC1K_SHIFT 7
324#define STATUS2_CHGTYP_SHIFT 0 324#define MAX77843_MUIC_STATUS2_CHGTYP_SHIFT 0
325#define STATUS2_CHGDETRUN_SHIFT 3 325#define MAX77843_MUIC_STATUS2_CHGDETRUN_SHIFT 3
326#define STATUS2_DCDTMR_SHIFT 4 326#define MAX77843_MUIC_STATUS2_DCDTMR_SHIFT 4
327#define STATUS2_DXOVP_SHIFT 5 327#define MAX77843_MUIC_STATUS2_DXOVP_SHIFT 5
328#define STATUS2_VBVOLT_SHIFT 6 328#define MAX77843_MUIC_STATUS2_VBVOLT_SHIFT 6
329#define STATUS3_VBADC_SHIFT 0 329#define MAX77843_MUIC_STATUS3_VBADC_SHIFT 0
330#define STATUS3_VDNMON_SHIFT 4 330#define MAX77843_MUIC_STATUS3_VDNMON_SHIFT 4
331#define STATUS3_DNRES_SHIFT 5 331#define MAX77843_MUIC_STATUS3_DNRES_SHIFT 5
332#define STATUS3_MPNACK_SHIFT 6 332#define MAX77843_MUIC_STATUS3_MPNACK_SHIFT 6
333 333
334#define MAX77843_MUIC_STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) 334#define MAX77843_MUIC_STATUS1_ADC_MASK (0x1f << MAX77843_MUIC_STATUS1_ADC_SHIFT)
335#define MAX77843_MUIC_STATUS1_ADCERROR_MASK BIT(STATUS1_ADCERROR_SHIFT) 335#define MAX77843_MUIC_STATUS1_ADCERROR_MASK BIT(MAX77843_MUIC_STATUS1_ADCERROR_SHIFT)
336#define MAX77843_MUIC_STATUS1_ADC1K_MASK BIT(STATUS1_ADC1K_SHIFT) 336#define MAX77843_MUIC_STATUS1_ADC1K_MASK BIT(MAX77843_MUIC_STATUS1_ADC1K_SHIFT)
337#define MAX77843_MUIC_STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) 337#define MAX77843_MUIC_STATUS2_CHGTYP_MASK (0x7 << MAX77843_MUIC_STATUS2_CHGTYP_SHIFT)
338#define MAX77843_MUIC_STATUS2_CHGDETRUN_MASK BIT(STATUS2_CHGDETRUN_SHIFT) 338#define MAX77843_MUIC_STATUS2_CHGDETRUN_MASK BIT(MAX77843_MUIC_STATUS2_CHGDETRUN_SHIFT)
339#define MAX77843_MUIC_STATUS2_DCDTMR_MASK BIT(STATUS2_DCDTMR_SHIFT) 339#define MAX77843_MUIC_STATUS2_DCDTMR_MASK BIT(MAX77843_MUIC_STATUS2_DCDTMR_SHIFT)
340#define MAX77843_MUIC_STATUS2_DXOVP_MASK BIT(STATUS2_DXOVP_SHIFT) 340#define MAX77843_MUIC_STATUS2_DXOVP_MASK BIT(MAX77843_MUIC_STATUS2_DXOVP_SHIFT)
341#define MAX77843_MUIC_STATUS2_VBVOLT_MASK BIT(STATUS2_VBVOLT_SHIFT) 341#define MAX77843_MUIC_STATUS2_VBVOLT_MASK BIT(MAX77843_MUIC_STATUS2_VBVOLT_SHIFT)
342#define MAX77843_MUIC_STATUS3_VBADC_MASK (0xf << STATUS3_VBADC_SHIFT) 342#define MAX77843_MUIC_STATUS3_VBADC_MASK (0xf << MAX77843_MUIC_STATUS3_VBADC_SHIFT)
343#define MAX77843_MUIC_STATUS3_VDNMON_MASK BIT(STATUS3_VDNMON_SHIFT) 343#define MAX77843_MUIC_STATUS3_VDNMON_MASK BIT(MAX77843_MUIC_STATUS3_VDNMON_SHIFT)
344#define MAX77843_MUIC_STATUS3_DNRES_MASK BIT(STATUS3_DNRES_SHIFT) 344#define MAX77843_MUIC_STATUS3_DNRES_MASK BIT(MAX77843_MUIC_STATUS3_DNRES_SHIFT)
345#define MAX77843_MUIC_STATUS3_MPNACK_MASK BIT(STATUS3_MPNACK_SHIFT) 345#define MAX77843_MUIC_STATUS3_MPNACK_MASK BIT(MAX77843_MUIC_STATUS3_MPNACK_SHIFT)
346 346
347/* MAX77843 CONTROL register */ 347/* MAX77843 CONTROL register */
348#define CONTROL1_COMP1SW_SHIFT 0 348#define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0
349#define CONTROL1_COMP2SW_SHIFT 3 349#define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3
350#define CONTROL1_IDBEN_SHIFT 7 350#define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7
351#define CONTROL2_LOWPWR_SHIFT 0 351#define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0
352#define CONTROL2_ADCEN_SHIFT 1 352#define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1
353#define CONTROL2_CPEN_SHIFT 2 353#define MAX77843_MUIC_CONTROL2_CPEN_SHIFT 2
354#define CONTROL2_ACC_DET_SHIFT 5 354#define MAX77843_MUIC_CONTROL2_ACC_DET_SHIFT 5
355#define CONTROL2_USBCPINT_SHIFT 6 355#define MAX77843_MUIC_CONTROL2_USBCPINT_SHIFT 6
356#define CONTROL2_RCPS_SHIFT 7 356#define MAX77843_MUIC_CONTROL2_RCPS_SHIFT 7
357#define CONTROL3_JIGSET_SHIFT 0 357#define MAX77843_MUIC_CONTROL3_JIGSET_SHIFT 0
358#define CONTROL4_ADCDBSET_SHIFT 0 358#define MAX77843_MUIC_CONTROL4_ADCDBSET_SHIFT 0
359#define CONTROL4_USBAUTO_SHIFT 4 359#define MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT 4
360#define CONTROL4_FCTAUTO_SHIFT 5 360#define MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT 5
361#define CONTROL4_ADCMODE_SHIFT 6 361#define MAX77843_MUIC_CONTROL4_ADCMODE_SHIFT 6
362 362
363#define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << CONTROL1_COMP1SW_SHIFT) 363#define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT)
364#define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << CONTROL1_COMP2SW_SHIFT) 364#define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT)
365#define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(CONTROL1_IDBEN_SHIFT) 365#define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT)
366#define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(CONTROL2_LOWPWR_SHIFT) 366#define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT)
367#define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(CONTROL2_ADCEN_SHIFT) 367#define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT)
368#define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(CONTROL2_CPEN_SHIFT) 368#define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT)
369#define MAX77843_MUIC_CONTROL2_ACC_DET_MASK BIT(CONTROL2_ACC_DET_SHIFT) 369#define MAX77843_MUIC_CONTROL2_ACC_DET_MASK BIT(MAX77843_MUIC_CONTROL2_ACC_DET_SHIFT)
370#define MAX77843_MUIC_CONTROL2_USBCPINT_MASK BIT(CONTROL2_USBCPINT_SHIFT) 370#define MAX77843_MUIC_CONTROL2_USBCPINT_MASK BIT(MAX77843_MUIC_CONTROL2_USBCPINT_SHIFT)
371#define MAX77843_MUIC_CONTROL2_RCPS_MASK BIT(CONTROL2_RCPS_SHIFT) 371#define MAX77843_MUIC_CONTROL2_RCPS_MASK BIT(MAX77843_MUIC_CONTROL2_RCPS_SHIFT)
372#define MAX77843_MUIC_CONTROL3_JIGSET_MASK (0x3 << CONTROL3_JIGSET_SHIFT) 372#define MAX77843_MUIC_CONTROL3_JIGSET_MASK (0x3 << MAX77843_MUIC_CONTROL3_JIGSET_SHIFT)
373#define MAX77843_MUIC_CONTROL4_ADCDBSET_MASK (0x3 << CONTROL4_ADCDBSET_SHIFT) 373#define MAX77843_MUIC_CONTROL4_ADCDBSET_MASK (0x3 << MAX77843_MUIC_CONTROL4_ADCDBSET_SHIFT)
374#define MAX77843_MUIC_CONTROL4_USBAUTO_MASK BIT(CONTROL4_USBAUTO_SHIFT) 374#define MAX77843_MUIC_CONTROL4_USBAUTO_MASK BIT(MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT)
375#define MAX77843_MUIC_CONTROL4_FCTAUTO_MASK BIT(CONTROL4_FCTAUTO_SHIFT) 375#define MAX77843_MUIC_CONTROL4_FCTAUTO_MASK BIT(MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT)
376#define MAX77843_MUIC_CONTROL4_ADCMODE_MASK (0x3 << CONTROL4_ADCMODE_SHIFT) 376#define MAX77843_MUIC_CONTROL4_ADCMODE_MASK (0x3 << MAX77843_MUIC_CONTROL4_ADCMODE_SHIFT)
377 377
378/* MAX77843 switch port */ 378/* MAX77843 switch port */
379#define COM_OPEN 0 379#define COM_OPEN 0
@@ -383,38 +383,38 @@ enum max77843_irq_muic {
383#define COM_AUX_USB 4 383#define COM_AUX_USB 4
384#define COM_AUX_UART 5 384#define COM_AUX_UART 5
385 385
386#define CONTROL1_COM_SW \ 386#define MAX77843_MUIC_CONTROL1_COM_SW \
387 ((MAX77843_MUIC_CONTROL1_COMP1SW_MASK | \ 387 ((MAX77843_MUIC_CONTROL1_COMP1SW_MASK | \
388 MAX77843_MUIC_CONTROL1_COMP2SW_MASK)) 388 MAX77843_MUIC_CONTROL1_COMP2SW_MASK))
389 389
390#define CONTROL1_SW_OPEN \ 390#define MAX77843_MUIC_CONTROL1_SW_OPEN \
391 ((COM_OPEN << CONTROL1_COMP1SW_SHIFT | \ 391 ((COM_OPEN << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
392 COM_OPEN << CONTROL1_COMP2SW_SHIFT)) 392 COM_OPEN << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
393#define CONTROL1_SW_USB \ 393#define MAX77843_MUIC_CONTROL1_SW_USB \
394 ((COM_USB << CONTROL1_COMP1SW_SHIFT | \ 394 ((COM_USB << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
395 COM_USB << CONTROL1_COMP2SW_SHIFT)) 395 COM_USB << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
396#define CONTROL1_SW_AUDIO \ 396#define MAX77843_MUIC_CONTROL1_SW_AUDIO \
397 ((COM_AUDIO << CONTROL1_COMP1SW_SHIFT | \ 397 ((COM_AUDIO << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
398 COM_AUDIO << CONTROL1_COMP2SW_SHIFT)) 398 COM_AUDIO << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
399#define CONTROL1_SW_UART \ 399#define MAX77843_MUIC_CONTROL1_SW_UART \
400 ((COM_UART << CONTROL1_COMP1SW_SHIFT | \ 400 ((COM_UART << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
401 COM_UART << CONTROL1_COMP2SW_SHIFT)) 401 COM_UART << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
402#define CONTROL1_SW_AUX_USB \ 402#define MAX77843_MUIC_CONTROL1_SW_AUX_USB \
403 ((COM_AUX_USB << CONTROL1_COMP1SW_SHIFT | \ 403 ((COM_AUX_USB << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
404 COM_AUX_USB << CONTROL1_COMP2SW_SHIFT)) 404 COM_AUX_USB << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
405#define CONTROL1_SW_AUX_UART \ 405#define MAX77843_MUIC_CONTROL1_SW_AUX_UART \
406 ((COM_AUX_UART << CONTROL1_COMP1SW_SHIFT | \ 406 ((COM_AUX_UART << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
407 COM_AUX_UART << CONTROL1_COMP2SW_SHIFT)) 407 COM_AUX_UART << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
408 408
409#define MAX77843_DISABLE 0 409#define MAX77843_DISABLE 0
410#define MAX77843_ENABLE 1 410#define MAX77843_ENABLE 1
411 411
412#define CONTROL4_AUTO_DISABLE \ 412#define CONTROL4_AUTO_DISABLE \
413 ((MAX77843_DISABLE << CONTROL4_USBAUTO_SHIFT) | \ 413 ((MAX77843_DISABLE << MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT) | \
414 (MAX77843_DISABLE << CONTROL4_FCTAUTO_SHIFT)) 414 (MAX77843_DISABLE << MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT))
415#define CONTROL4_AUTO_ENABLE \ 415#define CONTROL4_AUTO_ENABLE \
416 ((MAX77843_ENABLE << CONTROL4_USBAUTO_SHIFT) | \ 416 ((MAX77843_ENABLE << MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT) | \
417 (MAX77843_ENABLE << CONTROL4_FCTAUTO_SHIFT)) 417 (MAX77843_ENABLE << MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT))
418 418
419/* MAX77843 SAFEOUT LDO Control register */ 419/* MAX77843 SAFEOUT LDO Control register */
420#define SAFEOUTCTRL_SAFEOUT1_SHIFT 0 420#define SAFEOUTCTRL_SAFEOUT1_SHIFT 0
@@ -431,24 +431,4 @@ enum max77843_irq_muic {
431#define MAX77843_REG_SAFEOUTCTRL_SAFEOUT2_MASK \ 431#define MAX77843_REG_SAFEOUTCTRL_SAFEOUT2_MASK \
432 (0x3 << SAFEOUTCTRL_SAFEOUT2_SHIFT) 432 (0x3 << SAFEOUTCTRL_SAFEOUT2_SHIFT)
433 433
434struct max77843 {
435 struct device *dev;
436
437 struct i2c_client *i2c;
438 struct i2c_client *i2c_chg;
439 struct i2c_client *i2c_fuel;
440 struct i2c_client *i2c_muic;
441
442 struct regmap *regmap;
443 struct regmap *regmap_chg;
444 struct regmap *regmap_fuel;
445 struct regmap *regmap_muic;
446
447 struct regmap_irq_chip_data *irq_data;
448 struct regmap_irq_chip_data *irq_data_chg;
449 struct regmap_irq_chip_data *irq_data_fuel;
450 struct regmap_irq_chip_data *irq_data_muic;
451
452 int irq;
453};
454#endif /* __MAX77843_H__ */ 434#endif /* __MAX77843_H__ */