From: Santosh Shilimkar <santosh.shilimkar@ti.com>
To: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: linux-omap@vger.kernel.org, Thara Gopinath <thara@ti.com>
Subject: Re: [PATCH v13 04/11] OMAP2+: dmtimer: convert to platform devices
Date: Fri, 29 Apr 2011 16:15:04 +0530 [thread overview]
Message-ID: <4DBA96B0.9060308@ti.com> (raw)
In-Reply-To: <1302969063-8231-5-git-send-email-tarun.kanti@ti.com>
On 4/16/2011 9:20 PM, Tarun Kanti DebBarma wrote:
> Add routines to converts dmtimers to platform devices. The device data
> is obtained from hwmod database of respective platform and is registered
> to device model after successful binding to driver.
> In addition, capability attribute of each of the timers is added in
> hwmod database.
>
> Signed-off-by: Tarun Kanti DebBarma<tarun.kanti@ti.com>
> Signed-off-by: Thara Gopinath<thara@ti.com>
> Acked-by: Cousson, Benoit<b-cousson@ti.com>
> ---
> arch/arm/mach-omap2/omap_hwmod_2420_data.c | 22 ++++
> arch/arm/mach-omap2/omap_hwmod_2430_data.c | 22 ++++
> arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 27 +++++
> arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 25 +++++
> arch/arm/mach-omap2/timer.c | 158 +++++++++++++++++++++++++++-
> arch/arm/plat-omap/dmtimer.c | 17 ---
> arch/arm/plat-omap/include/plat/dmtimer.h | 13 ++-
> 7 files changed, 265 insertions(+), 19 deletions(-)
>
[...]
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index 2edeb1a..1c80337 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -1,5 +1,5 @@
> /*
> - * linux/arch/arm/mach-omap2/timer-gp.c
> + * linux/arch/arm/mach-omap2/timer.c
> *
> * OMAP2 GP timer support.
> *
> @@ -35,6 +35,7 @@
> #include<linux/irq.h>
> #include<linux/clocksource.h>
> #include<linux/clockchips.h>
> +#include<linux/slab.h>
>
> #include<asm/mach/time.h>
> #include<plat/dmtimer.h>
> @@ -42,6 +43,7 @@
> #include<asm/sched_clock.h>
> #include<plat/common.h>
> #include<plat/omap_hwmod.h>
> +#include<plat/omap_device.h>
>
> /* Parent clocks, eventually these will come from the clock framework */
>
> @@ -129,6 +131,23 @@ static struct clock_event_device clockevent_gpt = {
> .set_mode = omap2_gp_timer_set_mode,
> };
>
> +int __omap_dm_timer_set_source(struct clk *timer_fck, struct clk *parent)
> +{
> + int ret;
> +
> + clk_disable(timer_fck);
> + ret = clk_set_parent(timer_fck, parent);
> + clk_enable(timer_fck);
> +
> + /*
> + * When the functional clock disappears, too quick writes seem
> + * to cause an abort. XXX Is this still necessary?
> + */
> + __delay(300000);
> +
> + return ret;
> +}
> +
> static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
> int gptimer_id,
> const char *fck_source)
> @@ -359,3 +378,140 @@ struct sys_timer omap4_timer = {
> .init = omap4_timer_init,
> };
> #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 dmtimer_platform_data *pdata = pdev->dev.platform_data;
> + struct clk *fclk, *new_fclk;
> + char *new_fclk_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:
> + new_fclk_name = "sys_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_32_KHZ:
> + if (unlikely(cpu_is_omap2420()))
> + new_fclk_name = "func_32k_ck";
> + else
> + new_fclk_name = "32k_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_EXT_CLK:
> + if (pdata->timer_ip_type == OMAP_TIMER_IP_VERSION_1) {
> + new_fclk_name = "alt_ck";
> + break;
> + }
> + dev_err(&pdev->dev, "%s: %d: invalid clk src.\n",
> + __func__, __LINE__);
> + return -EINVAL;
> + }
> +
> + new_fclk = clk_get(&pdev->dev, new_fclk_name);
> + if (IS_ERR_OR_NULL(new_fclk)) {
> + dev_err(&pdev->dev, "%s: %d: clk_get() %s FAILED\n",
> + __func__, __LINE__, new_fclk_name);
> + clk_put(fclk);
> + return -EINVAL;
> + }
> +
> + ret = clk_set_parent(fclk, new_fclk);
> + if (IS_ERR_VALUE(ret)) {
> + dev_err(&pdev->dev, "%s: clk_set_parent() to %s FAILED\n",
> + __func__, new_fclk_name);
> + ret = -EINVAL;
> + }
> +
> + clk_put(new_fclk);
> + clk_put(fclk);
> +
> + return ret;
> +}
I see two functions doing same job of switching timer
clock-source between 32 K and sysclock. This should
be fixed.
Regards
Santosh
next prev parent reply other threads:[~2011-04-29 10:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-16 15:50 [PATCH v13 00/11] dmtimer adaptation to platform_driver Tarun Kanti DebBarma
2011-04-16 15:50 ` [PATCH v13 01/11] OMAP2+: dmtimer: add device names to flck nodes Tarun Kanti DebBarma
2011-04-16 15:50 ` [PATCH v13 02/11] OMAP4: hwmod data: add dmtimer version information Tarun Kanti DebBarma
2011-04-16 15:50 ` [PATCH v13 03/11] OMAP1: dmtimer: conversion to platform devices Tarun Kanti DebBarma
2011-04-16 15:50 ` [PATCH v13 04/11] OMAP2+: dmtimer: convert " Tarun Kanti DebBarma
2011-04-25 9:38 ` DebBarma, Tarun Kanti
2011-04-29 10:45 ` Santosh Shilimkar [this message]
2011-04-16 15:50 ` [PATCH v13 05/11] OMAP: dmtimer: platform driver Tarun Kanti DebBarma
2011-04-16 15:50 ` [PATCH v13 06/11] dmtimer: switch-over to platform device driver Tarun Kanti DebBarma
2011-04-16 15:50 ` [PATCH v13 07/11] OMAP: dmtimer: pm_runtime support Tarun Kanti DebBarma
2011-04-16 15:51 ` [PATCH v13 08/11] OMAP: dmtimer: add timeout to low-level routines Tarun Kanti DebBarma
2011-04-16 15:51 ` [PATCH v13 09/11] OMAP: dmtimer: use mutex instead of spinlock Tarun Kanti DebBarma
2011-04-16 15:51 ` [PATCH v13 10/11] OMAP: dmtimer: mark clocksource and clockevent timers reserved Tarun Kanti DebBarma
2011-04-17 6:12 ` Santosh Shilimkar
2011-04-18 5:50 ` DebBarma, Tarun Kanti
2011-04-25 9:41 ` DebBarma, Tarun Kanti
2011-04-29 10:40 ` Santosh Shilimkar
2011-04-16 15:51 ` [PATCH v13 11/11] OMAP: dmtimer: convert to a driver Tarun Kanti DebBarma
2011-04-29 10:51 ` Santosh Shilimkar
2011-04-29 11:05 ` [PATCH v13 00/11] dmtimer adaptation to platform_driver Santosh Shilimkar
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=4DBA96B0.9060308@ti.com \
--to=santosh.shilimkar@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=tarun.kanti@ti.com \
--cc=thara@ti.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