From: Kevin Hilman <khilman@ti.com>
To: "DebBarma, Tarun Kanti" <tarun.kanti@ti.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"Gopinath, Thara" <thara@ti.com>
Subject: Re: [PATCH v11 5/8] OMAP: dmtimer: platform driver
Date: Fri, 04 Mar 2011 08:53:14 -0800 [thread overview]
Message-ID: <87wrkej091.fsf@ti.com> (raw)
In-Reply-To: <5A47E75E594F054BAF48C5E4FC4B92AB037A3603BF@dbde02.ent.ti.com> (Tarun Kanti DebBarma's message of "Fri, 4 Mar 2011 12:26:15 +0530")
"DebBarma, Tarun Kanti" <tarun.kanti@ti.com> writes:
>> -----Original Message-----
>> From: Hilman, Kevin
>> Sent: Friday, March 04, 2011 6:59 AM
>> To: DebBarma, Tarun Kanti
>> Cc: linux-omap@vger.kernel.org; Gopinath, Thara
>> Subject: Re: [PATCH v11 5/8] OMAP: dmtimer: platform driver
>>
>> Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:
>>
>> > From: Thara Gopinath <thara@ti.com>
>> >
>> > Add dmtimer platform driver functions which include:
>> > (1) platform driver initialization
>> > (2) driver probe function
>> > (3) driver remove function
>> >
>> > 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>
>>
>> [...]
>>
>> > +/**
>> > + * omap_dm_timer_probe - probe function called for every registered
>> device
>> > + * @pdev: pointer to current timer platform device
>> > + *
>> > + * Called by driver framework at the end of device registration for all
>> > + * timer devices.
>> > + */
>> > +static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
>> > +{
>> > + int ret;
>> > + unsigned long flags;
>> > + struct omap_dm_timer *timer;
>> > + struct resource *mem, *irq, *ioarea;
>> > + struct dmtimer_platform_data *pdata = pdev->dev.platform_data;
>> > +
>> > + if (!pdata) {
>> > + dev_err(&pdev->dev, "%s: no platform data\n", __func__);
>> > + return -ENODEV;
>> > + }
>> > +
>> > + spin_lock_irqsave(&dm_timer_lock, flags);
>> > + list_for_each_entry(timer, &omap_timer_list, node)
>> > + if (!pdata->is_early_init && timer->id == pdev->id) {
>> > + timer->pdev = pdev;
>> > + spin_unlock_irqrestore(&dm_timer_lock, flags);
>> > + dev_dbg(&pdev->dev, "Regular Probed\n");
>> > + return 0;
>> > + }
>> > + spin_unlock_irqrestore(&dm_timer_lock, flags);
>> > +
>> > + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>> > + if (unlikely(!irq)) {
>> > + dev_err(&pdev->dev, "%s: no IRQ resource\n", __func__);
>> > + ret = -ENODEV;
>> > + goto err_free_pdev;
>> > + }
>> > +
>> > + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> > + if (unlikely(!mem)) {
>> > + dev_err(&pdev->dev, "%s: no memory resource\n", __func__);
>> > + ret = -ENODEV;
>> > + goto err_free_pdev;
>> > + }
>> > +
>> > + ioarea = request_mem_region(mem->start, resource_size(mem),
>> > + pdev->name);
>> > + if (!ioarea) {
>> > + dev_err(&pdev->dev, "%s: region already claimed\n", __func__);
>> > + ret = -EBUSY;
>> > + goto err_free_pdev;
>> > + }
>> > +
>> > + timer = kzalloc(sizeof(struct omap_dm_timer), GFP_KERNEL);
>> > + if (!timer) {
>> > + dev_err(&pdev->dev, "%s: no memory for omap_dm_timer\n",
>> > + __func__);
>> > + ret = -ENOMEM;
>> > + goto err_release_ioregion;
>> > + }
>> > +
>> > + timer->io_base = ioremap(mem->start, resource_size(mem));
>> > + if (!timer->io_base) {
>> > + dev_err(&pdev->dev, "%s: ioremap failed\n", __func__);
>> > + ret = -ENOMEM;
>> > + goto err_free_mem;
>> > + }
>> > +
>> > + /*
>> > + * Following func pointers are required by OMAP1's reset code
>> > + * in mach-omap1/dmtimer.c to access to low level read/write.
>> > + */
>> > + if (pdata->is_omap16xx) {
>> > + pdata->dm_timer_read_reg = omap_dm_timer_read_reg;
>> > + pdata->dm_timer_write_reg = omap_dm_timer_write_reg;
>> > + pdata->is_early_init = 0;
>> > + }
>>
>> Can this 'is_omap16xx' check be replaced with an IP revision check?
> Hmm, this not really!
> Unless we introduce a new version to indicate OMAP1.
Ah, I see. Looks like the revision change was after OMAP3, I thought it
was after OMAP1. Sorry.
> If this is what you mean I will make the change.
An OMAP1 check would make this more clear, but really the flag should be
a bool called something like "needs_manual_reset" since after all the
other 'is_omap16xx' checks are removed, this is the only one left.
That being said, I still don't really like this redirection, and find it
rather non intuitive. I'm basically not crazy about the driver passing
functions into the device-specific code. Typically the device-specific
code passes functions into the driver. I see why it's done for the
reset logic, but it's a bit confusing: device code sets 'is_omap16xx'
flag for driver, driver checks flag and sets function pointers for
device code.
What's probably cleaner is to just move the reset functions (back) into
the driver, but only set the reset pointer if pdata->needs_manual_reset
== true, and that flag will only be set on OMAP1 since OMAP2+ is using
hwmod.
Kevin
next prev parent reply other threads:[~2011-03-04 16:53 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 11:26 [PATCH v11 0/8] dmtimer adaptation to platform_driver Tarun Kanti DebBarma
2011-02-24 11:26 ` [PATCH v11 1/8] OMAP2+: dmtimer: add device names to flck nodes Tarun Kanti DebBarma
2011-02-24 11:26 ` [PATCH v11 2/8] OMAP4: hwmod data: add dmtimer version information Tarun Kanti DebBarma
2011-03-04 0:24 ` Kevin Hilman
2011-03-04 5:49 ` DebBarma, Tarun Kanti
2011-03-04 11:16 ` Cousson, Benoit
2011-03-07 11:19 ` DebBarma, Tarun Kanti
2011-02-24 11:26 ` [PATCH v11 3/8] OMAP1: dmtimer: conversion to platform devices Tarun Kanti DebBarma
2011-02-24 11:26 ` [PATCH v11 4/8] OMAP2+: dmtimer: convert " Tarun Kanti DebBarma
2011-03-04 1:01 ` Kevin Hilman
2011-03-04 6:34 ` DebBarma, Tarun Kanti
2011-03-04 17:25 ` Kevin Hilman
2011-03-04 19:24 ` DebBarma, Tarun Kanti
2011-02-24 11:26 ` [PATCH v11 5/8] OMAP: dmtimer: platform driver Tarun Kanti DebBarma
2011-03-04 0:35 ` Kevin Hilman
2011-03-04 9:07 ` DebBarma, Tarun Kanti
2011-03-04 1:29 ` Kevin Hilman
2011-03-04 6:56 ` DebBarma, Tarun Kanti
2011-03-04 16:53 ` Kevin Hilman [this message]
2011-03-04 19:07 ` DebBarma, Tarun Kanti
2011-02-24 11:26 ` [PATCH v11 6/8] dmtimer: switch-over to platform device driver Tarun Kanti DebBarma
2011-03-04 1:25 ` Kevin Hilman
2011-03-04 6:57 ` DebBarma, Tarun Kanti
2011-03-04 17:23 ` Tony Lindgren
2011-03-04 18:52 ` DebBarma, Tarun Kanti
2011-03-04 19:37 ` Tony Lindgren
2011-03-04 19:41 ` DebBarma, Tarun Kanti
2011-03-05 7:54 ` Santosh Shilimkar
2011-03-07 12:54 ` DebBarma, Tarun Kanti
2011-03-08 0:07 ` Tony Lindgren
2011-03-08 0:11 ` DebBarma, Tarun Kanti
2011-02-24 11:26 ` [PATCH v11 7/8] OMAP: dmtimer: pm_runtime support Tarun Kanti DebBarma
2011-03-04 1:22 ` Kevin Hilman
2011-03-04 9:18 ` DebBarma, Tarun Kanti
2011-03-04 17:28 ` Tony Lindgren
2011-03-04 18:57 ` DebBarma, Tarun Kanti
2011-03-04 19:37 ` Tony Lindgren
2011-03-04 19:52 ` DebBarma, Tarun Kanti
2011-03-05 0:01 ` Tony Lindgren
2011-03-05 0:22 ` DebBarma, Tarun Kanti
2011-03-08 0:10 ` Tony Lindgren
2011-03-08 0:13 ` DebBarma, Tarun Kanti
2011-02-24 11:26 ` [PATCH v11 8/8] OMAP: dmtimer: add timeout to low-level routines Tarun Kanti DebBarma
2011-02-25 14:08 ` [PATCH v11 0/8] dmtimer adaptation to platform_driver 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=87wrkej091.fsf@ti.com \
--to=khilman@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 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.