diff options
Diffstat (limited to 'drivers/mfd/max77693.c')
| -rw-r--r-- | drivers/mfd/max77693.c | 41 | 
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c index c04723efc70..7e05428c756 100644 --- a/drivers/mfd/max77693.c +++ b/drivers/mfd/max77693.c @@ -28,6 +28,7 @@  #include <linux/i2c.h>  #include <linux/err.h>  #include <linux/interrupt.h> +#include <linux/of.h>  #include <linux/pm_runtime.h>  #include <linux/mutex.h>  #include <linux/mfd/core.h> @@ -40,7 +41,7 @@  #define I2C_ADDR_MUIC	(0x4A >> 1)  #define I2C_ADDR_HAPTIC	(0x90 >> 1) -static struct mfd_cell max77693_devs[] = { +static const struct mfd_cell max77693_devs[] = {  	{ .name = "max77693-pmic", },  	{ .name = "max77693-charger", },  	{ .name = "max77693-flash", }, @@ -106,19 +107,19 @@ static const struct regmap_config max77693_regmap_config = {  	.max_register = MAX77693_PMIC_REG_END,  }; +static const struct regmap_config max77693_regmap_muic_config = { +	.reg_bits = 8, +	.val_bits = 8, +	.max_register = MAX77693_MUIC_REG_END, +}; +  static int max77693_i2c_probe(struct i2c_client *i2c,  			      const struct i2c_device_id *id)  {  	struct max77693_dev *max77693; -	struct max77693_platform_data *pdata = dev_get_platdata(&i2c->dev);  	u8 reg_data;  	int ret = 0; -	if (!pdata) { -		dev_err(&i2c->dev, "No platform data found.\n"); -		return -EINVAL; -	} -  	max77693 = devm_kzalloc(&i2c->dev,  			sizeof(struct max77693_dev), GFP_KERNEL);  	if (max77693 == NULL) @@ -138,8 +139,6 @@ static int max77693_i2c_probe(struct i2c_client *i2c,  		return ret;  	} -	max77693->wakeup = pdata->wakeup; -  	ret = max77693_read_reg(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2,  				®_data);  	if (ret < 0) { @@ -149,9 +148,18 @@ static int max77693_i2c_probe(struct i2c_client *i2c,  		dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);  	max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); +	if (!max77693->muic) { +		dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n"); +		return -ENODEV; +	}  	i2c_set_clientdata(max77693->muic, max77693);  	max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); +	if (!max77693->haptic) { +		dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n"); +		ret = -ENODEV; +		goto err_i2c_haptic; +	}  	i2c_set_clientdata(max77693->haptic, max77693);  	/* @@ -160,7 +168,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,  	 * before call max77693-muic probe() function.  	 */  	max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic, -					 &max77693_regmap_config); +					 &max77693_regmap_muic_config);  	if (IS_ERR(max77693->regmap_muic)) {  		ret = PTR_ERR(max77693->regmap_muic);  		dev_err(max77693->dev, @@ -179,16 +187,15 @@ static int max77693_i2c_probe(struct i2c_client *i2c,  	if (ret < 0)  		goto err_mfd; -	device_init_wakeup(max77693->dev, pdata->wakeup); -  	return ret;  err_mfd:  	max77693_irq_exit(max77693);  err_irq:  err_regmap_muic: -	i2c_unregister_device(max77693->muic);  	i2c_unregister_device(max77693->haptic); +err_i2c_haptic: +	i2c_unregister_device(max77693->muic);  	return ret;  } @@ -235,11 +242,19 @@ static const struct dev_pm_ops max77693_pm = {  	.resume = max77693_resume,  }; +#ifdef CONFIG_OF +static const struct of_device_id max77693_dt_match[] = { +	{ .compatible = "maxim,max77693" }, +	{}, +}; +#endif +  static struct i2c_driver max77693_i2c_driver = {  	.driver = {  		   .name = "max77693",  		   .owner = THIS_MODULE,  		   .pm = &max77693_pm, +		   .of_match_table = of_match_ptr(max77693_dt_match),  	},  	.probe = max77693_i2c_probe,  	.remove = max77693_i2c_remove,  | 
