This is the RFC version for converting the fixed clock to ACPI.
Since the ACPI namespace is ok at the very late stage of system boot, so I did some major change in boot sequence for the enumeration of fixed clock, amba bus and its child device. I think this part should be review carefully.
For DT, it works well for armv8 foudation model after the change in boot sequence, but the UART and amba bus are dependent on the fixed clock, if I only convert the fixed clock to ACPI, UART will not work. So this is the RFC version and the UART will be converted together in next version.
Hanjun Guo (5): Driver / clk: add platform driver for fixed clock ACPI / ARM64: Whitelist the ACPI ID for fixed clock ACPI / platform: add some comments for internel registry of _HID names ACPI / fixed-clock: Add ACPI driver for fixed clock Clk / fixed clock: Delay the enumeration of fixed clock and make it popssible for ACPI
arch/arm64/kernel/setup.c | 2 +- drivers/acpi/acpi_platform.c | 7 ++-- drivers/clk/clk-fixed-rate.c | 78 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 82 insertions(+), 5 deletions(-)
Add platform driver for fixed clock which makes the initialization of fixed clock visible and for easy understand.
TODO: maybe introduce a fixed-clock.c and its corresponding Kconfig is better.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- drivers/clk/clk-fixed-rate.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c index 1ed591a..8bbc240 100644 --- a/drivers/clk/clk-fixed-rate.c +++ b/drivers/clk/clk-fixed-rate.c @@ -15,6 +15,7 @@ #include <linux/io.h> #include <linux/err.h> #include <linux/of.h> +#include <linux/platform_device.h>
/* * DOC: basic fixed-rate clock that cannot gate @@ -102,5 +103,39 @@ void of_fixed_clk_setup(struct device_node *node) of_clk_add_provider(node, of_clk_src_simple_get, clk); } EXPORT_SYMBOL_GPL(of_fixed_clk_setup); -CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup); #endif + +static int fixed_clk_probe(struct platform_device *pdev) +{ + if (pdev->dev.of_node) + of_fixed_clk_setup(pdev->dev.of_node); + else + return -ENODEV; + + return 0; +} + +static const struct of_device_id fixed_clk_match[] = { + { .compatible = "fixed-clock" }, + {} +}; + +static struct platform_driver fixed_clk_driver = { + .driver = { + .name = "fixed-clk", + .owner = THIS_MODULE, + .of_match_table = fixed_clk_match, + }, + .probe = fixed_clk_probe, +}; + +static int __init fixed_clk_init(void) +{ + return platform_driver_register(&fixed_clk_driver); +} + +/** + * fixed clock will used for AMBA bus, UART and etc, so it should be + * initialized early enough. + */ +postcore_initcall(fixed_clk_init);
Whitelist the ACPI ID of fixed clock for representing as platform device.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- drivers/acpi/acpi_platform.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 24ee811..851c0e0 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -34,6 +34,7 @@ static const struct acpi_device_id acpi_platform_device_ids[] = { { "LINA0003" }, { "LINA0005" }, { "LINA0007" }, + { "LINA0008" }, /* Fixed clock */
{ } };
Add some comments for internel registry of _HID names, which can make the life of people reviewing the code much easy.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- drivers/acpi/acpi_platform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 851c0e0..37b8af8 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -31,9 +31,9 @@ static const struct acpi_device_id acpi_platform_device_ids[] = { { "PNP0D40" },
/* arm64 platform devices */ - { "LINA0003" }, - { "LINA0005" }, - { "LINA0007" }, + { "LINA0003" }, /* smc91x for ethernet */ + { "LINA0005" }, /* virtio mmio */ + { "LINA0007" }, /* armv8 pmu */ { "LINA0008" }, /* Fixed clock */
{ }
I pushed this one as it was not really part of the series.
G
On Thu, Oct 17, 2013 at 07:24:33PM +0800, Hanjun Guo wrote:
Add some comments for internel registry of _HID names, which can make the life of people reviewing the code much easy.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org
drivers/acpi/acpi_platform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 851c0e0..37b8af8 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -31,9 +31,9 @@ static const struct acpi_device_id acpi_platform_device_ids[] = { { "PNP0D40" }, /* arm64 platform devices */
- { "LINA0003" },
- { "LINA0005" },
- { "LINA0007" },
- { "LINA0003" }, /* smc91x for ethernet */
- { "LINA0005" }, /* virtio mmio */
- { "LINA0007" }, /* armv8 pmu */ { "LINA0008" }, /* Fixed clock */
{ } -- 1.7.9.5
Linaro-acpi mailing list Linaro-acpi@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-acpi
Add the ACPI driver for fixed clock, but still not enabled yet.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- drivers/clk/clk-fixed-rate.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c index 8bbc240..e25c4eb 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 @@ -105,10 +107,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;
@@ -120,11 +155,17 @@ static const struct of_device_id fixed_clk_match[] = { {} };
+static const struct acpi_device_id fixed_clk_acpi_match[] = { + { "LINA0008", 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, };
Delay the time of enumeration of fixed clock and make it popssible for ACPI enumeration.
ACPI's namespace is initialized in subsys_initcall stage, so make the fixed clock enumeration in subsys_initcall stage too, and let the AMBA and UART just after it.
Signed-off-by: Hanjun Guo hanjun.guo@linaro.org --- arch/arm64/kernel/setup.c | 2 +- drivers/clk/clk-fixed-rate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index fe8df38..3d7ed3b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -308,7 +308,7 @@ static int __init arm64_device_init(void) of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); return 0; } -arch_initcall(arm64_device_init); +subsys_initcall_sync(arm64_device_init);
DEFINE_PER_CPU(struct cpuinfo_arm, cpu_data);
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c index e25c4eb..655c7ab 100644 --- a/drivers/clk/clk-fixed-rate.c +++ b/drivers/clk/clk-fixed-rate.c @@ -179,4 +179,4 @@ static int __init fixed_clk_init(void) * fixed clock will used for AMBA bus, UART and etc, so it should be * initialized early enough. */ -postcore_initcall(fixed_clk_init); +subsys_initcall(fixed_clk_init);
Hi Mike,
Could you help me to review this patch set and give some comments?
Thanks Hanjun
On 2013-10-17 19:24, Hanjun Guo wrote:
This is the RFC version for converting the fixed clock to ACPI.
Since the ACPI namespace is ok at the very late stage of system boot, so I did some major change in boot sequence for the enumeration of fixed clock, amba bus and its child device. I think this part should be review carefully.
For DT, it works well for armv8 foudation model after the change in boot sequence, but the UART and amba bus are dependent on the fixed clock, if I only convert the fixed clock to ACPI, UART will not work. So this is the RFC version and the UART will be converted together in next version.
Hanjun Guo (5): Driver / clk: add platform driver for fixed clock ACPI / ARM64: Whitelist the ACPI ID for fixed clock ACPI / platform: add some comments for internel registry of _HID names ACPI / fixed-clock: Add ACPI driver for fixed clock Clk / fixed clock: Delay the enumeration of fixed clock and make it popssible for ACPI
arch/arm64/kernel/setup.c | 2 +- drivers/acpi/acpi_platform.c | 7 ++-- drivers/clk/clk-fixed-rate.c | 78 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 82 insertions(+), 5 deletions(-)