Exemplo 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;
}
Exemplo n.º 3
0
static int __devinit device_800_init(struct pm80x_chip *chip,
				     struct pm80x_platform_data *pdata)
{
	int ret, pmic_id;
	unsigned int val;

	ret = regmap_read(chip->regmap, PM800_CHIP_ID, &val);
	if (ret < 0) {
		dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
		goto out;
	}

	pmic_id = val & PM80X_VERSION_MASK;

	if ((pmic_id >= PM800_CHIP_A0) && (pmic_id <= PM800_CHIP_END)) {
		chip->version = val;
		dev_info(chip->dev,
			 "88PM80x:Marvell 88PM800 (ID:0x%x) detected\n", val);
	} else {
		dev_err(chip->dev,
			"Failed to detect Marvell 88PM800:ChipID[0x%x]\n", val);
		ret = -EINVAL;
		goto out;
	}

	/*
	 * 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 =
	    mfd_add_devices(chip->dev, 0, &onkey_devs[0],
			    ARRAY_SIZE(onkey_devs), &onkey_resources[0], 0);
	if (ret < 0) {
		dev_err(chip->dev, "Failed to add onkey subdev\n");
		goto out_dev;
	} else
		dev_info(chip->dev, "[%s]:Added mfd onkey_devs\n", __func__);

	if (pdata && pdata->rtc) {
		rtc_devs[0].platform_data = pdata->rtc;
		rtc_devs[0].pdata_size = sizeof(struct pm80x_rtc_pdata);
		ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
				      ARRAY_SIZE(rtc_devs), NULL, 0);
		if (ret < 0) {
			dev_err(chip->dev, "Failed to add rtc subdev\n");
			goto out_dev;
		} else
			dev_info(chip->dev,
				 "[%s]:Added mfd rtc_devs\n", __func__);
	}

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