Skip to contentSkip to conversation

mux framework rework

RFC PATCH In review Mike Rapoport 3 participants 11 messages Oct 28, 2009 – Oct 29, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mux framework rework

This is an attempt to start rework of the mux framework keeping as much backward compatibility as possible.
The patch serie introduces a new mux configuration interface that follows the ideas of PXA MFP implementation ([1] and [2]). The mux configuration interface is implemented for OMAP3 and partially for OMAP2 processors.
The OMAP2 implementation is far from being complete. Unfortunately I do not have OMAP2 docs, so I've added only configration for pins defined in omap24xx_pins table.

The older opam_cfg_reg interface is still present and can be used to avoid too many broken things in steps 2 & 3 as of Tony's plans ([3]).

[1] Documentation/arm/pxa/mfp.txt
[2] http://elinux.org/OMAP_wishlist#References
[3] http://elinux.org/OMAP_wishlist#Initial_plans_.28from_Tony.2C_for_next_merge_window.29

Changes since commit 0bbf5337f2f2957775051a3caf60b66d3306c815
Tony Lindgren
Fix compile for 1510 innovator

Mike Rapoport (3):
omap2: mux: intoduce omap_mux_{read,write}
omap: mux: add interface for encoded mux configration
omap2: mux: implement encoded mux configuration

 arch/arm/mach-omap2/include/mach/mux.h     |  452 +++++++++++++++
 arch/arm/mach-omap2/include/mach/mux24xx.h |  128 ++++
 arch/arm/mach-omap2/include/mach/mux34xx.h |  862 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/mux.c                  |  158 +++++-
 arch/arm/plat-omap/include/plat/mux.h      |   62 +--
 arch/arm/plat-omap/mux.c                   |   17 +
 6 files changed, 1614 insertions(+), 65 deletions(-)
 create mode 100644 arch/arm/mach-omap2/include/mach/mux.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux24xx.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux34xx.h
#1 lore raw

PATCH 1/3 omap2: mux: intoduce omap_mux_{read,write}

---
 arch/arm/mach-omap2/mux.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/mux.c +19 -6
index 32c953e..eb6e202 100644
@@ -37,6 +37,22 @@
 
 static struct omap_mux_cfg arch_mux_cfg;
 
+static inline u16 omap_mux_read(u16 reg)
+{
+	if (cpu_is_omap24xx())
+		return omap_ctrl_readb(reg);
+	else
+		return omap_ctrl_readw(reg);
+}
+
+static inline void omap_mux_write(u16 val, u16 reg)
+{
+	if (cpu_is_omap24xx())
+		return omap_ctrl_writeb(val, reg);
+	else
+		return omap_ctrl_writew(val, reg);
+}
+
 /* NOTE: See mux.h for the enumeration */
 
 #ifdef CONFIG_ARCH_OMAP24XX
@@ -566,10 +582,7 @@ static void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u16 r
 	u16 orig;
 	u8 warn = 0, debug = 0;
 
-	if (cpu_is_omap24xx())
-		orig = omap_ctrl_readb(cfg->mux_reg);
-	else
-		orig = omap_ctrl_readw(cfg->mux_reg);
+	orig = omap_mux_read(cfg->mux_reg);
 
 #ifdef	CONFIG_OMAP_MUX_DEBUG
 	debug = cfg->debug;
@@ -599,7 +612,7 @@ static int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
 	if (cfg->pu_pd_val)
 		reg |= OMAP2_PULL_UP;
 	omap2_cfg_debug(cfg, reg);
-	omap_ctrl_writeb(reg, cfg->mux_reg);
+	omap_mux_write(reg, cfg->mux_reg);
 	spin_unlock_irqrestore(&mux_spin_lock, flags);
 
 	return 0;
@@ -618,7 +631,7 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
 	spin_lock_irqsave(&mux_spin_lock, flags);
 	reg |= cfg->mux_val;
 	omap2_cfg_debug(cfg, reg);
-	omap_ctrl_writew(reg, cfg->mux_reg);
+	omap_mux_write(reg, cfg->mux_reg);
 	spin_unlock_irqrestore(&mux_spin_lock, flags);
 
 	return 0;
Signature · 1 line
1.6.0.6
#2 lore raw

PATCH 2/3 omap: mux: add interface for encoded mux configration

---
 arch/arm/plat-omap/include/plat/mux.h |    3 +++
 arch/arm/plat-omap/mux.c              |   17 +++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
arch/arm/plat-omap/include/plat/mux.h +3 -0
index f3c1d8a..edc3ff9 100644
@@ -846,6 +846,7 @@ struct omap_mux_cfg {
 	struct pin_config	*pins;
 	unsigned long		size;
 	int			(*cfg_reg)(const struct pin_config *cfg);
+	int			(*cfg_pin)(unsigned long pin_config);
 };
 
 #ifdef	CONFIG_OMAP_MUX
@@ -854,11 +855,13 @@ extern int omap1_mux_init(void);
 extern int omap2_mux_init(void);
 extern int omap_mux_register(struct omap_mux_cfg *);
 extern int omap_cfg_reg(unsigned long reg_cfg);
+extern int omap_cfg_pin(unsigned long pin_config);
 #else
 /* boot loader does it all (no warnings from CONFIG_OMAP_MUX_WARNINGS) */
 static inline int omap1_mux_init(void) { return 0; }
 static inline int omap2_mux_init(void) { return 0; }
 static inline int omap_cfg_reg(unsigned long reg_cfg) { return 0; }
+static inline int omap_cfg_pin(unsigned long pin_config) { return 0; }
 #endif
 
 #endif
arch/arm/plat-omap/mux.c +17 -0
index 05aebca..94b37c1 100644
@@ -77,7 +77,24 @@ int __init_or_module omap_cfg_reg(const unsigned long index)
 	return mux_cfg->cfg_reg(reg);
 }
 EXPORT_SYMBOL(omap_cfg_reg);
+
+int __init_or_module omap_cfg_pin(unsigned long pin_config)
+{
+	if (mux_cfg == NULL) {
+		printk(KERN_ERR "MUX: pin mux table not initialized\n");
+		return -ENODEV;
+	}
+
+	if (!mux_cfg->cfg_pin) {
+		printk(KERN_ERR "MUX: cfg_pin interface is not supported\n");
+		return -ENODEV;
+	}
+
+	return mux_cfg->cfg_pin(pin_config);
+}
+EXPORT_SYMBOL(omap_cfg_pin);
 #else
 #define omap_mux_init() do {} while(0)
 #define omap_cfg_reg(x)	do {} while(0)
