Lines Matching +full:max77693 +full:- +full:charger

1 // SPDX-License-Identifier: GPL-2.0+
3 // max77693.c - mfd core driver for the MAX 77693
21 #include <linux/mfd/max77693.h>
22 #include <linux/mfd/max77693-common.h>
23 #include <linux/mfd/max77693-private.h>
27 #define I2C_ADDR_PMIC (0xCC >> 1) /* Charger, Flash LED */
32 { .name = "max77693-pmic", },
34 .name = "max77693-charger",
35 .of_compatible = "maxim,max77693-charger",
38 .name = "max77693-muic",
39 .of_compatible = "maxim,max77693-muic",
42 .name = "max77693-haptic",
43 .of_compatible = "maxim,max77693-haptic",
46 .name = "max77693-led",
47 .of_compatible = "maxim,max77693-led",
66 .name = "max77693-led",
81 .name = "max77693-topsys",
98 .name = "max77693-charger",
134 .name = "max77693-muic",
151 struct max77693_dev *max77693; in max77693_i2c_probe() local
155 max77693 = devm_kzalloc(&i2c->dev, in max77693_i2c_probe()
157 if (max77693 == NULL) in max77693_i2c_probe()
158 return -ENOMEM; in max77693_i2c_probe()
160 i2c_set_clientdata(i2c, max77693); in max77693_i2c_probe()
161 max77693->dev = &i2c->dev; in max77693_i2c_probe()
162 max77693->i2c = i2c; in max77693_i2c_probe()
163 max77693->irq = i2c->irq; in max77693_i2c_probe()
164 max77693->type = id->driver_data; in max77693_i2c_probe()
166 max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config); in max77693_i2c_probe()
167 if (IS_ERR(max77693->regmap)) { in max77693_i2c_probe()
168 ret = PTR_ERR(max77693->regmap); in max77693_i2c_probe()
169 dev_err(max77693->dev, "failed to allocate register map: %d\n", in max77693_i2c_probe()
174 ret = regmap_read(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2, in max77693_i2c_probe()
177 dev_err(max77693->dev, "device not found on this channel\n"); in max77693_i2c_probe()
180 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); in max77693_i2c_probe()
182 max77693->i2c_muic = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_MUIC); in max77693_i2c_probe()
183 if (IS_ERR(max77693->i2c_muic)) { in max77693_i2c_probe()
184 dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n"); in max77693_i2c_probe()
185 return PTR_ERR(max77693->i2c_muic); in max77693_i2c_probe()
187 i2c_set_clientdata(max77693->i2c_muic, max77693); in max77693_i2c_probe()
189 max77693->i2c_haptic = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_HAPTIC); in max77693_i2c_probe()
190 if (IS_ERR(max77693->i2c_haptic)) { in max77693_i2c_probe()
191 dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n"); in max77693_i2c_probe()
192 ret = PTR_ERR(max77693->i2c_haptic); in max77693_i2c_probe()
195 i2c_set_clientdata(max77693->i2c_haptic, max77693); in max77693_i2c_probe()
197 max77693->regmap_haptic = devm_regmap_init_i2c(max77693->i2c_haptic, in max77693_i2c_probe()
199 if (IS_ERR(max77693->regmap_haptic)) { in max77693_i2c_probe()
200 ret = PTR_ERR(max77693->regmap_haptic); in max77693_i2c_probe()
201 dev_err(max77693->dev, in max77693_i2c_probe()
207 * Initialize register map for MUIC device because use regmap-muic in max77693_i2c_probe()
208 * instance of MUIC device when irq of max77693 is initialized in max77693_i2c_probe()
209 * before call max77693-muic probe() function. in max77693_i2c_probe()
211 max77693->regmap_muic = devm_regmap_init_i2c(max77693->i2c_muic, in max77693_i2c_probe()
213 if (IS_ERR(max77693->regmap_muic)) { in max77693_i2c_probe()
214 ret = PTR_ERR(max77693->regmap_muic); in max77693_i2c_probe()
215 dev_err(max77693->dev, in max77693_i2c_probe()
220 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, in max77693_i2c_probe()
223 &max77693->irq_data_led); in max77693_i2c_probe()
225 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); in max77693_i2c_probe()
229 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, in max77693_i2c_probe()
232 &max77693->irq_data_topsys); in max77693_i2c_probe()
234 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); in max77693_i2c_probe()
238 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, in max77693_i2c_probe()
241 &max77693->irq_data_chg); in max77693_i2c_probe()
243 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); in max77693_i2c_probe()
247 ret = regmap_add_irq_chip(max77693->regmap_muic, max77693->irq, in max77693_i2c_probe()
250 &max77693->irq_data_muic); in max77693_i2c_probe()
252 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); in max77693_i2c_probe()
257 ret = regmap_update_bits(max77693->regmap, in max77693_i2c_probe()
261 dev_err(max77693->dev, in max77693_i2c_probe()
267 pm_runtime_set_active(max77693->dev); in max77693_i2c_probe()
269 ret = mfd_add_devices(max77693->dev, -1, max77693_devs, in max77693_i2c_probe()
277 mfd_remove_devices(max77693->dev); in max77693_i2c_probe()
279 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); in max77693_i2c_probe()
281 regmap_del_irq_chip(max77693->irq, max77693->irq_data_chg); in max77693_i2c_probe()
283 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); in max77693_i2c_probe()
285 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); in max77693_i2c_probe()
287 i2c_unregister_device(max77693->i2c_haptic); in max77693_i2c_probe()
289 i2c_unregister_device(max77693->i2c_muic); in max77693_i2c_probe()
295 struct max77693_dev *max77693 = i2c_get_clientdata(i2c); in max77693_i2c_remove() local
297 mfd_remove_devices(max77693->dev); in max77693_i2c_remove()
299 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); in max77693_i2c_remove()
300 regmap_del_irq_chip(max77693->irq, max77693->irq_data_chg); in max77693_i2c_remove()
301 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); in max77693_i2c_remove()
302 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); in max77693_i2c_remove()
304 i2c_unregister_device(max77693->i2c_muic); in max77693_i2c_remove()
305 i2c_unregister_device(max77693->i2c_haptic); in max77693_i2c_remove()
309 { "max77693", TYPE_MAX77693 },
317 struct max77693_dev *max77693 = i2c_get_clientdata(i2c); in max77693_suspend() local
320 enable_irq_wake(max77693->irq); in max77693_suspend()
321 disable_irq(max77693->irq); in max77693_suspend()
330 struct max77693_dev *max77693 = i2c_get_clientdata(i2c); in max77693_resume() local
333 disable_irq_wake(max77693->irq); in max77693_resume()
334 enable_irq(max77693->irq); in max77693_resume()
347 { .compatible = "maxim,max77693" },
355 .name = "max77693",
366 MODULE_DESCRIPTION("MAXIM 77693 multi-function core driver");