Esempio n. 1
0
static int device_800_init(struct pm80x_chip *chip,
                           struct pm80x_platform_data *pdata)
{
    int ret;
    unsigned int val;

    /*
     * alarm wake up bit will be clear in device_irq_init(),
     * read before that
     */
    ret = regmap_read(chip->regmap, PM800_RTC_CONTROL, &val);
    if (ret < 0) {
        dev_err(chip->dev, "Failed to read RTC register: %d\n", ret);
        goto out;
    }
    if (val & PM800_ALARM_WAKEUP) {
        if (pdata && pdata->rtc)
            pdata->rtc->rtc_wakeup = 1;
    }

    ret = device_gpadc_init(chip, pdata);
    if (ret < 0) {
        dev_err(chip->dev, "[%s]Failed to init gpadc\n", __func__);
        goto out;
    }

    chip->regmap_irq_chip = &pm800_irq_chip;

    ret = device_irq_init_800(chip);
    if (ret < 0) {
        dev_err(chip->dev, "[%s]Failed to init pm800 irq\n", __func__);
        goto out;
    }

    ret = device_onkey_init(chip, pdata);
    if (ret) {
        dev_err(chip->dev, "Failed to add onkey subdev\n");
        goto out_dev;
    }

    ret = device_rtc_init(chip, pdata);
    if (ret) {
        dev_err(chip->dev, "Failed to add rtc subdev\n");
        goto out;
    }

    ret = device_regulator_init(chip, pdata);
    if (ret) {
        dev_err(chip->dev, "Failed to add regulators subdev\n");
        goto out;
    }

    return 0;
out_dev:
    mfd_remove_devices(chip->dev);
    device_irq_exit_800(chip);
out:
    return ret;
}
static int device_800_init(struct pm80x_chip *chip,
				     struct pm80x_platform_data *pdata)
{
	int ret;
	unsigned int val,data;

	if (!pdata) {
		dev_warn(chip->dev, "pdata is null!!!\n");
		return -EINVAL;
	}

#if defined(CONFIG_SEC_DEBUG)
	/* read power on reason from PMIC general use register */
	ret = regmap_read(chip->regmap, PMIC_GENERAL_USE_REGISTER, &data);
	if (ret < 0) {
		dev_err(chip->dev, "Failed to read PMIC_GENERAL_USE_REGISTER : %d\n"
				, ret);
		goto out;
	}
	
	pr_info("%s read register PMIC_GENERAL_USE_REGISTER [%d]\n", __func__,
			data);
	val = data & (PMIC_GENERAL_USE_REBOOT_DN_MASK);
	/* read power on reason from PMIC general use register */	
	if (val != PMIC_GENERAL_USE_BOOT_BY_FULL_RESET)		
	{
		data &= ~(PMIC_GENERAL_USE_REBOOT_DN_MASK);
		data |= PMIC_GENERAL_USE_BOOT_BY_HW_RESET;
		regmap_write(chip->regmap, PMIC_GENERAL_USE_REGISTER,data);
	}
	power_on_reason = (u8)val;
#endif
	/*
	 * alarm wake up bit will be clear in device_irq_init(),
	 * read before that
	 */
	ret = regmap_read(chip->regmap, PM800_RTC_CONTROL, &val);
	if (ret < 0) {
		dev_err(chip->dev, "Failed to read RTC register: %d\n", ret);
		goto out;
	}
	if (val & PM800_ALARM_WAKEUP) {
		if (pdata && pdata->rtc)
			pdata->rtc->rtc_wakeup = 1;
	}

	ret = device_gpadc_init(chip, pdata);
	if (ret < 0) {
		dev_err(chip->dev, "[%s]Failed to init gpadc\n", __func__);
		goto out;
	}

	chip->regmap_irq_chip = &pm800_irq_chip;
	chip->irq_mode = pdata->irq_mode;

	ret = device_irq_init_800(chip);
	if (ret < 0) {
		dev_err(chip->dev, "[%s]Failed to init pm800 irq\n", __func__);
		goto out;
	}

	ret = device_onkey_init(chip, pdata);
	if (ret) {
		dev_err(chip->dev, "Failed to add onkey subdev\n");
		goto out_dev;
	}

	ret = device_rtc_init(chip, pdata);
	if (ret) {
		dev_err(chip->dev, "Failed to add rtc subdev\n");
		goto out;
	}
	ret = device_battery_init(chip, pdata);
	if (ret) {
		dev_err(chip->dev, "Failed to add battery subdev\n");
		goto out;
	}

	ret = device_regulator_init(chip, pdata);
	if (ret) {
		dev_err(chip->dev, "Failed to add regulators subdev\n");
		goto out;
	}

	ret = device_headset_init(chip, pdata);
	if (ret < 0) {
		dev_err(chip->dev, "Failed to add headset subdev\n");
		goto out_dev;
	}

	ret = device_dvc_init(chip, pdata);
	if (ret) {
		dev_err(chip->dev, "Failed to add dvc subdev\n");

		goto out;
	}

	ret = device_usb_init(chip, pdata);
	if (ret) {
		dev_err(chip->dev, "Failed to add usb subdev\n");
		goto out;
	}

	ret = device_vibrator_init(chip, pdata);
	if (ret) {
		dev_err(chip->dev, "Failed to add vibrator subdev\n");

		goto out;
	}

	return 0;
out_dev:
	mfd_remove_devices(chip->dev);
	device_irq_exit_800(chip);
out:
	return ret;
}