Skip to contentSkip to conversation

OMAP4: mux: Add the OMAP4430 ES1 & ES2 support

RFC In review Benoit Cousson 2 participants 19 messages Oct 19, 2010 – Nov 11, 2010

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

v2 cover OMAP4: mux: Add the OMAP4430 ES1 & ES2 support

Hi Tony,

Upon Nishanth request, here is the updated version...

It takes into account your proposal to store partition information in a partition structure instead of inside every pad entries. The mechanism relies on the uniqueness of the pad name in each partition to find the correct partition during iteration.

Removed as well some cpu_is_xxx calls from the core code by adding a couple of flags during partition init.

Please note that due to low level access to mux api from the RX51 board code, I have to disable the mux change to build properly with omap2plus_defconfig. Look like you do have some idea to fix that :-)
I was thinking of:
- brute force approach that consist of keeping all the data after init, and thus allowing removing the __init in the omap_mux_init_signal API
- or adding some flag in the pad entry to keep them after init .

Boot tested on SDP4430 with ES1.0 & ES2.0 with omap2plus_defconfig. Still require some real driver to use that mux API in order to validate it.

The series is on top of lo/master (2.6.36-rc8) and is available here:
git://gitorious.org/omap-pm/linux.git ctrl-wip/mux-omap4-v2

Thanks,
Benoit

v1:

    http://www.spinics.net/lists/linux-omap/msg37158.html    

Benoit Cousson (7):
OMAP: mux: Replace printk with pr_xxx macros
OMAP3: RX-51: Temporary disable dynamic mux change for eMMC
OMAP: mux: Add support for control module split in several partitions
OMAP4: mux: Add CBL package data for OMAP4430 ES1
OMAP4: mux: Select CBL package for SDP4430 with ES1
OMAP4: mux: Add CBS package data for OMAP4430 ES2
OMAP4: mux: Select CBS package for SDP4430 with ES2

 arch/arm/mach-omap2/Kconfig                  |    8 +
 arch/arm/mach-omap2/Makefile                 |    1 +
 arch/arm/mach-omap2/board-4430sdp.c          |   14 +
 arch/arm/mach-omap2/board-rx51-peripherals.c |    3 +-
 arch/arm/mach-omap2/mux.c                    |  330 ++++--
 arch/arm/mach-omap2/mux.h                    |   92 +-
 arch/arm/mach-omap2/mux2420.c                |    7 +-
 arch/arm/mach-omap2/mux2430.c                |    7 +-
 arch/arm/mach-omap2/mux34xx.c                |    7 +-
 arch/arm/mach-omap2/mux44xx.c                | 1625 ++++++++++++++++++++++++++
 arch/arm/mach-omap2/mux44xx.h                |  298 +++++
 11 files changed, 2229 insertions(+), 163 deletions(-)
 create mode 100644 arch/arm/mach-omap2/mux44xx.c
 create mode 100644 arch/arm/mach-omap2/mux44xx.h
#1 lore raw

RFC v2 1/7 OMAP: mux: Replace printk with pr_xxx macros

Cc Tony Lindgren <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 arch/arm/mach-omap2/mux.c |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)
arch/arm/mach-omap2/mux.c +19 -19
index 074536a..979e9d1 100644
@@ -102,13 +102,13 @@ int __init omap_mux_init_gpio(int gpio, int val)
 	}
 
 	if (found == 0) {
-		printk(KERN_ERR "mux: Could not set gpio%i\n", gpio);
+		pr_err("mux: Could not set gpio%i\n", gpio);
 		return -ENODEV;
 	}
 
 	if (found > 1) {
-		printk(KERN_INFO "mux: Multiple gpio paths (%d) for gpio%i\n",
-				found, gpio);
+		pr_info("mux: Multiple gpio paths (%d) for gpio%i\n",
+			found, gpio);
 		return -EINVAL;
 	}
 
@@ -118,8 +118,8 @@ int __init omap_mux_init_gpio(int gpio, int val)
 		mux_mode |= OMAP_MUX_MODE3;
 	else
 		mux_mode |= OMAP_MUX_MODE4;
-	printk(KERN_DEBUG "mux: Setting signal %s.gpio%i 0x%04x -> 0x%04x\n",
-			gpio_mux->muxnames[0], gpio, old_mode, mux_mode);
+	pr_debug("mux: Setting signal %s.gpio%i 0x%04x -> 0x%04x\n",
+		 gpio_mux->muxnames[0], gpio, old_mode, mux_mode);
 	omap_mux_write(mux_mode, gpio_mux->reg_offset);
 
 	return 0;
@@ -161,9 +161,9 @@ int __init omap_mux_init_signal(const char *muxname, int val)
 
 				old_mode = omap_mux_read(m->reg_offset);
 				mux_mode = val | i;
-				printk(KERN_DEBUG "mux: Setting signal "
-					"%s.%s 0x%04x -> 0x%04x\n",
-					m0_entry, muxname, old_mode, mux_mode);
+				pr_debug("mux: Setting signal "
+					 "%s.%s 0x%04x -> 0x%04x\n",
+					 m0_entry, muxname, old_mode, mux_mode);
 				omap_mux_write(mux_mode, m->reg_offset);
 				found++;
 			}
@@ -174,12 +174,12 @@ int __init omap_mux_init_signal(const char *muxname, int val)
 		return 0;
 
 	if (found > 1) {
-		printk(KERN_ERR "mux: Multiple signal paths (%i) for %s\n",
-				found, muxname);
+		pr_err("mux: Multiple signal paths (%i) for %s\n",
+		       found, muxname);
 		return -EINVAL;
 	}
 
-	printk(KERN_ERR "mux: Could not set signal %s\n", muxname);
+	pr_err("mux: Could not set signal %s\n", muxname);
 
 	return -ENODEV;
 }
@@ -462,8 +462,8 @@ static void __init omap_mux_package_fixup(struct omap_mux *p,
 			s++;
 		}
 		if (!found)
-			printk(KERN_ERR "mux: Unknown entry offset 0x%x\n",
-					p->reg_offset);
+			pr_err("mux: Unknown entry offset 0x%x\n",
+			       p->reg_offset);
 		p++;
 	}
 }
@@ -487,8 +487,8 @@ static void __init omap_mux_package_init_balls(struct omap_ball *b,
 			s++;
 		}
 		if (!found)
-			printk(KERN_ERR "mux: Unknown ball offset 0x%x\n",
-					b->reg_offset);
+			pr_err("mux: Unknown ball offset 0x%x\n",
+			       b->reg_offset);
 		b++;
 	}
 }
@@ -615,7 +615,7 @@ u16 omap_mux_get_gpio(int gpio)
 
 	offset = omap_mux_get_by_gpio(gpio);
 	if (offset == OMAP_MUX_TERMINATOR) {
-		printk(KERN_ERR "mux: Could not get gpio%i\n", gpio);
+		pr_err("mux: Could not get gpio%i\n", gpio);
 		return offset;
 	}
 
@@ -629,7 +629,7 @@ void omap_mux_set_gpio(u16 val, int gpio)
 
 	offset = omap_mux_get_by_gpio(gpio);
 	if (offset == OMAP_MUX_TERMINATOR) {
-		printk(KERN_ERR "mux: Could not set gpio%i\n", gpio);
+		pr_err("mux: Could not set gpio%i\n", gpio);
 		return;
 	}
 
@@ -687,7 +687,7 @@ static void __init omap_mux_init_list(struct omap_mux *superset)
 
 		entry = omap_mux_list_add(superset);
 		if (!entry) {
-			printk(KERN_ERR "mux: Could not add entry\n");
+			pr_err("mux: Could not add entry\n");
 			return;
 		}
 		superset++;
@@ -738,7 +738,7 @@ int __init omap_mux_init(u32 mux_pbase, u32 mux_size,
 	mux_phys = mux_pbase;
 	mux_base = ioremap(mux_pbase, mux_size);
 	if (!mux_base) {
-		printk(KERN_ERR "mux: Could not ioremap\n");
+		pr_err("mux: Could not ioremap\n");
 		return -ENODEV;
 	}
 
Signature · 1 line
1.7.0.4
#2 lore raw

RFC v2 2/7 OMAP3: RX-51: Temporary disable dynamic mux change for eMMC

In reply to Benoit Cousson

RX-51 board is using some low level function in order to change the padconf settings at runtime.
Since these functions will not be usable anymore after the partition introduction, remove the code that use these code.

As soon as a proper API will be proposed, this patch will be drop.

---
 arch/arm/mach-omap2/board-rx51-peripherals.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/board-rx51-peripherals.c +2 -1
index 25a273d..56a49a0 100644
@@ -260,6 +260,7 @@ static struct twl4030_madc_platform_data rx51_madc_data = {
 	.irq_line		= 1,
 };
 
+#if 0
 /* Enable input logic and pull all lines up when eMMC is on. */
 static struct omap_board_mux rx51_mmc2_on_mux[] = {
 	OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
@@ -299,6 +300,7 @@ static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
 	else
 		omap_mux_write_array(rx51_mmc2_off_mux);
 }
+#endif
 
 static struct omap2_hsmmc_info mmc[] __initdata = {
 	{
@@ -319,7 +321,6 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.gpio_wp	= -EINVAL,
 		.nonremovable	= true,
 		.power_saving	= true,
-		.remux		= rx51_mmc2_remux,
 	},
 	{}	/* Terminator */
 };
Signature · 1 line
1.7.0.4
#3 lore raw

RFC v2 3/7 OMAP: mux: Add support for control module split in several partitions

In reply to Benoit Cousson

Starting on OMAP4, the pin mux configuration is located in two different partitions of the control module (CODE_PAD and WKUP_PAD). The first one is inside the core power domain whereas the second one is inside the wakeup.
Add the capability to add any number of partition during board init time depending of Soc partitioning.
Add some init flags as well in order to avoid explicit Soc version check inside the mux core code.

Note that this implementation change will make the mux_read, mux_write and omap_mux_write_array accessors unusable outside the mux code.

Cc Tony Lindgren <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Santosh Shilimkar <[email protected]>
---
 arch/arm/mach-omap2/mux.c     |  298 ++++++++++++++++++++++++++--------------
 arch/arm/mach-omap2/mux.h     |   79 +++++++-----
 arch/arm/mach-omap2/mux2420.c |    7 +-
 arch/arm/mach-omap2/mux2430.c |    7 +-
 arch/arm/mach-omap2/mux34xx.c |    7 +-
 5 files changed, 252 insertions(+), 146 deletions(-)
arch/arm/mach-omap2/mux.c +194 -104
index 979e9d1..9b9128e 100644
@@ -1,9 +1,9 @@
 /*
  * linux/arch/arm/mach-omap2/mux.c
  *
- * OMAP2 and OMAP3 pin multiplexing configurations
+ * OMAP2, OMAP3 and OMAP4 pin multiplexing configurations
  *
- * Copyright (C) 2004 - 2008 Texas Instruments Inc.
+ * Copyright (C) 2004 - 2010 Texas Instruments Inc.
  * Copyright (C) 2003 - 2008 Nokia Corporation
  *
  * Written by Tony Lindgren
@@ -40,60 +40,60 @@
 
 #define OMAP_MUX_BASE_OFFSET		0x30	/* Offset from CTRL_BASE */
 #define OMAP_MUX_BASE_SZ		0x5ca
-#define MUXABLE_GPIO_MODE3		BIT(0)
 
 struct omap_mux_entry {
 	struct omap_mux		mux;
 	struct list_head	node;
 };
 
-static unsigned long mux_phys;
-static void __iomem *mux_base;
-static u8 omap_mux_flags;
+static LIST_HEAD(mux_partitions);
+static DEFINE_MUTEX(muxmode_mutex);
 
-u16 omap_mux_read(u16 reg)
+static u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg)
 {
-	if (cpu_is_omap24xx())
-		return __raw_readb(mux_base + reg);
+	if (partition->flags & OMAP_MUX_REG_8BIT)
+		return __raw_readb(partition->base + reg);
 	else
-		return __raw_readw(mux_base + reg);
+		return __raw_readw(partition->base + reg);
 }
 
-void omap_mux_write(u16 val, u16 reg)
+static void omap_mux_write(struct omap_mux_partition *partition, u16 val,
+			   u16 reg)
 {
-	if (cpu_is_omap24xx())
-		__raw_writeb(val, mux_base + reg);
+	if (partition->flags & OMAP_MUX_REG_8BIT)
+		__raw_writeb(val, partition->base + reg);
 	else
-		__raw_writew(val, mux_base + reg);
+		__raw_writew(val, partition->base + reg);
 }
 
-void omap_mux_write_array(struct omap_board_mux *board_mux)
+static void omap_mux_write_array(struct omap_mux_partition *partition,
+				 struct omap_board_mux *board_mux)
 {
-	while (board_mux->reg_offset !=  OMAP_MUX_TERMINATOR) {
-		omap_mux_write(board_mux->value, board_mux->reg_offset);
+	while (board_mux->reg_offset != OMAP_MUX_TERMINATOR) {
+		omap_mux_write(partition, board_mux->value,
+			       board_mux->reg_offset);
 		board_mux++;
 	}
 }
 
-static LIST_HEAD(muxmodes);
-static DEFINE_MUTEX(muxmode_mutex);
-
 #ifdef CONFIG_OMAP_MUX
 
 static char *omap_mux_options;
 
-int __init omap_mux_init_gpio(int gpio, int val)
+static int __init _omap_mux_init_gpio(struct omap_mux_partition *partition,
+				      int gpio, int val)
 {
 	struct omap_mux_entry *e;
 	struct omap_mux *gpio_mux = NULL;
 	u16 old_mode;
 	u16 mux_mode;
 	int found = 0;
+	struct list_head *muxmodes = &partition->muxmodes;
 
 	if (!gpio)
 		return -EINVAL;
 
-	list_for_each_entry(e, &muxmodes, node) {
+	list_for_each_entry(e, muxmodes, node) {
 		struct omap_mux *m = &e->mux;
 		if (gpio == m->gpio) {
 			gpio_mux = m;
@@ -112,24 +112,40 @@ int __init omap_mux_init_gpio(int gpio, int val)
 		return -EINVAL;
 	}
 
-	old_mode = omap_mux_read(gpio_mux->reg_offset);
+	old_mode = omap_mux_read(partition, gpio_mux->reg_offset);
 	mux_mode = val & ~(OMAP_MUX_NR_MODES - 1);
-	if (omap_mux_flags & MUXABLE_GPIO_MODE3)
+	if (partition->flags & OMAP_MUX_GPIO_IN_MODE3)
 		mux_mode |= OMAP_MUX_MODE3;
 	else
 		mux_mode |= OMAP_MUX_MODE4;
 	pr_debug("mux: Setting signal %s.gpio%i 0x%04x -> 0x%04x\n",
 		 gpio_mux->muxnames[0], gpio, old_mode, mux_mode);
-	omap_mux_write(mux_mode, gpio_mux->reg_offset);
+	omap_mux_write(partition, mux_mode, gpio_mux->reg_offset);
 
 	return 0;
 }
 
-int __init omap_mux_init_signal(const char *muxname, int val)
+int __init omap_mux_init_gpio(int gpio, int val)
+{
+	struct omap_mux_partition *partition;
+	int ret;
+
+	list_for_each_entry(partition, &mux_partitions, node) {
+		ret = _omap_mux_init_gpio(partition, gpio, val);
+		if (!ret)
+			return ret;
+	}
+
+	return -ENODEV;
+}
+
+static int __init _omap_mux_init_signal(struct omap_mux_partition *partition,
+					const char *muxname, int val)
 {
 	struct omap_mux_entry *e;
 	const char *mode_name;
 	int found = 0, mode0_len = 0;
+	struct list_head *muxmodes = &partition->muxmodes;
 
 	mode_name = strchr(muxname, '.');
 	if (mode_name) {
@@ -139,7 +155,7 @@ int __init omap_mux_init_signal(const char *muxname, int val)
 		mode_name = muxname;
 	}
 
-	list_for_each_entry(e, &muxmodes, node) {
+	list_for_each_entry(e, muxmodes, node) {
 		struct omap_mux *m = &e->mux;
 		char *m0_entry = m->muxnames[0];
 		int i;
@@ -159,12 +175,14 @@ int __init omap_mux_init_signal(const char *muxname, int val)
 				u16 old_mode;
 				u16 mux_mode;
 
-				old_mode = omap_mux_read(m->reg_offset);
+				old_mode = omap_mux_read(partition,
+							 m->reg_offset);
 				mux_mode = val | i;
 				pr_debug("mux: Setting signal "
 					 "%s.%s 0x%04x -> 0x%04x\n",
 					 m0_entry, muxname, old_mode, mux_mode);
-				omap_mux_write(mux_mode, m->reg_offset);
+				omap_mux_write(partition, mux_mode,
+					       m->reg_offset);
 				found++;
 			}
 		}
@@ -184,6 +202,21 @@ int __init omap_mux_init_signal(const char *muxname, int val)
 	return -ENODEV;
 }
 
+int __init omap_mux_init_signal(const char *muxname, int val)
+{
+	struct omap_mux_partition *partition;
+	int ret;
+
+	list_for_each_entry(partition, &mux_partitions, node) {
+		ret = _omap_mux_init_signal(partition, muxname, val);
+		if (!ret)
+			return ret;
+	}
+
+	return -ENODEV;
+
+}
+
 #ifdef CONFIG_DEBUG_FS
 
 #define OMAP_MUX_MAX_NR_FLAGS	10
@@ -248,13 +281,15 @@ static inline void omap_mux_decode(struct seq_file *s, u16 val)
 	} while (i-- > 0);
 }
 
-#define OMAP_MUX_DEFNAME_LEN	16
+#define OMAP_MUX_DEFNAME_LEN	32
 
 static int omap_mux_dbg_board_show(struct seq_file *s, void *unused)
 {
+	struct omap_mux_partition *partition = s->private;
 	struct omap_mux_entry *e;
+	u8 omap_gen = omap_rev() >> 28;
 
-	list_for_each_entry(e, &muxmodes, node) {
+	list_for_each_entry(e, &partition->muxmodes, node) {
 		struct omap_mux *m = &e->mux;
 		char m0_def[OMAP_MUX_DEFNAME_LEN];
 		char *m0_name = m->muxnames[0];
@@ -272,11 +307,16 @@ static int omap_mux_dbg_board_show(struct seq_file *s, void *unused)
 			}
 			m0_def[i] = toupper(m0_name[i]);
 		}
-		val = omap_mux_read(m->reg_offset);
+		val = omap_mux_read(partition, m->reg_offset);
 		mode = val & OMAP_MUX_MODE7;
-
-		seq_printf(s, "OMAP%i_MUX(%s, ",
-					cpu_is_omap34xx() ? 3 : 0, m0_def);
+		if (mode != 0)
+			seq_printf(s, "/* %s */\n", m->muxnames[mode]);
+
+		/*
+		 * XXX: Might be revisited to support differences accross
+		 * same OMAP generation.
+		 */
+		seq_printf(s, "OMAP%d_MUX(%s, ", omap_gen, m0_def);
 		omap_mux_decode(s, val);
 		seq_printf(s, "),\n");
 	}
@@ -286,7 +326,7 @@ static int omap_mux_dbg_board_show(struct seq_file *s, void *unused)
 
 static int omap_mux_dbg_board_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, omap_mux_dbg_board_show, &inode->i_private);
