static void _max77888_restore_muic_reg(struct max77888_dev *max77888) { pr_info("%s:Restore muic irq\n", __func__); max77888_write_reg(max77888->muic, MAX77888_MUIC_REG_INTMASK1, 0x09); max77888_write_reg(max77888->muic, MAX77888_MUIC_REG_INTMASK2, 0x11); max77888_update_reg(max77888->muic, MAX77888_MUIC_REG_CDETCTRL1, (0x01 << CHGTYPM_SHIFT), CHGTYPM_MASK); max77888_write_reg(max77888->muic, MAX77888_MUIC_REG_CTRL4, 0x02); max77888_muic_regdump(); }
static void max77888_haptic_i2c(struct max77888_haptic_data *hap_data, bool en) { int ret; u8 value = hap_data->pdata->reg2; u8 lscnfg_val = 0x00; pr_debug("[VIB] %s %d\n", __func__, en); if (en) { value |= MOTOR_EN; lscnfg_val = 0x80; } ret = max77888_update_reg(hap_data->pmic_i2c, MAX77888_PMIC_REG_LSCNFG, lscnfg_val, 0x80); if (ret) pr_err("[VIB] i2c update error %d\n", ret); ret = max77888_write_reg(hap_data->i2c, MAX77888_HAPTIC_REG_CONFIG2, value); if (ret) pr_err("[VIB] i2c write error %d\n", ret); }
static int max77888_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *dev_id) { struct max77888_dev *max77888; struct max77888_platform_data *pdata = i2c->dev.platform_data; u8 reg_data; int ret = 0; pr_info("%s:%s\n", MFD_DEV_NAME, __func__); max77888 = kzalloc(sizeof(struct max77888_dev), GFP_KERNEL); if (!max77888) { dev_err(&i2c->dev, "%s: Failed to alloc mem for max77888\n", __func__); return -ENOMEM; } if (i2c->dev.of_node) { pdata = devm_kzalloc(&i2c->dev, sizeof(struct max77888_platform_data), GFP_KERNEL); if (!pdata) { dev_err(&i2c->dev, "Failed to allocate memory \n"); ret = -ENOMEM; goto err; } ret = of_max77888_dt(&i2c->dev, pdata); if (ret < 0){ dev_err(&i2c->dev, "Failed to get device of_node \n"); goto err; } i2c->dev.platform_data = pdata; } else pdata = i2c->dev.platform_data; max77888->dev = &i2c->dev; max77888->i2c = i2c; max77888->irq = i2c->irq; if (pdata) { max77888->pdata = pdata; pdata->irq_base = irq_alloc_descs(-1, 0, MAX77888_IRQ_NR, -1); if (pdata->irq_base < 0) { pr_err("%s:%s irq_alloc_descs Fail! ret(%d)\n", MFD_DEV_NAME, __func__, pdata->irq_base); ret = -EINVAL; goto err; } else max77888->irq_base = pdata->irq_base; max77888->irq_gpio = pdata->irq_gpio; max77888->irqf_trigger = pdata->irqf_trigger; max77888->wakeup = pdata->wakeup; } else { ret = -EINVAL; goto err; } mutex_init(&max77888->i2c_lock); i2c_set_clientdata(i2c, max77888); if (max77888_read_reg(i2c, MAX77888_PMIC_REG_PMIC_ID2, ®_data) < 0) { dev_err(max77888->dev, "device not found on this channel (this is not an error)\n"); ret = -ENODEV; goto err_w_lock; } else { /* print rev */ max77888->pmic_rev = (reg_data & 0x7); max77888->pmic_ver = ((reg_data & 0xF8) >> 0x3); pr_info("%s:%s device found: rev.0x%x, ver.0x%x\n", MFD_DEV_NAME, __func__, max77888->pmic_rev, max77888->pmic_ver); } /* No active discharge on safeout ldo 1,2 */ max77888_update_reg(i2c, MAX77888_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30); max77888->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); i2c_set_clientdata(max77888->muic, max77888); max77888->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); i2c_set_clientdata(max77888->haptic, max77888); ret = max77888_irq_init(max77888); if (ret < 0) goto err_irq_init; ret = mfd_add_devices(max77888->dev, -1, max77888_devs, ARRAY_SIZE(max77888_devs), NULL, 0, NULL); if (ret < 0) goto err_mfd; device_init_wakeup(max77888->dev, pdata->wakeup); return ret; err_mfd: mfd_remove_devices(max77888->dev); err_irq_init: i2c_unregister_device(max77888->muic); i2c_unregister_device(max77888->haptic); err_w_lock: mutex_destroy(&max77888->i2c_lock); err: kfree(max77888); return ret; }