static int max77693_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max77693_dev *max77693; struct max77693_platform_data *pdata; u8 reg_data; int ret = 0; printk(KERN_CRIT "[@@MAX77693@@]: %s called.\n",__func__); max77693 = kzalloc(sizeof(struct max77693_dev), GFP_KERNEL); if (max77693 == NULL) return -ENOMEM; if (i2c->dev.of_node) { pdata = devm_kzalloc(&i2c->dev, sizeof(struct max77693_platform_data), GFP_KERNEL); if (!pdata) { dev_err(&i2c->dev, "Failed to allocate memory \n"); ret = -ENOMEM; goto err; } ret = of_max77693_dt(&i2c->dev, pdata); if (ret < 0) { dev_err(&i2c->dev, "Failed to get device of_node \n"); return ret; } /*Filling the platform data*/ pdata->num_regulators = MAX77693_REG_MAX; pdata->muic = &max77693_muic; #if defined(CONFIG_CHARGER_MAX77693) pdata->charger_data = &sec_battery_pdata; #endif pdata->regulators = max77693_regulators, #ifdef CONFIG_VIBETONZ pdata->haptic_data = &max77693_haptic_pdata; #endif #ifdef CONFIG_LEDS_MAX77693 pdata->led_data = &max77693_led_pdata; #endif #if defined(CONFIG_CHARGER_MAX77803) /* set irq_base at sec_battery_pdata */ sec_battery_pdata.bat_irq = pdata->irq_base + MAX77693_CHG_IRQ_BATP_I; #endif /*pdata update to other modules*/ i2c->dev.platform_data = pdata; } else pdata = i2c->dev.platform_data; i2c_set_clientdata(i2c, max77693); max77693->dev = &i2c->dev; max77693->i2c = i2c; max77693->irq = i2c->irq; // max77693->type = id->driver_data; if (pdata) { max77693->irq_base = pdata->irq_base; max77693->irq_gpio = pdata->irq_gpio; max77693->wakeup = pdata->wakeup; gpio_tlmm_config(GPIO_CFG(max77693->irq_gpio, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE); } else { ret = -EIO; goto err; } mutex_init(&max77693->iolock); printk(KERN_CRIT "[@@MAX77693@@]: %s called,after mutex_init\n",__func__); if (max77693_read_reg(i2c, MAX77693_PMIC_REG_PMIC_ID2, ®_data) < 0) { dev_err(max77693->dev, "device not found on this channel (this is not an error)\n"); ret = -ENODEV; goto err; } else { /* print rev */ max77693->pmic_rev = (reg_data & 0x7); max77693->pmic_ver = ((reg_data & 0xF8) >> 0x3); pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__, max77693->pmic_rev, max77693->pmic_ver); } max77693_update_reg(i2c, MAX77693_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30); max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); i2c_set_clientdata(max77693->muic, max77693); max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); i2c_set_clientdata(max77693->haptic, max77693); ret = max77693_irq_init(max77693); if (ret < 0) goto err_irq_init; ret = mfd_add_devices(max77693->dev, -1, max77693_devs, ARRAY_SIZE(max77693_devs), NULL, 0); if (ret < 0) goto err_mfd; device_init_wakeup(max77693->dev, pdata->wakeup); return ret; err_mfd: mfd_remove_devices(max77693->dev); err_irq_init: i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->haptic); err: kfree(max77693); return ret; }
static int max77693_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max77693_dev *max77693; struct max77693_platform_data *pdata = i2c->dev.platform_data; u8 reg_data; int ret = 0; max77693 = kzalloc(sizeof(struct max77693_dev), GFP_KERNEL); if (max77693 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, max77693); max77693->dev = &i2c->dev; max77693->i2c = i2c; max77693->irq = i2c->irq; max77693->type = id->driver_data; if (pdata) { max77693->irq_base = pdata->irq_base; max77693->irq_gpio = pdata->irq_gpio; max77693->wakeup = pdata->wakeup; } else goto err; mutex_init(&max77693->iolock); if (max77693_read_reg(i2c, MAX77693_PMIC_REG_PMIC_ID2, ®_data) < 0) { dev_err(max77693->dev, "device not found on this channel (this is not an error)\n"); ret = -ENODEV; goto err; } else { /* print rev */ max77693->pmic_rev = (reg_data & 0x7); max77693->pmic_ver = ((reg_data & 0xF8) >> 0x3); pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__, max77693->pmic_rev, max77693->pmic_ver); } #if defined(CONFIG_MACH_JF_VZW) || defined(CONFIG_MACH_JF_LGT) if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) { pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET); max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x04); } else { pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET); max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x0c); } #else if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) { max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x04); } else { pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET); max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x0c); } #endif max77693_update_reg(i2c, MAX77693_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30); max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); i2c_set_clientdata(max77693->muic, max77693); max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); i2c_set_clientdata(max77693->haptic, max77693); ret = max77693_irq_init(max77693); if (ret < 0) goto err_irq_init; ret = mfd_add_devices(max77693->dev, -1, max77693_devs, ARRAY_SIZE(max77693_devs), NULL, 0); if (ret < 0) goto err_mfd; device_init_wakeup(max77693->dev, pdata->wakeup); return ret; err_mfd: mfd_remove_devices(max77693->dev); err_irq_init: i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->haptic); err: kfree(max77693); return ret; }
static int max77693_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max77693_dev *max77693; struct max77693_platform_data *pdata = i2c->dev.platform_data; u8 reg_data; int ret = 0; max77693 = devm_kzalloc(&i2c->dev, sizeof(struct max77693_dev), GFP_KERNEL); if (max77693 == NULL) return -ENOMEM; max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config); if (IS_ERR(max77693->regmap)) { ret = PTR_ERR(max77693->regmap); dev_err(max77693->dev,"failed to allocate register map: %d\n", ret); goto err_regmap; } i2c_set_clientdata(i2c, max77693); max77693->dev = &i2c->dev; max77693->i2c = i2c; max77693->irq = i2c->irq; max77693->type = id->driver_data; if (!pdata) goto err_regmap; max77693->wakeup = pdata->wakeup; mutex_init(&max77693->iolock); if (max77693_read_reg(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2, ®_data) < 0) { dev_err(max77693->dev, "device not found on this channel\n"); ret = -ENODEV; goto err_regmap; } else dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); i2c_set_clientdata(max77693->muic, max77693); max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); i2c_set_clientdata(max77693->haptic, max77693); ret = max77693_irq_init(max77693); if (ret < 0) goto err_mfd; pm_runtime_set_active(max77693->dev); ret = mfd_add_devices(max77693->dev, -1, max77693_devs, ARRAY_SIZE(max77693_devs), NULL, 0); if (ret < 0) goto err_mfd; device_init_wakeup(max77693->dev, pdata->wakeup); return ret; err_mfd: i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->haptic); err_regmap: kfree(max77693); return ret; }
static int max77693_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max77693_dev *max77693; struct max77693_platform_data *pdata = i2c->dev.platform_data; u8 reg_data; int ret = 0; pr_info("%s\n", __func__); max77693 = kzalloc(sizeof(struct max77693_dev), GFP_KERNEL); if (max77693 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, max77693); max77693->dev = &i2c->dev; max77693->i2c = i2c; max77693->irq = i2c->irq; max77693->type = id->driver_data; if (pdata) { max77693->irq_base = pdata->irq_base; max77693->irq_gpio = pdata->irq_gpio; max77693->wakeup = pdata->wakeup; } else { ret = -EIO; goto err; } mutex_init(&max77693->iolock); if (max77693_read_reg(i2c, MAX77693_PMIC_REG_PMIC_ID2, ®_data) < 0) { dev_err(max77693->dev, "device not found on this channel (this is not an error)\n"); ret = -ENODEV; goto err; } else { /* print rev */ max77693->pmic_rev = (reg_data & 0x7); max77693->pmic_ver = ((reg_data & 0xF8) >> 0x3); pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__, max77693->pmic_rev, max77693->pmic_ver); } max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); i2c_set_clientdata(max77693->muic, max77693); max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); i2c_set_clientdata(max77693->haptic, max77693); ret = max77693_irq_init(max77693); if (ret < 0) goto err_irq_init; ret = mfd_add_devices(max77693->dev, -1, max77693_devs, ARRAY_SIZE(max77693_devs), NULL, 0); if (ret < 0) goto err_mfd; device_init_wakeup(max77693->dev, pdata->wakeup); return ret; err_mfd: mfd_remove_devices(max77693->dev); err_irq_init: i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->haptic); err: kfree(max77693); return ret; }
static int max77693_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max77693_dev *max77693; struct max77693_platform_data *pdata = i2c->dev.platform_data; u8 reg_data; int ret = 0; max77693 = kzalloc(sizeof(struct max77693_dev), GFP_KERNEL); if (max77693 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, max77693); max77693->dev = &i2c->dev; max77693->i2c = i2c; max77693->irq = i2c->irq; max77693->type = id->driver_data; if (pdata) { max77693->irq_base = pdata->irq_base; max77693->irq_gpio = pdata->irq_gpio; max77693->irq_gpio_label = pdata->irq_gpio_label; max77693->wakeup = pdata->wakeup; pdata->haptic_data->pmic_i2c = i2c; } else { ret = -EINVAL; goto err_pdata; } mutex_init(&max77693->iolock); ret = max77693_read_reg(i2c, MAX77693_PMIC_REG_PMIC_ID2, ®_data); if (unlikely(ret < 0)) { dev_warn(max77693->dev, "No PMIC Version Information\n"); goto err_i2c; } max77693->pmic_rev = PMIC_REV(reg_data); max77693->pmic_ver = PMIC_VER(reg_data); reg_data = (pdata->man_reset_timer & MAIN_CTRL1_MRDBTMER_MASK) | (pdata->man_reset_en << MAIN_CTRL1_MREN_SHIFT); ret = max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, reg_data); if (unlikely(ret < 0)) { dev_warn(max77693->dev, "failed to set manctrl1\n"); goto err_i2c; } dev_info(max77693->dev, "%s: rev.0x%x, ver.0x%x, manctrl1: 0x%x\n", __func__, max77693->pmic_rev, max77693->pmic_ver, reg_data); max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); i2c_set_clientdata(max77693->muic, max77693); max77693->fuel = i2c_new_dummy(i2c->adapter, I2C_ADDR_FUEL); i2c_set_clientdata(max77693->fuel, max77693); max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); i2c_set_clientdata(max77693->haptic, max77693); pdata->haptic_data->haptic_i2c = max77693->haptic; ret = max77693_irq_init(max77693); if (ret < 0) goto err_irq; ret = mfd_add_devices(max77693->dev, -1, max77693_devs, ARRAY_SIZE(max77693_devs), NULL, 0); if (ret < 0) goto err_mfd; device_init_wakeup(max77693->dev, pdata->wakeup); return ret; err_mfd: mfd_remove_devices(max77693->dev); err_irq: i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->fuel); i2c_unregister_device(max77693->haptic); err_i2c: mutex_destroy(&max77693->iolock); err_pdata: kfree(max77693); return ret; }