Lines Matching refs:max14577

263 static void max14577_print_dev_type(struct max14577 *max14577)  in max14577_print_dev_type()  argument
268 ret = max14577_read_reg(max14577->regmap, MAX14577_REG_DEVICEID, in max14577_print_dev_type()
271 dev_err(max14577->dev, in max14577_print_dev_type()
281 dev_info(max14577->dev, "Device type: %u (ID: 0x%x, vendor: 0x%x)\n", in max14577_print_dev_type()
282 max14577->dev_type, device_id, vendor_id); in max14577_print_dev_type()
294 static int max77836_init(struct max14577 *max14577) in max77836_init() argument
299 max14577->i2c_pmic = i2c_new_dummy_device(max14577->i2c->adapter, in max77836_init()
301 if (IS_ERR(max14577->i2c_pmic)) { in max77836_init()
302 dev_err(max14577->dev, "Failed to register PMIC I2C device\n"); in max77836_init()
303 return PTR_ERR(max14577->i2c_pmic); in max77836_init()
305 i2c_set_clientdata(max14577->i2c_pmic, max14577); in max77836_init()
307 max14577->regmap_pmic = devm_regmap_init_i2c(max14577->i2c_pmic, in max77836_init()
309 if (IS_ERR(max14577->regmap_pmic)) { in max77836_init()
310 ret = PTR_ERR(max14577->regmap_pmic); in max77836_init()
311 dev_err(max14577->dev, "Failed to allocate PMIC register map: %d\n", in max77836_init()
317 ret = max14577_read_reg(max14577->regmap_pmic, in max77836_init()
320 dev_err(max14577->dev, "Failed to read PMIC register\n"); in max77836_init()
326 ret = max14577_write_reg(max14577->regmap_pmic, in max77836_init()
329 dev_err(max14577->dev, "Failed to write PMIC register\n"); in max77836_init()
333 ret = regmap_add_irq_chip(max14577->regmap_pmic, max14577->irq, in max77836_init()
336 &max14577->irq_data_pmic); in max77836_init()
338 dev_err(max14577->dev, "Failed to request PMIC IRQ %d: %d\n", in max77836_init()
339 max14577->irq, ret); in max77836_init()
346 i2c_unregister_device(max14577->i2c_pmic); in max77836_init()
354 static void max77836_remove(struct max14577 *max14577) in max77836_remove() argument
356 regmap_del_irq_chip(max14577->irq, max14577->irq_data_pmic); in max77836_remove()
357 i2c_unregister_device(max14577->i2c_pmic); in max77836_remove()
362 struct max14577 *max14577; in max14577_i2c_probe() local
383 max14577 = devm_kzalloc(&i2c->dev, sizeof(*max14577), GFP_KERNEL); in max14577_i2c_probe()
384 if (!max14577) in max14577_i2c_probe()
387 i2c_set_clientdata(i2c, max14577); in max14577_i2c_probe()
388 max14577->dev = &i2c->dev; in max14577_i2c_probe()
389 max14577->i2c = i2c; in max14577_i2c_probe()
390 max14577->irq = i2c->irq; in max14577_i2c_probe()
392 max14577->regmap = devm_regmap_init_i2c(i2c, in max14577_i2c_probe()
394 if (IS_ERR(max14577->regmap)) { in max14577_i2c_probe()
395 ret = PTR_ERR(max14577->regmap); in max14577_i2c_probe()
396 dev_err(max14577->dev, "Failed to allocate register map: %d\n", in max14577_i2c_probe()
401 max14577->dev_type = (kernel_ulong_t)i2c_get_match_data(i2c); in max14577_i2c_probe()
403 max14577_print_dev_type(max14577); in max14577_i2c_probe()
405 switch (max14577->dev_type) { in max14577_i2c_probe()
421 ret = regmap_add_irq_chip(max14577->regmap, max14577->irq, in max14577_i2c_probe()
423 &max14577->irq_data); in max14577_i2c_probe()
426 max14577->irq, ret); in max14577_i2c_probe()
431 if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836) { in max14577_i2c_probe()
432 ret = max77836_init(max14577); in max14577_i2c_probe()
437 ret = mfd_add_devices(max14577->dev, -1, mfd_devs, in max14577_i2c_probe()
442 device_init_wakeup(max14577->dev, 1); in max14577_i2c_probe()
447 if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836) in max14577_i2c_probe()
448 max77836_remove(max14577); in max14577_i2c_probe()
450 regmap_del_irq_chip(max14577->irq, max14577->irq_data); in max14577_i2c_probe()
457 struct max14577 *max14577 = i2c_get_clientdata(i2c); in max14577_i2c_remove() local
459 mfd_remove_devices(max14577->dev); in max14577_i2c_remove()
460 regmap_del_irq_chip(max14577->irq, max14577->irq_data); in max14577_i2c_remove()
461 if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836) in max14577_i2c_remove()
462 max77836_remove(max14577); in max14577_i2c_remove()
475 struct max14577 *max14577 = i2c_get_clientdata(i2c); in max14577_suspend() local
478 enable_irq_wake(max14577->irq); in max14577_suspend()
488 disable_irq(max14577->irq); in max14577_suspend()
496 struct max14577 *max14577 = i2c_get_clientdata(i2c); in max14577_resume() local
499 disable_irq_wake(max14577->irq); in max14577_resume()
500 enable_irq(max14577->irq); in max14577_resume()