+	return single_open(file, omap_mux_dbg_board_show, inode->i_private);
 }
 
 static const struct file_operations omap_mux_dbg_board_fops = {
@@ -299,16 +339,17 @@ static const struct file_operations omap_mux_dbg_board_fops = {
 static int omap_mux_dbg_signal_show(struct seq_file *s, void *unused)
 {
 	struct omap_mux *m = s->private;
+	struct omap_mux_partition *partition = m->partition;
 	const char *none = "NA";
 	u16 val;
 	int mode;
 
-	val = omap_mux_read(m->reg_offset);
+	val = omap_mux_read(partition, m->reg_offset);
 	mode = val & OMAP_MUX_MODE7;
 
-	seq_printf(s, "name: %s.%s (0x%08lx/0x%03x = 0x%04x), b %s, t %s\n",
+	seq_printf(s, "name: %s.%s (0x%08x/0x%03x = 0x%04x), b %s, t %s\n",
 			m->muxnames[0], m->muxnames[mode],
-			mux_phys + m->reg_offset, m->reg_offset, val,
+			partition->phys + m->reg_offset, m->reg_offset, val,
 			m->balls[0] ? m->balls[0] : none,
 			m->balls[1] ? m->balls[1] : none);
 	seq_printf(s, "mode: ");
@@ -330,8 +371,8 @@ static int omap_mux_dbg_signal_show(struct seq_file *s, void *unused)
 #define OMAP_MUX_MAX_ARG_CHAR  7
 
 static ssize_t omap_mux_dbg_signal_write(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+					 const char __user *user_buf,
+					 size_t count, loff_t *ppos)
 {
 	char buf[OMAP_MUX_MAX_ARG_CHAR];
 	struct seq_file *seqf;
@@ -358,7 +399,7 @@ static ssize_t omap_mux_dbg_signal_write(struct file *file,
 	seqf = file->private_data;
 	m = seqf->private;
 
-	omap_mux_write((u16)val, m->reg_offset);
+	omap_mux_write(m->partition, (u16)val, m->reg_offset);
 	*ppos += count;
 
 	return count;
@@ -379,22 +420,39 @@ static const struct file_operations omap_mux_dbg_signal_fops = {
 
 static struct dentry *mux_dbg_dir;
 
-static void __init omap_mux_dbg_init(void)
+static void __init omap_mux_dbg_create_entry(
+				struct omap_mux_partition *partition,
+				struct dentry *mux_dbg_dir)
 {
 	struct omap_mux_entry *e;
 
+	list_for_each_entry(e, &partition->muxmodes, node) {
+		struct omap_mux *m = &e->mux;
+		m->partition = partition;
+
+		(void)debugfs_create_file(m->muxnames[0], S_IWUGO, mux_dbg_dir,
+					  m, &omap_mux_dbg_signal_fops);
+	}
+}
+
+static void __init omap_mux_dbg_init(void)
+{
+	struct omap_mux_partition *partition;
+	static struct dentry *mux_dbg_board_dir;
+
 	mux_dbg_dir = debugfs_create_dir("omap_mux", NULL);
 	if (!mux_dbg_dir)
 		return;
 
-	(void)debugfs_create_file("board", S_IRUGO, mux_dbg_dir,
-					NULL, &omap_mux_dbg_board_fops);
-
-	list_for_each_entry(e, &muxmodes, node) {
-		struct omap_mux *m = &e->mux;
+	mux_dbg_board_dir = debugfs_create_dir("board", mux_dbg_dir);
+	if (!mux_dbg_board_dir)
+		return;
 
-		(void)debugfs_create_file(m->muxnames[0], S_IWUGO, mux_dbg_dir,
-					m, &omap_mux_dbg_signal_fops);
+	list_for_each_entry(partition, &mux_partitions, node) {
+		omap_mux_dbg_create_entry(partition, mux_dbg_dir);
+		(void)debugfs_create_file(partition->name, S_IRUGO,
+					  mux_dbg_board_dir, partition,
+					  &omap_mux_dbg_board_fops);
 	}
 }
 
@@ -421,23 +479,25 @@ static void __init omap_mux_free_names(struct omap_mux *m)
 /* Free all data except for GPIO pins unless CONFIG_DEBUG_FS is set */
 static int __init omap_mux_late_init(void)
 {
-	struct omap_mux_entry *e, *tmp;
+	struct omap_mux_partition *partition;
 
-	list_for_each_entry_safe(e, tmp, &muxmodes, node) {
-		struct omap_mux *m = &e->mux;
-		u16 mode = omap_mux_read(m->reg_offset);
+	list_for_each_entry(partition, &mux_partitions, node) {
+		struct omap_mux_entry *e, *tmp;
+		list_for_each_entry_safe(e, tmp, &partition->muxmodes, node) {
+			struct omap_mux *m = &e->mux;
+			u16 mode = omap_mux_read(partition, m->reg_offset);
 
-		if (OMAP_MODE_GPIO(mode))
-			continue;
+			if (OMAP_MODE_GPIO(mode))
+				continue;
 
 #ifndef CONFIG_DEBUG_FS
-		mutex_lock(&muxmode_mutex);
-		list_del(&e->node);
-		mutex_unlock(&muxmode_mutex);
-		omap_mux_free_names(m);
-		kfree(m);
+			mutex_lock(&muxmode_mutex);
+			list_del(&e->node);
+			mutex_unlock(&muxmode_mutex);
+			omap_mux_free_names(m);
+			kfree(m);
 #endif
-
+		}
 	}
 
 	omap_mux_dbg_init();
@@ -554,7 +614,7 @@ static void __init omap_mux_set_cmdline_signals(void)
 }
 
 static int __init omap_mux_copy_names(struct omap_mux *src,
-					struct omap_mux *dst)
+				      struct omap_mux *dst)
 {
 	int i;
 
@@ -592,51 +652,63 @@ free:
 
 #endif	/* CONFIG_OMAP_MUX */
 
-static u16 omap_mux_get_by_gpio(int gpio)
+static struct omap_mux *omap_mux_get_by_gpio(
+				struct omap_mux_partition *partition,
+				int gpio)
 {
 	struct omap_mux_entry *e;
-	u16 offset = OMAP_MUX_TERMINATOR;
+	struct omap_mux *ret = NULL;
 
-	list_for_each_entry(e, &muxmodes, node) {
+	list_for_each_entry(e, &partition->muxmodes, node) {
 		struct omap_mux *m = &e->mux;
 		if (m->gpio == gpio) {
-			offset = m->reg_offset;
+			ret = m;
 			break;
 		}
 	}
 
-	return offset;
+	return ret;
 }
 
 /* Needed for dynamic muxing of GPIO pins for off-idle */
 u16 omap_mux_get_gpio(int gpio)
 {
-	u16 offset;
+	struct omap_mux_partition *partition;
+	struct omap_mux *m;
 
-	offset = omap_mux_get_by_gpio(gpio);
-	if (offset == OMAP_MUX_TERMINATOR) {
-		pr_err("mux: Could not get gpio%i\n", gpio);
-		return offset;
+	list_for_each_entry(partition, &mux_partitions, node) {
+		m = omap_mux_get_by_gpio(partition, gpio);
+		if (m)
+			return omap_mux_read(partition->base, m->reg_offset);
 	}
 
-	return omap_mux_read(offset);
+	if (!m || m->reg_offset == OMAP_MUX_TERMINATOR)
+		pr_err("mux: Could not get gpio%i\n", gpio);
+
+	return OMAP_MUX_TERMINATOR;
 }
 
 /* Needed for dynamic muxing of GPIO pins for off-idle */
 void omap_mux_set_gpio(u16 val, int gpio)
 {
-	u16 offset;
+	struct omap_mux_partition *partition;
+	struct omap_mux *m = NULL;
 
-	offset = omap_mux_get_by_gpio(gpio);
-	if (offset == OMAP_MUX_TERMINATOR) {
-		pr_err("mux: Could not set gpio%i\n", gpio);
-		return;
+	list_for_each_entry(partition, &mux_partitions, node) {
+		m = omap_mux_get_by_gpio(partition, gpio);
+		if (m) {
+			omap_mux_write(partition, val, m->reg_offset);
+			return;
+		}
 	}
 
-	omap_mux_write(val, offset);
+	if (!m || m->reg_offset == OMAP_MUX_TERMINATOR)
+		pr_err("mux: Could not set gpio%i\n", gpio);
 }
 
-static struct omap_mux * __init omap_mux_list_add(struct omap_mux *src)
+static struct omap_mux * __init omap_mux_list_add(
+					struct omap_mux_partition *partition,
+					struct omap_mux *src)
 {
 	struct omap_mux_entry *entry;
 	struct omap_mux *m;
@@ -656,7 +728,7 @@ static struct omap_mux * __init omap_mux_list_add(struct omap_mux *src)
 #endif
 
 	mutex_lock(&muxmode_mutex);
-	list_add_tail(&entry->node, &muxmodes);
+	list_add_tail(&entry->node, &partition->muxmodes);
 	mutex_unlock(&muxmode_mutex);
 
 	return m;
@@ -667,7 +739,8 @@ static struct omap_mux * __init omap_mux_list_add(struct omap_mux *src)
  * the GPIO to mux offset mapping that is needed for dynamic muxing
  * of GPIO pins for off-idle.
  */
-static void __init omap_mux_init_list(struct omap_mux *superset)
+static void __init omap_mux_init_list(struct omap_mux_partition *partition,
+				      struct omap_mux *superset)
 {
 	while (superset->reg_offset !=  OMAP_MUX_TERMINATOR) {
 		struct omap_mux *entry;
@@ -685,7 +758,7 @@ static void __init omap_mux_init_list(struct omap_mux *superset)
 		}
 #endif
 
-		entry = omap_mux_list_add(superset);
+		entry = omap_mux_list_add(partition, superset);
 		if (!entry) {
 			pr_err("mux: Could not add entry\n");
 			return;
@@ -706,48 +779,65 @@ static void omap_mux_init_package(struct omap_mux *superset,
 		omap_mux_package_init_balls(package_balls, superset);
 }
 
-static void omap_mux_init_signals(struct omap_board_mux *board_mux)
+static void omap_mux_init_signals(struct omap_mux_partition *partition,
+				  struct omap_board_mux *board_mux)
 {
 	omap_mux_set_cmdline_signals();
-	omap_mux_write_array(board_mux);
+	omap_mux_write_array(partition->base, board_mux);
 }
 
 #else
 
-static void omap_mux_init_package(struct omap_mux *superset,
+static void omap_mux_init_package(struct omap_mux_partition *partition,
+				  struct omap_mux *superset,
 				  struct omap_mux *package_subset,
 				  struct omap_ball *package_balls)
 {
 }
 
-static void omap_mux_init_signals(struct omap_board_mux *board_mux)
+static void omap_mux_init_signals(struct omap_mux_partition *partition,
+				  struct omap_board_mux *board_mux)
 {
 }
 
 #endif
 
-int __init omap_mux_init(u32 mux_pbase, u32 mux_size,
-				struct omap_mux *superset,
-				struct omap_mux *package_subset,
-				struct omap_board_mux *board_mux,
-				struct omap_ball *package_balls)
-{
-	if (mux_base)
-		return -EBUSY;
+static u32 mux_partitions_cnt;
 
-	mux_phys = mux_pbase;
-	mux_base = ioremap(mux_pbase, mux_size);
-	if (!mux_base) {
-		pr_err("mux: Could not ioremap\n");
+int __init omap_mux_init(const char * name, u32 flags,
+			 u32 mux_pbase, u32 mux_size,
+			 struct omap_mux *superset,
+			 struct omap_mux *package_subset,
+			 struct omap_board_mux *board_mux,
+			 struct omap_ball *package_balls)
+{
+	struct omap_mux_partition *partition;
+
+	partition = kzalloc(sizeof(struct omap_mux_partition), GFP_KERNEL);
+	if (!partition)
+		return -ENOMEM;
+
+	partition->name = name;
+	partition->flags = flags;
+	partition->size = mux_size;
+	partition->phys = mux_pbase;
+	partition->base = ioremap(mux_pbase, mux_size);
+	if (!partition->base) {
+		pr_err("mux: Could not ioremap mux partition at 0x%08x\n",
+			partition->phys);
 		return -ENODEV;
 	}
 
-	if (cpu_is_omap24xx())
-		omap_mux_flags = MUXABLE_GPIO_MODE3;
+	INIT_LIST_HEAD(&partition->muxmodes);
+
+	list_add_tail(&partition->node, &mux_partitions);
+	mux_partitions_cnt++;
+	pr_info("MUX: Add partition: #%d: %s, flags: %x\n",
+		mux_partitions_cnt, partition->name, partition->flags);
 
 	omap_mux_init_package(superset, package_subset, package_balls);
-	omap_mux_init_list(superset);
-	omap_mux_init_signals(board_mux);
+	omap_mux_init_list(partition, superset);
+	omap_mux_init_signals(partition, board_mux);
 
 	return 0;
 }
arch/arm/mach-omap2/mux.h +46 -33

128 lines not on this page · raw message

arch/arm/mach-omap2/mux2420.c +4 -3
index 414af54..8231f0a 100644
@@ -681,8 +681,9 @@ int __init omap2420_mux_init(struct omap_board_mux *board_subset, int flags)
 		pr_warning("mux: No ball data available for omap2420 package\n");
 	}
 
-	return omap_mux_init(OMAP2420_CONTROL_PADCONF_MUX_PBASE,
+	return omap_mux_init("core", OMAP_MUX_REG_8BIT | OMAP_MUX_GPIO_IN_MODE3,
+			     OMAP2420_CONTROL_PADCONF_MUX_PBASE,
 			     OMAP2420_CONTROL_PADCONF_MUX_SIZE,
-				omap2420_muxmodes, NULL, board_subset,
-				package_balls);
+			     omap2420_muxmodes, NULL, board_subset,
+			     package_balls);
 }
arch/arm/mach-omap2/mux2430.c +4 -3
index 84d2c5a..cb6b404 100644
@@ -784,8 +784,9 @@ int __init omap2430_mux_init(struct omap_board_mux *board_subset, int flags)
 		pr_warning("mux: No ball data available for omap2420 package\n");
 	}
 
-	return omap_mux_init(OMAP2430_CONTROL_PADCONF_MUX_PBASE,
+	return omap_mux_init("core", OMAP_MUX_REG_8BIT | OMAP_MUX_GPIO_IN_MODE3,
+			     OMAP2430_CONTROL_PADCONF_MUX_PBASE,
 			     OMAP2430_CONTROL_PADCONF_MUX_SIZE,
-				omap2430_muxmodes, NULL, board_subset,
-				package_balls);
+			     omap2430_muxmodes, NULL, board_subset,
+			     package_balls);
 }
arch/arm/mach-omap2/mux34xx.c +4 -3
index 574e54e..4113c93 100644
@@ -2053,8 +2053,9 @@ int __init omap3_mux_init(struct omap_board_mux *board_subset, int flags)
 		return -EINVAL;
 	}
 
-	return omap_mux_init(OMAP3_CONTROL_PADCONF_MUX_PBASE,
+	return omap_mux_init("core", 0,
+			     OMAP3_CONTROL_PADCONF_MUX_PBASE,
 			     OMAP3_CONTROL_PADCONF_MUX_SIZE,
-				omap3_muxmodes, package_subset, board_subset,
-				package_balls);
+			     omap3_muxmodes, package_subset, board_subset,
+			     package_balls);
 }
Signature · 1 line
1.7.0.4
maintainer
#4 lore raw

Re: [RFC v2 3/7] OMAP: mux: Add support for control module split in several partitions

Quoted 12 lines · Benoit Cousson
arch/arm/mach-omap2/mux.h +10 -0
+
+/**
+ * struct mux_partition - contain partition related information
+ * @name: name of the current partition
+ * @flags: flags specific to this partition
+ * @phys: physical address
+ * @size: partition size
+ * @base: virtual address after ioremap
+ * @muxmodes: list of nodes that belong to a partition
+ * @node: list node for the partitions linked list

arch/arm/mach-omap2/mux.h line 101

Quoted 10 lines
arch/arm/mach-omap2/mux.h +10 -0
+ */
+struct omap_mux_partition {
+	const char		*name;
+	u32			flags;
+	u32			phys;
+	u32			size;
+	void __iomem		*base;
+	struct list_head	muxmodes;
+	struct list_head	node;
+};

With the omap_mux_parition..

Quoted 25 lines

/**
* 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
+ * @id: Partition identifier
* @muxnames: available signal modes for a ball
*/
struct omap_mux {

arch/arm/mach-omap2/mux.h +2 -0
@@ -82,6 +114,7 @@ struct omap_mux {
 	char	*muxnames[OMAP_MUX_NR_MODES];
 #ifdef CONFIG_DEBUG_FS
 	char	*balls[OMAP_MUX_NR_SIDES];
+	struct omap_mux_partition *partition;
 #endif
 #endif
 };
@@ -89,6 +122,7 @@ struct omap_mux {
 /**
  * struct omap_ball - data for balls on omap package
  * @reg_offset:	mux register offset from the mux base
+ * @id:		Partition identifier
  * @balls:	available balls on the package
  */
 struct omap_ball {

arch/arm/mach-omap2/mux.h struct omap_ball { · line 140

Quoted 7 lines
arch/arm/mach-omap2/mux.h +1 -0
@@ -100,6 +134,7 @@ struct omap_ball {
  * struct omap_board_mux - data for initializing mux registers
  * @reg_offset:	mux register offset from the mux base
  * @mux_value:	desired mux value to set
+ * @id:		Partition identifier
  */
 struct omap_board_mux {
 	u16	reg_offset;

..I think the above changes are no longer needed.

Regards,

Tony

#5 lore raw

Re: [RFC v2 3/7] OMAP: mux: Add support for control module split in several partitions

Quoted 52 lines · Tony Lindgren
Quoted 12 lines · Benoit Cousson
arch/arm/mach-omap2/mux.h +10 -0
+
+/**
+ * struct mux_partition - contain partition related information
+ * @name: name of the current partition
+ * @flags: flags specific to this partition
+ * @phys: physical address
+ * @size: partition size
+ * @base: virtual address after ioremap
+ * @muxmodes: list of nodes that belong to a partition
+ * @node: list node for the partitions linked list

arch/arm/mach-omap2/mux.h line 101

Quoted 10 lines
arch/arm/mach-omap2/mux.h +10 -0
+ */
+struct omap_mux_partition {
+	const char		*name;
+	u32			flags;
+	u32			phys;
+	u32			size;
+	void __iomem		*base;
+	struct list_head	muxmodes;
+	struct list_head	node;
+};

With the omap_mux_parition..

Quoted 26 lines

/**
* 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
+ * @id: Partition identifier
* @muxnames: available signal modes for a ball
*/
struct omap_mux {

arch/arm/mach-omap2/mux.h +2 -0
@@ -82,6 +114,7 @@ struct omap_mux {
  	char	*muxnames[OMAP_MUX_NR_MODES];
  #ifdef CONFIG_DEBUG_FS
  	char	*balls[OMAP_MUX_NR_SIDES];
+	struct omap_mux_partition *partition;
  #endif
  #endif
  };
@@ -89,6 +122,7 @@ struct omap_mux {
  /**
   * struct omap_ball - data for balls on omap package
   * @reg_offset:	mux register offset from the mux base
+ * @id:		Partition identifier
   * @balls:	available balls on the package
   */
  struct omap_ball {
@@ -100,6 +134,7 @@ struct omap_ball {
   * struct omap_board_mux - data for initializing mux registers
Quoted 8 lines

arch/arm/mach-omap2/mux.h struct omap_ball { · line 140

Quoted 6 lines
arch/arm/mach-omap2/mux.h +1 -0
   * @reg_offset:	mux register offset from the mux base
   * @mux_value:	desired mux value to set
+ * @id:		Partition identifier
   */
  struct omap_board_mux {
  	u16	reg_offset;

..I think the above changes are no longer needed.

Oops yep, I forgot to remove the @id in the kerneldoc.
I was about to send the next revision, maybe I should wait a little bit more.

Thanks,
Benoit

maintainer
#6 lore raw

Re: [RFC v2 3/7] OMAP: mux: Add support for control module split in several partitions

Quoted 5 lines · Cousson, Benoit

On 11/11/2010 5:35 PM, Tony Lindgren wrote:

Oops yep, I forgot to remove the @id in the kerneldoc.
I was about to send the next revision, maybe I should wait a little bit more.

Well I think that's all I had to comment on these. Just please update the patch description in 3/7 too.

Regards,

Tony

#7 lore raw

RFC v2 4/7 OMAP4: mux: Add CBL package data for OMAP4430 ES1

In reply to Benoit Cousson

Add data for OMAP4430 generated from HW pinout & register database. The data set is split in two partitions for both core and wkup.

Cc Tony Lindgren <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 arch/arm/mach-omap2/Kconfig   |    3 +
 arch/arm/mach-omap2/Makefile  |    1 +
 arch/arm/mach-omap2/mux.h     |   12 +
 arch/arm/mach-omap2/mux44xx.c |  900 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/mux44xx.h |  277 +++++++++++++
 5 files changed, 1193 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/mux44xx.c
 create mode 100644 arch/arm/mach-omap2/mux44xx.h
arch/arm/mach-omap2/Kconfig +3 -0
index ab784bf..e14c73d 100644
@@ -85,6 +85,9 @@ config OMAP_PACKAGE_CUS
 config OMAP_PACKAGE_CBP
        bool
 
+config OMAP_PACKAGE_CBL
+       bool
+
 comment "OMAP Board Type"
 	depends on ARCH_OMAP2PLUS
 
arch/arm/mach-omap2/Makefile +1 -0
index 7352412..7bc28f1 100644
@@ -42,6 +42,7 @@ AFLAGS_sram34xx.o			:=-Wa,-march=armv7-a
 obj-$(CONFIG_ARCH_OMAP2420)		+= mux2420.o
 obj-$(CONFIG_ARCH_OMAP2430)		+= mux2430.o
 obj-$(CONFIG_ARCH_OMAP3)		+= mux34xx.o
+obj-$(CONFIG_ARCH_OMAP4)		+= mux44xx.o
 
 # SMS/SDRC
 obj-$(CONFIG_ARCH_OMAP2)		+= sdrc2xxx.o
arch/arm/mach-omap2/mux.h +12 -0
index dad32f6..28286a9 100644
@@ -10,6 +10,7 @@
 #include "mux2420.h"
 #include "mux2430.h"
 #include "mux34xx.h"
+#include "mux44xx.h"
 
 #define OMAP_MUX_TERMINATOR	0xffff
 
@@ -37,6 +38,9 @@
 #define OMAP_OFF_PULL_UP		(1 << 13)
 #define OMAP_WAKEUP_EN			(1 << 14)
 
+/* 44xx specific mux bit defines */
+#define OMAP_WAKEUP_EVENT		(1 << 15)
+
 /* Active pin states */
 #define OMAP_PIN_OUTPUT			0
 #define OMAP_PIN_INPUT			OMAP_INPUT_EN
@@ -58,6 +62,7 @@
 
 /* Flags for omapX_mux_init */
 #define OMAP_PACKAGE_MASK		0xffff
+#define OMAP_PACKAGE_CBL		7		/* 547-pin 0.40 0.40 */
 #define OMAP_PACKAGE_CBP		6		/* 515-pin 0.40 0.50 */
 #define OMAP_PACKAGE_CUS		5		/* 423-pin 0.65 */
 #define OMAP_PACKAGE_CBB		4		/* 515-pin 0.40 0.50 */
@@ -207,6 +212,13 @@ int omap2430_mux_init(struct omap_board_mux *board_mux, int flags);
 int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
 
 /**
+ * omap4_mux_init() - initialize mux system with board specific set
+ * @board_mux:		Board specific mux table
+ * @flags:		OMAP package type used for the board
+ */
+int omap4_mux_init(struct omap_board_mux *board_mux, int flags);
+
+/**
  * omap_mux_init - private mux init function, do not call
  */
 int omap_mux_init(const char *name, u32 flags,
arch/arm/mach-omap2/mux44xx.c new file +900 -0

900 lines not on this page · raw message

arch/arm/mach-omap2/mux44xx.h new file +277 -0

277 lines not on this page · raw message

Signature · 1 line
1.7.0.4
maintainer
#8 lore raw

Re: [RFC v2 4/7] OMAP4: mux: Add CBL package data for OMAP4430 ES1

Quoted 2 lines · Benoit Cousson

Add data for OMAP4430 generated from HW pinout & register database. The data set is split in two partitions for both core and wkup.

We should drop patch 3/7 and merge the following patch to your 4/7 patch.

Basically let's keep the omap_mux_read/write around for now, by adding omap_mux_get for dealing with the partition information.

Regards,

Tony

From: Tony Lindgren <[email protected]>
Date: Wed, 10 Nov 2010 09:55:47 -0800
Subject: [PATCH] omap: mux: Fix support for partitions for dynamic muxing

Revert some parts of Benoit's patch to not make
omap_mux_read/write static at this point.

We may need to do remuxing for system wide idle states, and also for driver specific idle states.

So we still need to have omap_mux_read/write around for the platform level driver code.

Also add omap_mux_get for getting the partition data so platform level device code can use it.

arch/arm/mach-omap2/board-rx51-peripherals.c +9 -3
index 3fec4d6..3fda20d 100644
@@ -293,6 +293,8 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = {
 	{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
 
+static struct omap_mux_partition *partition;
+
 /*
  * Current flows to eMMC when eMMC is off and the data lines are pulled up,
  * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
@@ -300,9 +302,9 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = {
 static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
 {
 	if (power_on)
-		omap_mux_write_array(rx51_mmc2_on_mux);
+		omap_mux_write_array(partition, rx51_mmc2_on_mux);
 	else
-		omap_mux_write_array(rx51_mmc2_off_mux);
+		omap_mux_write_array(partition, rx51_mmc2_off_mux);
 }
 
 static struct omap2_hsmmc_info mmc[] __initdata = {
@@ -922,7 +924,11 @@ void __init rx51_peripherals_init(void)
 	rx51_init_wl1251();
 	spi_register_board_info(rx51_peripherals_spi_board_info,
 				ARRAY_SIZE(rx51_peripherals_spi_board_info));
-	omap2_hsmmc_init(mmc);
+
+	partition = omap_mux_get("core");
+	if (partition)
+		omap2_hsmmc_init(mmc);
+
 	platform_device_register(&rx51_charger_device);
 }
 
arch/arm/mach-omap2/mux.c +15 -3
index 9b9128e..6d91bb8 100644
@@ -49,7 +49,19 @@ struct omap_mux_entry {
 static LIST_HEAD(mux_partitions);
 static DEFINE_MUTEX(muxmode_mutex);
 
-static u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg)
+struct omap_mux_partition * omap_mux_get(const char *name)
+{
+	struct omap_mux_partition *partition;
+
+	list_for_each_entry(partition, &mux_partitions, node) {
+		if (!strcmp(name, partition->name))
+			return partition;
+	}
+
+	return NULL;
+}
+
+u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg)
 {
 	if (partition->flags & OMAP_MUX_REG_8BIT)
 		return __raw_readb(partition->base + reg);
@@ -57,7 +69,7 @@ static u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg)
 		return __raw_readw(partition->base + reg);
 }
 
-static void omap_mux_write(struct omap_mux_partition *partition, u16 val,
+void omap_mux_write(struct omap_mux_partition *partition, u16 val,
 			   u16 reg)
 {
 	if (partition->flags & OMAP_MUX_REG_8BIT)
@@ -66,7 +78,7 @@ static void omap_mux_write(struct omap_mux_partition *partition, u16 val,
 		__raw_writew(val, partition->base + reg);
 }
 
-static void omap_mux_write_array(struct omap_mux_partition *partition,
+void omap_mux_write_array(struct omap_mux_partition *partition,
 				 struct omap_board_mux *board_mux)
 {
 	while (board_mux->reg_offset != OMAP_MUX_TERMINATOR) {
arch/arm/mach-omap2/mux.h +34 -0
index dad32f6..6656043 100644
@@ -186,6 +186,40 @@ u16 omap_mux_get_gpio(int gpio);
 void omap_mux_set_gpio(u16 val, int gpio);
 
 /**
+ * omap_mux_get() - get a mux partition by name
+ * @name:		Name of the mux partition
+ *
+ */
+struct omap_mux_partition * omap_mux_get(const char *name);
+
+/**
+ * omap_mux_read() - read mux register
+ * @partition:		Mux partition
+ * @mux_offset:		Offset of the mux register
+ *
+ */
+u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset);
+
+/**
+ * omap_mux_write() - write mux register
+ * @partition:		Mux partition
+ * @val:		New mux register value
+ * @mux_offset:		Offset of the mux register
+ *
+ * This should be only needed for dynamic remuxing of non-gpio signals.
+ */
+void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset);
+
+/**
+ * omap_mux_write_array() - write an array of mux registers
+ * @partition:		Mux partition
+ * @board_mux:		Array of mux registers terminated by MAP_MUX_TERMINATOR
+ *
+ * This should be only needed for dynamic remuxing of non-gpio signals.
+ */
+void omap_mux_write_array(struct omap_mux_partition *p, struct omap_board_mux *board_mux);
+
+/**
  * omap2420_mux_init() - initialize mux system with board specific set
  * @board_mux:		Board specific mux table
  * @flags:		OMAP package type used for the board
#9 lore raw

Re: [RFC v2 4/7] OMAP4: mux: Add CBL package data for OMAP4430 ES1

Hi Tony,

Quoted 6 lines · Tony Lindgren
Quoted 2 lines · Benoit Cousson

Add data for OMAP4430 generated from HW pinout& register database. The data set is split in two partitions for both core and wkup.

We should drop patch 3/7 and merge the following patch to your 4/7 patch.

OK

Quoted 4 lines

Basically let's keep the omap_mux_read/write around for now, by adding omap_mux_get for dealing with the partition information.

Thanks for that.

I'll send the update today.

Regards,
Benoit

Quoted 150 lines

Regards,

Tony

From: Tony Lindgren<[email protected]>
Date: Wed, 10 Nov 2010 09:55:47 -0800
Subject: [PATCH] omap: mux: Fix support for partitions for dynamic muxing

Revert some parts of Benoit's patch to not make
omap_mux_read/write static at this point.

We may need to do remuxing for system wide idle states, and also for driver specific idle states.

So we still need to have omap_mux_read/write around for the platform level driver code.

Also add omap_mux_get for getting the partition data so platform level device code can use it.

arch/arm/mach-omap2/board-rx51-peripherals.c +9 -3
index 3fec4d6..3fda20d 100644
@@ -293,6 +293,8 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = {
  	{ .reg_offset = OMAP_MUX_TERMINATOR },
  };
 
+static struct omap_mux_partition *partition;
+
  /*
   * Current flows to eMMC when eMMC is off and the data lines are pulled up,
   * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
@@ -300,9 +302,9 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = {
  static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
  {
  	if (power_on)
-		omap_mux_write_array(rx51_mmc2_on_mux);
+		omap_mux_write_array(partition, rx51_mmc2_on_mux);
  	else
-		omap_mux_write_array(rx51_mmc2_off_mux);
+		omap_mux_write_array(partition, rx51_mmc2_off_mux);
  }
 
  static struct omap2_hsmmc_info mmc[] __initdata = {
@@ -922,7 +924,11 @@ void __init rx51_peripherals_init(void)
  	rx51_init_wl1251();
  	spi_register_board_info(rx51_peripherals_spi_board_info,
  				ARRAY_SIZE(rx51_peripherals_spi_board_info));
-	omap2_hsmmc_init(mmc);
+
+	partition = omap_mux_get("core");
+	if (partition)
+		omap2_hsmmc_init(mmc);
+
  	platform_device_register(&rx51_charger_device);
  }
 
arch/arm/mach-omap2/mux.c +15 -3
index 9b9128e..6d91bb8 100644
@@ -49,7 +49,19 @@ struct omap_mux_entry {
  static LIST_HEAD(mux_partitions);
  static DEFINE_MUTEX(muxmode_mutex);
 
-static u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg)
+struct omap_mux_partition * omap_mux_get(const char *name)
+{
+	struct omap_mux_partition *partition;
+
+	list_for_each_entry(partition,&mux_partitions, node) {
+		if (!strcmp(name, partition->name))
+			return partition;
+	}
+
+	return NULL;
+}
+
+u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg)
  {
  	if (partition->flags&  OMAP_MUX_REG_8BIT)
  		return __raw_readb(partition->base + reg);
@@ -57,7 +69,7 @@ static u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg)
  		return __raw_readw(partition->base + reg);
  }
 
-static void omap_mux_write(struct omap_mux_partition *partition, u16 val,
+void omap_mux_write(struct omap_mux_partition *partition, u16 val,
  			   u16 reg)
  {
  	if (partition->flags&  OMAP_MUX_REG_8BIT)
@@ -66,7 +78,7 @@ static void omap_mux_write(struct omap_mux_partition *partition, u16 val,
  		__raw_writew(val, partition->base + reg);
  }
 
-static void omap_mux_write_array(struct omap_mux_partition *partition,
+void omap_mux_write_array(struct omap_mux_partition *partition,
  				 struct omap_board_mux *board_mux)
  {
  	while (board_mux->reg_offset != OMAP_MUX_TERMINATOR) {
arch/arm/mach-omap2/mux.h +34 -0
index dad32f6..6656043 100644
@@ -186,6 +186,40 @@ u16 omap_mux_get_gpio(int gpio);
  void omap_mux_set_gpio(u16 val, int gpio);
 
  /**
+ * omap_mux_get() - get a mux partition by name
+ * @name:		Name of the mux partition
+ *
+ */
+struct omap_mux_partition * omap_mux_get(const char *name);
+
+/**
+ * omap_mux_read() - read mux register
+ * @partition:		Mux partition
+ * @mux_offset:		Offset of the mux register
+ *
+ */
+u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset);
+
+/**
+ * omap_mux_write() - write mux register
+ * @partition:		Mux partition
+ * @val:		New mux register value
+ * @mux_offset:		Offset of the mux register
+ *
+ * This should be only needed for dynamic remuxing of non-gpio signals.
+ */
+void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset);
+
+/**
+ * omap_mux_write_array() - write an array of mux registers
+ * @partition:		Mux partition
+ * @board_mux:		Array of mux registers terminated by MAP_MUX_TERMINATOR
+ *
+ * This should be only needed for dynamic remuxing of non-gpio signals.
+ */
+void omap_mux_write_array(struct omap_mux_partition *p, struct omap_board_mux *board_mux);
+
+/**
   * omap2420_mux_init() - initialize mux system with board specific set
   * @board_mux:		Board specific mux table
   * @flags:		OMAP package type used for the board
maintainer
#10 lore raw

Re: [RFC v2 4/7] OMAP4: mux: Add CBL package data for OMAP4430 ES1

Quoted 11 lines · Cousson, Benoit

Hi Tony,

Quoted 6 lines · Tony Lindgren
Quoted 2 lines · Benoit Cousson

Add data for OMAP4430 generated from HW pinout& register database. The data set is split in two partitions for both core and wkup.

We should drop patch 3/7 and merge the following patch to your 4/7 patch.

OK

Oops, sorry got the patch numbers wrong, the patch numbers should be 2/7 and 3/7. Well you probably figured that out already :)

Tony

#11 lore raw

Re: [RFC v2 4/7] OMAP4: mux: Add CBL package data for OMAP4430 ES1

Quoted 8 lines · Tony Lindgren
Quoted 7 lines · Cousson, Benoit

Hi Tony,

Quoted 4 lines · Tony Lindgren
Quoted 2 lines · Benoit Cousson

Add data for OMAP4430 generated from HW pinout& register database.
The data set is split in two partitions for both core and wkup.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

We should drop patch 3/7 and merge the following patch to your 4/7 patch.

OK

Oops, sorry got the patch numbers wrong, the patch numbers should be 2/7 and 3/7. Well you probably figured that out already :)

Well, yes, it took me some time, but I figured it out :-)

Benoit

#12 lore raw

RFC v2 5/7 OMAP4: mux: Select CBL package for SDP4430 with ES1

In reply to Benoit Cousson
Cc Tony Lindgren <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 arch/arm/mach-omap2/Kconfig         |    1 +
 arch/arm/mach-omap2/board-4430sdp.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/Kconfig +1 -0
index e14c73d..7efb256 100644
@@ -280,6 +280,7 @@ config MACH_OMAP_4430SDP
 	bool "OMAP 4430 SDP board"
 	default y
 	depends on ARCH_OMAP4
+	select OMAP_PACKAGE_CBL
 
 config MACH_OMAP4_PANDA
 	bool "OMAP4 Panda Board"
arch/arm/mach-omap2/board-4430sdp.c +10 -0
index aafd306..83ee5b4 100644
@@ -35,6 +35,7 @@
 #include <plat/usb.h>
 #include <plat/mmc.h>
 
+#include "mux.h"
 #include "hsmmc.h"
 #include "timer-gp.h"
 #include "control.h"
@@ -500,10 +501,19 @@ static void __init omap_sfh7741prox_init(void)
 	}
 }
 
+#ifdef CONFIG_OMAP_MUX
+static struct omap_board_mux board_mux[] __initdata = {
+	{ .reg_offset = OMAP_MUX_TERMINATOR },
+};
+#else
+#define board_mux	NULL
+#endif
+
 static void __init omap_4430sdp_init(void)
 {
 	int status;
 
+	omap4_mux_init(board_mux, OMAP_PACKAGE_CBL);
 	omap4_i2c_init();
 	omap_sfh7741prox_init();
 	platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
Signature · 1 line
1.7.0.4
#13 lore raw

RFC v2 6/7 OMAP4: mux: Add CBS package data for OMAP4430 ES2

In reply to Benoit Cousson

Please note that the full muxmodes are re-defined for ES2 instead of using the subset. There are 81 differences among 204 pins. The subset fixup will have to iterate over the whole list for each subset entry, which can lead to an important number of iteration. On the other hand, it will take much more memory at boot time.

Cc Tony Lindgren <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Anand Gadiyar <[email protected]>
---
 arch/arm/mach-omap2/Kconfig   |    3 +
 arch/arm/mach-omap2/mux.h     |    1 +
 arch/arm/mach-omap2/mux44xx.c |  741 ++++++++++++++++++++++++++++++++++++++++-
 arch/arm/mach-omap2/mux44xx.h |   21 ++
 4 files changed, 758 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/Kconfig +3 -0
index 7efb256..92fea63 100644
@@ -88,6 +88,9 @@ config OMAP_PACKAGE_CBP
 config OMAP_PACKAGE_CBL
        bool
 
+config OMAP_PACKAGE_CBS
+       bool
+
 comment "OMAP Board Type"
 	depends on ARCH_OMAP2PLUS
 
arch/arm/mach-omap2/mux.h +1 -0
index 28286a9..b34a2ad 100644
@@ -62,6 +62,7 @@
 
 /* Flags for omapX_mux_init */
 #define OMAP_PACKAGE_MASK		0xffff
+#define OMAP_PACKAGE_CBS		8		/* 547-pin 0.40 0.40 */
 #define OMAP_PACKAGE_CBL		7		/* 547-pin 0.40 0.40 */
 #define OMAP_PACKAGE_CBP		6		/* 515-pin 0.40 0.50 */
 #define OMAP_PACKAGE_CUS		5		/* 423-pin 0.65 */
arch/arm/mach-omap2/mux44xx.c +733 -8

785 lines not on this page · raw message

arch/arm/mach-omap2/mux44xx.h +21 -0
index ea8b235..c635026 100644
@@ -233,6 +233,27 @@
 #define OMAP4_CTRL_MODULE_PAD_DPM_EMU18_OFFSET			0x01d2
 #define OMAP4_CTRL_MODULE_PAD_DPM_EMU19_OFFSET			0x01d4
 
+/* ES2.0 only */
+#define OMAP4_CTRL_MODULE_PAD_GPMC_WAIT2_OFFSET			0x008e
+#define OMAP4_CTRL_MODULE_PAD_GPMC_NCS4_OFFSET			0x0090
+#define OMAP4_CTRL_MODULE_PAD_GPMC_NCS5_OFFSET			0x0092
+#define OMAP4_CTRL_MODULE_PAD_GPMC_NCS6_OFFSET			0x0094
+#define OMAP4_CTRL_MODULE_PAD_GPMC_NCS7_OFFSET			0x0096
+
+#define OMAP4_CTRL_MODULE_PAD_KPD_COL3_OFFSET			0x017c
+#define OMAP4_CTRL_MODULE_PAD_KPD_COL4_OFFSET			0x017e
+#define OMAP4_CTRL_MODULE_PAD_KPD_COL5_OFFSET			0x0180
+#define OMAP4_CTRL_MODULE_PAD_KPD_COL0_OFFSET			0x0182
+#define OMAP4_CTRL_MODULE_PAD_KPD_COL1_OFFSET			0x0184
+#define OMAP4_CTRL_MODULE_PAD_KPD_COL2_OFFSET			0x0186
+#define OMAP4_CTRL_MODULE_PAD_KPD_ROW3_OFFSET			0x0188
+#define OMAP4_CTRL_MODULE_PAD_KPD_ROW4_OFFSET			0x018a
+#define OMAP4_CTRL_MODULE_PAD_KPD_ROW5_OFFSET			0x018c
+#define OMAP4_CTRL_MODULE_PAD_KPD_ROW0_OFFSET			0x018e
+#define OMAP4_CTRL_MODULE_PAD_KPD_ROW1_OFFSET			0x0190
+#define OMAP4_CTRL_MODULE_PAD_KPD_ROW2_OFFSET			0x0192
+
+
 #define OMAP4_CTRL_MODULE_PAD_CORE_MUX_SIZE			\
 		(OMAP4_CTRL_MODULE_PAD_DPM_EMU19_OFFSET		\
 		 - OMAP4_CTRL_MODULE_PAD_GPMC_AD0_OFFSET + 2)
Signature · 1 line
1.7.0.4
#14 lore raw

RFC v2 7/7 OMAP4: mux: Select CBS package for SDP4430 with ES2

In reply to Benoit Cousson
Cc Tony Lindgren <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Anand Gadiyar <[email protected]>
---
 arch/arm/mach-omap2/Kconfig         |    1 +
 arch/arm/mach-omap2/board-4430sdp.c |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/Kconfig +1 -0
index 92fea63..39229cf 100644
@@ -284,6 +284,7 @@ config MACH_OMAP_4430SDP
 	default y
 	depends on ARCH_OMAP4
 	select OMAP_PACKAGE_CBL
+	select OMAP_PACKAGE_CBS
 
 config MACH_OMAP4_PANDA
 	bool "OMAP4 Panda Board"
arch/arm/mach-omap2/board-4430sdp.c +5 -1
index 83ee5b4..323b62e 100644
@@ -512,8 +512,12 @@ static struct omap_board_mux board_mux[] __initdata = {
 static void __init omap_4430sdp_init(void)
 {
 	int status;
+	int package = OMAP_PACKAGE_CBS;
+
+	if (omap_rev() == OMAP4430_REV_ES1_0)
+		package = OMAP_PACKAGE_CBL;
+	omap4_mux_init(board_mux, package);
 
-	omap4_mux_init(board_mux, OMAP_PACKAGE_CBL);
 	omap4_i2c_init();
 	omap_sfh7741prox_init();
 	platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
Signature · 1 line
1.7.0.4
maintainer
#15 lore raw
In reply to Benoit Cousson
Quoted 8 lines · Benoit Cousson

Hi Tony,

Upon Nishanth request, here is the updated version...

It takes into account your proposal to store partition information in a partition structure instead of inside every pad entries. The mechanism relies on the uniqueness of the pad name in each partition to find the correct partition during iteration.

OK, using the offset defines won't be unique necessarily..

Quoted 2 lines

Removed as well some cpu_is_xxx calls from the core code by adding a couple of flags during partition init.

That's great.

Quoted 7 lines

Please note that due to low level access to mux api from the RX51 board code, I have to disable the mux change to build properly with omap2plus_defconfig. Look like you do have some idea to fix that :-)
I was thinking of:
- brute force approach that consist of keeping all the data after init, and thus allowing removing the __init in the omap_mux_init_signal API
- or adding some flag in the pad entry to keep them after init .

Well I was thinking we just register a board specific dynamic mux table and then call that when hitting retention or off and restore after that. Still need to think about that a bit more, I don't know if we want the automatic muxing of gpio pins still in addition to that.

Quoted 2 lines

Boot tested on SDP4430 with ES1.0 & ES2.0 with omap2plus_defconfig. Still require some real driver to use that mux API in order to validate it.

You can test by echoing wrong values after booting via /sys to mess up the MMC data lines and then type sync :)

Quoted 2 lines

The series is on top of lo/master (2.6.36-rc8) and is available here:
git://gitorious.org/omap-pm/linux.git ctrl-wip/mux-omap4-v2

For pulling anything in, the git branches need to be based on something that's immutable. So preferrably v2.6.35 or some recent -rc tag in this case. Or rebase it on v2.6.36 after that's been released.

Regards,

Tony

#16 lore raw

Hi Tony,

Quoted 11 lines · Tony Lindgren
Quoted 8 lines · Benoit Cousson

Hi Tony,

Upon Nishanth request, here is the updated version...

It takes into account your proposal to store partition information in a partition structure instead of inside every pad entries. The mechanism relies on the uniqueness of the pad name in each partition to find the correct partition during iteration.

OK, using the offset defines won't be unique necessarily..

They should. The defines are all based on pad names that are all unique. Assuming HW folks didn't messed up the spec...

Quoted 14 lines
Quoted 3 lines

Removed as well some cpu_is_xxx calls from the core code by adding a couple of flags during partition init.

That's great.

Quoted 7 lines

Please note that due to low level access to mux api from the RX51 board code, I have to disable the mux change to build properly with omap2plus_defconfig. Look like you do have some idea to fix that :-)
I was thinking of:
- brute force approach that consist of keeping all the data after init, and thus allowing removing the __init in the omap_mux_init_signal API
- or adding some flag in the pad entry to keep them after init .

Quoted 4 lines

Well I was thinking we just register a board specific dynamic mux table and then call that when hitting retention or off and restore after that. Still need to think about that a bit more, I don't know if we want the automatic muxing of gpio pins still in addition to that.

OK, you were thinking of the MMC remux case only.
That might be enough for the moment, because the other needs I heard about does not seems to be in mainline anyway (USB or modem link).

Quoted 5 lines
Quoted 2 lines

Boot tested on SDP4430 with ES1.0& ES2.0 with omap2plus_defconfig. Still require some real driver to use that mux API in order to validate it.

You can test by echoing wrong values after booting via /sys to mess up the MMC data lines and then type sync :)

I played with debugfs a little bit but was trying to avoid messing up with pins already used... in fact I should do the opposite. That's a nice technique...

Quoted 6 lines
Quoted 2 lines

The series is on top of lo/master (2.6.36-rc8) and is available here:
git://gitorious.org/omap-pm/linux.git ctrl-wip/mux-omap4-v2

For pulling anything in, the git branches need to be based on something that's immutable. So preferrably v2.6.35 or some recent -rc tag in this case. Or rebase it on v2.6.36 after that's been released.

In that case only the ES1 can be there. ES2 support will be in 2.6.37 only.

That's why I have a dependency with lo/master. Do you want to split the series in two parts?

Thanks,
Benoit

maintainer
#17 lore raw
Quoted 9 lines · Cousson, Benoit
Quoted 7 lines · Tony Lindgren
Quoted 5 lines · Benoit Cousson

It takes into account your proposal to store partition information in a partition structure instead of inside every pad entries. The mechanism relies on the uniqueness of the pad name in each partition to find the correct partition during iteration.

Quoted 4 lines
Quoted 1 line

OK, using the offset defines won't be unique necessarily..

They should. The defines are all based on pad names that are all unique. Assuming HW folks didn't messed up the spec...

Just for the record to avoid confusion.. What I meant is the offset values from the partition base are not unique even if the define names are unique:

/* ctrl_module_pad_core registers offset */

#define OMAP4_CTRL_MODULE_PAD_GPMC_AD0_OFFSET                   0x0040
#define OMAP4_CTRL_MODULE_PAD_GPMC_AD1_OFFSET                   0x0042
#define OMAP4_CTRL_MODULE_PAD_GPMC_AD2_OFFSET                   0x0044

...

/* ctrl_module_pad_wkup registers offset */

#define OMAP4_CTRL_MODULE_PAD_SIM_IO_OFFSET                     0x0040
#define OMAP4_CTRL_MODULE_PAD_SIM_CLK_OFFSET                    0x0042
#define OMAP4_CTRL_MODULE_PAD_SIM_RESET_OFFSET                  0x0044

...

So now we have to use either a unique pad name, or a combination of partition + offset.

Regards,

Tony

#18 lore raw
Quoted 25 lines · Tony Lindgren
Quoted 9 lines · Cousson, Benoit
Quoted 7 lines · Tony Lindgren
Quoted 5 lines · Benoit Cousson

It takes into account your proposal to store partition information in a partition structure instead of inside every pad entries. The mechanism relies on the uniqueness of the pad name in each partition to find the correct partition during iteration.

Quoted 4 lines
Quoted 1 line

OK, using the offset defines won't be unique necessarily..

They should. The defines are all based on pad names that are all unique. Assuming HW folks didn't messed up the spec...

Just for the record to avoid confusion.. What I meant is the offset values from the partition base are not unique even if the define names are unique:

/* ctrl_module_pad_core registers offset */

#define OMAP4_CTRL_MODULE_PAD_GPMC_AD0_OFFSET                   0x0040
#define OMAP4_CTRL_MODULE_PAD_GPMC_AD1_OFFSET                   0x0042
#define OMAP4_CTRL_MODULE_PAD_GPMC_AD2_OFFSET                   0x0044

...

Quoted 8 lines

/* ctrl_module_pad_wkup registers offset */

#define OMAP4_CTRL_MODULE_PAD_SIM_IO_OFFSET                     0x0040
#define OMAP4_CTRL_MODULE_PAD_SIM_CLK_OFFSET                    0x0042
#define OMAP4_CTRL_MODULE_PAD_SIM_RESET_OFFSET                  0x0044

...

So now we have to use either a unique pad name, or a combination of partition + offset.

Yes. Hence the need for the omap_mux_get you've just done in order to access the low level API.

Benoit