+#define omap_cfg_pin(x)	do {} while(0)
 #endif	/* CONFIG_OMAP_MUX */
Signature · 1 line
1.6.0.6
#3 lore raw

PATCH 3/3 omap2: mux: implement encoded mux configuration

---
 arch/arm/mach-omap2/include/mach/mux.h     |  452 +++++++++++++++
 arch/arm/mach-omap2/include/mach/mux24xx.h |  128 ++++
 arch/arm/mach-omap2/include/mach/mux34xx.h |  862 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/mux.c                  |  133 +++++
 arch/arm/plat-omap/include/plat/mux.h      |   59 --
 5 files changed, 1575 insertions(+), 59 deletions(-)
 create mode 100644 arch/arm/mach-omap2/include/mach/mux.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux24xx.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux34xx.h
arch/arm/mach-omap2/include/mach/mux.h new file +452 -0
new file mode 100644
index 0000000..c8f8be6
@@ -0,0 +1,452 @@
+/*
+ * arch/arm/mach-omap2/include/mach/mux.h
+ *
+ * Copyright (C) 2009 CompuLab, Ltd.
+ * Author: Mike Rapoport <[email protected]>
+ *
+ * Based on PXA MFP code
+ * Copyright (C) 2007 Marvell International Ltd.
+ * Author: eric miao <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __MACH_OMAP2_MUX_H
+#define __MACH_OMAP2_MUX_H
+
+/*
+ * list of all the configurable pins for omap2 and omap3 processors
+ * FIXME: add missing omap2 pins
+ */
+enum {
+	/* OMAP3 configurable pins */
+	MUX_PIN_INVALID = -1,
+	MUX_PIN_GPMC_A1 = 0,
+	MUX_PIN_GPMC_A2,
+	MUX_PIN_GPMC_A3,
+	MUX_PIN_GPMC_A4,
+	MUX_PIN_GPMC_A5,
+	MUX_PIN_GPMC_A6,
+	MUX_PIN_GPMC_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+	MUX_PIN_MCBSP5_CLKX,
+	MUX_PIN_MCBSP5_FSX,
+	MUX_PIN_MCBSP5_DX,
+	MUX_PIN_MCBSP5_DR,
+	MUX_PIN_MMC_CLKO,
+	MUX_PIN_MMC_CLKI,
+	MUX_PIN_USB0_PUEN,
+	MUX_PIN_USB0_DAT,
+	MUX_PIN_MCBSP2_FSX_OFF,
+	MUX_PIN_MCBSP2_CLX_OFF,
+	MUX_PIN_MCBSP2_DX_OFF,
+	MUX_PIN_MCBSP2_DR_OFF,
+
+	MUX_PIN_MAX,
+};
+
+/*
+ * possible pin mux configuration is encoded into 32-bit integer
+ *
+ * for now very simplistic encoding is implemented:
+ * bits  0.. 9 - pin number (up to 1024 pins)
+ * bits 10..31 - PADCONF register value
+ *
+ * Currently only simple MUX_PIN and MUX_VAL accessors are defined.
+ */
+
+#define MUX_PIN(x)	((x) & 0x3ff)
+#define MUX_VAL(x)	((x) >> 10)
+
+struct omap_mux_addr_map {
+	unsigned int	start;
+	unsigned int	end;
+	unsigned long	offset;
+};
+
+#define MUX_ADDR_X(start, end, offset) \
+	{ MUX_PIN_##start, MUX_PIN_##end, offset }
+
+#define MUX_ADDR(pin, offset) \
+	{ MUX_PIN_##pin, -1, offset }
+
+#define MUX_ADDR_END	{ MUX_PIN_INVALID, 0 }
+
+/* 24xx/34xx mux bit defines */
+#define OMAP2_PULL_ENA		(1 << 3)
+#define OMAP2_PULL_UP		(1 << 4)
+#define OMAP2_ALTELECTRICALSEL	(1 << 5)
+
+/* 34xx specific mux bit defines */
+#define OMAP3_INPUT_EN		(1 << 8)
+#define OMAP3_OFF_EN		(1 << 9)
+#define OMAP3_OFFOUT_EN		(1 << 10)
+#define OMAP3_OFFOUT_VAL	(1 << 11)
+#define OMAP3_OFF_PULL_EN	(1 << 12)
+#define OMAP3_OFF_PULL_UP	(1 << 13)
+#define OMAP3_WAKEUP_EN		(1 << 14)
+
+/* 34xx mux mode options for each pin. See TRM for options */
+#define	OMAP34XX_MUX_MODE0	0
+#define	OMAP34XX_MUX_MODE1	1
+#define	OMAP34XX_MUX_MODE2	2
+#define	OMAP34XX_MUX_MODE3	3
+#define	OMAP34XX_MUX_MODE4	4
+#define	OMAP34XX_MUX_MODE5	5
+#define	OMAP34XX_MUX_MODE6	6
+#define	OMAP34XX_MUX_MODE7	7
+
+/* 34xx active pin states */
+#define OMAP34XX_PIN_OUTPUT		0
+#define OMAP34XX_PIN_INPUT		OMAP3_INPUT_EN
+#define OMAP34XX_PIN_INPUT_PULLUP	(OMAP2_PULL_ENA | OMAP3_INPUT_EN \
+						| OMAP2_PULL_UP)
+#define OMAP34XX_PIN_INPUT_PULLDOWN	(OMAP2_PULL_ENA | OMAP3_INPUT_EN)
+
+/* 34xx off mode states */
+#define OMAP34XX_PIN_OFF_NONE           0
+#define OMAP34XX_PIN_OFF_OUTPUT_HIGH	(OMAP3_OFF_EN | OMAP3_OFFOUT_EN \
+						| OMAP3_OFFOUT_VAL)
+#define OMAP34XX_PIN_OFF_OUTPUT_LOW	(OMAP3_OFF_EN | OMAP3_OFFOUT_EN)
+#define OMAP34XX_PIN_OFF_INPUT_PULLUP	(OMAP3_OFF_EN | OMAP3_OFF_PULL_EN \
+						| OMAP3_OFF_PULL_UP)
+#define OMAP34XX_PIN_OFF_INPUT_PULLDOWN	(OMAP3_OFF_EN | OMAP3_OFF_PULL_EN)
+#define OMAP34XX_PIN_OFF_WAKEUPENABLE	OMAP3_WAKEUP_EN
+
+#define MUX_CFG_24XX(desc, reg_offset, mode,			\
+				pull_en, pull_mode, dbg)	\
+{								\
+	.name		= desc,					\
+	.debug		= dbg,					\
+	.mux_reg	= reg_offset,				\
+	.mask		= mode,					\
+	.pull_val	= pull_en,				\
+	.pu_pd_val	= pull_mode,				\
+},
+
+#define MUX_CFG_34XX(desc, reg_offset, mux_value) {		\
+	.name		= desc,					\
+	.debug		= 0,					\
+	.mux_reg	= reg_offset,				\
+	.mux_val	= mux_value				\
+},
+
+#ifdef CONFIG_ARCH_OMAP24XX
+#include <mach/mux24xx.h>
+#endif
+
+#ifdef CONFIG_ARCH_OMAP34XX
+#include <mach/mux34xx.h>
+#endif
+
+#endif
arch/arm/mach-omap2/include/mach/mux24xx.h new file +128 -0

128 lines not on this page · raw message

arch/arm/mach-omap2/include/mach/mux34xx.h new file +862 -0

862 lines not on this page · raw message

arch/arm/mach-omap2/mux.c +133 -0

161 lines not on this page · raw message

arch/arm/plat-omap/include/plat/mux.h +0 -59

65 lines not on this page · raw message

Signature · 1 line
1.6.0.6
maintainer
#4 lore raw

Re: [PATCH 1/3] omap2: mux: intoduce omap_mux_{read,write}

In reply to Mike Rapoport
Quoted 19 lines · Mike Rapoport
---
 arch/arm/mach-omap2/mux.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/mux.c +6 -0
index 32c953e..eb6e202 100644
@@ -37,6 +37,22 @@
 
 static struct omap_mux_cfg arch_mux_cfg;
 
+static inline u16 omap_mux_read(u16 reg)
+{
+	if (cpu_is_omap24xx())
+		return omap_ctrl_readb(reg);
+	else
+		return omap_ctrl_readw(reg);

arch/arm/mach-omap2/mux.c line 55

Quoted 10 lines
arch/arm/mach-omap2/mux.c +10 -0
+}
+
+static inline void omap_mux_write(u16 val, u16 reg)
+{
+	if (cpu_is_omap24xx())
+		return omap_ctrl_writeb(val, reg);
+	else
+		return omap_ctrl_writew(val, reg);
+}
+

The void function should not return any values above..

I suggest we standardize on:

static void __iomem *mux_base;

static inline u16 omap_mux_read(u16 reg)

{
       if (cpu_is_omap24xx())
               return __raw_readb(mux_base + reg);
       else
               return __raw_readw(mux_base + reg);
}

static inline void _omap_mux_write(u16 val, u16 reg)

{
       if (cpu_is_omap24xx())
               __raw_writeb(val, mux_base + reg);
       else
               __raw_writew(val, mux_base + reg);
}

And then ioremap the mux_base during init. We should also specifiy the mux base as the start of the mux registers, 0x48002030 for omap3 instead of the ctrl base at 0x48002000.

This means that we should deduct 0x30 from the existing offset values to make conversion to new data less error prone..

Quoted 5 lines
arch/arm/mach-omap2/mux.c +0 -0
 /* NOTE: See mux.h for the enumeration */
 
 #ifdef CONFIG_ARCH_OMAP24XX
@@ -566,10 +582,7 @@ static void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u16 r
 	u16 orig;

arch/arm/mach-omap2/mux.c static void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u16 r · line 588

Quoted 10 lines
arch/arm/mach-omap2/mux.c +1 -4
 	u8 warn = 0, debug = 0;
 
-	if (cpu_is_omap24xx())
-		orig = omap_ctrl_readb(cfg->mux_reg);
-	else
-		orig = omap_ctrl_readw(cfg->mux_reg);
+	orig = omap_mux_read(cfg->mux_reg);
 
 #ifdef	CONFIG_OMAP_MUX_DEBUG
 	debug = cfg->debug;

Or maybe use orig = omap_mux_read(cfg->mux_reg - 0x30); here instead for the old mux data?

Quoted 25 lines
arch/arm/mach-omap2/mux.c +2 -2
@@ -599,7 +612,7 @@ static int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
 	if (cfg->pu_pd_val)
 		reg |= OMAP2_PULL_UP;
 	omap2_cfg_debug(cfg, reg);
-	omap_ctrl_writeb(reg, cfg->mux_reg);
+	omap_mux_write(reg, cfg->mux_reg);
 	spin_unlock_irqrestore(&mux_spin_lock, flags);
 
 	return 0;
@@ -618,7 +631,7 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
 	spin_lock_irqsave(&mux_spin_lock, flags);
 	reg |= cfg->mux_val;
 	omap2_cfg_debug(cfg, reg);
-	omap_ctrl_writew(reg, cfg->mux_reg);
+	omap_mux_write(reg, cfg->mux_reg);
 	spin_unlock_irqrestore(&mux_spin_lock, flags);
 
 	return 0;
Signature · 6 lines
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#5 lore raw

Re: [PATCH 1/3] omap2: mux: intoduce omap_mux_{read,write}, v2

Quoted 33 lines · Tony Lindgren
Quoted 19 lines · Mike Rapoport
---
 arch/arm/mach-omap2/mux.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/mux.c +6 -0
index 32c953e..eb6e202 100644
@@ -37,6 +37,22 @@
 
 static struct omap_mux_cfg arch_mux_cfg;
 
+static inline u16 omap_mux_read(u16 reg)
+{
+	if (cpu_is_omap24xx())
+		return omap_ctrl_readb(reg);
+	else
+		return omap_ctrl_readw(reg);

arch/arm/mach-omap2/mux.c line 55

Quoted 10 lines
arch/arm/mach-omap2/mux.c +10 -0
+}
+
+static inline void omap_mux_write(u16 val, u16 reg)
+{
+	if (cpu_is_omap24xx())
+		return omap_ctrl_writeb(val, reg);
+	else
+		return omap_ctrl_writew(val, reg);
+}
+

The void function should not return any values above..

Quoted 1 line

I suggest we standardize on:

Here's an updated version of your patch, what do you think?

Tony

Quoted 1 line

From db32fbf2e64174568e4ca4019926f9e43bba9b7e Mon Sep 17 00:00:00 2001

From: Mike Rapoport <[email protected]>
Date: Wed, 28 Oct 2009 14:36:38 -0700
Subject: [PATCH] omap2: mux: intoduce omap_mux_{read,write}

intoduce omap_mux_{read,write}

arch/arm/mach-omap2/mux.c +42 -6
index 32c953e..ad8e0d0 100644
@@ -35,7 +35,27 @@
 
 #ifdef CONFIG_OMAP_MUX
 
+#define OMAP_MUX_BASE_OFFSET		0x30	/* Offset from CTRL_BASE */
+#define OMAP_MUX_BASE_SZ		0x5ca
+
 static struct omap_mux_cfg arch_mux_cfg;
+static void __iomem *mux_base;
+
+static inline u16 omap_mux_read(u16 reg)
+{
+       if (cpu_is_omap24xx())
+               return __raw_readb(mux_base + reg);
+       else
+               return __raw_readw(mux_base + reg);
+}
+
+static inline void omap_mux_write(u16 val, u16 reg)
+{
+       if (cpu_is_omap24xx())
+               __raw_writeb(val, mux_base + reg);
+       else
+               __raw_writew(val, mux_base + reg);
+}
 
 /* NOTE: See mux.h for the enumeration */
 
@@ -566,10 +586,7 @@ static void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u16 r
 	u16 orig;
 	u8 warn = 0, debug = 0;
 
-	if (cpu_is_omap24xx())
-		orig = omap_ctrl_readb(cfg->mux_reg);
-	else
-		orig = omap_ctrl_readw(cfg->mux_reg);
+	orig = omap_mux_read(cfg->mux_reg - OMAP_MUX_BASE_OFFSET);
 
 #ifdef	CONFIG_OMAP_MUX_DEBUG
 	debug = cfg->debug;
@@ -599,7 +616,7 @@ static int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
 	if (cfg->pu_pd_val)
 		reg |= OMAP2_PULL_UP;
 	omap2_cfg_debug(cfg, reg);
-	omap_ctrl_writeb(reg, cfg->mux_reg);
+	omap_mux_write(reg, cfg->mux_reg - OMAP_MUX_BASE_OFFSET);
 	spin_unlock_irqrestore(&mux_spin_lock, flags);
 
 	return 0;
@@ -618,7 +635,7 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
 	spin_lock_irqsave(&mux_spin_lock, flags);
 	reg |= cfg->mux_val;
 	omap2_cfg_debug(cfg, reg);
-	omap_ctrl_writew(reg, cfg->mux_reg);
+	omap_mux_write(reg, cfg->mux_reg - OMAP_MUX_BASE_OFFSET);
 	spin_unlock_irqrestore(&mux_spin_lock, flags);
 
 	return 0;
@@ -627,8 +644,27 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
 #define omap34xx_cfg_reg	NULL
 #endif
 
+#define OMAP2
+#define OMAP2_CONTROL_PADCONF_MUX_PBASE	0x48002030LU
+#define OMAP3_CONTROL_PADCONF_MUX_PBASE	0x48002030LU
+
 int __init omap2_mux_init(void)
 {
+	u32 mux_pbase;
+
+	if (cpu_is_omap2420())
+		mux_pbase = OMAP2420_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+	else if (cpu_is_omap2430())
+		mux_pbase = OMAP243X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+	else if (cpu_is_omap34xx())
+		mux_pbase = OMAP343X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+
+	mux_base = ioremap(mux_pbase, OMAP_MUX_BASE_SZ);
+	if (!mux_base) {
+		printk(KERN_ERR "mux: Could not ioremap\n");
+		return -ENODEV;
+	}
+
 	if (cpu_is_omap24xx()) {
 		arch_mux_cfg.pins	= omap24xx_pins;
 		arch_mux_cfg.size	= OMAP24XX_PINS_SZ;
#6 lore raw

Re: [PATCH 1/3] omap2: mux: intoduce omap_mux_{read,write}, v2

Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Tony Lindgren
Quoted 5 lines · Mike Rapoport

---
 arch/arm/mach-omap2/mux.c |   25 +++++++++++++++++++------

 1 files changed, 19 insertions(+), 6 deletions(-)
Quoted 10 lines
Quoted 10 lines

arch/arm/mach-omap2/mux.c

Quoted 8 lines
arch/arm/mach-omap2/mux.c +8 -0
+static inline void omap_mux_write(u16 val, u16 reg)
+{
+   if (cpu_is_omap24xx())
+           return omap_ctrl_writeb(val, reg);
+   else
+           return omap_ctrl_writew(val, reg);
+}
+

The void function should not return any values above..

damn copy-paset :)

Quoted 3 lines
Quoted 1 line

I suggest we standardize on:

Here's an updated version of your patch, what do you think?

I'm fine with ioremap and the offsets. Just one thing below:

arch/arm/mach-omap2/mux.c static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg) · line 649

Quoted 7 lines
arch/arm/mach-omap2/mux.c +3 -0
@@ -627,8 +644,27 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
 #define omap34xx_cfg_reg	NULL
 #endif
 
+#define OMAP2
+#define OMAP2_CONTROL_PADCONF_MUX_PBASE	0x48002030LU
+#define OMAP3_CONTROL_PADCONF_MUX_PBASE	0x48002030LU

what are these for?

Quoted 15 lines
arch/arm/mach-omap2/mux.c +9 -0
 int __init omap2_mux_init(void)
 {
+	u32 mux_pbase;
+
+	if (cpu_is_omap2420())
+		mux_pbase = OMAP2420_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+	else if (cpu_is_omap2430())
+		mux_pbase = OMAP243X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+	else if (cpu_is_omap34xx())
+		mux_pbase = OMAP343X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+
 
 

Tony

Signature · 6 lines
	Sincerely Yours,
		Mike.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#7 lore raw

Re: [PATCH 1/3] omap2: mux: intoduce omap_mux_{read,write}, v2

Quoted 31 lines · Mike Rapoport
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Tony Lindgren
Quoted 5 lines · Mike Rapoport

---
 arch/arm/mach-omap2/mux.c |   25 +++++++++++++++++++------

 1 files changed, 19 insertions(+), 6 deletions(-)
Quoted 10 lines
Quoted 10 lines

arch/arm/mach-omap2/mux.c

Quoted 8 lines
arch/arm/mach-omap2/mux.c +8 -0
+static inline void omap_mux_write(u16 val, u16 reg)
+{
+   if (cpu_is_omap24xx())
+           return omap_ctrl_writeb(val, reg);
+   else
+           return omap_ctrl_writew(val, reg);
+}
+

The void function should not return any values above..

damn copy-paset :)

Quoted 3 lines
Quoted 1 line

I suggest we standardize on:

