diff options
author | Naresh Bhat <naresh.bhat@linaro.org> | 2013-12-09 17:07:28 +0530 |
---|---|---|
committer | Graeme Gregory <graeme.gregory@linaro.org> | 2014-06-03 09:24:38 +0100 |
commit | 5760a9decd53067047bb960fe6cef5672fd246f8 (patch) | |
tree | 74dc967e4b31853aea2d20e94bea6d7050cae170 | |
parent | 24e582f1ff985049ba90ea1aa7d7952c3ae1677d (diff) | |
download | leg-kernel-5760a9decd53067047bb960fe6cef5672fd246f8.tar.gz |
ACPI / fixed-clock: Add ACPI driver for fixed clk
Add the ACPI driver for fixed clock.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Reviewed-by: Naresh Bhat <naresh.bhat@linaro.org>
-rw-r--r-- | drivers/clk/clk-fixed-rate.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c index 321d3bbebe62..fa5cd77ece5b 100644 --- a/drivers/clk/clk-fixed-rate.c +++ b/drivers/clk/clk-fixed-rate.c @@ -16,6 +16,8 @@ #include <linux/err.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/acpi.h> +#include <linux/clkdev.h> /* * DOC: basic fixed-rate clock that cannot gate @@ -136,10 +138,43 @@ void of_fixed_clk_setup(struct device_node *node) EXPORT_SYMBOL_GPL(of_fixed_clk_setup); #endif +#ifdef CONFIG_ACPI +static int fixed_clk_probe_acpi(struct platform_device *pdev) +{ + struct clk *clk = ERR_PTR(-ENODEV); + unsigned long long rate = 0; + acpi_status status; + + /* there is a corresponding FREQ method under fixed clock object */ + status = acpi_evaluate_integer(ACPI_HANDLE(&pdev->dev), "FREQ", + NULL, &rate); + if (ACPI_FAILURE(status)) + return -ENODEV; + + clk = clk_register_fixed_rate(NULL, dev_name(&pdev->dev), NULL, + CLK_IS_ROOT, rate); + if (IS_ERR(clk)) + return -ENODEV; + + /* + * if we don't register the clk here, we can't get the clk + * for AMBA bus when CONFIG_OF=n + */ + return clk_register_clkdev(clk, NULL, dev_name(&pdev->dev)); +} +#else +static inline int fixed_clk_probe_acpi(struct platform_device *pdev) +{ + return -ENODEV; +} +#endif /* CONFIG_ACPI */ + static int fixed_clk_probe(struct platform_device *pdev) { if (pdev->dev.of_node) of_fixed_clk_setup(pdev->dev.of_node); + else if (ACPI_HANDLE(&pdev->dev)) + return fixed_clk_probe_acpi(pdev); else return -ENODEV; @@ -151,11 +186,17 @@ static const struct of_device_id fixed_clk_match[] = { {} }; +static const struct acpi_device_id fixed_clk_acpi_match[] = { + { "LNRO0008", 0 }, + { }, +}; + static struct platform_driver fixed_clk_driver = { .driver = { .name = "fixed-clk", .owner = THIS_MODULE, .of_match_table = fixed_clk_match, + .acpi_match_table = ACPI_PTR(fixed_clk_acpi_match), }, .probe = fixed_clk_probe, }; |