public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-omap@vger.kernel.org, Tony Lindgren <tony@atomide.com>
Subject: [PATCH 7/14] ARM: OMAP: Allow registering pin mux function
Date: Mon, 17 Mar 2008 11:42:31 +0200	[thread overview]
Message-ID: <1205746958-11242-8-git-send-email-tony@atomide.com> (raw)
In-Reply-To: <1205746958-11242-7-git-send-email-tony@atomide.com>

This patch changes pin multiplexing init to allow registering
custom function. The omap_cfg_reg() func will be split into
omap processor specific functions in later patch.

This is done to make adding omap3 pin multiplexing easier.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap1/mux.c       |   21 ++++++++++++++++++---
 arch/arm/mach-omap2/mux.c       |   21 +++++++++++++++++++--
 arch/arm/plat-omap/mux.c        |   30 ++++++++++++++++--------------
 include/asm-arm/arch-omap/mux.h |    8 +++++++-
 4 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap1/mux.c b/arch/arm/mach-omap1/mux.c
index 52c70e5..d74f679 100644
--- a/arch/arm/mach-omap1/mux.c
+++ b/arch/arm/mach-omap1/mux.c
@@ -32,6 +32,8 @@
 
 #ifdef CONFIG_OMAP_MUX
 
+static struct omap_mux_cfg arch_mux_cfg;
+
 #ifdef CONFIG_ARCH_OMAP730
 struct pin_config __initdata_or_module omap730_pins[] = {
 MUX_CFG_730("E2_730_KBR0",        12,   21,    0,   20,   1, 0)
@@ -310,18 +312,31 @@ MUX_CFG("Y14_1610_CCP_DATAM",	 9,   21,    6,   2,   3,   1,    2,     0,  0)
 };
 #endif	/* CONFIG_ARCH_OMAP15XX || CONFIG_ARCH_OMAP16XX */
 
+int __init_or_module omap1_cfg_reg(const struct pin_config *cfg)
+{
+	return 0;
+}
+
 int __init omap1_mux_init(void)
 {
 
 #ifdef CONFIG_ARCH_OMAP730
-	omap_mux_register(omap730_pins, ARRAY_SIZE(omap730_pins));
+	if (cpu_is_omap730()) {
+		arch_mux_cfg.pins	= omap730_pins;
+		arch_mux_cfg.size	= ARRAY_SIZE(omap730_pins);
+		arch_mux_cfg.cfg_reg	= omap1_cfg_reg;
+	}
 #endif
 
 #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
-	omap_mux_register(omap1xxx_pins, ARRAY_SIZE(omap1xxx_pins));
+	if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
+		arch_mux_cfg.pins	= omap1xxx_pins;
+		arch_mux_cfg.size	= ARRAY_SIZE(omap1xxx_pins);
+		arch_mux_cfg.cfg_reg	= omap1_cfg_reg;
+	}
 #endif
 
-	return 0;
+	return omap_mux_register(&arch_mux_cfg);
 }
 
 #endif
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 0575097..351baab 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -32,6 +32,8 @@
 
 #ifdef CONFIG_OMAP_MUX
 
+static struct omap_mux_cfg arch_mux_cfg;
+
 /* NOTE: See mux.h for the enumeration */
 
 struct pin_config __initdata_or_module omap24xx_pins[] = {
@@ -169,10 +171,25 @@ MUX_CFG_24XX("B13_24XX_KBC6",		0x110,	3,	0,	0,	1)
 
 };
 
-int __init omap2_mux_init(void)
+#ifdef CONFIG_ARCH_OMAP24XX
+int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
 {
-	omap_mux_register(omap24xx_pins, ARRAY_SIZE(omap24xx_pins));
 	return 0;
 }
+#endif
+
+int __init omap2_mux_init(void)
+{
+
+#ifdef CONFIG_ARCH_OMAP24XX
+	if (cpu_is_omap24xx()) {
+		arch_mux_cfg.pins	= omap24xx_pins;
+		arch_mux_cfg.size	= ARRAY_SIZE(omap24xx_pins);
+		arch_mux_cfg.cfg_reg	= omap24xx_cfg_reg;
+	}
+#endif
+
+	return omap_mux_register(&arch_mux_cfg);
+}
 
 #endif
diff --git a/arch/arm/plat-omap/mux.c b/arch/arm/plat-omap/mux.c
index 75211f2..d881379 100644
--- a/arch/arm/plat-omap/mux.c
+++ b/arch/arm/plat-omap/mux.c
@@ -36,17 +36,17 @@
 #define OMAP24XX_PULL_ENA	(1 << 3)
 #define OMAP24XX_PULL_UP	(1 << 4)
 
-static struct pin_config * pin_table;
-static unsigned long pin_table_sz;
+static struct omap_mux_cfg *mux_cfg;
 
-extern struct pin_config * omap730_pins;
-extern struct pin_config * omap1xxx_pins;
-extern struct pin_config * omap24xx_pins;
-
-int __init omap_mux_register(struct pin_config * pins, unsigned long size)
+int __init omap_mux_register(struct omap_mux_cfg *arch_mux_cfg)
 {
-	pin_table = pins;
-	pin_table_sz = size;
+	if (!arch_mux_cfg || !arch_mux_cfg->pins || arch_mux_cfg->size == 0
+			|| !arch_mux_cfg->cfg_reg) {
+		printk(KERN_ERR "Invalid pin table\n");
+		return -EINVAL;
+	}
+
+	mux_cfg = arch_mux_cfg;
 
 	return 0;
 }
@@ -64,17 +64,19 @@ int __init_or_module omap_cfg_reg(const unsigned long index)
 		pull_orig = 0, pull = 0;
 	unsigned int mask, warn = 0;
 
-	if (!pin_table)
-		BUG();
+	if (mux_cfg == NULL) {
+		printk(KERN_ERR "Pin mux table not initialized\n");
+		return -ENODEV;
+	}
 
-	if (index >= pin_table_sz) {
+	if (index >= mux_cfg->size) {
 		printk(KERN_ERR "Invalid pin mux index: %lu (%lu)\n",
-		       index, pin_table_sz);
+		       index, mux_cfg->size);
 		dump_stack();
 		return -ENODEV;
 	}
 
-	cfg = (struct pin_config *)&pin_table[index];
+	cfg = (struct pin_config *)&mux_cfg->pins[index];
 	if (cpu_is_omap24xx()) {
 		u8 reg = 0;
 
diff --git a/include/asm-arm/arch-omap/mux.h b/include/asm-arm/arch-omap/mux.h
index b8fff50..0edc6ce 100644
--- a/include/asm-arm/arch-omap/mux.h
+++ b/include/asm-arm/arch-omap/mux.h
@@ -559,11 +559,17 @@ enum omap24xx_index {
 	B13_24XX_KBC6,
 };
 
+struct omap_mux_cfg {
+	struct pin_config	*pins;
+	unsigned long		size;
+	int			(*cfg_reg)(const struct pin_config *cfg);
+};
+
 #ifdef	CONFIG_OMAP_MUX
 /* setup pin muxing in Linux */
 extern int omap1_mux_init(void);
 extern int omap2_mux_init(void);
-extern int omap_mux_register(struct pin_config * pins, unsigned long size);
+extern int omap_mux_register(struct omap_mux_cfg *);
 extern int omap_cfg_reg(unsigned long reg_cfg);
 #else
 /* boot loader does it all (no warnings from CONFIG_OMAP_MUX_WARNINGS) */
-- 
1.5.3.6


  reply	other threads:[~2008-03-17  9:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17  9:42 [PATCH 0/14] Omap patches for post 2.6.25 Tony Lindgren
2008-03-17  9:42 ` [PATCH 1/14] ARM: OMAP: Use gpiolib Tony Lindgren
2008-03-17  9:42   ` [PATCH 2/14] ARM: OMAP: 5912 OSK GPIO updates Tony Lindgren
2008-03-17  9:42     ` [PATCH 3/14] ARM: OMAP: I2C: tps65010 driver converts to gpiolib Tony Lindgren
2008-03-17  9:42       ` [PATCH 4/14] ARM: OMAP: Use gpiolib with tps65010 for OSK 5912 Tony Lindgren
2008-03-17  9:42         ` [PATCH 5/14] ARM: OMAP: Clear level-triggered GPIO interrupts in unmask hook Tony Lindgren
2008-03-17  9:42           ` [PATCH 6/14] ARM: OMAP: use edge/level handlers from generic IRQ framework Tony Lindgren
2008-03-17  9:42             ` Tony Lindgren [this message]
2008-03-17  9:42               ` [PATCH 8/14] ARM: OMAP: Split omap_cfg_reg() into omap processor specific functions Tony Lindgren
2008-03-17  9:42                 ` [PATCH 9/14] ARM: OMAP: Timer32K: Re-organize duplicated 32k-timer code Tony Lindgren
2008-03-17  9:42                   ` [PATCH 10/14] ARM: OMAP: Timer32K: Move 32k-based sched_clock() to common code Tony Lindgren
2008-03-17  9:42                     ` [PATCH 11/14] ARM: OMAP: Timer32K: Move timer32k to mach-omap1 Tony Lindgren
2008-03-17  9:42                       ` [PATCH 12/14] ARM: OMAP1: Timer32K: Fix timer32K for clockevents and clean it up Tony Lindgren
2008-03-17  9:42                         ` [PATCH 13/14] ARM: OMAP: TimerMPU: Remove unused cycles-to-nsec conversions Tony Lindgren
2008-03-17  9:42                           ` [PATCH 14/14] ARM: OMAP: TimerMPU: Remove MPU-timer based sched_clock() Tony Lindgren
2008-03-20 16:52                         ` [PATCH 12/14] ARM: OMAP1: Timer32K: Fix timer32K for clockevents and clean it up Russell King - ARM Linux
2008-03-20 18:25                           ` Kevin Hilman
2008-03-21 11:38                             ` Thomas Gleixner
2008-03-21 12:04                             ` Russell King - ARM Linux
2008-03-25 10:09                               ` [PATCH 12/14] ARM: OMAP1: Timer32K: Fix timer32K for clockevents and clean it up, take #2 Tony Lindgren
2008-03-25 22:16                                 ` Russell King - ARM Linux
2008-03-28 12:26                                   ` 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=1205746958-11242-8-git-send-email-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    /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