Here's an updated version of your patch, what do you think?

I'm fine with ioremap and the offsets. Just one thing below:

Quoted 4 lines
arch/arm/mach-omap2/mux.c +0 -0
@@ -627,8 +644,27 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
 #define omap34xx_cfg_reg	NULL
 #endif
 
Quoted 5 lines

arch/arm/mach-omap2/mux.c static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg) · line 649

Quoted 3 lines
arch/arm/mach-omap2/mux.c +3 -0
+#define OMAP2
+#define OMAP2_CONTROL_PADCONF_MUX_PBASE	0x48002030LU
+#define OMAP3_CONTROL_PADCONF_MUX_PBASE	0x48002030LU

what are these for?

Oops, more copy-patse :) Removed now. Will send you my patches now for you to check them out.

Tony

Quoted 13 lines
Quoted 11 lines
arch/arm/mach-omap2/mux.c +9 -0
 int __init omap2_mux_init(void)
 {
+	u32 mux_pbase;
+
+	if (cpu_is_omap2420())
+		mux_pbase = OMAP2420_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+	else if (cpu_is_omap2430())
+		mux_pbase = OMAP243X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+	else if (cpu_is_omap34xx())
+		mux_pbase = OMAP343X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
+
Quoted 8 lines
Quoted 2 lines

Tony

Signature · 2 lines
	Sincerely Yours,
		Mike.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#8 lore raw
In reply to Mike Rapoport
Quoted 10 lines · Mike Rapoport

This is an attempt to start rework of the mux framework keeping as much backward compatibility as possible.
The patch serie introduces a new mux configuration interface that follows the ideas of PXA MFP implementation ([1] and [2]). The mux configuration interface is implemented for OMAP3 and partially for OMAP2 processors.
The OMAP2 implementation is far from being complete. Unfortunately I do not have OMAP2 docs, so I've added only configration for pins defined in omap24xx_pins table.

Quoted 2 lines

The older opam_cfg_reg interface is still present and can be used to avoid too many broken things in steps 2 & 3 as of Tony's plans ([3]).

Cool! I too have been working on this for past several days, but luckily I've been working on the new mux data layout instead so far with some help from Paul and Benoit.

So this should all come together quite nicely. I'll try to post some patches as soon as the new mux data is working. I'll also take a close look at your patches, it seems like they already separate the mach-omap2 mux code nicely from what's needed for mach-omap1 (well, at least for 15xx).

The reason I think we need to redo all the mux data is because the new setup has several shortcomings:

- All the mux registers on the newer omaps are in a single register for each signal instead of being scattered across multiple registers like on 15xx. So the enumeration is not needed, and we don't need to specify each signal.

- We badly need mux register to GPIO mapping for runtime muxing of GPIO pins for the idle modes

- For debugging, we need to see the pin status if CONFIG_DEBUG_FS is set

- For adding custom hardware on boards such as Beagle, we need to be able to override pins via /debugfs or via cmdline

- Grepping the code for the signal + ball + mux register combination is currently impossible

So I suggest we get rid of defining each mux mode separately, and just define the register offsets from the mux base.

Then for the new omap_set_mux(), we should pass the register offset, the desired value, and optional flags.

For the new mux data, I currently have something like the below just to give an idea what I was thinking, maybe take a quick look at that and see how that fits into what you had in mind?

arch/arm/mach-omap2/mux.h:

/**
* struct omap_mux - data for omap mux register offset and it's value
* @reg_offset: mux register offset from the mux base
* @gpio: GPIO number
* @muxnames: available signal modes for a ball
*/

struct omap_mux {
	u16	reg_offset;
	u16	gpio;
#ifdef CONFIG_DEBUG_FS
	char	*muxnames[8];
	char	*balls[2];

#endif
};
...

arch/arm/mach-omap2/mux34xx.h:

/*
* OMAP3 CONTROL_PADCONF* register offsets for pin-muxing *
* Extracted from the TRM. Add 0x48002030 to these values to get the
* absolute addresses. The name in the macro is the mode-0 name of
* the pin. NOTE: These registers are 16-bits wide.
*/
#define OMAP3_CONTROL_PADCONF_SDRC_D0_OFFSET 0x000
#define OMAP3_CONTROL_PADCONF_SDRC_D1_OFFSET 0x002
#define OMAP3_CONTROL_PADCONF_SDRC_D2_OFFSET 0x004
#define OMAP3_CONTROL_PADCONF_SDRC_D3_OFFSET 0x006
#define OMAP3_CONTROL_PADCONF_SDRC_D4_OFFSET 0x008
...

arch/arm/mach-omap2/mux34xx.h:

#ifdef CONFIG_DEBUG_FS

#define _OMAP3_MUXENTRY(M0, g, m0, m1, m2, m3, m4, m5, m6, m7) \

{									\
	.reg_offset	= (OMAP3_CONTROL_PADCONF_##M0##_OFFSET),	\
	.gpio		= (g),						\
	.muxnames	= { m0, m1, m2, m3, m4, m5, m6, m7 },		\
}

#else

#define _OMAP3_MUXENTRY(M0, g, m0, m1, m2, m3, m4, m5, m6, m7) \

{									\
	.reg_offset	= (OMAP3_CONTROL_PADCONF_##M0##_OFFSET),	\
	.gpio		= (g),						\
}

#endif

/*
* OMAP3 CONTROL_PADCONF* register offsets for pin-muxing *
* Extracted from the TRM. Add 0x48002030 to these values to get the
* absolute addresses. The name in the macro is the mode-0 name of
* the pin. NOTE: These registers are 16-bits wide.
*/
#define OMAP3_CONTROL_PADCONF_SDRC_D0_OFFSET 0x000
#define OMAP3_CONTROL_PADCONF_SDRC_D1_OFFSET 0x002
#define OMAP3_CONTROL_PADCONF_SDRC_D2_OFFSET 0x004
#define OMAP3_CONTROL_PADCONF_SDRC_D3_OFFSET 0x006
#define OMAP3_CONTROL_PADCONF_SDRC_D4_OFFSET 0x008
...

/*
* Superset of all mux modes, same as the CBC package */

struct omap_mux omap3_muxmodes[] = {
	_OMAP3_MUXENTRY(CAM_D0, 99,
		"cam_d0", NULL, NULL, NULL,
		"gpio_99", NULL, NULL, "safe_mode"),
	_OMAP3_MUXENTRY(CAM_D10, 109,
		"cam_d10", NULL, NULL, NULL,
		"gpio_109", "hw_dbg8", NULL, "safe_mode"),
	_OMAP3_MUXENTRY(CAM_D11, 110,
		"cam_d11", NULL, NULL, NULL,
		"gpio_110", "hw_dbg9", NULL, "safe_mode"),
	_OMAP3_MUXENTRY(CAM_D1, 100,
		"cam_d1", NULL, NULL, NULL,
		"gpio_100", NULL, NULL, "safe_mode"),
	_OMAP3_MUXENTRY(CAM_D2, 101,
		"cam_d2", NULL, NULL, NULL,
		"gpio_101", "hw_dbg4", NULL, "safe_mode"),

...
{ .reg_offset = OMAP_MUX_TERMINATOR },
};
...

And this is what I was thinking for the new mux function:

int omap_set_mux(u16 val, u16 offset, int flags);

And then also have a function to initialize a whole struct omap_mux array from each board-*.c files.

Regards,

Tony

Quoted 28 lines

[1] Documentation/arm/pxa/mfp.txt
[2] http://elinux.org/OMAP_wishlist#References
[3] http://elinux.org/OMAP_wishlist#Initial_plans_.28from_Tony.2C_for_next_merge_window.29

Changes since commit 0bbf5337f2f2957775051a3caf60b66d3306c815
Tony Lindgren
Fix compile for 1510 innovator

Mike Rapoport (3):
omap2: mux: intoduce omap_mux_{read,write}
omap: mux: add interface for encoded mux configration
omap2: mux: implement encoded mux configuration

 arch/arm/mach-omap2/include/mach/mux.h     |  452 +++++++++++++++
 arch/arm/mach-omap2/include/mach/mux24xx.h |  128 ++++
 arch/arm/mach-omap2/include/mach/mux34xx.h |  862 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/mux.c                  |  158 +++++-
 arch/arm/plat-omap/include/plat/mux.h      |   62 +--
 arch/arm/plat-omap/mux.c                   |   17 +
 6 files changed, 1614 insertions(+), 65 deletions(-)
 create mode 100644 arch/arm/mach-omap2/include/mach/mux.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux24xx.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux34xx.h

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
Quoted 18 lines · Tony Lindgren
Quoted 10 lines · Mike Rapoport

This is an attempt to start rework of the mux framework keeping as much backward compatibility as possible.
The patch serie introduces a new mux configuration interface that follows the ideas of PXA MFP implementation ([1] and [2]). The mux configuration interface is implemented for OMAP3 and partially for OMAP2 processors.
The OMAP2 implementation is far from being complete. Unfortunately I do not have OMAP2 docs, so I've added only configration for pins defined in omap24xx_pins table.

Quoted 2 lines

The older opam_cfg_reg interface is still present and can be used to avoid too many broken things in steps 2 & 3 as of Tony's plans ([3]).

Cool! I too have been working on this for past several days, but luckily I've been working on the new mux data layout instead so far with some help from Paul and Benoit.

Quoted 5 lines

So this should all come together quite nicely. I'll try to post some patches as soon as the new mux data is working. I'll also take a close look at your patches, it seems like they already separate the mach-omap2 mux code nicely from what's needed for mach-omap1 (well, at least for 15xx).

I'd be glad to get those patches even before the new mux data is working :)

Quoted 11 lines

The reason I think we need to redo all the mux data is because the new setup has several shortcomings:

- All the mux registers on the newer omaps are in a single register for each signal instead of being scattered across multiple registers like on 15xx. So the enumeration is not needed, and we don't need to specify each signal.

- We badly need mux register to GPIO mapping for runtime muxing of GPIO pins for the idle modes

Quoted 8 lines

- For debugging, we need to see the pin status if CONFIG_DEBUG_FS is set

- For adding custom hardware on boards such as Beagle, we need to be able to override pins via /debugfs or via cmdline

- Grepping the code for the signal + ball + mux register combination is currently impossible

Is it really necessary to have ball information? OMAP35x packages differ, so having ball information may be misleading.

Quoted 18 lines

So I suggest we get rid of defining each mux mode separately, and just define the register offsets from the mux base.

Then for the new omap_set_mux(), we should pass the register offset, the desired value, and optional flags.

For the new mux data, I currently have something like the below just to give an idea what I was thinking, maybe take a quick look at that and see how that fits into what you had in mind?

arch/arm/mach-omap2/mux.h:

/**
* struct omap_mux - data for omap mux register offset and it's value
* @reg_offset: mux register offset from the mux base
* @gpio: GPIO number
* @muxnames: available signal modes for a ball
*/

Quoted 6 lines
struct omap_mux {
	u16	reg_offset;
	u16	gpio;
#ifdef CONFIG_DEBUG_FS
	char	*muxnames[8];
	char	*balls[2];

Again, I do not quite understand what do we need the ball names for?

Quoted 46 lines

#endif
};
...

arch/arm/mach-omap2/mux34xx.h:

#ifdef CONFIG_DEBUG_FS

#define _OMAP3_MUXENTRY(M0, g, m0, m1, m2, m3, m4, m5, m6, m7) \

{									\
	.reg_offset	= (OMAP3_CONTROL_PADCONF_##M0##_OFFSET),	\
	.gpio		= (g),						\
	.muxnames	= { m0, m1, m2, m3, m4, m5, m6, m7 },		\
}

#else

#define _OMAP3_MUXENTRY(M0, g, m0, m1, m2, m3, m4, m5, m6, m7) \

{									\
	.reg_offset	= (OMAP3_CONTROL_PADCONF_##M0##_OFFSET),	\
	.gpio		= (g),						\
}

#endif

/*
* OMAP3 CONTROL_PADCONF* register offsets for pin-muxing *
* Extracted from the TRM. Add 0x48002030 to these values to get the
* absolute addresses. The name in the macro is the mode-0 name of
* the pin. NOTE: These registers are 16-bits wide.
*/
#define OMAP3_CONTROL_PADCONF_SDRC_D0_OFFSET 0x000
#define OMAP3_CONTROL_PADCONF_SDRC_D1_OFFSET 0x002
#define OMAP3_CONTROL_PADCONF_SDRC_D2_OFFSET 0x004
#define OMAP3_CONTROL_PADCONF_SDRC_D3_OFFSET 0x006
#define OMAP3_CONTROL_PADCONF_SDRC_D4_OFFSET 0x008
...

/*
* Superset of all mux modes, same as the CBC package */

struct omap_mux omap3_muxmodes[] = {
	_OMAP3_MUXENTRY(CAM_D0, 99,
		"cam_d0", NULL, NULL, NULL,
		"gpio_99", NULL, NULL, "safe_mode"),

[ snip ]

Quoted 9 lines

...
{ .reg_offset = OMAP_MUX_TERMINATOR },
};
...

And this is what I was thinking for the new mux function:

int omap_set_mux(u16 val, u16 offset, int flags);

I have slightly different approach in mind. My idea was to have a table that provides some mapping between pin and it's PADCONF offset. That table initialization is CPU variant specific, so mapping for OMAP24XX will be different from the mapping for OMAP2430 and OMAP35x. The mapping table is indexed with enumeration that lists all configurable pins for all processor and package variants.
Next, there are macros that encode the index and PADCONF value for each possible pin configuration into u32, e.g.

#define OMAP3_CAM_D0 OMAP3_PIN(CAM_D0, MODE0)
#define OMAP3_CAM_D0_CSI2_DX2 OMAP3_PIN(CAM_D0, MODE2)
#define OMAP3_CAM_D0_GPIO_99 OMAP3_PIN(CAM_D0, MODE4)

And omap_cfg_pin (my name for omap_cfg_mux) takes the encoded mux configuration, extracts from there the index into the mapping table and PADCONF value and updates the PADCONF register.

My approach allows reusing the same code for setting mux configuration for OMAP2
and OMAP3 (and probably OMAP4), and , apparently would use less memory that
your proposal. Another advantage of using encoded mux configuration is a simplification of board-specific code. You can use an array with all pins configured there and pass this array to, say, omap_cfg_pins:

unsigned long board_pins[] = {
	OMAP3_CAM_D0_GPIO_99,
	OMAP3_GPMC_WAIT3_GPIO_65,

	OMAP3_MCBSP2_FSX,
	OMAP3_MCBSP2_CLKX,
	OMAP3_MCBSP2_DR,
	OMAP3_MCBSP2_DX,

...
};

static void __init some_board_init(void)
{
...

	omap_cfg_pins(board_pins, ARRAY_SIZE(board_pins));

...
}

The drawbacks of using encoded mux configuration are
- limit maximal number of configurable pins by bitfield size in the encoding
- absence of pin <-> gpio mapping
- absence of nice debug strings :)

So, if you think that large "struct omap_mux omap_xxx_muxmodes" tables are acceptable, I'd propose to go with "struct omap_mux" as you described it and add some macros to allow simple interface for board-* files like the one above.

Quoted 38 lines

And then also have a function to initialize a whole struct omap_mux array from each board-*.c files.

Regards,

Tony

Quoted 28 lines

[1] Documentation/arm/pxa/mfp.txt
[2] http://elinux.org/OMAP_wishlist#References
[3] http://elinux.org/OMAP_wishlist#Initial_plans_.28from_Tony.2C_for_next_merge_window.29

Changes since commit 0bbf5337f2f2957775051a3caf60b66d3306c815
Tony Lindgren
Fix compile for 1510 innovator

Mike Rapoport (3):
omap2: mux: intoduce omap_mux_{read,write}
omap: mux: add interface for encoded mux configration
omap2: mux: implement encoded mux configuration

 arch/arm/mach-omap2/include/mach/mux.h     |  452 +++++++++++++++
 arch/arm/mach-omap2/include/mach/mux24xx.h |  128 ++++
 arch/arm/mach-omap2/include/mach/mux34xx.h |  862 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/mux.c                  |  158 +++++-
 arch/arm/plat-omap/include/plat/mux.h      |   62 +--
 arch/arm/plat-omap/mux.c                   |   17 +
 6 files changed, 1614 insertions(+), 65 deletions(-)
 create mode 100644 arch/arm/mach-omap2/include/mach/mux.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux24xx.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux34xx.h

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Sincerely yours,
Mike.
maintainer
#10 lore raw
Quoted 21 lines · Mike Rapoport
Quoted 18 lines · Tony Lindgren
Quoted 10 lines · Mike Rapoport

This is an attempt to start rework of the mux framework keeping as much backward compatibility as possible.
The patch serie introduces a new mux configuration interface that follows the ideas of PXA MFP implementation ([1] and [2]). The mux configuration interface is implemented for OMAP3 and partially for OMAP2 processors.
The OMAP2 implementation is far from being complete. Unfortunately I do not have OMAP2 docs, so I've added only configration for pins defined in omap24xx_pins table.

Quoted 2 lines

The older opam_cfg_reg interface is still present and can be used to avoid too many broken things in steps 2 & 3 as of Tony's plans ([3]).

Cool! I too have been working on this for past several days, but luckily I've been working on the new mux data layout instead so far with some help from Paul and Benoit.

Quoted 7 lines
Quoted 5 lines

So this should all come together quite nicely. I'll try to post some patches as soon as the new mux data is working. I'll also take a close look at your patches, it seems like they already separate the mach-omap2 mux code nicely from what's needed for mach-omap1 (well, at least for 15xx).

I'd be glad to get those patches even before the new mux data is working :)

Got it working mostly, still need to clean it a bit this morning.

Quoted 14 lines
Quoted 14 lines

The reason I think we need to redo all the mux data is because the new setup has several shortcomings:

- All the mux registers on the newer omaps are in a single register for each signal instead of being scattered across multiple registers like on 15xx. So the enumeration is not needed, and we don't need to specify each signal.

- We badly need mux register to GPIO mapping for runtime muxing of GPIO pins for the idle modes

- For debugging, we need to see the pin status if CONFIG_DEBUG_FS is set

Quoted 8 lines
Quoted 5 lines

- For adding custom hardware on boards such as Beagle, we need to be able to override pins via /debugfs or via cmdline

- Grepping the code for the signal + ball + mux register combination is currently impossible

Is it really necessary to have ball information? OMAP35x packages differ, so having ball information may be misleading.

Well it's very handy for debugging, it's there only if CONFIG_DEBUG_FS is set. Everything gets optimized out if CONFIG_OMAP_MUX is not set, all the bloat is optimized out if CONFIG_DEBUG_FS is set. Or it could be behind the CONFIG_OMAP_MUX_DEBUG that we already have.

BTW, I already got the all the three existing 34xx package types covered, 3630 still needs to be added.

Quoted 25 lines
Quoted 18 lines

So I suggest we get rid of defining each mux mode separately, and just define the register offsets from the mux base.

Then for the new omap_set_mux(), we should pass the register offset, the desired value, and optional flags.

For the new mux data, I currently have something like the below just to give an idea what I was thinking, maybe take a quick look at that and see how that fits into what you had in mind?

arch/arm/mach-omap2/mux.h:

/**
* struct omap_mux - data for omap mux register offset and it's value
* @reg_offset: mux register offset from the mux base
* @gpio: GPIO number
* @muxnames: available signal modes for a ball
*/

Quoted 6 lines
struct omap_mux {
	u16	reg_offset;
	u16	gpio;
#ifdef CONFIG_DEBUG_FS
	char	*muxnames[8];
	char	*balls[2];
Quoted 1 line

Again, I do not quite understand what do we need the ball names for?

Just debug info (if compiled in). We could allow muxing by ball name if we wanted to.

Quoted 98 lines
Quoted 46 lines

#endif
};
...

arch/arm/mach-omap2/mux34xx.h:

#ifdef CONFIG_DEBUG_FS

#define _OMAP3_MUXENTRY(M0, g, m0, m1, m2, m3, m4, m5, m6, m7) \

{									\
	.reg_offset	= (OMAP3_CONTROL_PADCONF_##M0##_OFFSET),	\
	.gpio		= (g),						\
	.muxnames	= { m0, m1, m2, m3, m4, m5, m6, m7 },		\
}

#else

#define _OMAP3_MUXENTRY(M0, g, m0, m1, m2, m3, m4, m5, m6, m7) \

{									\
	.reg_offset	= (OMAP3_CONTROL_PADCONF_##M0##_OFFSET),	\
	.gpio		= (g),						\
}

#endif

/*
* OMAP3 CONTROL_PADCONF* register offsets for pin-muxing *
* Extracted from the TRM. Add 0x48002030 to these values to get the
* absolute addresses. The name in the macro is the mode-0 name of
* the pin. NOTE: These registers are 16-bits wide.
*/
#define OMAP3_CONTROL_PADCONF_SDRC_D0_OFFSET 0x000
#define OMAP3_CONTROL_PADCONF_SDRC_D1_OFFSET 0x002
#define OMAP3_CONTROL_PADCONF_SDRC_D2_OFFSET 0x004
#define OMAP3_CONTROL_PADCONF_SDRC_D3_OFFSET 0x006
#define OMAP3_CONTROL_PADCONF_SDRC_D4_OFFSET 0x008
...

/*
* Superset of all mux modes, same as the CBC package */

struct omap_mux omap3_muxmodes[] = {
	_OMAP3_MUXENTRY(CAM_D0, 99,
		"cam_d0", NULL, NULL, NULL,
		"gpio_99", NULL, NULL, "safe_mode"),

[ snip ]

Quoted 9 lines

...
{ .reg_offset = OMAP_MUX_TERMINATOR },
};
...

And this is what I was thinking for the new mux function:

int omap_set_mux(u16 val, u16 offset, int flags);

I have slightly different approach in mind. My idea was to have a table that provides some mapping between pin and it's PADCONF offset. That table initialization is CPU variant specific, so mapping for OMAP24XX will be different from the mapping for OMAP2430 and OMAP35x. The mapping table is indexed with enumeration that lists all configurable pins for all processor and package variants.
Next, there are macros that encode the index and PADCONF value for each possible pin configuration into u32, e.g.

#define OMAP3_CAM_D0 OMAP3_PIN(CAM_D0, MODE0)
#define OMAP3_CAM_D0_CSI2_DX2 OMAP3_PIN(CAM_D0, MODE2)
#define OMAP3_CAM_D0_GPIO_99 OMAP3_PIN(CAM_D0, MODE4)

And omap_cfg_pin (my name for omap_cfg_mux) takes the encoded mux configuration, extracts from there the index into the mapping table and PADCONF value and updates the PADCONF register.

My approach allows reusing the same code for setting mux configuration for OMAP2
and OMAP3 (and probably OMAP4), and , apparently would use less memory that
your proposal. Another advantage of using encoded mux configuration is a simplification of board-specific code. You can use an array with all pins configured there and pass this array to, say, omap_cfg_pins:

unsigned long board_pins[] = {
	OMAP3_CAM_D0_GPIO_99,
	OMAP3_GPMC_WAIT3_GPIO_65,

	OMAP3_MCBSP2_FSX,
	OMAP3_MCBSP2_CLKX,
	OMAP3_MCBSP2_DR,
	OMAP3_MCBSP2_DX,

...
};

static void __init some_board_init(void)
{
...

	omap_cfg_pins(board_pins, ARRAY_SIZE(board_pins));

...
}

Quoted 8 lines

The drawbacks of using encoded mux configuration are
- limit maximal number of configurable pins by bitfield size in the encoding
- absence of pin <-> gpio mapping
- absence of nice debug strings :)

So, if you think that large "struct omap_mux omap_xxx_muxmodes" tables are acceptable, I'd propose to go with "struct omap_mux" as you described it and add some macros to allow simple interface for board-* files like the one above.

OK, well let's play with it a bit and see what's the best way to go.

Currently all the tables are __initdata, and copied to a list for only for pins that are set as GPIO (mode4), or flagged as dynamic from the board-*.c file.

Regards,

Tony

Quoted 43 lines
Quoted 38 lines

And then also have a function to initialize a whole struct omap_mux array from each board-*.c files.

Regards,

Tony

Quoted 28 lines

[1] Documentation/arm/pxa/mfp.txt
[2] http://elinux.org/OMAP_wishlist#References
[3] http://elinux.org/OMAP_wishlist#Initial_plans_.28from_Tony.2C_for_next_merge_window.29

Changes since commit 0bbf5337f2f2957775051a3caf60b66d3306c815
Tony Lindgren
Fix compile for 1510 innovator

Mike Rapoport (3):
omap2: mux: intoduce omap_mux_{read,write}
omap: mux: add interface for encoded mux configration
omap2: mux: implement encoded mux configuration

 arch/arm/mach-omap2/include/mach/mux.h     |  452 +++++++++++++++
 arch/arm/mach-omap2/include/mach/mux24xx.h |  128 ++++
 arch/arm/mach-omap2/include/mach/mux34xx.h |  862 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/mux.c                  |  158 +++++-
 arch/arm/plat-omap/include/plat/mux.h      |   62 +--
 arch/arm/plat-omap/mux.c                   |   17 +
 6 files changed, 1614 insertions(+), 65 deletions(-)
 create mode 100644 arch/arm/mach-omap2/include/mach/mux.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux24xx.h
 create mode 100644 arch/arm/mach-omap2/include/mach/mux34xx.h

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Sincerely yours,
Mike.