From: Jon Hunter <jon-hunter@ti.com>
To: linux-omap <linux-omap@vger.kernel.org>
Cc: Tony Lindgren <tony@atomide.com>,
Tarun Kanti DebBarma <tarun.kanti@ti.com>,
Jon Hunter <jon-hunter@ti.com>
Subject: [PATCH V4 11/12] ARM: OMAP2+: Move dmtimer clock set function to dmtimer driver
Date: Tue, 5 Jun 2012 12:34:59 -0500 [thread overview]
Message-ID: <1338917700-29174-12-git-send-email-jon-hunter@ti.com> (raw)
In-Reply-To: <1338917700-29174-1-git-send-email-jon-hunter@ti.com>
OMAP1 uses an architecture specific function for setting the dmtimer clock
source, where as the OMAP2+ devices use the clock framework. Eventually OMAP1
device should also use the clock framework and hence we should not any
architecture specific functions.
For now move the OMAP2+ function for configuring the clock source into the
dmtimer driver. Therefore, we do no longer need to specify an architecture
specific function for setting the clock source for OMAP2+ devices. This will
simplify device tree migration of the dmtimers for OMAP2+ devices.
>From now on, only OMAP1 devices should specify an architecture specific
function for setting the clock source via the platform data set_dmtimer_src()
function pointer.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
arch/arm/mach-omap2/timer.c | 55 -----------------------------
arch/arm/plat-omap/dmtimer.c | 46 +++++++++++++++++++++++-
arch/arm/plat-omap/include/plat/dmtimer.h | 1 +
3 files changed, 46 insertions(+), 56 deletions(-)
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 67a97cd..b5b5d92 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -395,59 +395,6 @@ OMAP_SYS_TIMER(4)
#endif
/**
- * omap2_dm_timer_set_src - change the timer input clock source
- * @pdev: timer platform device pointer
- * @source: array index of parent clock source
- */
-static int omap2_dm_timer_set_src(struct platform_device *pdev, int source)
-{
- int ret;
- struct clk *fclk, *parent;
- char *parent_name = NULL;
-
- fclk = clk_get(&pdev->dev, "fck");
- if (IS_ERR_OR_NULL(fclk)) {
- dev_err(&pdev->dev, "%s: %d: clk_get() FAILED\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- switch (source) {
- case OMAP_TIMER_SRC_SYS_CLK:
- parent_name = "sys_ck";
- break;
-
- case OMAP_TIMER_SRC_32_KHZ:
- parent_name = "32k_ck";
- break;
-
- case OMAP_TIMER_SRC_EXT_CLK:
- parent_name = "alt_ck";
- break;
- }
-
- parent = clk_get(&pdev->dev, parent_name);
- if (IS_ERR_OR_NULL(parent)) {
- dev_err(&pdev->dev, "%s: %d: clk_get() %s FAILED\n",
- __func__, __LINE__, parent_name);
- clk_put(fclk);
- return -EINVAL;
- }
-
- ret = clk_set_parent(fclk, parent);
- if (IS_ERR_VALUE(ret)) {
- dev_err(&pdev->dev, "%s: clk_set_parent() to %s FAILED\n",
- __func__, parent_name);
- ret = -EINVAL;
- }
-
- clk_put(parent);
- clk_put(fclk);
-
- return ret;
-}
-
-/**
* omap_timer_init - build and register timer device with an
* associated timer hwmod
* @oh: timer hwmod pointer to be used to build timer device
@@ -494,8 +441,6 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
*/
sscanf(oh->name, "timer%2d", &id);
- pdata->set_timer_src = omap2_dm_timer_set_src;
-
if (timer_dev_attr)
pdata->timer_capability = timer_dev_attr->timer_capability;
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 6510e5e..6a70889 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -397,6 +397,8 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
{
int ret;
+ char *parent_name = NULL;
+ struct clk *fclk, *parent;
struct dmtimer_platform_data *pdata;
if (unlikely(!timer))
@@ -407,7 +409,49 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
if (source < 0 || source >= 3)
return -EINVAL;
- ret = pdata->set_timer_src(timer->pdev, source);
+ /*
+ * FIXME: Used for OMAP1 devices only because they do not currently
+ * 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)
+ return pdata->set_timer_src(timer->pdev, source);
+
+ fclk = clk_get(&timer->pdev->dev, "fck");
+ if (IS_ERR_OR_NULL(fclk)) {
+ pr_err("%s: fck not found\n", __func__);
+ return -EINVAL;
+ }
+
+ switch (source) {
+ case OMAP_TIMER_SRC_SYS_CLK:
+ parent_name = "sys_ck";
+ break;
+
+ case OMAP_TIMER_SRC_32_KHZ:
+ parent_name = "32k_ck";
+ break;
+
+ case OMAP_TIMER_SRC_EXT_CLK:
+ parent_name = "alt_ck";
+ break;
+ }
+
+ parent = clk_get(&timer->pdev->dev, parent_name);
+ if (IS_ERR_OR_NULL(parent)) {
+ pr_err("%s: %s not found\n", __func__, parent_name);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = clk_set_parent(fclk, parent);
+ if (IS_ERR_VALUE(ret))
+ pr_err("%s: failed to set %s as parent\n", __func__,
+ parent_name);
+
+ clk_put(parent);
+out:
+ clk_put(fclk);
return ret;
}
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index c039e84..19e7fa5 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -90,6 +90,7 @@ struct timer_regs {
};
struct dmtimer_platform_data {
+ /* set_timer_src - Only used for OMAP1 devices */
int (*set_timer_src)(struct platform_device *pdev, int source);
u32 timer_capability;
};
--
1.7.9.5
next prev parent reply other threads:[~2012-06-05 17:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-05 17:34 [PATCH V4 00/12] ARM: OMAP: DMTIMER clean-up and fixes in preparation for device-tree Jon Hunter
2012-06-05 17:34 ` [PATCH V4 01/12] ARM: OMAP: Remove unnecessary clk structure Jon Hunter
2012-06-05 17:34 ` [PATCH V4 02/12] ARM: OMAP2+: Remove unused max number of timers definition Jon Hunter
2012-06-05 17:34 ` [PATCH V4 03/12] ARM: OMAP2+: Add dmtimer platform function to reserve systimers Jon Hunter
2012-06-05 17:34 ` [PATCH V4 04/12] ARM: OMAP: Add DMTIMER capability variable to represent timer features Jon Hunter
2012-06-05 17:34 ` [PATCH V4 05/12] ARM: OMAP2+: HWMOD: Correct timer device attributes Jon Hunter
2012-06-08 7:40 ` Tony Lindgren
2012-06-13 23:53 ` Paul Walmsley
2012-06-14 9:44 ` Tony Lindgren
2012-06-13 23:53 ` Paul Walmsley
2012-06-05 17:34 ` [PATCH V4 06/12] ARM: OMAP2+: Fix external clock support for dmtimers Jon Hunter
2012-06-05 17:34 ` [PATCH V4 07/12] ARM: OMAP: Remove loses_context variable from timer platform data Jon Hunter
2012-06-05 17:34 ` [PATCH V4 08/12] ARM: OMAP: Remove timer function pointer for context loss counter Jon Hunter
2012-06-05 17:34 ` [PATCH V4 09/12] ARM: OMAP: Add flag to indicate if a timer needs a manual reset Jon Hunter
2012-06-05 17:34 ` [PATCH V4 10/12] ARM: OMAP1: Fix dmtimer support Jon Hunter
2012-06-05 17:34 ` Jon Hunter [this message]
2012-06-05 17:35 ` [PATCH V4 12/12] ARM: OMAP2+: Simplify dmtimer clock aliases Jon Hunter
2012-06-14 20:31 ` Paul Walmsley
2012-06-15 15:27 ` Jon Hunter
2012-06-16 1:34 ` Paul Walmsley
2012-06-16 1:38 ` Paul Walmsley
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=1338917700-29174-12-git-send-email-jon-hunter@ti.com \
--to=jon-hunter@ti.com \
--cc=linux-omap@vger.kernel.org \
--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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox