From: Jon Hunter <jon-hunter@ti.com>
To: Afzal Mohammed <afzal@ti.com>
Cc: tony@atomide.com, paul@pwsan.com, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 04/14] ARM: OMAP2+: gpmc: minimal driver support
Date: Tue, 12 Jun 2012 14:19:22 -0500 [thread overview]
Message-ID: <4FD7963A.9000003@ti.com> (raw)
In-Reply-To: <54e643eb1b4dbefcbb52580fa582043bf4f0da3d.1339419492.git.afzal@ti.com>
On 06/11/2012 09:26 AM, Afzal Mohammed wrote:
> Create a minimal driver out of gpmc code.
> Responsibilities handled by earlier gpmc
> initialization is now achieved in probe.
>
> Signed-off-by: Afzal Mohammed <afzal@ti.com>
> ---
> arch/arm/mach-omap2/gpmc.c | 170 ++++++++++++++++++++++++++++++++------------
> 1 file changed, 123 insertions(+), 47 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
> index 6dbddb9..a91f40f 100644
> --- a/arch/arm/mach-omap2/gpmc.c
> +++ b/arch/arm/mach-omap2/gpmc.c
> @@ -24,6 +24,7 @@
> #include <linux/io.h>
> #include <linux/module.h>
> #include <linux/interrupt.h>
> +#include <linux/platform_device.h>
>
> #include <asm/mach-types.h>
> #include <plat/gpmc.h>
> @@ -31,6 +32,8 @@
>
> #include <plat/sdrc.h>
>
> +#define DRIVER_NAME "omap-gpmc"
> +
> /* GPMC register offsets */
> #define GPMC_REVISION 0x00
> #define GPMC_SYSCONFIG 0x10
> @@ -115,6 +118,21 @@ struct omap3_gpmc_regs {
> struct gpmc_cs_config cs_context[GPMC_CS_NUM];
> };
>
> +struct gpmc_peripheral {
> + char *name;
> + int id;
> + void *pdata;
> + unsigned pdata_size;
> + struct resource *per_res;
> + unsigned per_res_cnt;
> + struct resource *gpmc_res;
> + unsigned gpmc_res_cnt;
> + bool have_waitpin;
> + bool waitpin_polarity;
> + unsigned waitpin;
> + struct platform_device *pdev;
> +};
> +
> static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
> static struct irq_chip gpmc_irq_chip;
> static unsigned gpmc_irq_start;
> @@ -124,6 +142,10 @@ static struct resource gpmc_cs_mem[GPMC_CS_NUM];
> static DEFINE_SPINLOCK(gpmc_mem_lock);
> static unsigned int gpmc_cs_map; /* flag for cs which are initialized */
> static int gpmc_ecc_used = -EINVAL; /* cs using ecc engine */
> +static struct device *gpmc_dev;
> +static u32 gpmc_revision;
> +static int gpmc_irq;
> +static resource_size_t phys_base, mem_size;
>
> static void __iomem *gpmc_base;
>
> @@ -433,6 +455,19 @@ static int gpmc_cs_insert_mem(int cs, unsigned long base, unsigned long size)
> return r;
> }
>
> +static int gpmc_cs_delete_mem(int cs)
> +{
> + struct resource *res = &gpmc_cs_mem[cs];
> + int r;
> +
> + spin_lock(&gpmc_mem_lock);
> + r = release_resource(&gpmc_cs_mem[cs]);
> + res->start = res->end = 0;
> + spin_unlock(&gpmc_mem_lock);
> +
> + return r;
> +}
> +
> int gpmc_cs_request(int cs, unsigned long size, unsigned long *base)
> {
> struct resource *res = &gpmc_cs_mem[cs];
> @@ -769,7 +804,7 @@ static void gpmc_irq_noop(struct irq_data *data) { }
>
> static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
>
> -static int gpmc_setup_irq(int gpmc_irq)
> +static int gpmc_setup_irq(void)
> {
> int i;
> u32 regval;
> @@ -813,7 +848,37 @@ static int gpmc_setup_irq(int gpmc_irq)
> return request_irq(gpmc_irq, gpmc_handle_irq, 0, "gpmc", NULL);
> }
>
> -static void __init gpmc_mem_init(void)
> +static __exit int gpmc_free_irq(void)
> +{
> + int i;
> +
> + if (gpmc_irq)
> + free_irq(gpmc_irq, NULL);
> +
> + for (i = 0; i < GPMC_NR_IRQ; i++) {
> + irq_set_handler(gpmc_client_irq[i].irq, NULL);
> + irq_set_chip(gpmc_client_irq[i].irq, &no_irq_chip);
> + irq_modify_status(gpmc_client_irq[i].irq, 0, 0);
> + }
> +
> + irq_free_descs(gpmc_irq_start, GPMC_NR_IRQ);
> +
> + return 0;
> +}
> +
> +static void __devexit gpmc_mem_exit(void)
> +{
> + int cs;
> +
> + for (cs = 0; cs < GPMC_CS_NUM; cs++) {
> + if (!gpmc_cs_mem_enabled(cs))
> + continue;
> + gpmc_cs_delete_mem(cs);
> + }
> +
> +}
> +
> +static void __devinit gpmc_mem_init(void)
> {
> int cs;
> unsigned long boot_rom_space = 0;
> @@ -840,64 +905,75 @@ static void __init gpmc_mem_init(void)
> }
> }
>
> -static int __init gpmc_init(void)
> +static __devinit int gpmc_probe(struct platform_device *pdev)
> {
> u32 l;
> - int ret = -EINVAL;
> - int gpmc_irq;
> - char *ck = NULL;
> -
> - if (cpu_is_omap24xx()) {
> - ck = "core_l3_ck";
> - if (cpu_is_omap2420())
> - l = OMAP2420_GPMC_BASE;
> - else
> - l = OMAP34XX_GPMC_BASE;
> - gpmc_irq = INT_34XX_GPMC_IRQ;
> - } else if (cpu_is_omap34xx()) {
> - ck = "gpmc_fck";
> - l = OMAP34XX_GPMC_BASE;
> - gpmc_irq = INT_34XX_GPMC_IRQ;
> - } else if (cpu_is_omap44xx()) {
> - ck = "gpmc_ck";
> - l = OMAP44XX_GPMC_BASE;
> - gpmc_irq = OMAP44XX_IRQ_GPMC;
> - }
> + struct resource *res;
>
> - if (WARN_ON(!ck))
> - return ret;
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (res == NULL)
> + return -ENOENT;
>
> - gpmc_l3_clk = clk_get(NULL, ck);
> - if (IS_ERR(gpmc_l3_clk)) {
> - printk(KERN_ERR "Could not get GPMC clock %s\n", ck);
> - BUG();
> - }
> + phys_base = res->start;
> + mem_size = resource_size(res);
>
> - gpmc_base = ioremap(l, SZ_4K);
> - if (!gpmc_base) {
> - clk_put(gpmc_l3_clk);
> - printk(KERN_ERR "Could not get GPMC register memory\n");
> - BUG();
> - }
> + gpmc_base = devm_request_and_ioremap(&pdev->dev, res);
> + if (!gpmc_base)
> + return -EADDRNOTAVAIL;
> +
> + gpmc_dev = &pdev->dev;
> +
> + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> + if (res == NULL)
> + dev_warn(gpmc_dev, "Failed to get resource: irq\n");
> + else
> + gpmc_irq = res->start;
>
> clk_enable(gpmc_l3_clk);
We should be able to get rid of the clk_enable() here and use ...
pm_runtime_enable(&pdev->dev);
pm_runtime_get(&pdev->dev);
The clk_disable should also be replaced with a pm_runtime_put(). You
will also need to include pm_runtime.h.
Jon
next prev parent reply other threads:[~2012-06-12 19:19 UTC|newest]
Thread overview: 116+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-11 14:25 [PATCH v5 00/14] GPMC driver conversion Afzal Mohammed
2012-06-11 14:26 ` [PATCH v5 01/14] ARM: OMAP2+: gpmc: platform definitions Afzal Mohammed
2012-06-12 18:58 ` Jon Hunter
2012-06-13 6:25 ` Mohammed, Afzal
2012-06-11 14:26 ` [PATCH v5 02/14] ARM: OMAP2+: gpmc: Adapt to HWMOD Afzal Mohammed
2012-06-11 19:56 ` Jon Hunter
2012-06-12 6:53 ` Mohammed, Afzal
2012-06-12 17:40 ` Jon Hunter
2012-06-13 5:20 ` Mohammed, Afzal
2012-06-13 12:02 ` Tony Lindgren
2012-06-13 13:05 ` Mohammed, Afzal
2012-06-13 13:39 ` Tony Lindgren
2012-06-13 13:59 ` Mohammed, Afzal
2012-06-13 15:08 ` Jon Hunter
2012-06-14 7:07 ` Mohammed, Afzal
2012-06-13 14:51 ` Jon Hunter
2012-06-14 6:17 ` Mohammed, Afzal
2012-06-14 6:20 ` Mohammed, Afzal
2012-06-14 20:51 ` Jon Hunter
2012-06-15 0:20 ` Paul Walmsley
2012-06-15 15:33 ` Jon Hunter
2012-06-15 10:40 ` Mohammed, Afzal
2012-06-14 7:03 ` Mohammed, Afzal
2012-06-14 13:22 ` Jon Hunter
2012-06-14 13:32 ` Mohammed, Afzal
2012-06-14 18:58 ` Jon Hunter
2012-06-15 10:22 ` Mohammed, Afzal
2012-06-15 12:45 ` Tony Lindgren
2012-06-16 9:15 ` Mohammed, Afzal
2012-06-20 13:28 ` Tony Lindgren
2012-06-20 14:52 ` Mohammed, Afzal
2012-06-20 15:12 ` Tony Lindgren
2012-06-20 23:35 ` Jon Hunter
2012-06-22 13:29 ` Mohammed, Afzal
2012-06-11 14:26 ` [PATCH v5 03/14] ARM: OMAP2+: gpmc: driver migration helper Afzal Mohammed
2012-06-11 20:30 ` Jon Hunter
2012-06-12 7:09 ` Mohammed, Afzal
2012-06-12 17:46 ` Jon Hunter
2012-06-13 5:25 ` Mohammed, Afzal
2012-06-13 12:04 ` Tony Lindgren
2012-06-13 12:18 ` Mohammed, Afzal
2012-06-13 13:46 ` Mohammed, Afzal
2012-06-14 6:34 ` Tony Lindgren
2012-06-11 14:26 ` [PATCH v5 04/14] ARM: OMAP2+: gpmc: minimal driver support Afzal Mohammed
2012-06-11 20:43 ` Jon Hunter
2012-06-12 7:16 ` Mohammed, Afzal
2012-06-12 17:57 ` Jon Hunter
2012-06-13 12:07 ` Tony Lindgren
2012-06-13 13:12 ` Mohammed, Afzal
2012-06-13 13:40 ` Tony Lindgren
2012-06-13 13:44 ` Tony Lindgren
2012-06-13 13:50 ` Mohammed, Afzal
2012-06-13 13:52 ` Mohammed, Afzal
2012-06-14 6:35 ` Tony Lindgren
2012-06-14 6:40 ` Mohammed, Afzal
2012-06-14 8:39 ` Tony Lindgren
2012-06-14 8:42 ` Mohammed, Afzal
2012-06-13 17:05 ` Jon Hunter
2012-06-12 19:19 ` Jon Hunter [this message]
2012-06-13 6:29 ` Mohammed, Afzal
2012-06-11 14:26 ` [PATCH v5 05/14] ARM: OMAP2+: gpmc: resource creation helpers Afzal Mohammed
2012-06-11 20:57 ` Jon Hunter
2012-06-12 8:30 ` Mohammed, Afzal
2012-06-12 18:02 ` Jon Hunter
2012-06-13 5:29 ` Mohammed, Afzal
2012-06-13 15:33 ` Jon Hunter
2012-06-14 8:44 ` Mohammed, Afzal
2012-06-11 14:26 ` [PATCH v5 06/14] ARM: OMAP2+: gpmc: CS configuration helper Afzal Mohammed
2012-06-11 21:43 ` Jon Hunter
2012-06-12 8:40 ` Mohammed, Afzal
2012-06-12 12:58 ` Mohammed, Afzal
2012-06-12 18:09 ` Jon Hunter
2012-06-13 5:50 ` Mohammed, Afzal
2012-06-13 15:39 ` Jon Hunter
2012-06-14 8:45 ` Mohammed, Afzal
2012-06-12 18:06 ` Jon Hunter
2012-06-13 5:35 ` Mohammed, Afzal
2012-06-11 14:27 ` [PATCH v5 07/14] ARM: OMAP2+: gpmc: time setting (register#) helper Afzal Mohammed
2012-06-12 18:55 ` Jon Hunter
2012-06-13 6:15 ` Mohammed, Afzal
2012-06-11 14:27 ` [PATCH v5 08/14] ARM: OMAP2+: gpmc: bool type timing helper Afzal Mohammed
2012-06-11 22:27 ` Jon Hunter
2012-06-12 8:41 ` Mohammed, Afzal
2012-06-11 14:27 ` [PATCH v5 09/14] ARM: OMAP2+: gpmc: holler if no configuration Afzal Mohammed
2012-06-11 22:30 ` Jon Hunter
2012-06-12 8:44 ` Mohammed, Afzal
2012-06-12 18:11 ` Jon Hunter
2012-06-11 14:27 ` [PATCH v5 10/14] ARM: OMAP2+: gpmc: waitpin helper Afzal Mohammed
2012-06-11 22:59 ` Jon Hunter
2012-06-12 9:00 ` Mohammed, Afzal
2012-06-12 18:15 ` Jon Hunter
2012-06-13 7:37 ` Mohammed, Afzal
2012-06-13 15:44 ` Jon Hunter
2012-06-14 8:48 ` Mohammed, Afzal
2012-06-14 21:06 ` Jon Hunter
2012-06-15 10:50 ` Mohammed, Afzal
2012-06-12 18:37 ` Jon Hunter
2012-06-13 7:47 ` Mohammed, Afzal
2012-06-11 14:27 ` [PATCH v5 11/14] ARM: OMAP2+: gpmc: handle connected peripherals Afzal Mohammed
2012-06-13 15:31 ` Jon Hunter
2012-06-14 8:40 ` Mohammed, Afzal
2012-06-11 14:27 ` [PATCH v5 12/14] ARM: OMAP2+: gpmc: cs reconfigure helper Afzal Mohammed
2012-06-11 23:04 ` Jon Hunter
2012-06-12 9:01 ` Mohammed, Afzal
2012-06-11 14:27 ` [PATCH v5 13/14] ARM: OMAP2+: gpmc: update nand register info Afzal Mohammed
2012-06-11 14:27 ` [PATCH v5 14/14] ARM: OMAP2+: gpmc: writeprotect helper Afzal Mohammed
2012-06-12 18:42 ` Jon Hunter
2012-06-13 6:10 ` Mohammed, Afzal
2012-06-13 16:28 ` Jon Hunter
2012-06-14 8:54 ` Mohammed, Afzal
2012-06-14 9:36 ` Tony Lindgren
2012-06-14 10:21 ` Mohammed, Afzal
2012-06-12 10:39 ` [PATCH v5 00/14] GPMC driver conversion Mohammed, Afzal
2012-06-13 12:33 ` Tony Lindgren
2012-06-15 10:56 ` Mohammed, Afzal
2012-06-15 12:51 ` Tony Lindgren
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=4FD7963A.9000003@ti.com \
--to=jon-hunter@ti.com \
--cc=afzal@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=paul@pwsan.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