示例#1
0
static int __devinit c55_ctrl_probe(struct platform_device *pdev)
{
	struct c55_ctrl_data *cdata;
	int ret;

	if (!pdev->dev.of_node) {
		/* Platform data not currently supported */
		dev_err(&pdev->dev, "%s: of devtree data not found\n", __func__);
		return -EINVAL;
	}

	cdata = devm_kzalloc(&pdev->dev, sizeof(*cdata), GFP_KERNEL);
	if (cdata == NULL) {
		dev_err(&pdev->dev, "%s: devm_kzalloc failed.\n", __func__);
		return -ENOMEM;
	}

	cdata->mclk = devm_clk_get(&pdev->dev, "adc_mclk");

	if (IS_ERR(cdata->mclk)) {
		dev_err(&pdev->dev, "%s: devm_clk_get failed.\n", __func__);
		return PTR_ERR(cdata->mclk);
	}

	clk_prepare_enable(cdata->mclk);

	ret = c55_ctrl_gpio_setup(cdata, &pdev->dev);

	if (ret) {
		dev_err(&pdev->dev, "%s: c55_ctrl_gpio_setup failed.\n", __func__);
		return ret;
	}

	wake_lock_init(&cdata->wake_lock, WAKE_LOCK_SUSPEND, "c55_ctrl");

	platform_set_drvdata(pdev, cdata);
	return 0;
}
static int c55_ctrl_probe(struct platform_device *pdev)
{
	struct c55_ctrl_data *cdata;
	int ret;
	if (!pdev->dev.of_node) {
		/* Platform data not currently supported */
		dev_err(&pdev->dev, "%s: of devtree data not found\n", __func__);
		return -EINVAL;
	}

	cdata = devm_kzalloc(&pdev->dev, sizeof(*cdata), GFP_KERNEL);
	if (cdata == NULL) {
		dev_err(&pdev->dev, "%s: devm_kzalloc failed.\n", __func__);
		return -ENOMEM;
	}

	mutex_init(&cdata->ctrl_mutex);

	ret = c55_ctrl_pin_setup(&pdev->dev, cdata);
	if (ret) {
		dev_err(&pdev->dev, "%s: c55_ctrl_pin_setup failed.\n",
			__func__);
		return ret;
	}

	cdata->c55_ap_int_gpio = -1;
	cdata->ap_c55_int_gpio = -1;
	ret = c55_ctrl_gpio_setup(cdata, &pdev->dev);

	if (ret) {
		dev_err(&pdev->dev, "%s: c55_ctrl_gpio_setup failed.\n", __func__);
		return ret;
	}

	cdata->reg_vddc = devm_regulator_get(&pdev->dev, "vddc");
	if (IS_ERR(cdata->reg_vddc))
		cdata->reg_vddc = NULL;
	else if (regulator_enable(cdata->reg_vddc))
		dev_err(&pdev->dev, "regulator_enable failed for vddc\n");

	cdata->reg_vddldo = devm_regulator_get(&pdev->dev, "vddldo");
	if (IS_ERR(cdata->reg_vddldo))
		cdata->reg_vddldo = NULL;
	else if (regulator_enable(cdata->reg_vddldo))
		dev_err(&pdev->dev, "regulator_enable failed for vddldo\n");

	/* M4 by default has C55 ON at power up */
	cdata->c55_mode = C55_ON;

	ret = device_create_file(&pdev->dev, &dev_attr_enable);
	if (ret) {
		dev_err(&pdev->dev, "%s: c55_ctrl creating set_mode failed.\n",
			__func__);
		return ret;
	}

	cdata->fw_verified = 0;

	ret = device_create_file(&pdev->dev, &dev_attr_fw_verified);
	if (ret) {
		dev_err(&pdev->dev, "%s: c55_ctrl creating fw_verified failed.\n",
			__func__);
		return ret;
	}

	wake_lock_init(&cdata->wake_lock, WAKE_LOCK_SUSPEND, "c55_ctrl");

	platform_set_drvdata(pdev, cdata);
	return 0;
}