void max77693_haptic_enable(bool on)
{
	int ret;
	u8 value = MOTOR_LRA | EXT_PWM | DIVIDER_128;
	u8 lscnfg_val = 0x00;

	if (on) {
		value |= MOTOR_EN;
		lscnfg_val = 0x80;
	}

	ret = max77693_update_reg(palau_max77693_pdata.haptic_data->pmic_i2c
				, MAX77693_PMIC_REG_LSCNFG, lscnfg_val, 0x80);
	if (ret)
		pr_err("max77693: pmic i2c error %d\n", ret);

	ret = max77693_write_reg(palau_max77693_pdata.haptic_data->haptic_i2c
					, MAX77693_HAPTIC_REG_CONFIG2, value);
	if (ret)
		pr_err("max77693: haptic i2c error %d\n", ret);
}
Exemple #2
0
static void max77693_haptic_i2c(struct max77693_haptic_data *hap_data, bool en)
{
	int ret;
	u8 value = hap_data->pdata->reg2;
	u8 lscnfg_val = 0x00;

	if (en) {
		value |= MOTOR_EN;
		lscnfg_val = 0x80;
	}

	ret = max77693_update_reg(hap_data->pmic_i2c, MAX77693_PMIC_REG_LSCNFG,
				lscnfg_val, 0x80);
	if (ret)
		pr_err("[VIB] i2c update error %d\n", ret);

	ret = max77693_write_reg(hap_data->i2c,
				 MAX77693_HAPTIC_REG_CONFIG2, value);
	if (ret)
		pr_err("[VIB] i2c write error %d\n", ret);
}
Exemple #3
0
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, &reg_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;
}
Exemple #4
0
static irqreturn_t max77693_irq_thread(int irq, void *data)
{
	struct max77693_dev *max77693 = data;
	u8 irq_reg[MAX77693_IRQ_GROUP_NR] = {};
	u8 irq_src;
	int ret;
	int i;
	pr_debug("%s: irq gpio pre-state(0x%02x)\n", __func__,
		gpio_get_value(max77693->irq_gpio));

clear_retry:
	ret = max77693_read_reg(max77693->i2c,
		MAX77693_PMIC_REG_INTSRC, &irq_src);
	if (ret < 0) {
		dev_err(max77693->dev, "Failed to read interrupt source: %d\n",
				ret);
		return IRQ_NONE;
	}
	pr_info("%s: interrupt source(0x%02x)\n", __func__, irq_src);

	if (irq_src & MAX77693_IRQSRC_CHG) {
		/* CHG_INT */
		ret = max77693_read_reg(max77693->i2c, MAX77693_CHG_REG_CHG_INT,
				&irq_reg[CHG_INT]);
		pr_info("%s: charger interrupt(0x%02x)\n",
			__func__, irq_reg[CHG_INT]);
		/* mask chgin to prevent chgin infinite interrupt
		 * chgin is unmasked chgin isr
		 */
		if (irq_reg[CHG_INT] & max77693_irqs[MAX77693_CHG_IRQ_WCIN_I].mask) {
			u8 reg_data;
			reg_data = (1 << WCIN_SHIFT);
			max77693_update_reg(max77693->i2c, MAX77693_CHG_REG_CHG_INT_MASK, reg_data,
					WCIN_MASK);
		}
	}

	if (irq_src & MAX77693_IRQSRC_TOP) {
		/* TOPSYS_INT */
		ret = max77693_read_reg(max77693->i2c,
				MAX77693_PMIC_REG_TOPSYS_INT,
				&irq_reg[TOPSYS_INT]);
		pr_info("%s: topsys interrupt(0x%02x)\n",
			__func__, irq_reg[TOPSYS_INT]);
	}

	if (irq_src & MAX77693_IRQSRC_FLASH) {
		/* LED_INT */
		ret = max77693_read_reg(max77693->i2c,
				MAX77693_LED_REG_FLASH_INT,
				&irq_reg[LED_INT]);
		pr_info("%s: led interrupt(0x%02x)\n",
			__func__, irq_reg[LED_INT]);
	}

	if (irq_src & MAX77693_IRQSRC_MUIC) {
		/* MUIC INT1 ~ INT3 */
		max77693_bulk_read(max77693->muic,
		MAX77693_MUIC_REG_INT1,
		MAX77693_NUM_IRQ_MUIC_REGS,
				&irq_reg[MUIC_INT1]);
		pr_info("%s: muic interrupt(0x%02x, 0x%02x, 0x%02x)\n",
			__func__, irq_reg[MUIC_INT1],
			irq_reg[MUIC_INT2], irq_reg[MUIC_INT3]);
	}

	pr_debug("%s: irq gpio post-state(0x%02x)\n", __func__,
		gpio_get_value(max77693->irq_gpio));

	if (gpio_get_value(max77693->irq_gpio) == 0) {
		pr_warn("%s: irq_gpio is not High!\n", __func__);
		goto clear_retry;
	}

	/* Apply masking */
	for (i = 0; i < MAX77693_IRQ_GROUP_NR; i++) {
		if (i >= MUIC_INT1 && i <= MUIC_INT3)
			irq_reg[i] &= max77693->irq_masks_cur[i];
		else
			irq_reg[i] &= ~max77693->irq_masks_cur[i];
	}

	/* Report */
	for (i = 0; i < MAX77693_IRQ_NR; i++) {
		if (irq_reg[max77693_irqs[i].group] & max77693_irqs[i].mask)
			handle_nested_irq(max77693->irq_base + i);
	}

	return IRQ_HANDLED;
}
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, &reg_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 = 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, &reg_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;
}