aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski.k@gmail.com>2015-07-15 08:59:51 -0400
committerMark Brown <broonie@kernel.org>2015-07-16 16:39:30 -0400
commitbc1aadc18621ccf93fb33ecbb847b422c354899d (patch)
tree869054114aa849801a112c7691909abd85c3d843
parent61b305cd2ae747b8c9a2e4467dea2575a390162c (diff)
drivers: max77843: Switch to common max77693 state container
Switch to the same definition of state container as in MAX77693 drivers. This will allow usage of one regulator driver in both devices: MAX77693 and MAX77843. Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/extcon/extcon-max77843.c17
-rw-r--r--drivers/input/misc/max77843-haptic.c3
-rw-r--r--drivers/mfd/max77843.c20
-rw-r--r--drivers/regulator/max77843.c6
-rw-r--r--include/linux/mfd/max77693-common.h5
-rw-r--r--include/linux/mfd/max77843-private.h20
6 files changed, 31 insertions, 40 deletions
diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index fac2f1417a79..4dfe0a6337d8 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,7 +199,7 @@ 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
@@ -539,7 +540,7 @@ static void max77843_muic_irq_work(struct work_struct *work)
539{ 540{
540 struct max77843_muic_info *info = container_of(work, 541 struct max77843_muic_info *info = container_of(work,
541 struct max77843_muic_info, irq_work); 542 struct max77843_muic_info, irq_work);
542 struct max77843 *max77843 = info->max77843; 543 struct max77693_dev *max77843 = info->max77843;
543 int ret = 0; 544 int ret = 0;
544 545
545 mutex_lock(&info->mutex); 546 mutex_lock(&info->mutex);
@@ -615,7 +616,7 @@ static void max77843_muic_detect_cable_wq(struct work_struct *work)
615{ 616{
616 struct max77843_muic_info *info = container_of(to_delayed_work(work), 617 struct max77843_muic_info *info = container_of(to_delayed_work(work),
617 struct max77843_muic_info, wq_detcable); 618 struct max77843_muic_info, wq_detcable);
618 struct max77843 *max77843 = info->max77843; 619 struct max77693_dev *max77843 = info->max77843;
619 int chg_type, adc, ret; 620 int chg_type, adc, ret;
620 bool attached; 621 bool attached;
621 622
@@ -656,7 +657,7 @@ err_cable_wq:
656static int max77843_muic_set_debounce_time(struct max77843_muic_info *info, 657static int max77843_muic_set_debounce_time(struct max77843_muic_info *info,
657 enum max77843_muic_adc_debounce_time time) 658 enum max77843_muic_adc_debounce_time time)
658{ 659{
659 struct max77843 *max77843 = info->max77843; 660 struct max77693_dev *max77843 = info->max77843;
660 int ret; 661 int ret;
661 662
662 switch (time) { 663 switch (time) {
@@ -681,7 +682,7 @@ static int max77843_muic_set_debounce_time(struct max77843_muic_info *info,
681 return 0; 682 return 0;
682} 683}
683 684
684static int max77843_init_muic_regmap(struct max77843 *max77843) 685static int max77843_init_muic_regmap(struct max77693_dev *max77843)
685{ 686{
686 int ret; 687 int ret;
687 688
@@ -720,7 +721,7 @@ err_muic_i2c:
720 721
721static int max77843_muic_probe(struct platform_device *pdev) 722static int max77843_muic_probe(struct platform_device *pdev)
722{ 723{
723 struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent); 724 struct max77693_dev *max77843 = dev_get_drvdata(pdev->dev.parent);
724 struct max77843_muic_info *info; 725 struct max77843_muic_info *info;
725 unsigned int id; 726 unsigned int id;
726 int i, ret; 727 int i, ret;
@@ -821,7 +822,7 @@ err_muic_irq:
821static int max77843_muic_remove(struct platform_device *pdev) 822static int max77843_muic_remove(struct platform_device *pdev)
822{ 823{
823 struct max77843_muic_info *info = platform_get_drvdata(pdev); 824 struct max77843_muic_info *info = platform_get_drvdata(pdev);
824 struct max77843 *max77843 = info->max77843; 825 struct max77693_dev *max77843 = info->max77843;
825 826
826 cancel_work_sync(&info->irq_work); 827 cancel_work_sync(&info->irq_work);
827 regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic); 828 regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic);
diff --git a/drivers/input/misc/max77843-haptic.c b/drivers/input/misc/max77843-haptic.c
index dccbb465a055..30da81ab5a21 100644
--- a/drivers/input/misc/max77843-haptic.c
+++ b/drivers/input/misc/max77843-haptic.c
@@ -14,6 +14,7 @@
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/input.h> 16#include <linux/input.h>
17#include <linux/mfd/max77693-common.h>
17#include <linux/mfd/max77843-private.h> 18#include <linux/mfd/max77843-private.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
@@ -243,7 +244,7 @@ static void max77843_haptic_close(struct input_dev *dev)
243 244
244static int max77843_haptic_probe(struct platform_device *pdev) 245static int max77843_haptic_probe(struct platform_device *pdev)
245{ 246{
246 struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent); 247 struct max77693_dev *max77843 = dev_get_drvdata(pdev->dev.parent);
247 struct max77843_haptic *haptic; 248 struct max77843_haptic *haptic;
248 int error; 249 int error;
249 250
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/regulator/max77843.c b/drivers/regulator/max77843.c
index f4fd0d3cfa6e..9926247aae6b 100644
--- a/drivers/regulator/max77843.c
+++ b/drivers/regulator/max77843.c
@@ -15,6 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h> 16#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h> 17#include <linux/regulator/machine.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/regulator/of_regulator.h> 20#include <linux/regulator/of_regulator.h>
20 21
@@ -130,7 +131,8 @@ static const struct regulator_desc max77843_supported_regulators[] = {
130 }, 131 },
131}; 132};
132 133
133static struct regmap *max77843_get_regmap(struct max77843 *max77843, int reg_id) 134static struct regmap *max77843_get_regmap(struct max77693_dev *max77843,
135 int reg_id)
134{ 136{
135 switch (reg_id) { 137 switch (reg_id) {
136 case MAX77843_SAFEOUT1: 138 case MAX77843_SAFEOUT1:
@@ -145,7 +147,7 @@ static struct regmap *max77843_get_regmap(struct max77843 *max77843, int reg_id)
145 147
146static int max77843_regulator_probe(struct platform_device *pdev) 148static int max77843_regulator_probe(struct platform_device *pdev)
147{ 149{
148 struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent); 150 struct max77693_dev *max77843 = dev_get_drvdata(pdev->dev.parent);
149 struct regulator_config config = {}; 151 struct regulator_config config = {};
150 int i; 152 int i;
151 153
diff --git a/include/linux/mfd/max77693-common.h b/include/linux/mfd/max77693-common.h
index 7da4cc38e982..095b121aa725 100644
--- a/include/linux/mfd/max77693-common.h
+++ b/include/linux/mfd/max77693-common.h
@@ -15,6 +15,9 @@
15enum max77693_types { 15enum max77693_types {
16 TYPE_MAX77693_UNKNOWN, 16 TYPE_MAX77693_UNKNOWN,
17 TYPE_MAX77693, 17 TYPE_MAX77693,
18 TYPE_MAX77843,
19
20 TYPE_MAX77693_NUM,
18}; 21};
19 22
20/* 23/*
@@ -25,12 +28,14 @@ struct max77693_dev {
25 struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */ 28 struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */
26 struct i2c_client *i2c_muic; /* 0x4A , MUIC */ 29 struct i2c_client *i2c_muic; /* 0x4A , MUIC */
27 struct i2c_client *i2c_haptic; /* MAX77693: 0x90 , Haptic */ 30 struct i2c_client *i2c_haptic; /* MAX77693: 0x90 , Haptic */
31 struct i2c_client *i2c_chg; /* MAX77843: 0xD2, Charger */
28 32
29 enum max77693_types type; 33 enum max77693_types type;
30 34
31 struct regmap *regmap; 35 struct regmap *regmap;
32 struct regmap *regmap_muic; 36 struct regmap *regmap_muic;
33 struct regmap *regmap_haptic; /* Only MAX77693 */ 37 struct regmap *regmap_haptic; /* Only MAX77693 */
38 struct regmap *regmap_chg; /* Only MAX77843 */
34 39
35 struct regmap_irq_chip_data *irq_data_led; 40 struct regmap_irq_chip_data *irq_data_led;
36 struct regmap_irq_chip_data *irq_data_topsys; 41 struct regmap_irq_chip_data *irq_data_topsys;
diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h
index 7178ace8379e..0121d9440340 100644
--- a/include/linux/mfd/max77843-private.h
+++ b/include/linux/mfd/max77843-private.h
@@ -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__ */