Ejemplo n.º 1
0
static int footswitch_disable(struct regulator_dev *rdev)
{
	struct footswitch *fs = rdev_get_drvdata(rdev);
	int rc;

	rc = enable_clocks(fs);
	if (rc)
		return rc;

	rc = set_rail_state(fs->pcom_id, PCOM_CLKCTL_RPC_RAIL_DISABLE);
	if (!rc)
		fs->is_enabled = false;

	disable_clocks(fs);

	return rc;
}
static int __init footswitch_init(void)
{
	struct footswitch *fs;
	int ret;

	/*
	 * Enable all footswitches in manual mode (ie. not controlled along
	 * with pcom clocks).
	 */
	for (fs = footswitches; fs < footswitches + ARRAY_SIZE(footswitches);
	     fs++) {
		set_rail_state(fs->pcom_id, PCOM_CLKCTL_RPC_RAIL_ENABLE);
		ret = set_rail_mode(fs->pcom_id, PCOM_RAIL_MODE_MANUAL);
		if (!ret)
			fs->is_manual = 1;
	}

	return platform_driver_register(&footswitch_driver);
}
Ejemplo n.º 3
0
static int footswitch_probe(struct platform_device *pdev)
{
	struct footswitch *fs;
	struct regulator_init_data *init_data;
	int rc;

	if (pdev == NULL)
		return -EINVAL;

	if (pdev->id >= MAX_FS)
		return -ENODEV;

	init_data = pdev->dev.platform_data;
	fs = &footswitches[pdev->id];

	rc = set_rail_state(fs->pcom_id, PCOM_CLKCTL_RPC_RAIL_ENABLE);
	if (rc)
		return rc;
	rc = set_rail_mode(fs->pcom_id, PCOM_RAIL_MODE_MANUAL);
	if (rc)
		return rc;

	rc = get_clocks(&pdev->dev, fs);
	if (rc)
		return rc;

	fs->rdev = regulator_register(&fs->desc, &pdev->dev,
							init_data, fs, NULL);
	if (IS_ERR(fs->rdev)) {
		pr_err("regulator_register(%s) failed\n", fs->desc.name);
		rc = PTR_ERR(fs->rdev);
		goto err_register;
	}

	return 0;

err_register:
	put_clocks(fs);

	return rc;
}