From: Jon Hunter <jon-hunter@ti.com> To: Tarun Kanti DebBarma <tarun.kanti@ti.com>, Tony Lindgren <tony@atomide.com>, Rob Herring <rob.herring@calxeda.com>, Grant Likely <grant.likely@secretlab.ca>, Paul Walmsley <paul@pwsan.com> Cc: Benoit Cousson <b-cousson@ti.com>, linux-omap <linux-omap@vger.kernel.org>, linux-arm <linux-arm-kernel@lists.infradead.org>, device-tree <devicetree-discuss@lists.ozlabs.org>, Jon Hunter <jon-hunter@ti.com> Subject: [RFC RESEND 4/4] ARM: OMAP: Add DT support for timer driver Date: Fri, 13 Jul 2012 17:26:53 -0500 [thread overview] Message-ID: <1342218413-30116-5-git-send-email-jon-hunter@ti.com> (raw) In-Reply-To: <1342218413-30116-1-git-send-email-jon-hunter@ti.com> In order to add device-tree support to the timer driver the following changes were made ... 1. If DT blob is present, then let HWMOD create the timer devices dynamically. 2. When device-tree is present the "id" field in the platform_device structure (pdev->id) is initialised to -1 and the timer instance is looked-up using the device tree alias mechanism. Therefore, avoid using "pdev-id" in the driver and use "timer->id" which will be initialised correctly regardless of whether device tree is present. 3. When device-tree is present the platform_data structure will be NULL and so check for this. 4. The OMAP timer device tree binding optional parameters ... a. ti,timer-alwon --> Timer is in an always-on power domain b. ti,timer-pwn --> Timer can generate a PWM output Search for the above parameters and set the appropriate timer attribute flags. Signed-off-by: Jon Hunter <jon-hunter@ti.com> --- arch/arm/mach-omap2/timer.c | 4 ++++ arch/arm/plat-omap/dmtimer.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index e3b9931..ad5b29a 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c @@ -473,6 +473,10 @@ static int __init omap2_dm_timer_init(void) { int ret; + /* If dtb is there, the devices will be created dynamically */ + if (of_have_populated_dt()) + return -ENODEV; + ret = omap_hwmod_for_each_by_class("timer", omap_timer_init, NULL); if (unlikely(ret)) { pr_err("%s: device registration failed.\n", __func__); diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 626ad8c..5a51b67 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -40,6 +40,8 @@ #include <linux/device.h> #include <linux/err.h> #include <linux/pm_runtime.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <plat/dmtimer.h> #include <plat/omap-pm.h> @@ -123,7 +125,7 @@ static void omap_dm_timer_wait_for_reset(struct omap_dm_timer *timer) static void omap_dm_timer_reset(struct omap_dm_timer *timer) { omap_dm_timer_enable(timer); - if (timer->pdev->id != 1) { + if (timer->id != 1) { omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG, 0x06); omap_dm_timer_wait_for_reset(timer); } @@ -214,7 +216,7 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int id) spin_lock_irqsave(&dm_timer_lock, flags); list_for_each_entry(t, &omap_timer_list, node) { - if (t->pdev->id == id && !t->reserved) { + if (t->id == id && !t->reserved) { timer = t; timer->reserved = 1; break; @@ -414,7 +416,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) * use the clock framework to set the parent clock. To be removed * once OMAP1 migrated to using clock framework for dmtimers */ - if (pdata->set_timer_src) + if (pdata && pdata->set_timer_src) return pdata->set_timer_src(timer->pdev, source); fclk = clk_get(&timer->pdev->dev, "fck"); @@ -695,7 +697,7 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct dmtimer_platform_data *pdata = pdev->dev.platform_data; - if (!pdata) { + if (!pdata && !dev->of_node) { dev_err(dev, "%s: no platform data.\n", __func__); return -ENODEV; } @@ -724,11 +726,21 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev) return -ENOMEM; } - timer->id = pdev->id; + if (dev->of_node) { + timer->id = of_alias_get_id(dev->of_node, "timer"); + + if (of_find_property(dev->of_node, "ti,timer-alwon", NULL)) + timer->capability |= OMAP_TIMER_ALWON; + if (of_find_property(dev->of_node, "ti,timer-pwm", NULL)) + timer->capability |= OMAP_TIMER_HAS_PWM; + } else { + timer->id = pdev->id; + timer->capability = pdata->timer_capability; + } + timer->irq = irq->start; timer->reserved = omap_dm_timer_reserved_systimer(timer->id); timer->pdev = pdev; - timer->capability = pdata->timer_capability; /* Skip pm_runtime_enable for OMAP1 */ if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) { @@ -778,11 +790,19 @@ static int __devexit omap_dm_timer_remove(struct platform_device *pdev) return ret; } +static const struct of_device_id omap_timer_match[] = { + { .compatible = "ti,omap3-timer", }, + { .compatible = "ti,omap2-timer", }, + {}, +}; +MODULE_DEVICE_TABLE(of, omap_timer_match); + static struct platform_driver omap_dm_timer_driver = { .probe = omap_dm_timer_probe, .remove = __devexit_p(omap_dm_timer_remove), .driver = { .name = "omap_timer", + .of_match_table = of_match_ptr(omap_timer_match), }, }; -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: jon-hunter@ti.com (Jon Hunter) To: linux-arm-kernel@lists.infradead.org Subject: [RFC RESEND 4/4] ARM: OMAP: Add DT support for timer driver Date: Fri, 13 Jul 2012 17:26:53 -0500 [thread overview] Message-ID: <1342218413-30116-5-git-send-email-jon-hunter@ti.com> (raw) In-Reply-To: <1342218413-30116-1-git-send-email-jon-hunter@ti.com> In order to add device-tree support to the timer driver the following changes were made ... 1. If DT blob is present, then let HWMOD create the timer devices dynamically. 2. When device-tree is present the "id" field in the platform_device structure (pdev->id) is initialised to -1 and the timer instance is looked-up using the device tree alias mechanism. Therefore, avoid using "pdev-id" in the driver and use "timer->id" which will be initialised correctly regardless of whether device tree is present. 3. When device-tree is present the platform_data structure will be NULL and so check for this. 4. The OMAP timer device tree binding optional parameters ... a. ti,timer-alwon --> Timer is in an always-on power domain b. ti,timer-pwn --> Timer can generate a PWM output Search for the above parameters and set the appropriate timer attribute flags. Signed-off-by: Jon Hunter <jon-hunter@ti.com> --- arch/arm/mach-omap2/timer.c | 4 ++++ arch/arm/plat-omap/dmtimer.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index e3b9931..ad5b29a 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c @@ -473,6 +473,10 @@ static int __init omap2_dm_timer_init(void) { int ret; + /* If dtb is there, the devices will be created dynamically */ + if (of_have_populated_dt()) + return -ENODEV; + ret = omap_hwmod_for_each_by_class("timer", omap_timer_init, NULL); if (unlikely(ret)) { pr_err("%s: device registration failed.\n", __func__); diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 626ad8c..5a51b67 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -40,6 +40,8 @@ #include <linux/device.h> #include <linux/err.h> #include <linux/pm_runtime.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <plat/dmtimer.h> #include <plat/omap-pm.h> @@ -123,7 +125,7 @@ static void omap_dm_timer_wait_for_reset(struct omap_dm_timer *timer) static void omap_dm_timer_reset(struct omap_dm_timer *timer) { omap_dm_timer_enable(timer); - if (timer->pdev->id != 1) { + if (timer->id != 1) { omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG, 0x06); omap_dm_timer_wait_for_reset(timer); } @@ -214,7 +216,7 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int id) spin_lock_irqsave(&dm_timer_lock, flags); list_for_each_entry(t, &omap_timer_list, node) { - if (t->pdev->id == id && !t->reserved) { + if (t->id == id && !t->reserved) { timer = t; timer->reserved = 1; break; @@ -414,7 +416,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) * use the clock framework to set the parent clock. To be removed * once OMAP1 migrated to using clock framework for dmtimers */ - if (pdata->set_timer_src) + if (pdata && pdata->set_timer_src) return pdata->set_timer_src(timer->pdev, source); fclk = clk_get(&timer->pdev->dev, "fck"); @@ -695,7 +697,7 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct dmtimer_platform_data *pdata = pdev->dev.platform_data; - if (!pdata) { + if (!pdata && !dev->of_node) { dev_err(dev, "%s: no platform data.\n", __func__); return -ENODEV; } @@ -724,11 +726,21 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev) return -ENOMEM; } - timer->id = pdev->id; + if (dev->of_node) { + timer->id = of_alias_get_id(dev->of_node, "timer"); + + if (of_find_property(dev->of_node, "ti,timer-alwon", NULL)) + timer->capability |= OMAP_TIMER_ALWON; + if (of_find_property(dev->of_node, "ti,timer-pwm", NULL)) + timer->capability |= OMAP_TIMER_HAS_PWM; + } else { + timer->id = pdev->id; + timer->capability = pdata->timer_capability; + } + timer->irq = irq->start; timer->reserved = omap_dm_timer_reserved_systimer(timer->id); timer->pdev = pdev; - timer->capability = pdata->timer_capability; /* Skip pm_runtime_enable for OMAP1 */ if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) { @@ -778,11 +790,19 @@ static int __devexit omap_dm_timer_remove(struct platform_device *pdev) return ret; } +static const struct of_device_id omap_timer_match[] = { + { .compatible = "ti,omap3-timer", }, + { .compatible = "ti,omap2-timer", }, + {}, +}; +MODULE_DEVICE_TABLE(of, omap_timer_match); + static struct platform_driver omap_dm_timer_driver = { .probe = omap_dm_timer_probe, .remove = __devexit_p(omap_dm_timer_remove), .driver = { .name = "omap_timer", + .of_match_table = of_match_ptr(omap_timer_match), }, }; -- 1.7.9.5
next prev parent reply other threads:[~2012-07-13 22:26 UTC|newest] Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-07-13 22:26 [RFC RESEND 0/4] ARM: OMAP3+: Add device-tree support for timers Jon Hunter 2012-07-13 22:26 ` Jon Hunter 2012-07-13 22:26 ` [RFC RESEND 1/4] arm/dts: OMAP: Add timer nodes Jon Hunter 2012-07-13 22:26 ` Jon Hunter 2012-07-14 2:15 ` Rob Herring 2012-07-14 2:15 ` Rob Herring [not found] ` <5000D647.4090200-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2012-07-14 5:30 ` Mis?use of aliases Mitch Bradley [not found] ` <50010402.3050502-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org> 2012-07-14 16:37 ` David Gibson 2012-07-14 16:37 ` David Gibson [not found] ` <20120714163701.GI11326-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org> 2012-07-14 17:07 ` Mitch Bradley 2012-07-14 17:07 ` Mitch Bradley [not found] ` <5001A745.3000509-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org> 2012-07-15 7:39 ` David Gibson 2012-07-15 7:39 ` David Gibson 2012-07-14 6:56 ` [RFC RESEND 1/4] arm/dts: OMAP: Add timer nodes Paul Walmsley 2012-07-14 6:56 ` Paul Walmsley 2012-07-14 14:01 ` Rob Herring 2012-07-14 14:01 ` Rob Herring [not found] ` <50017BB1.8010702-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2012-07-14 17:42 ` Paul Walmsley 2012-07-14 17:42 ` Paul Walmsley 2012-07-16 17:48 ` Paul Walmsley 2012-07-16 17:48 ` Paul Walmsley 2012-07-16 15:56 ` Jon Hunter 2012-07-16 15:56 ` Jon Hunter 2012-07-18 7:19 ` Tony Lindgren 2012-07-18 7:19 ` Tony Lindgren 2012-07-18 15:11 ` Jon Hunter 2012-07-18 15:11 ` Jon Hunter 2012-07-23 15:24 ` Jon Hunter 2012-07-23 15:24 ` Jon Hunter 2012-08-15 9:11 ` Vaibhav Hiremath 2012-08-15 9:11 ` Vaibhav Hiremath 2012-08-16 15:04 ` Jon Hunter 2012-08-16 15:04 ` Jon Hunter 2012-08-30 20:14 ` Tony Lindgren 2012-08-30 20:14 ` Tony Lindgren 2012-09-07 20:26 ` Jon Hunter 2012-09-07 20:26 ` Jon Hunter 2012-09-07 20:56 ` Tony Lindgren 2012-09-07 20:56 ` Tony Lindgren 2012-09-07 21:16 ` Jon Hunter 2012-09-07 21:16 ` Jon Hunter 2012-09-06 13:45 ` Rob Herring 2012-09-06 13:45 ` Rob Herring [not found] ` <5048A8F6.6080108-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2012-09-07 2:09 ` Jon Hunter 2012-09-07 2:09 ` Jon Hunter 2012-07-13 22:26 ` [RFC RESEND 2/4] ARM: OMAP3: Dynamically disable secure timer nodes for secure devices Jon Hunter 2012-07-13 22:26 ` Jon Hunter 2012-08-15 9:13 ` Vaibhav Hiremath 2012-08-15 9:13 ` Vaibhav Hiremath 2012-08-16 16:57 ` Jon Hunter 2012-08-16 16:57 ` Jon Hunter [not found] ` <502D2686.4090107-l0cyMroinI0@public.gmane.org> 2012-08-17 5:32 ` Hiremath, Vaibhav 2012-08-17 5:32 ` Hiremath, Vaibhav 2012-08-17 12:24 ` Jon Hunter 2012-08-17 12:24 ` Jon Hunter 2012-08-24 15:56 ` Hiremath, Vaibhav 2012-08-24 15:56 ` Hiremath, Vaibhav 2012-07-13 22:26 ` [RFC RESEND 3/4] ARM: OMAP4: Add timer clock aliases for device-tree Jon Hunter 2012-07-13 22:26 ` Jon Hunter 2012-07-13 22:26 ` Jon Hunter [this message] 2012-07-13 22:26 ` [RFC RESEND 4/4] ARM: OMAP: Add DT support for timer driver Jon Hunter 2012-07-13 23:41 ` Paul Walmsley 2012-07-13 23:41 ` Paul Walmsley [not found] ` <alpine.DEB.2.00.1207131740460.25585-rwI8Ez+7Ko+d5PgPZx9QOdBPR1lH4CV8@public.gmane.org> 2012-07-14 0:57 ` Jon Hunter 2012-07-14 0:57 ` Jon Hunter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1342218413-30116-5-git-send-email-jon-hunter@ti.com \ --to=jon-hunter@ti.com \ --cc=b-cousson@ti.com \ --cc=devicetree-discuss@lists.ozlabs.org \ --cc=grant.likely@secretlab.ca \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-omap@vger.kernel.org \ --cc=paul@pwsan.com \ --cc=rob.herring@calxeda.com \ --cc=tarun.kanti@ti.com \ --cc=tony@atomide.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.