All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Varadarajan, Charulatha" <charu@ti.com>
To: tony@atomide.com, linux-omap@vger.kernel.org
Cc: khilman@deeprootsystems.com, paul@pwsan.com, b-cousson@ti.com,
	rnayak@ti.com, p-basak2@ti.com, "Varadarajan,
	Charulatha" <charu@ti.com>
Subject: [PATCH v6 09/13] OMAP2PLUS: GPIO: use omap_device_build for device registration
Date: Sat, 18 Sep 2010 19:45:49 +0530	[thread overview]
Message-ID: <1284819353-8512-10-git-send-email-charu@ti.com> (raw)
In-Reply-To: <1284819353-8512-1-git-send-email-charu@ti.com>

Use omap_device_build() API instead of platform_device_register for
GPIO device registration. For OMAP2PLUS chips, the device specific
data defined in centralized hwmod database will be used.

gpio_init needs to be done before machine_init functions access
gpio APIs. Hence gpio_init is made as a postcore_initcall.

Signed-off-by: Charulatha V <charu@ti.com>
Reviewed-by: Basak, Partha <p-basak2@ti.com>
---
 arch/arm/mach-omap2/gpio.c |   92 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/gpio.c

diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
new file mode 100644
index 0000000..e759311
--- /dev/null
+++ b/arch/arm/mach-omap2/gpio.c
@@ -0,0 +1,92 @@
+/*
+ * gpio.c - OMAP2PLUS-specific gpio code
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ *
+ * Author:
+ *	Charulatha V <charu@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.
+ */
+
+#include <linux/gpio.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+
+#include <plat/omap_hwmod.h>
+#include <plat/omap_device.h>
+
+static struct omap_device_pm_latency omap_gpio_latency[] = {
+	[0] = {
+		.deactivate_func = omap_device_idle_hwmods,
+		.activate_func   = omap_device_enable_hwmods,
+		.flags		 = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
+	},
+};
+
+static int omap2_init_gpio(struct omap_hwmod *oh, void *user)
+{
+	struct omap_device *od;
+	struct omap_gpio_platform_data *pdata;
+	char *name = "omap-gpio";
+	struct omap_gpio_dev_attr *gpio_dev_data;
+
+	if (!oh) {
+		pr_err("Could not look up omap gpio %d\n",
+				gpio_bank_count + 1);
+		return -EINVAL;
+	}
+
+	pdata = kzalloc(sizeof(struct omap_gpio_platform_data),
+					GFP_KERNEL);
+	if (!pdata) {
+		pr_err("Memory allocation failed gpio%d\n",
+				gpio_bank_count + 1);
+		return -ENOMEM;
+	}
+
+	gpio_dev_data = (struct omap_gpio_dev_attr *)oh->dev_attr;
+
+	pdata->gpio_attr = gpio_dev_data;
+	pdata->virtual_irq_start = IH_GPIO_BASE + 32 * gpio_bank_count;
+	pdata->pwrdm = omap_hwmod_get_pwrdm(oh);
+
+	switch (oh->class->rev) {
+	case 0:
+	case 1:
+		pdata->bank_type = METHOD_GPIO_24XX;
+		break;
+	case 2:
+		pdata->bank_type = METHOD_GPIO_44XX;
+		break;
+	default:
+		WARN(1, "Invalid gpio bank_type\n");
+		break;
+	}
+
+	od = omap_device_build(name, gpio_bank_count, oh, pdata,
+				sizeof(*pdata),	omap_gpio_latency,
+				ARRAY_SIZE(omap_gpio_latency),
+				false);
+	WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n",
+				name, oh->name);
+	gpio_bank_count++;
+
+	kfree(pdata);
+	return 0;
+}
+
+/*
+ * gpio_init needs to be done before
+ * machine_init functions access gpio APIs.
+ * Hence gpio_init is a postcore_initcall.
+ */
+static int __init omap2_gpio_init(void)
+{
+	return omap_hwmod_for_each_by_class("gpio", omap2_init_gpio,
+						NULL);
+}
+postcore_initcall(omap2_gpio_init);
-- 
1.7.0.4


  parent reply	other threads:[~2010-09-18 14:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-18 14:15 [PATCH v6 00/13] OMAP: GPIO: Implement GPIO in hwmod way Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 01/13] OMAP: GPIO: Modify init() in preparation for platform device implementation Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 02/13] OMAP: GPIO: Introduce support for OMAP15xx chip GPIO init Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 03/13] OMAP: GPIO: Introduce support for OMAP16xx " Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 04/13] OMAP: GPIO: Introduce support for OMAP7xx " Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 05/13] OMAP2420: hwmod data: Add GPIO Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 06/13] OMAP2430: " Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 07/13] OMAP3: " Varadarajan, Charulatha
2010-09-21 23:22   ` Kevin Hilman
2010-09-18 14:15 ` [PATCH v6 08/13] OMAP4: " Varadarajan, Charulatha
2010-09-18 14:15 ` Varadarajan, Charulatha [this message]
2010-09-18 14:15 ` [PATCH v6 10/13] OMAP: GPIO: Implement GPIO as a platform device Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 11/13] OMAP: GPIO: Make gpio_context as part of gpio_bank structure Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 12/13] OMAP: GPIO: Use dev_pm_ops instead of sys_dev_class Varadarajan, Charulatha
2010-09-18 14:15 ` [PATCH v6 13/13] OMAP: GPIO: Remove omap_gpio_init() Varadarajan, Charulatha
2010-09-21  0:07 ` [PATCH v6 00/13] OMAP: GPIO: Implement GPIO in hwmod way Kevin Hilman
2010-09-21 14:06   ` Varadarajan, Charulatha
2010-09-21 17:57     ` Kevin Hilman
2010-09-21 23:34       ` Kevin Hilman
2010-09-22  0:18         ` Kevin Hilman
2010-09-22 14:27           ` Varadarajan, Charulatha
2010-09-22 14:33             ` Kevin Hilman
2010-09-22 23:11           ` Kevin Hilman
2010-09-24 15:12           ` Varadarajan, Charulatha
2010-09-24 18:37             ` Kevin Hilman
2010-09-25 11:59               ` Varadarajan, Charulatha

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=1284819353-8512-10-git-send-email-charu@ti.com \
    --to=charu@ti.com \
    --cc=b-cousson@ti.com \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=p-basak2@ti.com \
    --cc=paul@pwsan.com \
    --cc=rnayak@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 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.