Commit 61b305cd authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

drivers: max77693: Move state container to common header

This prepares for merging some of the drivers between max77693 and
max77843 so the child MFD driver can be attached to any parent MFD main
driver.

Move the state container to common header file. Additionally add
consistent 'i2c' prefixes to its members (of 'struct i2c_client' type).
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski.k@gmail.com>
Acked-by: default avatarSebastian Reichel <sre@kernel.org>
Acked-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Acked-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
Acked-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5b5e771f
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mfd/max77693.h> #include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77693-private.h> #include <linux/mfd/max77693-private.h>
#include <linux/extcon.h> #include <linux/extcon.h>
#include <linux/regmap.h> #include <linux/regmap.h>
...@@ -1077,7 +1078,7 @@ static int max77693_muic_probe(struct platform_device *pdev) ...@@ -1077,7 +1078,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "allocate register map\n"); dev_dbg(&pdev->dev, "allocate register map\n");
} else { } else {
info->max77693->regmap_muic = devm_regmap_init_i2c( info->max77693->regmap_muic = devm_regmap_init_i2c(
info->max77693->muic, info->max77693->i2c_muic,
&max77693_muic_regmap_config); &max77693_muic_regmap_config);
if (IS_ERR(info->max77693->regmap_muic)) { if (IS_ERR(info->max77693->regmap_muic)) {
ret = PTR_ERR(info->max77693->regmap_muic); ret = PTR_ERR(info->max77693->regmap_muic);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/mfd/max77693.h> #include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77693-private.h> #include <linux/mfd/max77693-private.h>
#define MAX_MAGNITUDE_SHIFT 16 #define MAX_MAGNITUDE_SHIFT 16
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/led-class-flash.h> #include <linux/led-class-flash.h>
#include <linux/mfd/max77693.h> #include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77693-private.h> #include <linux/mfd/max77693-private.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/max77693.h> #include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77693-private.h> #include <linux/mfd/max77693-private.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/regmap.h> #include <linux/regmap.h>
...@@ -193,22 +194,22 @@ static int max77693_i2c_probe(struct i2c_client *i2c, ...@@ -193,22 +194,22 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
} else } else
dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);
max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); max77693->i2c_muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
if (!max77693->muic) { if (!max77693->i2c_muic) {
dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n"); dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n");
return -ENODEV; return -ENODEV;
} }
i2c_set_clientdata(max77693->muic, max77693); i2c_set_clientdata(max77693->i2c_muic, max77693);
max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); max77693->i2c_haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
if (!max77693->haptic) { if (!max77693->i2c_haptic) {
dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n"); dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n");
ret = -ENODEV; ret = -ENODEV;
goto err_i2c_haptic; goto err_i2c_haptic;
} }
i2c_set_clientdata(max77693->haptic, max77693); i2c_set_clientdata(max77693->i2c_haptic, max77693);
max77693->regmap_haptic = devm_regmap_init_i2c(max77693->haptic, max77693->regmap_haptic = devm_regmap_init_i2c(max77693->i2c_haptic,
&max77693_regmap_haptic_config); &max77693_regmap_haptic_config);
if (IS_ERR(max77693->regmap_haptic)) { if (IS_ERR(max77693->regmap_haptic)) {
ret = PTR_ERR(max77693->regmap_haptic); ret = PTR_ERR(max77693->regmap_haptic);
...@@ -222,7 +223,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c, ...@@ -222,7 +223,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
* instance of MUIC device when irq of max77693 is initialized * instance of MUIC device when irq of max77693 is initialized
* before call max77693-muic probe() function. * before call max77693-muic probe() function.
*/ */
max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic, max77693->regmap_muic = devm_regmap_init_i2c(max77693->i2c_muic,
&max77693_regmap_muic_config); &max77693_regmap_muic_config);
if (IS_ERR(max77693->regmap_muic)) { if (IS_ERR(max77693->regmap_muic)) {
ret = PTR_ERR(max77693->regmap_muic); ret = PTR_ERR(max77693->regmap_muic);
...@@ -255,7 +256,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c, ...@@ -255,7 +256,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
IRQF_ONESHOT | IRQF_SHARED | IRQF_ONESHOT | IRQF_SHARED |
IRQF_TRIGGER_FALLING, 0, IRQF_TRIGGER_FALLING, 0,
&max77693_charger_irq_chip, &max77693_charger_irq_chip,
&max77693->irq_data_charger); &max77693->irq_data_chg);
if (ret) { if (ret) {
dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
goto err_irq_charger; goto err_irq_charger;
...@@ -296,15 +297,15 @@ static int max77693_i2c_probe(struct i2c_client *i2c, ...@@ -296,15 +297,15 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
err_intsrc: err_intsrc:
regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic);
err_irq_muic: err_irq_muic:
regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); regmap_del_irq_chip(max77693->irq, max77693->irq_data_chg);
err_irq_charger: err_irq_charger:
regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys);
err_irq_topsys: err_irq_topsys:
regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); regmap_del_irq_chip(max77693->irq, max77693->irq_data_led);
err_regmap: err_regmap:
i2c_unregister_device(max77693->haptic); i2c_unregister_device(max77693->i2c_haptic);
err_i2c_haptic: err_i2c_haptic:
i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->i2c_muic);
return ret; return ret;
} }
...@@ -315,12 +316,12 @@ static int max77693_i2c_remove(struct i2c_client *i2c) ...@@ -315,12 +316,12 @@ static int max77693_i2c_remove(struct i2c_client *i2c)
mfd_remove_devices(max77693->dev); mfd_remove_devices(max77693->dev);
regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic);
regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); regmap_del_irq_chip(max77693->irq, max77693->irq_data_chg);
regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys);
regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); regmap_del_irq_chip(max77693->irq, max77693->irq_data_led);
i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->i2c_muic);
i2c_unregister_device(max77693->haptic); i2c_unregister_device(max77693->i2c_haptic);
return 0; return 0;
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/power_supply.h> #include <linux/power_supply.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/mfd/max77693.h> #include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77693-private.h> #include <linux/mfd/max77693-private.h>
#define MAX77693_CHARGER_NAME "max77693-charger" #define MAX77693_CHARGER_NAME "max77693-charger"
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/mfd/max77693.h> #include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77693-private.h> #include <linux/mfd/max77693-private.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/regmap.h> #include <linux/regmap.h>
......
/*
* Common data shared between Maxim 77693 and 77843 drivers
*
* Copyright (C) 2015 Samsung Electronics
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef __LINUX_MFD_MAX77693_COMMON_H
#define __LINUX_MFD_MAX77693_COMMON_H
enum max77693_types {
TYPE_MAX77693_UNKNOWN,
TYPE_MAX77693,
};
/*
* Shared also with max77843.
*/
struct max77693_dev {
struct device *dev;
struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */
struct i2c_client *i2c_muic; /* 0x4A , MUIC */
struct i2c_client *i2c_haptic; /* MAX77693: 0x90 , Haptic */
enum max77693_types type;
struct regmap *regmap;
struct regmap *regmap_muic;
struct regmap *regmap_haptic; /* Only MAX77693 */
struct regmap_irq_chip_data *irq_data_led;
struct regmap_irq_chip_data *irq_data_topsys;
struct regmap_irq_chip_data *irq_data_chg; /* Only MAX77693 */
struct regmap_irq_chip_data *irq_data_muic;
int irq;
};
#endif /* __LINUX_MFD_MAX77693_COMMON_H */
...@@ -529,29 +529,4 @@ enum max77693_irq_muic { ...@@ -529,29 +529,4 @@ enum max77693_irq_muic {
MAX77693_MUIC_IRQ_NR, MAX77693_MUIC_IRQ_NR,
}; };
enum max77693_types {
TYPE_MAX77693_UNKNOWN,
TYPE_MAX77693,
};
struct max77693_dev {
struct device *dev;
struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */
struct i2c_client *muic; /* 0x4A , MUIC */
struct i2c_client *haptic; /* 0x90 , Haptic */
enum max77693_types type;
struct regmap *regmap;
struct regmap *regmap_muic;
struct regmap *regmap_haptic;
struct regmap_irq_chip_data *irq_data_led;
struct regmap_irq_chip_data *irq_data_topsys;
struct regmap_irq_chip_data *irq_data_charger;
struct regmap_irq_chip_data *irq_data_muic;
int irq;
};
#endif /* __LINUX_MFD_MAX77693_PRIV_H */ #endif /* __LINUX_MFD_MAX77693_PRIV_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment