All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads.
@ 2011-01-28  5:08 sricharan
  2011-01-28  5:08 ` [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic sricharan
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: sricharan @ 2011-01-28  5:08 UTC (permalink / raw)
  To: r.sricharan, linux-omap; +Cc: santosh.shilimkar, tony, paul


1) The support to add the pad data to the device hwmod entry and to use
   it to dynamically configure the pads based on the state of the
   hwmod is already present.

2) But using that for pads that requires only initialisation and not
   dynamic remux, brings in a overhead to iterate over all the
   hwmod signals of the device for every device enable/idle transitions.

3) By seperating the pads that requires remux as dynamic and the
   ones that do not as static the above overhead is avoided.

4) This way the static and dynamic pads are initialised, 
   and only dynamic pads are taken for remuxing.

sricharan (5):
  omap2+: mux: Seperate the pads of a hwmod as static and dynamic.
  omap4: board-4430sdp: Initialise the serial pads
  omap3: board-3430sdp: Initialise the serial pads.
  omap4: board-omap4panda: Initialise the serial pads
  omap2+: board-n8x0: Change the flags for the serial pads.

 arch/arm/mach-omap2/board-3430sdp.c          |   86 ++++++++++-
 arch/arm/mach-omap2/board-4430sdp.c          |   73 +++++++++-
 arch/arm/mach-omap2/board-n8x0.c             |    2 +-
 arch/arm/mach-omap2/board-omap4panda.c       |   72 +++++++++-
 arch/arm/mach-omap2/mux.c                    |  219 +++++++++++++++++++++-----
 arch/arm/mach-omap2/mux.h                    |   33 ++++-
 arch/arm/mach-omap2/omap_hwmod.c             |    6 +-
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    7 +-
 8 files changed, 441 insertions(+), 57 deletions(-)


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic.
  2011-01-28  5:08 [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads sricharan
@ 2011-01-28  5:08 ` sricharan
  2011-01-28 20:49   ` Anand Gadiyar
  2011-02-23 18:49   ` Tony Lindgren
  2011-01-28  5:08 ` [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads sricharan
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 19+ messages in thread
From: sricharan @ 2011-01-28  5:08 UTC (permalink / raw)
  To: r.sricharan, linux-omap; +Cc: santosh.shilimkar, tony, paul

1) All the pads of a hwmod for the device are classified
   as static/dynamic. If a pad requires remuxing during
   the device transitions between enable/idle transitions
   then it is added to the dynamic list, static otherwise.

2) Both the static/dynamic pads of a hwmod are initialised
   when the device gets enabled. When the device transitions
   between enable/idle the dynamic pads are remuxed and
   static pads are skipped.

3) When the driver gets removed both the static and the
   dynamic pads are muxed to safe mode as default.

Signed-off-by: sricharan <r.sricharan@ti.com>
---
 arch/arm/mach-omap2/mux.c                    |  219 +++++++++++++++++++++-----
 arch/arm/mach-omap2/mux.h                    |   33 ++++-
 arch/arm/mach-omap2/omap_hwmod.c             |    6 +-
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    7 +-
 4 files changed, 212 insertions(+), 53 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 17bd639..50ac117 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -258,7 +258,7 @@ struct omap_hwmod_mux_info * __init
 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
 {
 	struct omap_hwmod_mux_info *hmux;
-	int i;
+	int i, pads_static = 0, pads_dynamic = 0;
 
 	if (!bpads || nr_pads < 1)
 		return NULL;
@@ -267,18 +267,48 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
 	if (!hmux)
 		goto err1;
 
-	hmux->nr_pads = nr_pads;
+	hmux->nr_pads_static = 0;
+	hmux->nr_pads_dynamic = 0;
+	hmux->static_pads_initialised = 0;
+
+	for (i = 0; i < nr_pads; i++) {
+		struct omap_device_pad *bpad = &bpads[i];
+
+		/*
+		 * only pads for which a remux is required during the
+		 * device state transitions between idle/enable are
+		 * added to dynamic list
+		 */
+
+		if ((bpad->flags) & (OMAP_DEVICE_PAD_REMUX_IDLE))
+			hmux->nr_pads_dynamic++;
+		else
+			hmux->nr_pads_static++;
 
-	hmux->pads = kzalloc(sizeof(struct omap_device_pad) *
-				nr_pads, GFP_KERNEL);
-	if (!hmux->pads)
+	}
+
+	hmux->pads_static = kzalloc(sizeof(struct omap_device_pad) *
+				hmux->nr_pads_static, GFP_KERNEL);
+	hmux->pads_dynamic = kzalloc(sizeof(struct omap_device_pad) *
+				hmux->nr_pads_dynamic, GFP_KERNEL);
+
+	if ((!hmux->pads_static) || (!hmux->pads_dynamic))
 		goto err2;
 
-	for (i = 0; i < hmux->nr_pads; i++) {
+	for (i = 0; i < nr_pads; i++) {
 		struct omap_mux_partition *partition;
-		struct omap_device_pad *bpad = &bpads[i], *pad = &hmux->pads[i];
+		struct omap_device_pad *bpad = &bpads[i], *pad;
 		struct omap_mux *mux;
 		int mux_mode;
+		int pad_dynamic = 0;
+
+		if ((bpad->flags) & (OMAP_DEVICE_PAD_REMUX_IDLE)) {
+			pad = &hmux->pads_dynamic[pads_dynamic++];
+			pad_dynamic = 1;
+		} else {
+			pad = &hmux->pads_static[pads_static++];
+			pad_dynamic = 0;
+		}
 
 		mux_mode = omap_mux_get_by_name(bpad->name, &partition, &mux);
 		if (mux_mode < 0)
@@ -290,10 +320,28 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
 
 		pad->name = kzalloc(strlen(bpad->name) + 1, GFP_KERNEL);
 		if (!pad->name) {
-			int j;
+			int j, k;
+
+			/*
+			 * pads_dynamic or pads_static has the count of the
+			 * next pad in the list. So current pad is 1 less
+			 * than the index. Since current pad is unallocated
+			 * start deleting from 2 less than the index
+			 */
+
+			if (pad_dynamic) {
+				j = pads_dynamic - 2;
+				k = pads_static - 1;
+			} else {
+				j = pads_static - 2;
+				k = pads_dynamic - 1;
+			}
+
+			for (; j >= 0; j--)
+				kfree(hmux->pads_dynamic[j].name);
+			for (; k >= 0; k--)
+				kfree(hmux->pads_static[k].name);
 
-			for (j = i - 1; j >= 0; j--)
-				kfree(hmux->pads[j].name);
 			goto err3;
 		}
 		strcpy(pad->name, bpad->name);
@@ -308,7 +356,8 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
 	return hmux;
 
 err3:
-	kfree(hmux->pads);
+	kfree(hmux->pads_static);
+	kfree(hmux->pads_dynamic);
 err2:
 	kfree(hmux);
 err1:
@@ -318,53 +367,137 @@ err1:
 }
 
 /* Assumes the calling function takes care of locking */
-void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
+void omap_hwmod_mux_enable(struct omap_hwmod_mux_info *hmux, u8 state)
 {
 	int i;
 
-	for (i = 0; i < hmux->nr_pads; i++) {
-		struct omap_device_pad *pad = &hmux->pads[i];
-		int flags, val = -EINVAL;
+	if (!hmux->static_pads_initialised) {
+		hmux->static_pads_initialised = 1;
 
-		flags = pad->flags;
+		for (i = 0; i < hmux->nr_pads_static; i++) {
+			struct omap_device_pad *pad = &hmux->pads_static[i];
+			int val = -EINVAL;
 
-		switch (state) {
-		case _HWMOD_STATE_ENABLED:
-			if (flags & OMAP_DEVICE_PAD_ENABLED)
-				break;
-			flags |= OMAP_DEVICE_PAD_ENABLED;
 			val = pad->enable;
 			pr_debug("%s: Enabling %s %x\n", __func__,
-					pad->name, val);
-			break;
-		case _HWMOD_STATE_IDLE:
-			if (!(flags & OMAP_DEVICE_PAD_REMUX))
-				break;
-			flags &= ~OMAP_DEVICE_PAD_ENABLED;
-			val = pad->idle;
-			pr_debug("%s: Idling %s %x\n", __func__,
-					pad->name, val);
-			break;
-		case _HWMOD_STATE_DISABLED:
-		default:
-			/* Use safe mode unless OMAP_DEVICE_PAD_REMUX */
-			if (flags & OMAP_DEVICE_PAD_REMUX)
-				val = pad->off;
-			else
-				val = OMAP_MUX_MODE7;
-			flags &= ~OMAP_DEVICE_PAD_ENABLED;
-			pr_debug("%s: Disabling %s %x\n", __func__,
-					pad->name, val);
-		};
+				pad->name, val);
+
+			if (val >= 0) {
+				omap_mux_write(pad->partition, val,
+					pad->mux->reg_offset);
+			}
+		}
+	}
+
+	for (i = 0; i < hmux->nr_pads_dynamic; i++) {
+		struct omap_device_pad *pad = &hmux->pads_dynamic[i];
+		int flags, val = -EINVAL;
+
+		flags = pad->flags;
+
+		if (flags & OMAP_DEVICE_PAD_ENABLED)
+			continue;
+
+		flags |= OMAP_DEVICE_PAD_ENABLED;
+		val = pad->enable;
+		pr_debug("%s: Enabling %s %x\n", __func__,
+			pad->name, val);
 
 		if (val >= 0) {
 			omap_mux_write(pad->partition, val,
-					pad->mux->reg_offset);
+				pad->mux->reg_offset);
 			pad->flags = flags;
 		}
 	}
 }
 
+/* Assumes the calling function takes care of locking */
+void omap_hwmod_mux_disable(struct omap_hwmod_mux_info *hmux, u8 state)
+{
+	int i;
+
+	/*
+	 * All the static pads are uninitialised because of driver
+	 * being removed. They have to be initialised again by Enable
+	 */
+	hmux->static_pads_initialised = 0;
+
+	for (i = 0; i < hmux->nr_pads_static; i++) {
+		struct omap_device_pad *pad = &hmux->pads_static[i];
+		int flags, val = -EINVAL;
+
+		flags = pad->flags;
+
+		/* Use safe mode unless OMAP_DEVICE_PAD_REMUX */
+		if (flags & OMAP_DEVICE_PAD_REMUX_DISABLE)
+			val = pad->off;
+		else
+			val = OMAP_MUX_MODE7;
+
+		pr_debug("%s: Disabling static %s %x\n", __func__,
+						pad->name, val);
+		if (val >= 0) {
+			omap_mux_write(pad->partition, val,
+				pad->mux->reg_offset);
+		}
+	}
+
+	/*
+	 * All the dynamic pads should also be remuxed. So this
+	 * functions remuxes all the pads of a hwmod
+	 */
+
+	for (i = 0; i < hmux->nr_pads_dynamic; i++) {
+		struct omap_device_pad *pad = &hmux->pads_dynamic[i];
+		int flags, val = -EINVAL;
+
+		flags = pad->flags;
+
+		/* Use safe mode unless OMAP_DEVICE_PAD_REMUX_DISABLE */
+		if (flags & OMAP_DEVICE_PAD_REMUX_DISABLE)
+			val = pad->off;
+		else
+			val = OMAP_MUX_MODE7;
+
+		flags &= ~OMAP_DEVICE_PAD_ENABLED;
+
+		pr_debug("%s: Disabling dynamic %s %x\n", __func__,
+						pad->name, val);
+		if (val >= 0) {
+			omap_mux_write(pad->partition, val,
+				pad->mux->reg_offset);
+			pad->flags = flags;
+		}
+	}
+}
+
+/* Assumes the calling function takes care of locking */
+void omap_hwmod_mux_idle(struct omap_hwmod_mux_info *hmux, u8 state)
+{
+	int i;
+
+	for (i = 0; i < hmux->nr_pads_dynamic; i++) {
+		struct omap_device_pad *pad = &hmux->pads_dynamic[i];
+		int flags, val = -EINVAL;
+
+		flags = pad->flags;
+
+		/* Use the pad idle mode remux value */
+		val = pad->idle;
+
+		flags &= ~OMAP_DEVICE_PAD_ENABLED;
+
+		pr_debug("%s: Disabling %s %x\n", __func__,
+						pad->name, val);
+		if (val >= 0) {
+			omap_mux_write(pad->partition, val,
+				pad->mux->reg_offset);
+			pad->flags = flags;
+		}
+	}
+}
+
+
 #ifdef CONFIG_DEBUG_FS
 
 #define OMAP_MUX_MAX_NR_FLAGS	10
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index a4ab17a..909d9b5 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -160,9 +160,13 @@ struct omap_board_mux {
 };
 
 #define OMAP_DEVICE_PAD_ENABLED		BIT(7)	/* Not needed for board-*.c */
-#define OMAP_DEVICE_PAD_REMUX		BIT(1)	/* Dynamically remux a pad,
-						   needs enable, idle and off
-						   values */
+#define OMAP_DEVICE_PAD_REMUX_DISABLE	BIT(2)  /* Dynamic remux needed
+						   when pad would be
+						   disabled. Say when
+						   the driver is removed */
+#define OMAP_DEVICE_PAD_REMUX_IDLE	BIT(1)	/* Dynamic remux needed
+						   for pad, during power
+						   state transitions. */
 #define OMAP_DEVICE_PAD_WAKEUP		BIT(0)	/* Pad is wake-up capable */
 
 /**
@@ -212,13 +216,32 @@ extern struct omap_hwmod_mux_info *
 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads);
 
 /**
- * omap_hwmod_mux - omap hwmod specific pin muxing
+ * omap_hwmod_mux_enable - omap hwmod specific pin muxing
  * @hmux:		Pads for a hwmod
  * @state:		Desired _HWMOD_STATE
  *
  * Called only from omap_hwmod.c, do not use.
  */
-void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
+void omap_hwmod_mux_enable(struct omap_hwmod_mux_info *hmux, u8 state);
+
+/**
+ * omap_hwmod_mux_idle - omap hwmod specific pin muxing
+ * @hmux:		Pads for a hwmod
+ * @state:		Desired _HWMOD_STATE
+ *
+ * Called only from omap_hwmod.c, do not use.
+ */
+void omap_hwmod_mux_idle(struct omap_hwmod_mux_info *hmux, u8 state);
+
+/**
+ * omap_hwmod_mux_disable - omap hwmod specific pin muxing
+ * @hmux:		Pads for a hwmod
+ * @state:		Desired _HWMOD_STATE
+ *
+ * Called only from omap_hwmod.c, do not use.
+ */
+void omap_hwmod_mux_disable(struct omap_hwmod_mux_info *hmux, u8 state);
+
 
 #else
 
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index e282e35..49ed741 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1231,7 +1231,7 @@ static int _enable(struct omap_hwmod *oh)
 
 	/* Mux pins for device runtime if populated */
 	if (oh->mux)
-		omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
+		omap_hwmod_mux_enable(oh->mux, _HWMOD_STATE_ENABLED);
 
 	_add_initiator_dep(oh, mpu_oh);
 	_enable_clocks(oh);
@@ -1280,7 +1280,7 @@ static int _idle(struct omap_hwmod *oh)
 
 	/* Mux pins for device idle if populated */
 	if (oh->mux)
-		omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE);
+		omap_hwmod_mux_idle(oh->mux, _HWMOD_STATE_IDLE);
 
 	oh->_state = _HWMOD_STATE_IDLE;
 
@@ -1342,7 +1342,7 @@ static int _shutdown(struct omap_hwmod *oh)
 
 	/* Mux pins to safe mode or use populated off mode values */
 	if (oh->mux)
-		omap_hwmod_mux(oh->mux, _HWMOD_STATE_DISABLED);
+		omap_hwmod_mux_disable(oh->mux, _HWMOD_STATE_DISABLED);
 
 	oh->_state = _HWMOD_STATE_DISABLED;
 
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 6864a99..cdb329d 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -88,8 +88,11 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2;
  * Note that this is currently built during init as needed.
  */
 struct omap_hwmod_mux_info {
-	int				nr_pads;
-	struct omap_device_pad		*pads;
+	int				nr_pads_static;
+	struct omap_device_pad		*pads_static;
+	int				nr_pads_dynamic;
+	struct omap_device_pad		*pads_dynamic;
+	int				static_pads_initialised;
 };
 
 /**
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads
  2011-01-28  5:08 [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads sricharan
  2011-01-28  5:08 ` [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic sricharan
@ 2011-01-28  5:08 ` sricharan
  2011-02-23 18:49   ` Tony Lindgren
  2011-01-28  5:08 ` [PATCH 3/5] omap3: board-3430sdp: " sricharan
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: sricharan @ 2011-01-28  5:08 UTC (permalink / raw)
  To: r.sricharan, linux-omap; +Cc: santosh.shilimkar, tony, paul

Use the mux framework to initialise the serial pads.

Signed-off-by: sricharan <r.sricharan@ti.com>
---
 arch/arm/mach-omap2/board-4430sdp.c |   73 ++++++++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 1cb208b..d77f099 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -537,8 +537,79 @@ static void __init omap_sfh7741prox_init(void)
 static struct omap_board_mux board_mux[] __initdata = {
 	{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
+
+static struct omap_device_pad serial2_pads[] __initdata = {
+	{ .name   = "uart2_cts.uart2_cts",
+	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
+	  .idle   = OMAP_MUX_MODE7,
+	},
+	{ .name   = "uart2_rts.uart2_rts",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart2_rx.uart2_rx",
+	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart2_tx.uart2_tx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_device_pad serial3_pads[] __initdata = {
+	{ .name   = "uart3_cts_rctx.uart3_cts_rctx",
+	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_rts_sd.uart3_rts_sd",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_rx_irrx.uart3_rx_irrx",
+	  .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_tx_irtx.uart3_tx_irtx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_device_pad serial4_pads[] __initdata = {
+	{ .name   = "uart4_rx.uart4_rx",
+	  .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart4_tx.uart4_tx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_board_data serial2_data = {
+	.id		= 1,
+	.pads		= serial2_pads,
+	.pads_cnt	= ARRAY_SIZE(serial2_pads),
+};
+
+static struct omap_board_data serial3_data = {
+	.id		= 2,
+	.pads		= serial3_pads,
+	.pads_cnt	= ARRAY_SIZE(serial3_pads),
+};
+
+static struct omap_board_data serial4_data = {
+	.id		= 3,
+	.pads		= serial4_pads,
+	.pads_cnt	= ARRAY_SIZE(serial4_pads),
+};
+
+static inline void board_serial_init(void)
+{
+	omap_serial_init_port(&serial2_data);
+	omap_serial_init_port(&serial3_data);
+	omap_serial_init_port(&serial4_data);
+}
 #else
 #define board_mux	NULL
+
+static inline void board_serial_init(void)
+{
+	omap_serial_init();
+}
 #endif
 
 static void __init omap_4430sdp_init(void)
@@ -553,7 +624,7 @@ static void __init omap_4430sdp_init(void)
 	omap4_i2c_init();
 	omap_sfh7741prox_init();
 	platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
-	omap_serial_init();
+	board_serial_init();
 	omap4_twl6030_hsmmc_init(mmc);
 	/* OMAP4 SDP uses internal transceiver so register nop transceiver */
 	usb_nop_xceiv_register();
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/5] omap3: board-3430sdp: Initialise the serial pads.
  2011-01-28  5:08 [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads sricharan
  2011-01-28  5:08 ` [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic sricharan
  2011-01-28  5:08 ` [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads sricharan
@ 2011-01-28  5:08 ` sricharan
  2011-01-28  5:08 ` [PATCH 4/5] omap4: board-omap4panda: " sricharan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 19+ messages in thread
From: sricharan @ 2011-01-28  5:08 UTC (permalink / raw)
  To: r.sricharan, linux-omap; +Cc: santosh.shilimkar, tony, paul

Use the mux framework to initialise the serial pads.

Signed-off-by: sricharan <r.sricharan@ti.com>
---
 arch/arm/mach-omap2/board-3430sdp.c |   86 ++++++++++++++++++++++++++++++++++-
 1 files changed, 85 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 3b39ef1..422c259 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -663,6 +663,90 @@ static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
 static struct omap_board_mux board_mux[] __initdata = {
 	{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
+
+static struct omap_device_pad serial1_pads[] __initdata = {
+	{ .name   = "uart1_cts.uart1_cts",
+	  .enable = OMAP_PIN_INPUT|
+		    OMAP_PIN_OFF_INPUT_PULLDOWN | 
+		    OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart1_rts.uart1_rts",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart1_rx.uart1_rx",
+	  .enable = OMAP_PIN_INPUT | OMAP_PIN_OFF_INPUT_PULLDOWN |
+		    OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart1_tx.uart1_tx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_device_pad serial2_pads[] __initdata = {
+	{ .name   = "uart2_cts.uart2_cts",
+	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_INPUT_PULLDOWN | 
+		    OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart2_rts.uart2_rts",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart2_rx.uart2_rx",
+	  .enable = OMAP_PIN_INPUT | OMAP_PIN_OFF_INPUT_PULLDOWN |
+		    OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart2_tx.uart2_tx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_device_pad serial3_pads[] __initdata = {
+	{ .name   = "uart3_cts_rctx.uart3_cts_rctx",
+	  .enable = OMAP_PIN_INPUT_PULLDOWN | 
+		    OMAP_PIN_OFF_INPUT_PULLDOWN | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_rts_sd.uart3_rts_sd",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_rx_irrx.uart3_rx_irrx",
+	  .enable = OMAP_PIN_INPUT | OMAP_PIN_OFF_INPUT_PULLDOWN | 
+		    OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_tx_irtx.uart3_tx_irtx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_board_data serial1_data = {
+	.id		= 0,
+	.pads		= serial1_pads,
+	.pads_cnt	= ARRAY_SIZE(serial1_pads),
+};
+
+static struct omap_board_data serial2_data = {
+	.id		= 1,
+	.pads		= serial2_pads,
+	.pads_cnt	= ARRAY_SIZE(serial2_pads),
+};
+
+static struct omap_board_data serial3_data = {
+	.id		= 2,
+	.pads		= serial3_pads,
+	.pads_cnt	= ARRAY_SIZE(serial3_pads),
+};
+
+static inline void board_serial_init(void)
+{
+	omap_serial_init_port(&serial1_data);
+	omap_serial_init_port(&serial2_data);
+	omap_serial_init_port(&serial3_data);
+}
+#else
+#define board_mux	NULL
+
+static inline void board_serial_init(void)
+{
+	omap_serial_init();
+}
 #endif
 
 /*
@@ -804,7 +888,7 @@ static void __init omap_3430sdp_init(void)
 	spi_register_board_info(sdp3430_spi_board_info,
 				ARRAY_SIZE(sdp3430_spi_board_info));
 	ads7846_dev_init();
-	omap_serial_init();
+	board_serial_init();
 	usb_musb_init(&musb_board_data);
 	board_smc91x_init();
 	board_flash_init(sdp_flash_partitions, chip_sel_3430);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/5] omap4: board-omap4panda: Initialise the serial pads
  2011-01-28  5:08 [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads sricharan
                   ` (2 preceding siblings ...)
  2011-01-28  5:08 ` [PATCH 3/5] omap3: board-3430sdp: " sricharan
@ 2011-01-28  5:08 ` sricharan
  2011-01-28 20:53   ` Anand Gadiyar
  2011-02-23 18:49   ` Tony Lindgren
  2011-01-28  5:08 ` [PATCH 5/5] omap2+: board-n8x0: Change the flags for " sricharan
  2011-02-10 12:04 ` [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads Sricharan R
  5 siblings, 2 replies; 19+ messages in thread
From: sricharan @ 2011-01-28  5:08 UTC (permalink / raw)
  To: r.sricharan, linux-omap; +Cc: santosh.shilimkar, tony, paul

Use the mux framework to initialise the serial pads.

Signed-off-by: sricharan <r.sricharan@ti.com>
---
 arch/arm/mach-omap2/board-omap4panda.c |   72 +++++++++++++++++++++++++++++++-
 1 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index b43e3ff..9688ea9 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -370,13 +370,83 @@ static int __init omap4_panda_i2c_init(void)
 	omap_register_i2c_bus(4, 400, NULL, 0);
 	return 0;
 }
-
 #ifdef CONFIG_OMAP_MUX
 static struct omap_board_mux board_mux[] __initdata = {
 	{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
+
+static struct omap_device_pad serial2_pads[] __initdata = {
+	{ .name   = "uart2_cts.uart2_cts",
+	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
+	  .idle   = OMAP_MUX_MODE7,
+	},
+	{ .name   = "uart2_rts.uart2_rts",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart2_rx.uart2_rx",
+	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart2_tx.uart2_tx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_device_pad serial3_pads[] __initdata = {
+	{ .name   = "uart3_cts_rctx.uart3_cts_rctx",
+	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_rts_sd.uart3_rts_sd",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_rx_irrx.uart3_rx_irrx",
+	  .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart3_tx_irtx.uart3_tx_irtx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_device_pad serial4_pads[] __initdata = {
+	{ .name   = "uart4_rx.uart4_rx",
+	.enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+	},
+	{ .name   = "uart4_tx.uart4_tx",
+	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+	},
+};
+
+static struct omap_board_data serial2_data = {
+	.id             = 1,
+	.pads           = serial2_pads,
+	.pads_cnt       = ARRAY_SIZE(serial2_pads),
+};
+
+static struct omap_board_data serial3_data = {
+	.id             = 2,
+	.pads           = serial3_pads,
+	.pads_cnt       = ARRAY_SIZE(serial3_pads),
+};
+
+static struct omap_board_data serial4_data = {
+	.id             = 3,
+	.pads           = serial4_pads,
+	.pads_cnt       = ARRAY_SIZE(serial4_pads),
+};
+
+static inline void board_serial_init(void)
+{
+	omap_serial_init_port(&serial2_data);
+	omap_serial_init_port(&serial3_data);
+	omap_serial_init_port(&serial4_data);
+}
 #else
 #define board_mux	NULL
+
+static inline void board_serial_init(void)
+{
+	omap_serial_init();
+}
 #endif
 
 static void __init omap4_panda_init(void)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5/5] omap2+: board-n8x0: Change the flags for the serial pads.
  2011-01-28  5:08 [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads sricharan
                   ` (3 preceding siblings ...)
  2011-01-28  5:08 ` [PATCH 4/5] omap4: board-omap4panda: " sricharan
@ 2011-01-28  5:08 ` sricharan
  2011-02-23 18:49   ` Tony Lindgren
  2011-02-10 12:04 ` [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads Sricharan R
  5 siblings, 1 reply; 19+ messages in thread
From: sricharan @ 2011-01-28  5:08 UTC (permalink / raw)
  To: r.sricharan, linux-omap; +Cc: santosh.shilimkar, tony, paul

The flag for remuxing uart3_rx_irxx pad is changed.

Signed-off-by: sricharan <r.sricharan@ti.com>
---
 arch/arm/mach-omap2/board-n8x0.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index 9b52e2d..bd51356 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -751,7 +751,7 @@ static struct omap_board_mux board_mux[] __initdata = {
 static struct omap_device_pad serial2_pads[] __initdata = {
 	{
 		.name	= "uart3_rx_irrx.uart3_rx_irrx",
-		.flags	= OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
+		.flags	= OMAP_DEVICE_PAD_REMUX_IDLE | OMAP_DEVICE_PAD_WAKEUP,
 		.enable	= OMAP_MUX_MODE0,
 		.idle	= OMAP_MUX_MODE3	/* Mux as GPIO for idle */
 	},
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* RE: [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic.
  2011-01-28  5:08 ` [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic sricharan
@ 2011-01-28 20:49   ` Anand Gadiyar
  2011-01-31 14:20     ` Sricharan R
  2011-02-23 18:49   ` Tony Lindgren
  1 sibling, 1 reply; 19+ messages in thread
From: Anand Gadiyar @ 2011-01-28 20:49 UTC (permalink / raw)
  To: Sricharan R, linux-omap; +Cc: Santosh Shilimkar, tony, paul

sricharan wrote:
>
> 1) All the pads of a hwmod for the device are classified
>    as static/dynamic. If a pad requires remuxing during
>    the device transitions between enable/idle transitions
>    then it is added to the dynamic list, static otherwise.
>
> 2) Both the static/dynamic pads of a hwmod are initialised
>    when the device gets enabled. When the device transitions
>    between enable/idle the dynamic pads are remuxed and
>    static pads are skipped.
>
> 3) When the driver gets removed both the static and the
>    dynamic pads are muxed to safe mode as default.
>

I haven't taken a look at the code. I do have a few
concerns (which may really be non-issues, but I'm
pointing them out anyway):

- Not all pads have a safe mode.
--- And why would you want statically muxed pads to be remuxed
into safe mode anyway? What is the advantage of such a change,
as against leaving them in a functional mode?

- Many signals are muxed on more than one pad.
- Many peripherals need pads to be configured in different
  mux modes depending on the way a board is wired up.


With this, moving pad info to hwmod databases does not sound
useful to me. Maybe I do not understand the need for this
change, in place of what we have today.

- Anand

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 4/5] omap4: board-omap4panda: Initialise the serial pads
  2011-01-28  5:08 ` [PATCH 4/5] omap4: board-omap4panda: " sricharan
@ 2011-01-28 20:53   ` Anand Gadiyar
  2011-01-31 14:20     ` Sricharan R
  2011-02-23 18:49   ` Tony Lindgren
  1 sibling, 1 reply; 19+ messages in thread
From: Anand Gadiyar @ 2011-01-28 20:53 UTC (permalink / raw)
  To: Sricharan R, linux-omap; +Cc: Santosh Shilimkar, tony, paul

Sricharan wrote:
> Use the mux framework to initialise the serial pads.
>
> Signed-off-by: sricharan <r.sricharan@ti.com>
> ---
>  arch/arm/mach-omap2/board-omap4panda.c |   72
+++++++++++++++++++++++++++++++-
>  1 files changed, 71 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/board-omap4panda.c
> b/arch/arm/mach-omap2/board-omap4panda.c
> index b43e3ff..9688ea9 100644
> --- a/arch/arm/mach-omap2/board-omap4panda.c
> +++ b/arch/arm/mach-omap2/board-omap4panda.c
> @@ -370,13 +370,83 @@ static int __init omap4_panda_i2c_init(void)
>  	omap_register_i2c_bus(4, 400, NULL, 0);
>  	return 0;
>  }
> -
>  #ifdef CONFIG_OMAP_MUX
>  static struct omap_board_mux board_mux[] __initdata = {
>  	{ .reg_offset = OMAP_MUX_TERMINATOR },
>  };
> +
> +static struct omap_device_pad serial2_pads[] __initdata = {
> +	{ .name   = "uart2_cts.uart2_cts",
> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
> +	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
> +	  .idle   = OMAP_MUX_MODE7,
> +	},
> +	{ .name   = "uart2_rts.uart2_rts",
> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
> +	},
> +	{ .name   = "uart2_rx.uart2_rx",
> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
> +	},
> +	{ .name   = "uart2_tx.uart2_tx",
> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
> +	},
> +};
> +
> +static struct omap_device_pad serial3_pads[] __initdata = {
> +	{ .name   = "uart3_cts_rctx.uart3_cts_rctx",
> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
> +	},
> +	{ .name   = "uart3_rts_sd.uart3_rts_sd",
> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
> +	},
> +	{ .name   = "uart3_rx_irrx.uart3_rx_irrx",
> +	  .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
> +	},
> +	{ .name   = "uart3_tx_irtx.uart3_tx_irtx",
> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
> +	},
> +};
> +
> +static struct omap_device_pad serial4_pads[] __initdata = {
> +	{ .name   = "uart4_rx.uart4_rx",
> +	.enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
> +	},
> +	{ .name   = "uart4_tx.uart4_tx",
> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
> +	},
> +};
> +
> +static struct omap_board_data serial2_data = {
> +	.id             = 1,
> +	.pads           = serial2_pads,
> +	.pads_cnt       = ARRAY_SIZE(serial2_pads),
> +};
> +
> +static struct omap_board_data serial3_data = {
> +	.id             = 2,
> +	.pads           = serial3_pads,
> +	.pads_cnt       = ARRAY_SIZE(serial3_pads),
> +};
> +
> +static struct omap_board_data serial4_data = {
> +	.id             = 3,
> +	.pads           = serial4_pads,
> +	.pads_cnt       = ARRAY_SIZE(serial4_pads),
> +};
> +
> +static inline void board_serial_init(void)
> +{
> +	omap_serial_init_port(&serial2_data);
> +	omap_serial_init_port(&serial3_data);
> +	omap_serial_init_port(&serial4_data);
> +}
>  #else
>  #define board_mux	NULL
> +
> +static inline void board_serial_init(void)
> +{
> +	omap_serial_init();
> +}
>  #endif
>
>  static void __init omap4_panda_init(void)

You are changing the behavior with this patch.
Original code configured all 4 UARTs, while it
appears that your patch changes this to skip UART1.

This is not explained in the changelog. Is this
a deliberate change? Why would you want to do this?

- Anand

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic.
  2011-01-28 20:49   ` Anand Gadiyar
@ 2011-01-31 14:20     ` Sricharan R
  0 siblings, 0 replies; 19+ messages in thread
From: Sricharan R @ 2011-01-31 14:20 UTC (permalink / raw)
  To: Anand Gadiyar, linux-omap; +Cc: Santosh Shilimkar, tony, paul

>-----Original Message-----
>From: Anand Gadiyar [mailto:gadiyar@ti.com]
>Sent: Saturday, January 29, 2011 2:19 AM
>To: Sricharan R; linux-omap@vger.kernel.org
>Cc: Santosh Shilimkar; tony@atomide.com; paul@pwsan.com
>Subject: RE: [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as
>static and dynamic.
>
>sricharan wrote:
>>
>> 1) All the pads of a hwmod for the device are classified
>>    as static/dynamic. If a pad requires remuxing during
>>    the device transitions between enable/idle transitions
>>    then it is added to the dynamic list, static otherwise.
>>
>> 2) Both the static/dynamic pads of a hwmod are initialised
>>    when the device gets enabled. When the device transitions
>>    between enable/idle the dynamic pads are remuxed and
>>    static pads are skipped.
>>
>> 3) When the driver gets removed both the static and the
>>    dynamic pads are muxed to safe mode as default.
>>
>
>I haven't taken a look at the code. I do have a few
>concerns (which may really be non-issues, but I'm
>pointing them out anyway):
>
>- Not all pads have a safe mode.
>--- And why would you want statically muxed pads to be remuxed
>into safe mode anyway? What is the advantage of such a change,
>as against leaving them in a functional mode?
There is an option to mux the pads to different mode
than safe mode when the driver is removed. Those which
do not specify are put to safe mode.

With safe mode, the pins becomes a input with no functional
interface connected to it. This avoids the either omap
or outside device seeing any false logic from the pin.

>
>- Many signals are muxed on more than one pad.
>- Many peripherals need pads to be configured in different
>  mux modes depending on the way a board is wired up.
>
>
>With this, moving pad info to hwmod databases does not sound
>useful to me. Maybe I do not understand the need for this
>change, in place of what we have today.
>

The structure for containing the mux data is part of hwmod
for the device.

The hwmod is not static and it is dynamically
populated during the device init, with the
data being passed from board files if it is different across
boards.

The device state transitions (enable/idle) passes the through
the hwmod layer, which takes caring of muxing the pins
right way for each transition.

This helps to mux correctly the
1) shared pins
2) Initialsing the pads
3) Remux only pads that require change during enable/idle
   transitions.
4) Put the pads to safemode( default) when the driver is
   unplugged.


>- Anand

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 4/5] omap4: board-omap4panda: Initialise the serial pads
  2011-01-28 20:53   ` Anand Gadiyar
@ 2011-01-31 14:20     ` Sricharan R
  0 siblings, 0 replies; 19+ messages in thread
From: Sricharan R @ 2011-01-31 14:20 UTC (permalink / raw)
  To: Anand Gadiyar, linux-omap; +Cc: Santosh Shilimkar, tony, paul

>-----Original Message-----
>From: Anand Gadiyar [mailto:gadiyar@ti.com]
>Sent: Saturday, January 29, 2011 2:23 AM
>To: Sricharan R; linux-omap@vger.kernel.org
>Cc: Santosh Shilimkar; tony@atomide.com; paul@pwsan.com
>Subject: RE: [PATCH 4/5] omap4: board-omap4panda: Initialise the serial
>pads
>
>Sricharan wrote:
>> Use the mux framework to initialise the serial pads.
>>
>> Signed-off-by: sricharan <r.sricharan@ti.com>
>> ---
>>  arch/arm/mach-omap2/board-omap4panda.c |   72
>+++++++++++++++++++++++++++++++-
>>  1 files changed, 71 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/board-omap4panda.c
>> b/arch/arm/mach-omap2/board-omap4panda.c
>> index b43e3ff..9688ea9 100644
>> --- a/arch/arm/mach-omap2/board-omap4panda.c
>> +++ b/arch/arm/mach-omap2/board-omap4panda.c
>> @@ -370,13 +370,83 @@ static int __init omap4_panda_i2c_init(void)
>>  	omap_register_i2c_bus(4, 400, NULL, 0);
>>  	return 0;
>>  }
>> -
>>  #ifdef CONFIG_OMAP_MUX
>>  static struct omap_board_mux board_mux[] __initdata = {
>>  	{ .reg_offset = OMAP_MUX_TERMINATOR },
>>  };
>> +
>> +static struct omap_device_pad serial2_pads[] __initdata = {
>> +	{ .name   = "uart2_cts.uart2_cts",
>> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
>> +	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
>> +	  .idle   = OMAP_MUX_MODE7,
>> +	},
>> +	{ .name   = "uart2_rts.uart2_rts",
>> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
>> +	},
>> +	{ .name   = "uart2_rx.uart2_rx",
>> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
>> +	},
>> +	{ .name   = "uart2_tx.uart2_tx",
>> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
>> +	},
>> +};
>> +
>> +static struct omap_device_pad serial3_pads[] __initdata = {
>> +	{ .name   = "uart3_cts_rctx.uart3_cts_rctx",
>> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
>> +	},
>> +	{ .name   = "uart3_rts_sd.uart3_rts_sd",
>> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
>> +	},
>> +	{ .name   = "uart3_rx_irrx.uart3_rx_irrx",
>> +	  .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
>> +	},
>> +	{ .name   = "uart3_tx_irtx.uart3_tx_irtx",
>> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
>> +	},
>> +};
>> +
>> +static struct omap_device_pad serial4_pads[] __initdata = {
>> +	{ .name   = "uart4_rx.uart4_rx",
>> +	.enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
>> +	},
>> +	{ .name   = "uart4_tx.uart4_tx",
>> +	  .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
>> +	},
>> +};
>> +
>> +static struct omap_board_data serial2_data = {
>> +	.id             = 1,
>> +	.pads           = serial2_pads,
>> +	.pads_cnt       = ARRAY_SIZE(serial2_pads),
>> +};
>> +
>> +static struct omap_board_data serial3_data = {
>> +	.id             = 2,
>> +	.pads           = serial3_pads,
>> +	.pads_cnt       = ARRAY_SIZE(serial3_pads),
>> +};
>> +
>> +static struct omap_board_data serial4_data = {
>> +	.id             = 3,
>> +	.pads           = serial4_pads,
>> +	.pads_cnt       = ARRAY_SIZE(serial4_pads),
>> +};
>> +
>> +static inline void board_serial_init(void)
>> +{
>> +	omap_serial_init_port(&serial2_data);
>> +	omap_serial_init_port(&serial3_data);
>> +	omap_serial_init_port(&serial4_data);
>> +}
>>  #else
>>  #define board_mux	NULL
>> +
>> +static inline void board_serial_init(void)
>> +{
>> +	omap_serial_init();
>> +}
>>  #endif
>>
>>  static void __init omap4_panda_init(void)
>
>You are changing the behavior with this patch.
>Original code configured all 4 UARTs, while it
>appears that your patch changes this to skip UART1.
>
>This is not explained in the changelog. Is this
>a deliberate change? Why would you want to do this?
>
I see that UART1 is not muxed out and all uart1 pads
are all used for alternate functionalities.
So I did not initialize UART1.

However, there was a mistake with serial2 mux
which I have corrected in version2.

>- Anand

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads.
  2011-01-28  5:08 [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads sricharan
                   ` (4 preceding siblings ...)
  2011-01-28  5:08 ` [PATCH 5/5] omap2+: board-n8x0: Change the flags for " sricharan
@ 2011-02-10 12:04 ` Sricharan R
  5 siblings, 0 replies; 19+ messages in thread
From: Sricharan R @ 2011-02-10 12:04 UTC (permalink / raw)
  To: tony; +Cc: linux-omap, paul, Santosh Shilimkar

Hi Tony,

>-----Original Message-----
>From: sricharan [mailto:r.sricharan@ti.com]
>Sent: Friday, January 28, 2011 10:38 AM
>To: r.sricharan@ti.com; linux-omap@vger.kernel.org
>Cc: santosh.shilimkar@ti.com; tony@atomide.com; paul@pwsan.com
>Subject: [PATCH 0/5] omap2+: mux: Add support for static and dynamic
pads.
>
>
>1) The support to add the pad data to the device hwmod entry and to use
>   it to dynamically configure the pads based on the state of the
>   hwmod is already present.
>
>2) But using that for pads that requires only initialisation and not
>   dynamic remux, brings in a overhead to iterate over all the
>   hwmod signals of the device for every device enable/idle transitions.
>
>3) By seperating the pads that requires remux as dynamic and the
>   ones that do not as static the above overhead is avoided.
>
>4) This way the static and dynamic pads are initialised,
>   and only dynamic pads are taken for remuxing.
>
>sricharan (5):
>  omap2+: mux: Seperate the pads of a hwmod as static and dynamic.
>  omap4: board-4430sdp: Initialise the serial pads
>  omap3: board-3430sdp: Initialise the serial pads.
>  omap4: board-omap4panda: Initialise the serial pads
>  omap2+: board-n8x0: Change the flags for the serial pads.
>
Any comments on this??

Thanks,
  Sricharan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic.
  2011-01-28  5:08 ` [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic sricharan
  2011-01-28 20:49   ` Anand Gadiyar
@ 2011-02-23 18:49   ` Tony Lindgren
  2011-02-25 13:21     ` Sricharan R
  1 sibling, 1 reply; 19+ messages in thread
From: Tony Lindgren @ 2011-02-23 18:49 UTC (permalink / raw)
  To: sricharan; +Cc: linux-omap, santosh.shilimkar, paul

Hi,

Some comments and an alternative patch below.

* sricharan <r.sricharan@ti.com> [110127 21:05]:
> --- a/arch/arm/mach-omap2/mux.c
> +++ b/arch/arm/mach-omap2/mux.c

> +	hmux->pads_static = kzalloc(sizeof(struct omap_device_pad) *
> +				hmux->nr_pads_static, GFP_KERNEL);
> +	hmux->pads_dynamic = kzalloc(sizeof(struct omap_device_pad) *
> +				hmux->nr_pads_dynamic, GFP_KERNEL);
> +

We can just add a runtime alias list of pointers instead to keep
things simpler.

> --- a/arch/arm/mach-omap2/mux.h
> +++ b/arch/arm/mach-omap2/mux.h
> @@ -160,9 +160,13 @@ struct omap_board_mux {
>  };
>  
>  #define OMAP_DEVICE_PAD_ENABLED		BIT(7)	/* Not needed for board-*.c */
> -#define OMAP_DEVICE_PAD_REMUX		BIT(1)	/* Dynamically remux a pad,
> -						   needs enable, idle and off
> -						   values */
> +#define OMAP_DEVICE_PAD_REMUX_DISABLE	BIT(2)  /* Dynamic remux needed
> +						   when pad would be
> +						   disabled. Say when
> +						   the driver is removed */

In this case we should just disable all the pads.

> +#define OMAP_DEVICE_PAD_REMUX_IDLE	BIT(1)	/* Dynamic remux needed
> +						   for pad, during power
> +						   state transitions. */
>  #define OMAP_DEVICE_PAD_WAKEUP		BIT(0)	/* Pad is wake-up capable */

We just need OMAP_DEVICE_PAD_ENABLED and OMAP_DEVICE_PAD_IDLE.
  
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -1231,7 +1231,7 @@ static int _enable(struct omap_hwmod *oh)
>  
>  	/* Mux pins for device runtime if populated */
>  	if (oh->mux)
> -		omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
> +		omap_hwmod_mux_enable(oh->mux, _HWMOD_STATE_ENABLED);
>  
>  	_add_initiator_dep(oh, mpu_oh);
>  	_enable_clocks(oh);

No need for these kind of changes.

Alternative patch below that keeps things simpler.

Regards,

Tony

From: Tony Lindgren <tony@atomide.com>
Date: Tue, 22 Feb 2011 16:05:15 -0800
Subject: [PATCH] omap2+: Add separate list for dynamic pads to mux

This avoids going through the list unnecessarily when
idling devices for runtime PM.

Based on an earlier patch by sricharan <r.sricharan@ti.com>.

Signed-off-by: Tony Lindgren <tony@atomide.com>

--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -258,7 +258,7 @@ struct omap_hwmod_mux_info * __init
 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
 {
 	struct omap_hwmod_mux_info *hmux;
-	int i;
+	int i, nr_pads_dynamic = 0;
 
 	if (!bpads || nr_pads < 1)
 		return NULL;
@@ -302,9 +302,40 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
 		pad->enable = bpad->enable;
 		pad->idle = bpad->idle;
 		pad->off = bpad->off;
+
+		if (pad->flags & OMAP_DEVICE_PAD_REMUX)
+			nr_pads_dynamic++;
+
 		pr_debug("%s: Initialized %s\n", __func__, pad->name);
 	}
 
+	if (!nr_pads_dynamic)
+		return hmux;
+
+	/*
+	 * Add pads that need dynamic muxing into a separate list
+	 */
+
+	hmux->nr_pads_dynamic = nr_pads_dynamic;
+	hmux->pads_dynamic = kzalloc(sizeof(struct omap_device_pad *) *
+					nr_pads_dynamic, GFP_KERNEL);
+	if (!hmux->pads_dynamic) {
+		pr_err("%s: Could not allocate dynamic pads\n", __func__);
+		return hmux;
+	}
+
+	nr_pads_dynamic = 0;
+	for (i = 0; i < hmux->nr_pads; i++) {
+		struct omap_device_pad *pad = &hmux->pads[i];
+
+		if (pad->flags & OMAP_DEVICE_PAD_REMUX) {
+			pr_debug("%s: pad %s tagged dynamic\n",
+					__func__, pad->name);
+			hmux->pads_dynamic[nr_pads_dynamic] = pad;
+			nr_pads_dynamic++;
+		}
+	}
+
 	return hmux;
 
 err3:
@@ -322,6 +353,46 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 {
 	int i;
 
+	/* Runtime idling of dynamic pads */
+	if (state == _HWMOD_STATE_IDLE && hmux->enabled) {
+		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
+			struct omap_device_pad *pad = &hmux->pads[i];
+			int val = -EINVAL;
+
+			pad->flags &= ~OMAP_DEVICE_PAD_ENABLED;
+			pad->flags |= OMAP_DEVICE_PAD_IDLE;
+			val = pad->idle;
+			omap_mux_write(pad->partition, val,
+					pad->mux->reg_offset);
+		}
+
+		return;
+	}
+
+	/* Runtime enabling of dynamic pads */
+	if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic) {
+		int idled = 0;
+
+		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
+			struct omap_device_pad *pad = &hmux->pads[i];
+			int val = -EINVAL;
+
+			if (!(pad->flags & OMAP_DEVICE_PAD_IDLE))
+				continue;
+
+			pad->flags &= ~OMAP_DEVICE_PAD_IDLE;
+			pad->flags |= OMAP_DEVICE_PAD_ENABLED;
+			val = pad->enable;
+			omap_mux_write(pad->partition, val,
+					pad->mux->reg_offset);
+			idled++;
+		}
+
+		if (idled)
+			return;
+	}
+
+	/* Enabling, disabling or idling of all pads */
 	for (i = 0; i < hmux->nr_pads; i++) {
 		struct omap_device_pad *pad = &hmux->pads[i];
 		int flags, val = -EINVAL;
@@ -363,6 +434,11 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 			pad->flags = flags;
 		}
 	}
+
+	if (state == _HWMOD_STATE_ENABLED)
+		hmux->enabled = true;
+	else
+		hmux->enabled = false;
 }
 
 #ifdef CONFIG_DEBUG_FS
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -159,7 +159,8 @@ struct omap_board_mux {
 	u16	value;
 };
 
-#define OMAP_DEVICE_PAD_ENABLED		BIT(7)	/* Not needed for board-*.c */
+#define OMAP_DEVICE_PAD_IDLE		BIT(7)	/* Not needed for board-*.c */
+#define OMAP_DEVICE_PAD_ENABLED		BIT(6)	/* Not needed for board-*.c */
 #define OMAP_DEVICE_PAD_REMUX		BIT(1)	/* Dynamically remux a pad,
 						   needs enable, idle and off
 						   values */
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1230,8 +1230,9 @@ static int _enable(struct omap_hwmod *oh)
 		_deassert_hardreset(oh, oh->rst_lines[0].name);
 
 	/* Mux pins for device runtime if populated */
-	if (oh->mux)
-		omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
+	if (oh->mux && ((oh->_state == _HWMOD_STATE_DISABLED) ||
+		((oh->_state == _HWMOD_STATE_IDLE) && oh->mux->pads_dynamic)))
+			omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
 
 	_add_initiator_dep(oh, mpu_oh);
 	_enable_clocks(oh);
@@ -1279,7 +1280,7 @@ static int _idle(struct omap_hwmod *oh)
 	_disable_clocks(oh);
 
 	/* Mux pins for device idle if populated */
-	if (oh->mux)
+	if (oh->mux && oh->mux->pads_dynamic)
 		omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE);
 
 	oh->_state = _HWMOD_STATE_IDLE;
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -90,6 +90,9 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2;
 struct omap_hwmod_mux_info {
 	int				nr_pads;
 	struct omap_device_pad		*pads;
+	int				nr_pads_dynamic;
+	struct omap_device_pad		**pads_dynamic;
+	bool				enabled;
 };
 
 /**

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads
  2011-01-28  5:08 ` [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads sricharan
@ 2011-02-23 18:49   ` Tony Lindgren
  2011-02-25 13:21     ` Sricharan R
  0 siblings, 1 reply; 19+ messages in thread
From: Tony Lindgren @ 2011-02-23 18:49 UTC (permalink / raw)
  To: sricharan; +Cc: linux-omap, santosh.shilimkar, paul

* sricharan <r.sricharan@ti.com> [110127 21:04]:
> Use the mux framework to initialise the serial pads.
> 
> Signed-off-by: sricharan <r.sricharan@ti.com>
> ---
>  arch/arm/mach-omap2/board-4430sdp.c |   73 ++++++++++++++++++++++++++++++++++-
>  1 files changed, 72 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
> index 1cb208b..d77f099 100644
> --- a/arch/arm/mach-omap2/board-4430sdp.c
> +++ b/arch/arm/mach-omap2/board-4430sdp.c
> @@ -537,8 +537,79 @@ static void __init omap_sfh7741prox_init(void)
>  static struct omap_board_mux board_mux[] __initdata = {
>  	{ .reg_offset = OMAP_MUX_TERMINATOR },
>  };
> +
> +static struct omap_device_pad serial2_pads[] __initdata = {
> +	{ .name   = "uart2_cts.uart2_cts",
> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
> +	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
> +	  .idle   = OMAP_MUX_MODE7,
> +	},

Is there need to dynamically remux uart2_cts? If so, please
describe the reason in the patch description and comments.

Note that if there's need for dynamic remuxing, this should
be updated for just OMAP_DEVICE_PAD_REMUX to work with the
patch I posted to replace patch 1/5.

Regards,

Tony

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/5] omap4: board-omap4panda: Initialise the serial pads
  2011-01-28  5:08 ` [PATCH 4/5] omap4: board-omap4panda: " sricharan
  2011-01-28 20:53   ` Anand Gadiyar
@ 2011-02-23 18:49   ` Tony Lindgren
  2011-02-25 13:22     ` Sricharan R
  1 sibling, 1 reply; 19+ messages in thread
From: Tony Lindgren @ 2011-02-23 18:49 UTC (permalink / raw)
  To: sricharan; +Cc: linux-omap, santosh.shilimkar, paul

* sricharan <r.sricharan@ti.com> [110127 21:05]:
> --- a/arch/arm/mach-omap2/board-omap4panda.c
> +++ b/arch/arm/mach-omap2/board-omap4panda.c
> @@ -370,13 +370,83 @@ static int __init omap4_panda_i2c_init(void)
>  	omap_register_i2c_bus(4, 400, NULL, 0);
>  	return 0;
>  }
> -
>  #ifdef CONFIG_OMAP_MUX
>  static struct omap_board_mux board_mux[] __initdata = {
>  	{ .reg_offset = OMAP_MUX_TERMINATOR },
>  };
> +
> +static struct omap_device_pad serial2_pads[] __initdata = {
> +	{ .name   = "uart2_cts.uart2_cts",
> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
> +	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
> +	  .idle   = OMAP_MUX_MODE7,
> +	},

Here too please check the need for dynamic remuxing and
update the patch if necessary.

Regards,

Tony

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 5/5] omap2+: board-n8x0: Change the flags for the serial pads.
  2011-01-28  5:08 ` [PATCH 5/5] omap2+: board-n8x0: Change the flags for " sricharan
@ 2011-02-23 18:49   ` Tony Lindgren
  2011-02-25 13:21     ` Sricharan R
  0 siblings, 1 reply; 19+ messages in thread
From: Tony Lindgren @ 2011-02-23 18:49 UTC (permalink / raw)
  To: sricharan; +Cc: linux-omap, santosh.shilimkar, paul

* sricharan <r.sricharan@ti.com> [110127 21:05]:
> The flag for remuxing uart3_rx_irxx pad is changed.
> 
> Signed-off-by: sricharan <r.sricharan@ti.com>
> ---
>  arch/arm/mach-omap2/board-n8x0.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
> index 9b52e2d..bd51356 100644
> --- a/arch/arm/mach-omap2/board-n8x0.c
> +++ b/arch/arm/mach-omap2/board-n8x0.c
> @@ -751,7 +751,7 @@ static struct omap_board_mux board_mux[] __initdata = {
>  static struct omap_device_pad serial2_pads[] __initdata = {
>  	{
>  		.name	= "uart3_rx_irrx.uart3_rx_irrx",
> -		.flags	= OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
> +		.flags	= OMAP_DEVICE_PAD_REMUX_IDLE | OMAP_DEVICE_PAD_WAKEUP,
>  		.enable	= OMAP_MUX_MODE0,
>  		.idle	= OMAP_MUX_MODE3	/* Mux as GPIO for idle */
>  	},

This should not be needed when rebased on my patch to replace patch 1/5.

Regards,

Tony

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic.
  2011-02-23 18:49   ` Tony Lindgren
@ 2011-02-25 13:21     ` Sricharan R
  0 siblings, 0 replies; 19+ messages in thread
From: Sricharan R @ 2011-02-25 13:21 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Santosh Shilimkar, paul

Hi Tony,
>From: Tony Lindgren <tony@atomide.com>
>Date: Tue, 22 Feb 2011 16:05:15 -0800
>Subject: [PATCH] omap2+: Add separate list for dynamic pads to mux
>
>This avoids going through the list unnecessarily when
>idling devices for runtime PM.
>
>Based on an earlier patch by sricharan <r.sricharan@ti.com>.
>
yes, this looks simpler actually.

>Signed-off-by: Tony Lindgren <tony@atomide.com>
>
>--- a/arch/arm/mach-omap2/mux.c
>+++ b/arch/arm/mach-omap2/mux.c
>@@ -258,7 +258,7 @@ struct omap_hwmod_mux_info * __init
> omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
> {
> 	struct omap_hwmod_mux_info *hmux;
>-	int i;
>+	int i, nr_pads_dynamic = 0;
>
> 	if (!bpads || nr_pads < 1)
> 		return NULL;
>@@ -302,9 +302,40 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads,
int
>nr_pads)
> 		pad->enable = bpad->enable;
> 		pad->idle = bpad->idle;
> 		pad->off = bpad->off;
>+
>+		if (pad->flags & OMAP_DEVICE_PAD_REMUX)
>+			nr_pads_dynamic++;
>+
> 		pr_debug("%s: Initialized %s\n", __func__, pad->name);
> 	}
>
>+	if (!nr_pads_dynamic)
>+		return hmux;
>+
>+	/*
>+	 * Add pads that need dynamic muxing into a separate list
>+	 */
>+
>+	hmux->nr_pads_dynamic = nr_pads_dynamic;
>+	hmux->pads_dynamic = kzalloc(sizeof(struct omap_device_pad *) *
>+					nr_pads_dynamic, GFP_KERNEL);
>+	if (!hmux->pads_dynamic) {
>+		pr_err("%s: Could not allocate dynamic pads\n", __func__);
>+		return hmux;
>+	}
>+
>+	nr_pads_dynamic = 0;
>+	for (i = 0; i < hmux->nr_pads; i++) {
>+		struct omap_device_pad *pad = &hmux->pads[i];
>+
>+		if (pad->flags & OMAP_DEVICE_PAD_REMUX) {
>+			pr_debug("%s: pad %s tagged dynamic\n",
>+					__func__, pad->name);
>+			hmux->pads_dynamic[nr_pads_dynamic] = pad;
>+			nr_pads_dynamic++;
>+		}
>+	}
>+
> 	return hmux;
>
> err3:
>@@ -322,6 +353,46 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info
*hmux,
>u8 state)
> {
> 	int i;
>
>+	/* Runtime idling of dynamic pads */
>+	if (state == _HWMOD_STATE_IDLE && hmux->enabled) {
>+		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
>+			struct omap_device_pad *pad = &hmux->pads[i];
>+			int val = -EINVAL;
>+
>+			pad->flags &= ~OMAP_DEVICE_PAD_ENABLED;
>+			pad->flags |= OMAP_DEVICE_PAD_IDLE;
>+			val = pad->idle;
>+			omap_mux_write(pad->partition, val,
>+					pad->mux->reg_offset);
>+		}
>+
>+		return;
>+	}
>+
>+	/* Runtime enabling of dynamic pads */
>+	if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic) {
>+		int idled = 0;
>+
>+		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
>+			struct omap_device_pad *pad = &hmux->pads[i];
>+			int val = -EINVAL;
>+
>+			if (!(pad->flags & OMAP_DEVICE_PAD_IDLE))
>+				continue;
>+
>+			pad->flags &= ~OMAP_DEVICE_PAD_IDLE;
>+			pad->flags |= OMAP_DEVICE_PAD_ENABLED;
>+			val = pad->enable;
>+			omap_mux_write(pad->partition, val,
>+					pad->mux->reg_offset);
>+			idled++;
>+		}
>+
>+		if (idled)
>+			return;
>+	}
>+
>+	/* Enabling, disabling or idling of all pads */
> 	for (i = 0; i < hmux->nr_pads; i++) {
> 		struct omap_device_pad *pad = &hmux->pads[i];
> 		int flags, val = -EINVAL;
>@@ -363,6 +434,11 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info
*hmux,
>u8 state)
> 			pad->flags = flags;
> 		}
> 	}
>+
>+	if (state == _HWMOD_STATE_ENABLED)
>+		hmux->enabled = true;
>+	else
>+		hmux->enabled = false;
> }
>
> #ifdef CONFIG_DEBUG_FS
>--- a/arch/arm/mach-omap2/mux.h
>+++ b/arch/arm/mach-omap2/mux.h
>@@ -159,7 +159,8 @@ struct omap_board_mux {
> 	u16	value;
> };
>
>-#define OMAP_DEVICE_PAD_ENABLED		BIT(7)	/* Not needed for
>board-*.c */
>+#define OMAP_DEVICE_PAD_IDLE		BIT(7)	/* Not needed for
board-*.c
>*/
>+#define OMAP_DEVICE_PAD_ENABLED		BIT(6)	/* Not needed for
>board-*.c */
> #define OMAP_DEVICE_PAD_REMUX		BIT(1)	/* Dynamically remux
>a pad,
> 						   needs enable, idle and
off
> 						   values */
>--- a/arch/arm/mach-omap2/omap_hwmod.c
>+++ b/arch/arm/mach-omap2/omap_hwmod.c
>@@ -1230,8 +1230,9 @@ static int _enable(struct omap_hwmod *oh)
> 		_deassert_hardreset(oh, oh->rst_lines[0].name);
>
> 	/* Mux pins for device runtime if populated */
>-	if (oh->mux)
>-		omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
>+	if (oh->mux && ((oh->_state == _HWMOD_STATE_DISABLED) ||
>+		((oh->_state == _HWMOD_STATE_IDLE) &&
oh->mux->pads_dynamic)))
>+			omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
>

