From: "G, Manjunath Kondaiah" <manjugk@ti.com>
To: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: linux-omap@vger.kernel.org, Thara Gopinath <thara@ti.com>
Subject: Re: [PATCH v5 8/12] OMAP2+: dmtimer: convert to platform devices
Date: Mon, 6 Dec 2010 23:56:33 +0530 [thread overview]
Message-ID: <20101206182633.GE4924@manju-desktop> (raw)
In-Reply-To: <1291679059-13419-9-git-send-email-tarun.kanti@ti.com>
On Tue, Dec 07, 2010 at 05:14:15AM +0530, Tarun Kanti DebBarma wrote:
> Add routines to converts dmtimers to platform devices. The device data
s/converts/convert
> is obtained from hwmod database of respective platform and is registered
> to device model after successful binding to driver. It also provides
> provision to access timers during early boot when pm_runtime framework
> is not completely up and running.
>
> Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> Signed-off-by: Thara Gopinath <thara@ti.com>
> Reviewed-by: Cousson, Benoit <b-cousson@ti.com>
> Reviewed-by: Varadarajan, Charulatha <charu@ti.com>
> ---
> arch/arm/mach-omap2/Makefile | 2 +-
> arch/arm/mach-omap2/dmtimer.c | 174 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 175 insertions(+), 1 deletions(-)
> create mode 100644 arch/arm/mach-omap2/dmtimer.c
>
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 60e51bc..7700ccd 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -4,7 +4,7 @@
>
> # Common support
> obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o \
> - common.o
> + common.o dmtimer.o
>
> omap-2-3-common = irq.o sdrc.o prm2xxx_3xxx.o
> hwmod-common = omap_hwmod.o \
> diff --git a/arch/arm/mach-omap2/dmtimer.c b/arch/arm/mach-omap2/dmtimer.c
> new file mode 100644
> index 0000000..b639082
> --- /dev/null
> +++ b/arch/arm/mach-omap2/dmtimer.c
> @@ -0,0 +1,174 @@
> +/**
> + * OMAP2PLUS Dual-Mode Timers - platform device registration
> + *
> + * Contains first level initialization routines which extracts timers
> + * information from hwmod database and registers with linux device model.
> + * It also has low level function to change the timer input clock source.
> + *
> + * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
> + * Tarun Kanti DebBarma <tarun.kanti@ti.com>
> + * Thara Gopinath <thara@ti.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/io.h>
not required
> +#include <linux/err.h>
> +#include <linux/slab.h>
> +
> +#include <plat/dmtimer.h>
> +#include <plat/omap_hwmod.h>
not required
> +#include <plat/omap_device.h>
> +
> +static int early_timer_count __initdata = 1;
> +
> +/**
> + * omap2_dm_timer_set_src - change the timer input clock source
> + * @pdev: timer platform device pointer
> + * @timer_clk: current clock source
> + * @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 = clk_get(&pdev->dev, "fck");
> + struct clk *new_fclk;
> + char *fclk_name = "32k_ck"; /* default name */
> +
> + switch (source) {
> + case OMAP_TIMER_SRC_SYS_CLK:
> + fclk_name = "sys_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_32_KHZ:
> + fclk_name = "32k_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_EXT_CLK:
> + if (pdata->timer_ip_type == OMAP_TIMER_IP_VERSION_1) {
> + fclk_name = "alt_ck";
> + break;
> + }
> + dev_dbg(&pdev->dev, "%s: %d: invalid clk src.\n",
> + __func__, __LINE__);
> + return -EINVAL;
> + }
> +
> + if (IS_ERR_OR_NULL(fclk)) {
> + dev_dbg(&pdev->dev, "%s: %d: clk_get() FAILED\n",
> + __func__, __LINE__);
> + return -EINVAL;
> + }
> +
> + new_fclk = clk_get(&pdev->dev, fclk_name);
> + if (IS_ERR_OR_NULL(new_fclk)) {
> + dev_dbg(&pdev->dev, "%s: %d: clk_get() %s FAILED\n",
> + __func__, __LINE__, fclk_name);
> + clk_put(fclk);
> + return -EINVAL;
> + }
> +
> + ret = clk_set_parent(fclk, new_fclk);
> + if (IS_ERR_VALUE(ret)) {
> + dev_dbg(&pdev->dev, "%s: clk_set_parent() to %s FAILED\n",
> + __func__, fclk_name);
> + ret = -EINVAL;
> + }
> +
> + clk_put(new_fclk);
> + clk_put(fclk);
> +
> + return ret;
> +}
> +
> +struct omap_device_pm_latency omap2_dmtimer_latency[] = {
> + {
> + .deactivate_func = omap_device_idle_hwmods,
> + .activate_func = omap_device_enable_hwmods,
> + .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
> + },
> +};
> +
> +/**
> + * omap_timer_init - build and register timer device with an
> + * associated timer hwmod
> + * @oh: timer hwmod pointer to be used to build timer device
> + * @user: parameter that can be passed from calling hwmod API
> + *
> + * Called by omap_hwmod_for_each_by_class to register each of the timer
> + * devices present in the system. The number of timer devices is known
> + * by parsing through the hwmod database for a given class name. At the
> + * end of function call memory is allocated for timer device and it is
> + * registered to the framework ready to be proved by the driver.
> + */
> +static int __init omap_timer_init(struct omap_hwmod *oh, void *user)
> +{
> + int id;
> + int ret = 0;
> + char *name = "omap_timer";
> + struct dmtimer_platform_data *pdata;
> + struct omap_device *od;
> +
> + pr_debug("%s: %s\n", __func__, oh->name);
> +
> + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
> + if (!pdata) {
> + pr_err("%s: No memory for [%s]\n", __func__, oh->name);
> + return -ENOMEM;
> + }
> +
> + if (user)
> + pdata->is_early_init = 1;
> + else
> + pdata->is_early_init = 0;
> +
> + /* hook clock set/get functions */
> + pdata->set_timer_src = omap2_dm_timer_set_src;
> +
> + /* read timer ip version */
redundant. mentioning VERSION2 is omap4 will be helpful.
> + pdata->timer_ip_type = oh->class->rev;
> + if (pdata->timer_ip_type == OMAP_TIMER_IP_VERSION_2) {
> + pdata->func_offset = VERSION2_TIMER_WAKEUP_EN_REG_OFFSET;
> + pdata->intr_offset = VERSION2_TIMER_STAT_REG_OFFSET;
> + } else {
> + pdata->func_offset = 0;
> + pdata->intr_offset = 0;
> + }
> +
> + /*
> + * Extract the id from name field in hwmod database
> + * and use the same for constructing ids' for the
id's
-Manjunath
next prev parent reply other threads:[~2010-12-06 18:26 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-06 23:44 [PATCH v5 0/12] dmtimer adaptation to platform_driver Tarun Kanti DebBarma
2010-12-06 16:28 ` G, Manjunath Kondaiah
2010-12-07 4:59 ` DebBarma, Tarun Kanti
2010-12-14 2:09 ` Kevin Hilman
2010-12-06 23:44 ` [PATCH v5 1/12] OMAP2+: dmtimer: add device names to flck nodes Tarun Kanti DebBarma
2010-12-06 23:44 ` [PATCH v5 2/12] OMAP2420: hwmod data: add dmtimer Tarun Kanti DebBarma
2010-12-06 16:57 ` G, Manjunath Kondaiah
2010-12-06 23:44 ` [PATCH v5 3/12] OMAP2430: " Tarun Kanti DebBarma
2010-12-06 23:44 ` [PATCH v5 4/12] OMAP3: " Tarun Kanti DebBarma
2010-12-06 23:44 ` [PATCH v5 5/12] OMAP4: " Tarun Kanti DebBarma
2010-12-06 23:44 ` [PATCH v5 6/12] OMAP: dmtimer: infrastructure to support hwmod Tarun Kanti DebBarma
2010-12-06 17:09 ` G, Manjunath Kondaiah
2010-12-07 4:50 ` DebBarma, Tarun Kanti
2010-12-06 23:44 ` [PATCH v5 7/12] OMAP1: dmtimer: conversion to platform devices Tarun Kanti DebBarma
2010-12-06 17:56 ` G, Manjunath Kondaiah
2010-12-07 5:17 ` DebBarma, Tarun Kanti
2010-12-06 23:44 ` [PATCH v5 8/12] OMAP2+: dmtimer: convert " Tarun Kanti DebBarma
2010-12-06 18:26 ` G, Manjunath Kondaiah [this message]
2010-12-07 5:21 ` DebBarma, Tarun Kanti
2010-12-07 5:46 ` Varadarajan, Charulatha
2010-12-07 5:50 ` DebBarma, Tarun Kanti
2010-12-06 23:44 ` [PATCH v5 9/12] OMAP: dmtimer: platform driver Tarun Kanti DebBarma
2010-12-06 19:10 ` G, Manjunath Kondaiah
2010-12-07 5:32 ` DebBarma, Tarun Kanti
2010-12-07 5:47 ` G, Manjunath Kondaiah
2010-12-07 6:14 ` DebBarma, Tarun Kanti
2010-12-06 23:44 ` [PATCH v5 10/12] OMAP: dmtimer: switch-over to platform device driver Tarun Kanti DebBarma
2010-12-07 5:27 ` Varadarajan, Charulatha
2010-12-07 5:49 ` DebBarma, Tarun Kanti
2010-12-13 15:07 ` Cousson, Benoit
2010-12-06 23:44 ` [PATCH v5 11/12] OMAP: dmtimer: pm_runtime support Tarun Kanti DebBarma
2010-12-06 23:44 ` [PATCH v5 12/12] OMAP: dmtimer: add timeout to low-level routines Tarun Kanti DebBarma
2010-12-14 6:45 ` [PATCH v5 0/12] dmtimer adaptation to platform_driver Paul Walmsley
2010-12-15 2:06 ` Kevin Hilman
2010-12-15 4:59 ` DebBarma, Tarun Kanti
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=20101206182633.GE4924@manju-desktop \
--to=manjugk@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;
as well as URLs for NNTP newsgroup(s).