devfreq: devfreq_simple_dev: Add support for preparing device clock

For certain implementation, device clock needs to be prepared before
rate voting taking effect. Add support for preparing device clock
during initialization.

Change-Id: Ib22e83952187118342ff2546d4c79d3970a288f9
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
This commit is contained in:
Junjie Wu 2015-03-03 17:15:35 -08:00 committed by David Keitel
parent 7abb04398a
commit 708a8f999e
2 changed files with 15 additions and 3 deletions

View file

@ -14,6 +14,7 @@ Required properties:
Optional properties: Optional properties:
- polling-ms: Polling interval for the device in milliseconds. Default: 50 - polling-ms: Polling interval for the device in milliseconds. Default: 50
- governor: Initial governor to user for the device. Default: "performance" - governor: Initial governor to user for the device. Default: "performance"
- qcom,prepare-clk: Prepare the device clock during initialization.
Example: Example:

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -146,12 +146,23 @@ static int devfreq_clock_probe(struct platform_device *pdev)
if (of_property_read_string(dev->of_node, "governor", &gov_name)) if (of_property_read_string(dev->of_node, "governor", &gov_name))
gov_name = "performance"; gov_name = "performance";
if (of_property_read_bool(dev->of_node, "qcom,prepare-clk")) {
ret = clk_prepare(d->clk);
if (ret)
return ret;
}
d->df = devfreq_add_device(dev, p, gov_name, NULL); d->df = devfreq_add_device(dev, p, gov_name, NULL);
if (IS_ERR(d->df)) if (IS_ERR(d->df)) {
return PTR_ERR(d->df); ret = PTR_ERR(d->df);
goto add_err;
}
return 0; return 0;
add_err:
if (of_property_read_bool(dev->of_node, "qcom,prepare-clk"))
clk_unprepare(d->clk);
return ret;
} }
static int devfreq_clock_remove(struct platform_device *pdev) static int devfreq_clock_remove(struct platform_device *pdev)