This will avoid the static pads initialization.
I have made few modications to your patch, so that static pads
Initialization is taken care and iteration does not happen unnessecarily.
I have given the patch below.i have tested the patch on 3430sdp
with by enabling dynamic pads for test purpose.


-----------------------------------------

arch/arm/mach-omap2/mux.c                    |   86
++++++++++++++++++++++---
 arch/arm/mach-omap2/mux.h                    |    3 +-
 arch/arm/mach-omap2/omap_hwmod.c             |    2 +-
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    3 +
 4 files changed, 81 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 6c84659..e2a535b 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -258,7 +258,7 @@ struct omap_hwmod_mux_info * __init
 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
 {
 	struct omap_hwmod_mux_info *hmux;
-	int i;
+	int i, nr_pads_dynamic = 0;

 	if (!bpads || nr_pads < 1)
 		return NULL;
@@ -302,9 +302,40 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads,
int nr_pads)
 		pad->enable = bpad->enable;
 		pad->idle = bpad->idle;
 		pad->off = bpad->off;
+
+		if (pad->flags & OMAP_DEVICE_PAD_REMUX)
+			nr_pads_dynamic++;
+
 		pr_debug("%s: Initialized %s\n", __func__, pad->name);
 	}

+	if (!nr_pads_dynamic)
+		return hmux;
+
+	/*
+	 * Add pads that need dynamic muxing into a separate list
+	 */
+
+	hmux->nr_pads_dynamic = nr_pads_dynamic;
+	hmux->pads_dynamic = kzalloc(sizeof(struct omap_device_pad *) *
+					nr_pads_dynamic, GFP_KERNEL);
+	if (!hmux->pads_dynamic) {
+		pr_err("%s: Could not allocate dynamic pads\n", __func__);
+		return hmux;
+	}
+
+	nr_pads_dynamic = 0;
+	for (i = 0; i < hmux->nr_pads; i++) {
+		struct omap_device_pad *pad = &hmux->pads[i];
+
+		if (pad->flags & OMAP_DEVICE_PAD_REMUX) {
+			pr_err("%s: pad %s tagged dynamic\n",
+					__func__, pad->name);
+			hmux->pads_dynamic[nr_pads_dynamic] = pad;
+			nr_pads_dynamic++;
+		}
+	}
+
 	return hmux;

 err3:
@@ -322,6 +353,39 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux,
u8 state)
 {
 	int i;

+	/* Runtime idling of dynamic pads */
+	if (state == _HWMOD_STATE_IDLE && hmux->enabled) {
+		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
+			struct omap_device_pad *pad =
hmux->pads_dynamic[i];
+			int val = -EINVAL;
+
+			val = pad->idle;
+			omap_mux_write(pad->partition, val,
+					pad->mux->reg_offset);
+		}
+		return;
+	}
+
+	/* Runtime enabling of dynamic pads */
+	if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic
+						&& hmux->enabled) {
+		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
+			struct omap_device_pad *pad =
hmux->pads_dynamic[i];
+			int val = -EINVAL;
+
+			val = pad->enable;
+			omap_mux_write(pad->partition, val,
+					pad->mux->reg_offset);
+		}
+		return;
+	}
+
+	/* When there are only static pads which are initialised, return
*/
+	if((state == _HWMOD_STATE_ENABLED) && (!(hmux->pads_dynamic))
+						&& (hmux->enabled))
+		return;
+
+	/* Enabling, disabling or idling of all pads */
 	for (i = 0; i < hmux->nr_pads; i++) {
 		struct omap_device_pad *pad = &hmux->pads[i];
 		int flags, val = -EINVAL;
@@ -337,16 +401,7 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux,
u8 state)
 			pr_debug("%s: Enabling %s %x\n", __func__,
 					pad->name, val);
 			break;
-		case _HWMOD_STATE_IDLE:
-			if (!(flags & OMAP_DEVICE_PAD_REMUX))
-				break;
-			flags &= ~OMAP_DEVICE_PAD_ENABLED;
-			val = pad->idle;
-			pr_debug("%s: Idling %s %x\n", __func__,
-					pad->name, val);
-			break;
 		case _HWMOD_STATE_DISABLED:
-		default:
 			/* Use safe mode unless OMAP_DEVICE_PAD_REMUX */
 			if (flags & OMAP_DEVICE_PAD_REMUX)
 				val = pad->off;
@@ -355,7 +410,11 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux,
u8 state)
 			flags &= ~OMAP_DEVICE_PAD_ENABLED;
 			pr_debug("%s: Disabling %s %x\n", __func__,
 					pad->name, val);
-		};
+			break;
+		default:
+			/* Nothing to be done */
+			break;
+		}

 		if (val >= 0) {
 			omap_mux_write(pad->partition, val,
@@ -363,6 +422,11 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux,
u8 state)
 			pad->flags = flags;
 		}
 	}
+
+	if (state == _HWMOD_STATE_ENABLED)
+		hmux->enabled = true;
+	else
+		hmux->enabled = false;
 }

 #ifdef CONFIG_DEBUG_FS
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index a4ab17a..8f6e326 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -159,7 +159,8 @@ struct omap_board_mux {
 	u16	value;
 };

-#define OMAP_DEVICE_PAD_ENABLED		BIT(7)	/* Not needed for
board-*.c */
+#define OMAP_DEVICE_PAD_IDLE		BIT(7)	/* Not needed for
board-*.c */
+#define OMAP_DEVICE_PAD_ENABLED		BIT(6)	/* Not needed for
board-*.c */
 #define OMAP_DEVICE_PAD_REMUX		BIT(1)	/* Dynamically remux a
pad,
 						   needs enable, idle and
off
 						   values */
diff --git a/arch/arm/mach-omap2/omap_hwmod.c
b/arch/arm/mach-omap2/omap_hwmod.c
index 9e89a58..5f7aaf7 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1279,7 +1279,7 @@ static int _idle(struct omap_hwmod *oh)
 	_disable_clocks(oh);

 	/* Mux pins for device idle if populated */
-	if (oh->mux)
+	if (oh->mux && oh->mux->pads_dynamic)
 		omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE);

 	oh->_state = _HWMOD_STATE_IDLE;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h
b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index fedd829..11efa2d 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -90,6 +90,9 @@ extern struct omap_hwmod_sysc_fields
omap_hwmod_sysc_type2;
 struct omap_hwmod_mux_info {
 	int				nr_pads;
 	struct omap_device_pad		*pads;
+	int				nr_pads_dynamic;
+	struct omap_device_pad		**pads_dynamic;
+	bool				enabled;
 };

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* RE: [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads
  2011-02-23 18:49   ` Tony Lindgren
@ 2011-02-25 13:21     ` Sricharan R
  0 siblings, 0 replies; 19+ messages in thread
From: Sricharan R @ 2011-02-25 13:21 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Santosh Shilimkar, paul

Hi Tony,
>-----Original Message-----
>From: Tony Lindgren [mailto:tony@atomide.com]
>Sent: Thursday, February 24, 2011 12:20 AM
>To: sricharan
>Cc: linux-omap@vger.kernel.org; santosh.shilimkar@ti.com; paul@pwsan.com
>Subject: Re: [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads
>
>* sricharan <r.sricharan@ti.com> [110127 21:04]:
>> Use the mux framework to initialise the serial pads.
>>
>> Signed-off-by: sricharan <r.sricharan@ti.com>
>> ---
>>  arch/arm/mach-omap2/board-4430sdp.c |   73
>++++++++++++++++++++++++++++++++++-
>>  1 files changed, 72 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-
>omap2/board-4430sdp.c
>> index 1cb208b..d77f099 100644
>> --- a/arch/arm/mach-omap2/board-4430sdp.c
>> +++ b/arch/arm/mach-omap2/board-4430sdp.c
>> @@ -537,8 +537,79 @@ static void __init omap_sfh7741prox_init(void)
>>  static struct omap_board_mux board_mux[] __initdata = {
>>  	{ .reg_offset = OMAP_MUX_TERMINATOR },
>>  };
>> +
>> +static struct omap_device_pad serial2_pads[] __initdata = {
>> +	{ .name   = "uart2_cts.uart2_cts",
>> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
>> +	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
>> +	  .idle   = OMAP_MUX_MODE7,
>> +	},
>
>Is there need to dynamically remux uart2_cts? If so, please
>describe the reason in the patch description and comments.
>
>Note that if there's need for dynamic remuxing, this should
>be updated for just OMAP_DEVICE_PAD_REMUX to work with the
>patch I posted to replace patch 1/5.
>
Actually there was not a need for remixing here. I added
This for testing purpose.i will remove this and send a updated
Patch.
>Regards,
>
>Tony

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 5/5] omap2+: board-n8x0: Change the flags for the serial pads.
  2011-02-23 18:49   ` Tony Lindgren
@ 2011-02-25 13:21     ` Sricharan R
  0 siblings, 0 replies; 19+ messages in thread
From: Sricharan R @ 2011-02-25 13:21 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Santosh Shilimkar, paul

Hi Tony,
>-----Original Message-----
>From: Tony Lindgren [mailto:tony@atomide.com]
>Sent: Thursday, February 24, 2011 12:20 AM
>To: sricharan
>Cc: linux-omap@vger.kernel.org; santosh.shilimkar@ti.com; paul@pwsan.com
>Subject: Re: [PATCH 5/5] omap2+: board-n8x0: Change the flags for the
>serial pads.
>
>* sricharan <r.sricharan@ti.com> [110127 21:05]:
>> The flag for remuxing uart3_rx_irxx pad is changed.
>>
>> Signed-off-by: sricharan <r.sricharan@ti.com>
>> ---
>>  arch/arm/mach-omap2/board-n8x0.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-
>omap2/board-n8x0.c
>> index 9b52e2d..bd51356 100644
>> --- a/arch/arm/mach-omap2/board-n8x0.c
>> +++ b/arch/arm/mach-omap2/board-n8x0.c
>> @@ -751,7 +751,7 @@ static struct omap_board_mux board_mux[] __initdata
=
>{
>>  static struct omap_device_pad serial2_pads[] __initdata = {
>>  	{
>>  		.name	= "uart3_rx_irrx.uart3_rx_irrx",
>> -		.flags	= OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
>> +		.flags	= OMAP_DEVICE_PAD_REMUX_IDLE |
>OMAP_DEVICE_PAD_WAKEUP,
>>  		.enable	= OMAP_MUX_MODE0,
>>  		.idle	= OMAP_MUX_MODE3	/* Mux as GPIO for idle */
>>  	},
>
>This should not be needed when rebased on my patch to replace patch 1/5.
>
Yes correct. This patch should not be needed now.
>Regards,
>
>Tony

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 4/5] omap4: board-omap4panda: Initialise the serial pads
  2011-02-23 18:49   ` Tony Lindgren
@ 2011-02-25 13:22     ` Sricharan R
  0 siblings, 0 replies; 19+ messages in thread
From: Sricharan R @ 2011-02-25 13:22 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Santosh Shilimkar, paul

Hi Tony,
>-----Original Message-----
>From: Tony Lindgren [mailto:tony@atomide.com]
>Sent: Thursday, February 24, 2011 12:20 AM
>To: sricharan
>Cc: linux-omap@vger.kernel.org; santosh.shilimkar@ti.com; paul@pwsan.com
>Subject: Re: [PATCH 4/5] omap4: board-omap4panda: Initialise the serial
>pads
>
>* sricharan <r.sricharan@ti.com> [110127 21:05]:
>> --- a/arch/arm/mach-omap2/board-omap4panda.c
>> +++ b/arch/arm/mach-omap2/board-omap4panda.c
>> @@ -370,13 +370,83 @@ static int __init omap4_panda_i2c_init(void)
>>  	omap_register_i2c_bus(4, 400, NULL, 0);
>>  	return 0;
>>  }
>> -
>>  #ifdef CONFIG_OMAP_MUX
>>  static struct omap_board_mux board_mux[] __initdata = {
>>  	{ .reg_offset = OMAP_MUX_TERMINATOR },
>>  };
>> +
>> +static struct omap_device_pad serial2_pads[] __initdata = {
>> +	{ .name   = "uart2_cts.uart2_cts",
>> +	  .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
>> +	  .flags  = OMAP_DEVICE_PAD_REMUX_IDLE,
>> +	  .idle   = OMAP_MUX_MODE7,
>> +	},
>
>Here too please check the need for dynamic remuxing and
>update the patch if necessary.
>
Actually there was not a need for remixing here. I added
This for testing purpose.i will remove this and send an updated
Patch.
>Regards,
>
>Tony

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-02-25 13:22 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-28  5:08 [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads sricharan
2011-01-28  5:08 ` [PATCH 1/5] omap2+: mux: Seperate the pads of a hwmod as static and dynamic sricharan
2011-01-28 20:49   ` Anand Gadiyar
2011-01-31 14:20     ` Sricharan R
2011-02-23 18:49   ` Tony Lindgren
2011-02-25 13:21     ` Sricharan R
2011-01-28  5:08 ` [PATCH 2/5] omap4: board-4430sdp: Initialise the serial pads sricharan
2011-02-23 18:49   ` Tony Lindgren
2011-02-25 13:21     ` Sricharan R
2011-01-28  5:08 ` [PATCH 3/5] omap3: board-3430sdp: " sricharan
2011-01-28  5:08 ` [PATCH 4/5] omap4: board-omap4panda: " sricharan
2011-01-28 20:53   ` Anand Gadiyar
2011-01-31 14:20     ` Sricharan R
2011-02-23 18:49   ` Tony Lindgren
2011-02-25 13:22     ` Sricharan R
2011-01-28  5:08 ` [PATCH 5/5] omap2+: board-n8x0: Change the flags for " sricharan
2011-02-23 18:49   ` Tony Lindgren
2011-02-25 13:21     ` Sricharan R
2011-02-10 12:04 ` [PATCH 0/5] omap2+: mux: Add support for static and dynamic pads Sricharan R

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.