[PATCH v3] OMAP2+: UART: Add mechanism to probe uart pins and configure rx wakeup

2012-05-11 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The commit (bce492c0  ARM: OMAP2+: UART: Fix incorrect population of
default uart pads) removed default uart pads that where getting populated
and which was making rx pin wakeup capable. If uart pads were used in
different mode by any other module then it would fail since the default
pads took over all the uart pins forcefully. With removal of default pads
the rx_pad wakeup for console uart while waking up from off mode is broken.

Utilise the mux api available to probe the availability of mux pins
in uart mode and probe for availability of uart pin in mux mode0
if uart is available as uart pin itself then configure rx pin
as wakeup capable.

This patch itself doesn't cater to all boards. Boards using uart rx wakeup
mechanism should ensure the usage of omap_serial_init_port by configuring
required uart ports and pass necessary mux data, till then this probing of
uart pins can cater to enabling of rx pad wakeup to most of the boards.

This patch can also throw some boot warning from _omap_mux_get_by_name
if pin is requested for availability is not present while dynamically probing
the uart pins availability such boot warnings can be addressed only when board
files are patched with omap_serial_init_port calls passing the right pads
needed for a given port.

Discussion Threads for reference:
http://www.spinics.net/lists/linux-omap/msg69859.html
http://www.spinics.net/lists/linux-omap/msg68659.html

Cc: Felipe Balbi ba...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Russ Dill russ.d...@gmail.com
Cc: Tony Lindgren t...@atomide.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Ameya Palande ameya.pala...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---

Patching of all board files would be difficult as even I am not aware of all
omap-board schematics and uart port usage. So individual board file can be
enabled accordingly for uart usage by calling omap_serial_init_port call
with right mux data.

for testing: Patch based on v3.4-rc6
(tested on beagle-xm for off mode rx wakeup)
Patch targeted for v3.5

 arch/arm/mach-omap2/mux.c|3 +-
 arch/arm/mach-omap2/mux.h|   11 +++
 arch/arm/mach-omap2/serial.c |   65 +++--
 3 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 65c3391..d937ddd 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -217,8 +217,7 @@ static int __init _omap_mux_get_by_name(struct 
omap_mux_partition *partition,
return -ENODEV;
 }
 
-static int __init
-omap_mux_get_by_name(const char *muxname,
+int __init omap_mux_get_by_name(const char *muxname,
struct omap_mux_partition **found_partition,
struct omap_mux **found_mux)
 {
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 69fe060..471e62a 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -59,6 +59,7 @@
 #define OMAP_PIN_OFF_WAKEUPENABLE  OMAP_WAKEUP_EN
 
 #define OMAP_MODE_GPIO(x)  (((x)  OMAP_MUX_MODE7) == OMAP_MUX_MODE4)
+#define OMAP_MODE_UART(x)  (((x)  OMAP_MUX_MODE7) == OMAP_MUX_MODE0)
 
 /* Flags for omapX_mux_init */
 #define OMAP_PACKAGE_MASK  0x
@@ -225,8 +226,18 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int 
nr_pads);
  */
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
 
+int omap_mux_get_by_name(const char *muxname,
+   struct omap_mux_partition **found_partition,
+   struct omap_mux **found_mux);
 #else
 
+static inline int omap_mux_get_by_name(const char *muxname,
+   struct omap_mux_partition **found_partition,
+   struct omap_mux **found_mux)
+{
+   return 0;
+}
+
 static inline int omap_mux_init_gpio(int gpio, int val)
 {
return 0;
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 9fc2f44..2dc50e7 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -57,6 +57,7 @@ struct omap_uart_state {
 
struct list_head node;
struct omap_hwmod *oh;
+   struct omap_device_pad default_omap_uart_pads[2];
 };
 
 static LIST_HEAD(uart_list);
@@ -126,11 +127,68 @@ static void omap_uart_set_smartidle(struct 
platform_device *pdev) {}
 #endif /* CONFIG_PM */
 
 #ifdef CONFIG_OMAP_MUX
-static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
+
+#define OMAP_UART_DEFAULT_PAD_NAME_LEN 28
+static char rx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN],
+   tx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN] __initdata;
+
+static void  __init
+omap_serial_fill_uart_tx_rx_pads(struct omap_board_data *bdata,
+   struct omap_uart_state *uart)
+{
+   uart-default_omap_uart_pads[0].name = rx_pad_name;
+   uart-default_omap_uart_pads[0].flags = OMAP_DEVICE_PAD_REMUX

[PATCH v2] OMAP2+: UART: Add mechanism to probe uart pins and configure rx wakeup

2012-05-10 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The commit (bce492c0  ARM: OMAP2+: UART: Fix incorrect population of
default uart pads) removed default uart pads that where getting populated
and which was making rx pin wakeup capable. If uart pads was used in
different mode by any other module then it would fail since the default
pads took over all the uart pins forcefully. With removal of default pads
the rx_pad wakeup for console uart while waking up from off mode is broken.

Utilise the mux api available to probe the availability of mux pins
in uart mode and probe for availability of uart pin in mux mode0
if uart is available as uart pin itself then configure rx pin
as wakeup capable.

This patch itself doesn't cater to all boards. Boards using uart rx wakeup
mechanism should ensure the usage of omap_serial_init_port by configuring
required uart ports and pass necessary mux data, till then this probing of
uart pins can cater to enabling of rx pad wakeup to most of the boards.

This patch can also throw some boot warning from _omap_mux_get_by_name
if pin is requested for availability is not present while dynamically probing
the uart pins availability such boot warnings can be addressed only when board
files are patched with omap_serial_init_port calls passing the right pads
needed for a given port.

Discussion Threads for reference:
http://www.spinics.net/lists/linux-omap/msg69859.html
http://www.spinics.net/lists/linux-omap/msg68659.html

Cc: Felipe Balbi ba...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Russ Dill russ.d...@gmail.com
Cc: Tony Lindgren t...@atomide.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Ameya Palande ameya.pala...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---

Patching of all board files would be difficult as even I am not aware of all
omap-board schematics and uart port usage. So individual board file can be
enabled accordingly for uart usage by calling omap_serial_init_port call
with right mux data.

for testing: Patch based on v3.4-rc6
(tested on beagle-xm for off mode rx wakeup)
Patch targeted for v3.5

 arch/arm/mach-omap2/mux.c|3 +-
 arch/arm/mach-omap2/mux.h|   10 ++
 arch/arm/mach-omap2/serial.c |   65 +++--
 3 files changed, 72 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 65c3391..d937ddd 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -217,8 +217,7 @@ static int __init _omap_mux_get_by_name(struct 
omap_mux_partition *partition,
return -ENODEV;
 }
 
-static int __init
-omap_mux_get_by_name(const char *muxname,
+int __init omap_mux_get_by_name(const char *muxname,
struct omap_mux_partition **found_partition,
struct omap_mux **found_mux)
 {
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 69fe060..68927f1 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -225,8 +225,18 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int 
nr_pads);
  */
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
 
+int omap_mux_get_by_name(const char *muxname,
+   struct omap_mux_partition **found_partition,
+   struct omap_mux **found_mux);
 #else
 
+static inline int omap_mux_get_by_name(const char *muxname,
+   struct omap_mux_partition **found_partition,
+   struct omap_mux **found_mux)
+{
+   return 0;
+}
+
 static inline int omap_mux_init_gpio(int gpio, int val)
 {
return 0;
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 9fc2f44..c097317 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -57,6 +57,7 @@ struct omap_uart_state {
 
struct list_head node;
struct omap_hwmod *oh;
+   struct omap_device_pad default_omap_uart_pads[2];
 };
 
 static LIST_HEAD(uart_list);
@@ -126,11 +127,68 @@ static void omap_uart_set_smartidle(struct 
platform_device *pdev) {}
 #endif /* CONFIG_PM */
 
 #ifdef CONFIG_OMAP_MUX
-static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
+
+#define OMAP_UART_DEFAULT_PAD_NAME_LEN 28
+static char rx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN],
+   tx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN] __initdata;
+
+static void  __init
+omap_serial_fill_uart_tx_rx_pads(struct omap_board_data *bdata,
+   struct omap_uart_state *uart)
+{
+   uart-default_omap_uart_pads[0].name = rx_pad_name;
+   uart-default_omap_uart_pads[0].flags = OMAP_DEVICE_PAD_REMUX |
+   OMAP_DEVICE_PAD_WAKEUP;
+   uart-default_omap_uart_pads[0].enable = OMAP_PIN_INPUT |
+   OMAP_MUX_MODE0;
+   uart-default_omap_uart_pads[0].idle = OMAP_PIN_INPUT | OMAP_MUX_MODE0;
+   uart-default_omap_uart_pads[1].name = tx_pad_name;
+   uart

[PATCH v4 0/2] ARM: omap_hwmod: add api to enable/disable module level wakeup

2012-05-08 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On omap2/3 module level wakeup is handled using PM_WKEN registers.
Expand the hwmod framework to handle the module level wakeup enable 
registers.

Patch series based on:
git://git.pwsan.com/linux-2.6 hwmod_soc_conditional_cleanup_3.5

Tested on Beagle-xm by enabling and disabling uart wakeups from sysfs
Series depends on following patches for testing.
http://marc.info/?l=linux-omapm=133527588923598w=2
http://marc.info/?l=linux-omapm=133518614022144w=2

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Tero Kristo t-kri...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Changes from v3:
---
Using hwmod soc init support to populate soc specific
funcs.
http://www.spinics.net/lists/linux-omap/msg69676.html


Govindraj.R (2):
  ARM: OMAP2/3: omap_hwmod: Add api to enable/disable module level
wakeup events
  ARM: omap3: pm: Remove uart module level wakeup configurations

 arch/arm/mach-omap2/omap_hwmod.c   |   29 +
 arch/arm/mach-omap2/pm34xx.c   |   14 +-
 arch/arm/mach-omap2/prm2xxx_3xxx.c |   16 
 arch/arm/mach-omap2/prm2xxx_3xxx.h |9 +
 4 files changed, 59 insertions(+), 9 deletions(-)

-- 
1.7.9

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


[PATCH v4 1/2] ARM: OMAP2/3: omap_hwmod: Add api to enable/disable module level wakeup events

2012-05-08 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On 24xx/34xx/36xx Module level wakeup events are enabled/disabled using
PM_WKEN1_CORE/PM_WKEN_PER regs.

Add soc specific api to control the module level wakeup mechanism in hwmod
layer. omap_hwmod_enable/disable_wakeup is used from serial.c which should
configure PM_WKEN register to enable or disable the module level wakeup.

Cc: Tero Kristo t-kri...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c   |   29 +
 arch/arm/mach-omap2/prm2xxx_3xxx.c |   16 
 arch/arm/mach-omap2/prm2xxx_3xxx.h |9 +
 3 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index acc616c..e82bf80 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -186,6 +186,7 @@ struct omap_hwmod_soc_ops {
int (*is_hardreset_asserted)(struct omap_hwmod *oh,
 struct omap_hwmod_rst_info *ohri);
int (*init_clkdm)(struct omap_hwmod *oh);
+   void (*module_wakeup)(struct omap_hwmod *oh, bool set_wake);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -453,6 +454,27 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 
autoidle,
 }
 
 /**
+ * _enable_module_level_wakeup - enable/disable module level wakeup on hwmod.
+ * @oh: struct omap_hwmod *
+ * @set_wake: bool value indicating to set (true) or clear (false) module level
+ * wakeup enable
+ *
+ * Set or clear the  module level wakeup capability the
+ * hwmod @oh. This function configures th PM_WKEN reg bits if they
+ * are available from hwmod. No return value
+ */
+static void _enable_module_level_wakeup(struct omap_hwmod *oh, bool set_wake)
+{
+   if (oh-prcm.omap2.module_offs  oh-prcm.omap2.prcm_reg_id 
+   oh-prcm.omap2.idlest_idle_bit)
+   omap2_prm_enable_prcm_module_wakeup(
+   oh-prcm.omap2.module_offs,
+   oh-prcm.omap2.prcm_reg_id,
+   oh-prcm.omap2.idlest_idle_bit,
+   set_wake);
+}
+
+/**
  * _set_idle_ioring_wakeup - enable/disable IO pad wakeup on hwmod idle for mux
  * @oh: struct omap_hwmod *
  * @set_wake: bool value indicating to set (true) or clear (false) wakeup 
enable
@@ -3242,6 +3264,9 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   if (soc_ops.module_wakeup)
+   soc_ops.module_wakeup(oh, true);
+
_set_idle_ioring_wakeup(oh, true);
spin_unlock_irqrestore(oh-_lock, flags);
 
@@ -3275,6 +3300,9 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   if (soc_ops.module_wakeup)
+   soc_ops.module_wakeup(oh, false);
+
_set_idle_ioring_wakeup(oh, false);
spin_unlock_irqrestore(oh-_lock, flags);
 
@@ -3561,6 +3589,7 @@ void __init omap_hwmod_init(void)
soc_ops.assert_hardreset = _omap2_assert_hardreset;
soc_ops.deassert_hardreset = _omap2_deassert_hardreset;
soc_ops.is_hardreset_asserted = _omap2_is_hardreset_asserted;
+   soc_ops.module_wakeup = _enable_module_level_wakeup;
} else if (cpu_is_omap44xx()) {
soc_ops.enable_module = _omap4_enable_module;
soc_ops.disable_module = _omap4_disable_module;
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c 
b/arch/arm/mach-omap2/prm2xxx_3xxx.c
index 9ce7654..85a753e 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -28,6 +28,10 @@
 #include prm-regbits-24xx.h
 #include prm-regbits-34xx.h
 
+static const u8 pm_wken_offs[] = {
+   PM_WKEN1, OMAP24XX_PM_WKEN2
+};
+
 static const struct omap_prcm_irq omap3_prcm_irqs[] = {
OMAP_PRCM_IRQ(wkup,   0,  0),
OMAP_PRCM_IRQ(io, 9,  1),
@@ -91,6 +95,18 @@ u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 
idx)
return omap2_prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
 }
 
+void omap2_prm_enable_prcm_module_wakeup(s16 prcm_mod, u8 prm_reg_id,
+   u8 prm_reg_shift, bool set_wake)
+{
+   if (prm_reg_id  (prm_reg_id = ARRAY_SIZE(pm_wken_offs))) {
+   if (set_wake)
+   omap2_prm_set_mod_reg_bits(1  prm_reg_shift,
+   prcm_mod, pm_wken_offs[prm_reg_id - 1]);
+   else
+   omap2_prm_clear_mod_reg_bits(1  prm_reg_shift,
+   prcm_mod, pm_wken_offs[prm_reg_id - 1

[PATCH v4 2/2] ARM: omap3: pm: Remove uart module level wakeup configurations

2012-05-08 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The uart module level wakeups enabling and disabling
are now handled from uart driver itself remove the uart module
level configurations from pm code.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Tero Kristo t-kri...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/pm34xx.c |   14 +-
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 703bd10..7a19498 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -529,8 +529,6 @@ static void __init omap3_d2d_idle(void)
 
 static void __init prcm_setup_regs(void)
 {
-   u32 omap3630_en_uart4_mask = cpu_is_omap3630() ?
-   OMAP3630_EN_UART4_MASK : 0;
u32 omap3630_grpsel_uart4_mask = cpu_is_omap3630() ?
OMAP3630_GRPSEL_UART4_MASK : 0;
 
@@ -562,13 +560,11 @@ static void __init prcm_setup_regs(void)
OMAP3430_DSS_MOD, PM_WKEN);
 
/* Enable wakeups in PER */
-   omap2_prm_write_mod_reg(omap3630_en_uart4_mask |
- OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK |
- OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK |
- OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK |
- OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
- OMAP3430_EN_MCBSP4_MASK,
- OMAP3430_PER_MOD, PM_WKEN);
+   omap2_prm_write_mod_reg(OMAP3430_EN_GPIO2_MASK |
+   OMAP3430_EN_GPIO3_MASK | OMAP3430_EN_GPIO4_MASK |
+   OMAP3430_EN_GPIO5_MASK | OMAP3430_EN_GPIO6_MASK |
+   OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
+   OMAP3430_EN_MCBSP4_MASK, OMAP3430_PER_MOD, PM_WKEN);
/* and allow them to wake up MPU */
omap2_prm_write_mod_reg(omap3630_grpsel_uart4_mask |
  OMAP3430_GRPSEL_GPIO2_MASK |
-- 
1.7.9

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


[PATCH 1/2 v4] ARM: OMAP2+: omap_hwmod: Add api to enable/disable module level wakeup events

2012-04-25 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On 24xx/34xx/36xx Module level wakeup events are enabled/disabled using
PM_WKEN1_CORE/PM_WKEN_PER regs.

Add api to control the module level wakeup mechanism from info provided from
hwmod data.

omap_hwmod_enable/disable_wakeup is used from serial.c which should
configure PM_WKEN register to enable or disable the module level wakeup.

Cc: Tero Kristo t-kri...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c   |   23 +++
 arch/arm/mach-omap2/prm2xxx_3xxx.c |   16 
 arch/arm/mach-omap2/prm2xxx_3xxx.h |9 +
 3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2c27fdb..25f306b 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -382,6 +382,27 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 
autoidle,
 }
 
 /**
+ * _enable_module_level_wakeup - enable/disable module level wakeup on hwmod.
+ * @oh: struct omap_hwmod *
+ * @set_wake: bool value indicating to set (true) or clear (false) module level
+ * wakeup enable
+ *
+ * Set or clear the  module level wakeup capability the
+ * hwmod @oh. This function configures th PM_WKEN reg bits if they
+ * are available from hwmod. No return value
+ */
+static void _enable_module_level_wakeup(struct omap_hwmod *oh, bool set_wake)
+{
+   if (oh-prcm.omap2.module_offs  oh-prcm.omap2.prcm_reg_id 
+   oh-prcm.omap2.idlest_idle_bit)
+   omap2_prm_enable_prcm_module_wakeup(
+   oh-prcm.omap2.module_offs,
+   oh-prcm.omap2.prcm_reg_id,
+   oh-prcm.omap2.idlest_idle_bit,
+   set_wake);
+}
+
+/**
  * _set_idle_ioring_wakeup - enable/disable IO pad wakeup on hwmod idle for mux
  * @oh: struct omap_hwmod *
  * @set_wake: bool value indicating to set (true) or clear (false) wakeup 
enable
@@ -2471,6 +2492,7 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, true);
_set_idle_ioring_wakeup(oh, true);
spin_unlock_irqrestore(oh-_lock, flags);
 
@@ -2504,6 +2526,7 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, false);
_set_idle_ioring_wakeup(oh, false);
spin_unlock_irqrestore(oh-_lock, flags);
 
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c 
b/arch/arm/mach-omap2/prm2xxx_3xxx.c
index 9ce7654..85a753e 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -28,6 +28,10 @@
 #include prm-regbits-24xx.h
 #include prm-regbits-34xx.h
 
+static const u8 pm_wken_offs[] = {
+   PM_WKEN1, OMAP24XX_PM_WKEN2
+};
+
 static const struct omap_prcm_irq omap3_prcm_irqs[] = {
OMAP_PRCM_IRQ(wkup,   0,  0),
OMAP_PRCM_IRQ(io, 9,  1),
@@ -91,6 +95,18 @@ u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 
idx)
return omap2_prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
 }
 
+void omap2_prm_enable_prcm_module_wakeup(s16 prcm_mod, u8 prm_reg_id,
+   u8 prm_reg_shift, bool set_wake)
+{
+   if (prm_reg_id  (prm_reg_id = ARRAY_SIZE(pm_wken_offs))) {
+   if (set_wake)
+   omap2_prm_set_mod_reg_bits(1  prm_reg_shift,
+   prcm_mod, pm_wken_offs[prm_reg_id - 1]);
+   else
+   omap2_prm_clear_mod_reg_bits(1  prm_reg_shift,
+   prcm_mod, pm_wken_offs[prm_reg_id - 1]);
+   }
+}
 
 /**
  * omap2_prm_is_hardreset_asserted - read the HW reset line state of
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.h 
b/arch/arm/mach-omap2/prm2xxx_3xxx.h
index 70ac2a1..49a185a 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.h
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.h
@@ -289,6 +289,13 @@ static inline int omap2_prm_deassert_hardreset(s16 
prm_mod, u8 rst_shift,
not suppose to be used on omap4\n);
return 0;
 }
+static inline void omap2_prm_enable_prcm_module_wakeup(s16 prcm_mod,
+   u8 prm_reg_id, u8 prm_reg_shift, bool set_wake)
+{
+   WARN(1, prm: omap2xxx/omap3xxx specific function and 
+   not suppose to be used on omap4\n);
+   return 0;
+}
 #else
 /* Power/reset management domain register get/set */
 extern u32 omap2_prm_read_mod_reg(s16 module, u16 idx);
@@ -297,6 +304,8 @@ extern u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, 
s16 module, s16 idx);
 extern u32 omap2_prm_set_mod_reg_bits(u32

[PATCH v3 1/2] ARM: OMAP2+: omap_hwmod: Add api to enable/disable module level wakeup events

2012-04-24 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On 24xx/34xx/36xx Module level wakeup events are enabled/disabled using
PM_WKEN1_CORE/PM_WKEN_PER regs.

Add api to control the module level wakeup mechanism from info provided from
hwmod data.

omap_hwmod_enable/disable_wakeup is used from serial.c which should
configure PM_WKEN register to enable or disable the module level wakeup.

Cc: Tero Kristo t-kri...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c   |   22 ++
 arch/arm/mach-omap2/prm2xxx_3xxx.c |   16 
 arch/arm/mach-omap2/prm2xxx_3xxx.h |9 +
 3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2c27fdb..4f10619 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -382,6 +382,26 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 
autoidle,
 }
 
 /**
+ * _enable_module_level_wakeup - enable/disable module level wakeup on hwmod.
+ * @oh: struct omap_hwmod *
+ * @set_wake: bool value indicating to set (true) or clear (false) module level
+ * wakeup enable
+ *
+ * Set or clear the  module level wakeup capability the
+ * hwmod @oh. This function configures th PM_WKEN reg bits if they
+ * are available from hwmod. No return value
+ */
+static void _enable_module_level_wakeup(struct omap_hwmod *oh, bool set_wake)
+{
+   if (cpu_is_omap24xx() || cpu_is_omap34xx())
+   omap2_prm_enable_prcm_module_wakeup(
+   oh-prcm.omap2.module_offs,
+   oh-prcm.omap2.prcm_reg_id,
+   oh-prcm.omap2.idlest_idle_bit,
+   set_wake);
+}
+
+/**
  * _set_idle_ioring_wakeup - enable/disable IO pad wakeup on hwmod idle for mux
  * @oh: struct omap_hwmod *
  * @set_wake: bool value indicating to set (true) or clear (false) wakeup 
enable
@@ -2471,6 +2491,7 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, true);
_set_idle_ioring_wakeup(oh, true);
spin_unlock_irqrestore(oh-_lock, flags);
 
@@ -2504,6 +2525,7 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, false);
_set_idle_ioring_wakeup(oh, false);
spin_unlock_irqrestore(oh-_lock, flags);
 
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c 
b/arch/arm/mach-omap2/prm2xxx_3xxx.c
index 9ce7654..85a753e 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -28,6 +28,10 @@
 #include prm-regbits-24xx.h
 #include prm-regbits-34xx.h
 
+static const u8 pm_wken_offs[] = {
+   PM_WKEN1, OMAP24XX_PM_WKEN2
+};
+
 static const struct omap_prcm_irq omap3_prcm_irqs[] = {
OMAP_PRCM_IRQ(wkup,   0,  0),
OMAP_PRCM_IRQ(io, 9,  1),
@@ -91,6 +95,18 @@ u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 
idx)
return omap2_prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
 }
 
+void omap2_prm_enable_prcm_module_wakeup(s16 prcm_mod, u8 prm_reg_id,
+   u8 prm_reg_shift, bool set_wake)
+{
+   if (prm_reg_id  (prm_reg_id = ARRAY_SIZE(pm_wken_offs))) {
+   if (set_wake)
+   omap2_prm_set_mod_reg_bits(1  prm_reg_shift,
+   prcm_mod, pm_wken_offs[prm_reg_id - 1]);
+   else
+   omap2_prm_clear_mod_reg_bits(1  prm_reg_shift,
+   prcm_mod, pm_wken_offs[prm_reg_id - 1]);
+   }
+}
 
 /**
  * omap2_prm_is_hardreset_asserted - read the HW reset line state of
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.h 
b/arch/arm/mach-omap2/prm2xxx_3xxx.h
index 70ac2a1..49a185a 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.h
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.h
@@ -289,6 +289,13 @@ static inline int omap2_prm_deassert_hardreset(s16 
prm_mod, u8 rst_shift,
not suppose to be used on omap4\n);
return 0;
 }
+static inline void omap2_prm_enable_prcm_module_wakeup(s16 prcm_mod,
+   u8 prm_reg_id, u8 prm_reg_shift, bool set_wake)
+{
+   WARN(1, prm: omap2xxx/omap3xxx specific function and 
+   not suppose to be used on omap4\n);
+   return 0;
+}
 #else
 /* Power/reset management domain register get/set */
 extern u32 omap2_prm_read_mod_reg(s16 module, u16 idx);
@@ -297,6 +304,8 @@ extern u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, 
s16 module, s16 idx);
 extern u32 omap2_prm_set_mod_reg_bits(u32 bits, s16 module, s16 idx);
 extern u32 omap2_prm_clear_mod_reg_bits

[PATCH v3 2/2] ARM: omap3: pm: Remove uart module level wakeup configurations

2012-04-24 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The uart module level wakeups enabling and disabling
are now handled from uart driver itself remove the uart module
level configurations from pm code.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Tero Kristo t-kri...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/pm34xx.c |   14 +-
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 703bd10..7a19498 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -529,8 +529,6 @@ static void __init omap3_d2d_idle(void)
 
 static void __init prcm_setup_regs(void)
 {
-   u32 omap3630_en_uart4_mask = cpu_is_omap3630() ?
-   OMAP3630_EN_UART4_MASK : 0;
u32 omap3630_grpsel_uart4_mask = cpu_is_omap3630() ?
OMAP3630_GRPSEL_UART4_MASK : 0;
 
@@ -562,13 +560,11 @@ static void __init prcm_setup_regs(void)
OMAP3430_DSS_MOD, PM_WKEN);
 
/* Enable wakeups in PER */
-   omap2_prm_write_mod_reg(omap3630_en_uart4_mask |
- OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK |
- OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK |
- OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK |
- OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
- OMAP3430_EN_MCBSP4_MASK,
- OMAP3430_PER_MOD, PM_WKEN);
+   omap2_prm_write_mod_reg(OMAP3430_EN_GPIO2_MASK |
+   OMAP3430_EN_GPIO3_MASK | OMAP3430_EN_GPIO4_MASK |
+   OMAP3430_EN_GPIO5_MASK | OMAP3430_EN_GPIO6_MASK |
+   OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
+   OMAP3430_EN_MCBSP4_MASK, OMAP3430_PER_MOD, PM_WKEN);
/* and allow them to wake up MPU */
omap2_prm_write_mod_reg(omap3630_grpsel_uart4_mask |
  OMAP3430_GRPSEL_GPIO2_MASK |
-- 
1.7.9

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


[PATCH v3 0/2] ARM: omap_hwmod: add api to enable/disable module level wakeup

2012-04-24 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On omap2/3 module level wakeup is handled using PM_WKEN registers.
Expand the hwmod framework to handle the module level wakeup enable 
registers.

Tested on Beagle-xm by enabling and disabling uart wakeups from sysfs
Series depends on following patches for testing.
http://marc.info/?l=linux-omapm=133527588923598w=2
http://marc.info/?l=linux-omapm=133518614022144w=2

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Tero Kristo t-kri...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Govindraj.R (2):
  ARM: OMAP2+: omap_hwmod: Add api to enable/disable module level
wakeup events
  ARM: omap3: pm: Remove uart module level wakeup configurations

 arch/arm/mach-omap2/omap_hwmod.c   |   22 ++
 arch/arm/mach-omap2/pm34xx.c   |   14 +-
 arch/arm/mach-omap2/prm2xxx_3xxx.c |   16 
 arch/arm/mach-omap2/prm2xxx_3xxx.h |9 +
 4 files changed, 52 insertions(+), 9 deletions(-)

-- 
1.7.9

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


[PATCH] tty: omap-serial: configure wakeup mechanism based on port usage.

2012-04-23 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

With set_wakeup port ops availability from serial_core layer
which will be called when port is opened with state as true
indicating the wakeups can be enabled for this port and state
as false while port shutdown where we can disable the wakeups.

But wakeup can be also enabled/disabled when requested from sysfs.
If disabled wakeup will be disabled while entering suspend and be
enabled back based on pm state while resuming.

Thanks to Kevin Hilman khil...@ti.com for suggesting this.
Discussion References:
http://www.spinics.net/lists/linux-omap/msg67764.html
http://www.spinics.net/lists/linux-omap/msg67838.html

Cc: Paul Walmsley p...@pwsan.com
Signed-off-by: Kevin Hilman khil...@ti.com
[suggestion and modification to enable and disable wakeup
capability based on port usage]
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---

Patch is tested using the patch as in here[1]
Tested on beagle-XM by enabling and disabling wakeups
from sysfs and opening and closing a uart port.

[1]: http://marc.info/?l=linux-omapm=133518614022144w=2


 arch/arm/plat-omap/include/plat/omap-serial.h |1 -
 drivers/tty/serial/omap-serial.c  |   45 +++--
 2 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 9ff..8e6d734 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -130,7 +130,6 @@ struct uart_omap_port {
unsigned long   port_activity;
u32 context_loss_cnt;
u32 errata;
-   u8  wakeups_enabled;
 
struct pm_qos_request   pm_qos_request;
u32 latency;
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index d00b38e..b8f328e 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -525,6 +525,7 @@ static int serial_omap_startup(struct uart_port *port)
dev_dbg(up-port.dev, serial_omap_startup+%d\n, up-port.line);
 
pm_runtime_get_sync(up-pdev-dev);
+
/*
 * Clear the FIFO buffers and disable them.
 * (they will be reenabled in set_termios())
@@ -910,11 +911,27 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
dev_dbg(up-port.dev, serial_omap_set_termios+%d\n, up-port.line);
 }
 
+static int serial_omap_set_wake(struct uart_port *port, unsigned int state)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   struct omap_uart_port_info *pdata = up-pdev-dev.platform_data;
+   u8 enable_wakeup = false;
+
+   if (state)
+   enable_wakeup = true;
+
+   if (pdata-enable_wakeup)
+   pdata-enable_wakeup(up-pdev, enable_wakeup);
+
+   return 0;
+}
+
 static void
 serial_omap_pm(struct uart_port *port, unsigned int state,
   unsigned int oldstate)
 {
struct uart_omap_port *up = (struct uart_omap_port *)port;
+   struct omap_uart_port_info *pdata = up-pdev-dev.platform_data;
unsigned char efr;
 
dev_dbg(up-port.dev, serial_omap_pm+%d\n, up-port.line);
@@ -930,12 +947,8 @@ serial_omap_pm(struct uart_port *port, unsigned int state,
serial_out(up, UART_EFR, efr);
serial_out(up, UART_LCR, 0);
 
-   if (!device_may_wakeup(up-pdev-dev)) {
-   if (!state)
-   pm_runtime_forbid(up-pdev-dev);
-   else
-   pm_runtime_allow(up-pdev-dev);
-   }
+   if (!state  pdata-enable_wakeup)
+   pdata-enable_wakeup(up-pdev, true);
 
pm_runtime_put(up-pdev-dev);
 }
@@ -1161,6 +1174,7 @@ static struct uart_ops serial_omap_pops = {
.shutdown   = serial_omap_shutdown,
.set_termios= serial_omap_set_termios,
.pm = serial_omap_pm,
+   .set_wake   = serial_omap_set_wake,
.type   = serial_omap_type,
.release_port   = serial_omap_release_port,
.request_port   = serial_omap_request_port,
@@ -1184,10 +1198,14 @@ static struct uart_driver serial_omap_reg = {
 static int serial_omap_suspend(struct device *dev)
 {
struct uart_omap_port *up = dev_get_drvdata(dev);
+   struct omap_uart_port_info *pdata = dev-platform_data;
 
if (up) {
uart_suspend_port(serial_omap_reg, up-port);
flush_work_sync(up-qos_work);
+
+   if (!device_may_wakeup(dev))
+   pdata-enable_wakeup(up-pdev, false);
}
 
return 0;
@@ -1476,6 +1494,9 @@ static int serial_omap_probe(struct platform_device *pdev)
if (ret != 0)
goto err_add_port;
 
+   if (omap_up_info-enable_wakeup)
+   omap_up_info-enable_wakeup(pdev, false);
+
pm_runtime_put(pdev-dev

[PATCH] tty: serial_core: Add mechanism to identify port closure.

2012-04-20 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Currently all low level uart driver register to serial_core layer
this core layer exposes various serial uart ops.

Currently the core layer provides startup and shutdown hooks
to low level driver, but in port suspend case the shutdown gets called
from uart_suspend_port this makes little difficult in low level driver
to any action specific to port closure.

For example if low level driver tries to disable uart platform
specific wakeups after port closure in low level driver it can be only done
in shutdown ops since this ops is called even in suspend case low level
driver needs some info whether the current shutdown ops is result of
port close or if its suspend ops.

To differentiate this expand the core layer uart_port info with closing flag
this flag is set to true during shutdown and set to false while port open.

Thus closing flag added with this patch can be used in low level driver to
identify the port close.

Discussion reference:
http://marc.info/?l=linux-omapm=133491321605924w=2

Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 drivers/tty/serial/serial_core.c |3 +++
 include/linux/serial_core.h  |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 9c4c05b..0dc246d 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1284,6 +1284,8 @@ static void uart_close(struct tty_struct *tty, struct 
file *filp)
uart_wait_until_sent(tty, uport-timeout);
}
 
+   state-uart_port-closing = true;
+
mutex_lock(port-mutex);
uart_shutdown(tty, state);
uart_flush_buffer(tty);
@@ -1518,6 +1520,7 @@ static int uart_open(struct tty_struct *tty, struct file 
*filp)
if (port-count == 1)
uart_change_pm(state, 0);
 
+   state-uart_port-closing = false;
/*
 * Start up the serial port.
 */
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 2db407a..f5cd1ee 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -381,6 +381,7 @@ struct uart_port {
unsigned char   irq_wake;
unsigned char   unused[2];
void*private_data;  /* generic platform 
data pointer */
+   unsigned char   closing;
 };
 
 static inline int serial_port_in(struct uart_port *up, int offset)
-- 
1.7.9

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


[PATCH v2 0/3] ARM: omap_hwmod: add api to enable/disable module level wakeup

2012-04-20 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On omap2/3 module level wakeup is handled using PM_WKEN registers.
Expand the hwmod framework to handle the module level wakeup enable 
registers.

Tested on Beagle-xm by enabling and disabling uart wakeups from sysfs
Series depends on following patch for testing.
http://marc.info/?l=linux-omapm=133457952909998w=2

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Tero Kristo t-kri...@ti.com

Govindraj.R (3):
  ARM: OMAP2+: omap_hwmod: Add interface to incorporate module level
wakeup
  ARM: OMAP2+: omap_hwmod: Add api to enable/disable module level
wakeup events
  ARM: omap3: pm: Remove uart module level wakeup configurations

 arch/arm/mach-omap2/omap_hwmod.c |   24 
 arch/arm/mach-omap2/omap_hwmod_2420_data.c   |6 ++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c   |6 ++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c   |8 
 arch/arm/mach-omap2/pm34xx.c |   14 +-
 arch/arm/mach-omap2/prm2xxx_3xxx.c   |8 
 arch/arm/mach-omap2/prm2xxx_3xxx.h   |9 +
 arch/arm/plat-omap/include/plat/omap_hwmod.h |4 
 8 files changed, 70 insertions(+), 9 deletions(-)

-- 
1.7.9

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


[PATCH v2 1/3] ARM: OMAP2+: omap_hwmod: Add interface to incorporate module level wakeup

2012-04-20 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On 24xx/34xx/36xx Module level wakeup events are enabled/disabled using
PM_WKEN1_CORE/PM_WKEN_PER regs. The module level wakeups are enabled by
default, by PRM soft reset default value of PM_WKEN reg is all one's which means
all module level wakeups are enabled.

However the wakeups can be enabled/disabled using sysfs entry example for uart:
echo disabled  /sys/devices/platform/omap/omap_uart.X/power/wakeup
[X=0,1,2,3]

So expand omap2 prcm structure to incorporate the PM_WKEN reg offset
and bit mask to control the module level wakeup. This info from hwmod
data can be used from hwmod framework in omap_hwmod_enable/disable_wakeup
api's to configure module level wakeups.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod_2420_data.c   |6 ++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c   |6 ++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c   |8 
 arch/arm/plat-omap/include/plat/omap_hwmod.h |4 
 4 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c 
b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index a5409ce..676274b 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -791,6 +791,8 @@ static struct omap_hwmod omap2420_uart1_hwmod = {
.module_bit = OMAP24XX_EN_UART1_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART1_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART1_MASK,
},
},
.slaves = omap2420_uart1_slaves,
@@ -816,6 +818,8 @@ static struct omap_hwmod omap2420_uart2_hwmod = {
.module_bit = OMAP24XX_EN_UART2_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART2_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART2_MASK,
},
},
.slaves = omap2420_uart2_slaves,
@@ -841,6 +845,8 @@ static struct omap_hwmod omap2420_uart3_hwmod = {
.module_bit = OMAP24XX_EN_UART3_SHIFT,
.idlest_reg_id = 2,
.idlest_idle_bit = OMAP24XX_EN_UART3_SHIFT,
+   .module_wakeup_offs = OMAP24XX_PM_WKEN2,
+   .module_wakeup_bit = OMAP24XX_ST_UART3_MASK,
},
},
.slaves = omap2420_uart3_slaves,
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c 
b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index c4f56cb..94d4463 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -864,6 +864,8 @@ static struct omap_hwmod omap2430_uart1_hwmod = {
.module_bit = OMAP24XX_EN_UART1_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART1_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART1_MASK,
},
},
.slaves = omap2430_uart1_slaves,
@@ -889,6 +891,8 @@ static struct omap_hwmod omap2430_uart2_hwmod = {
.module_bit = OMAP24XX_EN_UART2_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART2_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART2_MASK,
},
},
.slaves = omap2430_uart2_slaves,
@@ -914,6 +918,8 @@ static struct omap_hwmod omap2430_uart3_hwmod = {
.module_bit = OMAP24XX_EN_UART3_SHIFT,
.idlest_reg_id = 2,
.idlest_idle_bit = OMAP24XX_EN_UART3_SHIFT,
+   .module_wakeup_offs = OMAP24XX_PM_WKEN2,
+   .module_wakeup_bit = OMAP24XX_ST_UART3_MASK,
},
},
.slaves = omap2430_uart3_slaves,
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 34b9766d..9ed038d 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -1248,6 +1248,8 @@ static struct omap_hwmod omap3xxx_uart1_hwmod = {
.module_bit = OMAP3430_EN_UART1_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP3430_EN_UART1_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP3430_ST_UART1_MASK,
},
},
.slaves

[PATCH v2 2/3] ARM: OMAP2+: omap_hwmod: Add api to enable/disable module level wakeup events

2012-04-20 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On 24xx/34xx/36xx Module level wakeup events are enabled/disabled using
PM_WKEN1_CORE/PM_WKEN_PER regs.

Add api to control the module level wakeup mechanism from info provided from
hwmod data. If module level wakeups are available from hwmod data then they
have to be enabled/disabled as per driver request.

omap_hwmod_enable/disable_wakeup is used from serial.c which should
configure those registers to enable or disable the module level wakeup.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Tero Kristo t-kri...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c   |   24 
 arch/arm/mach-omap2/prm2xxx_3xxx.c |8 
 arch/arm/mach-omap2/prm2xxx_3xxx.h |9 +
 3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2c27fdb..0200daa 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -382,6 +382,28 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 
autoidle,
 }
 
 /**
+ * _enable_module_level_wakeup - enable/disable module level wakeup on hwmod.
+ * @oh: struct omap_hwmod *
+ * @set_wake: bool value indicating to set (true) or clear (false) module level
+ * wakeup enable
+ *
+ * Set or clear the  module level wakeup capability the
+ * hwmod @oh. This function configures th PM_WKEN reg bits if they
+ * are available from hwmod. No return value
+ */
+static void _enable_module_level_wakeup(struct omap_hwmod *oh, bool set_wake)
+{
+   if (oh-prcm.omap2.module_wakeup_offs 
+   oh-prcm.omap2.module_wakeup_bit 
+   oh-prcm.omap2.module_offs)
+   omap2_prm_enable_prcm_module_wakeup(
+   oh-prcm.omap2.module_wakeup_bit,
+   oh-prcm.omap2.module_offs,
+   oh-prcm.omap2.module_wakeup_offs,
+   set_wake);
+}
+
+/**
  * _set_idle_ioring_wakeup - enable/disable IO pad wakeup on hwmod idle for mux
  * @oh: struct omap_hwmod *
  * @set_wake: bool value indicating to set (true) or clear (false) wakeup 
enable
@@ -2471,6 +2493,7 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, true);
_set_idle_ioring_wakeup(oh, true);
spin_unlock_irqrestore(oh-_lock, flags);
 
@@ -2504,6 +2527,7 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, false);
_set_idle_ioring_wakeup(oh, false);
spin_unlock_irqrestore(oh-_lock, flags);
 
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c 
b/arch/arm/mach-omap2/prm2xxx_3xxx.c
index 9ce7654..2b38e34 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -91,6 +91,14 @@ u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 
idx)
return omap2_prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
 }
 
+void omap2_prm_enable_prcm_module_wakeup(u32 bits, s16 module, s16 idx,
+   bool set_wake)
+{
+   if (set_wake)
+   omap2_prm_set_mod_reg_bits(bits, module, idx);
+   else
+   omap2_prm_clear_mod_reg_bits(bits, module, idx);
+}
 
 /**
  * omap2_prm_is_hardreset_asserted - read the HW reset line state of
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.h 
b/arch/arm/mach-omap2/prm2xxx_3xxx.h
index 70ac2a1..1b4194d 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.h
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.h
@@ -289,6 +289,13 @@ static inline int omap2_prm_deassert_hardreset(s16 
prm_mod, u8 rst_shift,
not suppose to be used on omap4\n);
return 0;
 }
+static inline void omap2_prm_enable_prcm_module_wakeup(u32 bits, s16 module,
+   s16 idx, bool set_wake)
+{
+   WARN(1, prm: omap2xxx/omap3xxx specific function and 
+   not suppose to be used on omap4\n);
+   return 0;
+}
 #else
 /* Power/reset management domain register get/set */
 extern u32 omap2_prm_read_mod_reg(s16 module, u16 idx);
@@ -297,6 +304,8 @@ extern u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, 
s16 module, s16 idx);
 extern u32 omap2_prm_set_mod_reg_bits(u32 bits, s16 module, s16 idx);
 extern u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx);
 extern u32 omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask);
+extern void omap2_prm_enable_prcm_module_wakeup(u32 bits, s16 module,
+   s16 idx, bool set_wake);
 
 /* These omap2_ PRM functions apply to both OMAP2 and 3 */
 extern int omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift);
-- 
1.7.9

--
To unsubscribe from this list: send

[PATCH v2 3/3] ARM: omap3: pm: Remove uart module level wakeup configurations

2012-04-20 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The uart module level wakeups enabling and disabling
are now handled from uart driver itself remove the uart module
level configurations from pm code.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Tero Kristo t-kri...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/pm34xx.c |   14 +-
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 703bd10..7a19498 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -529,8 +529,6 @@ static void __init omap3_d2d_idle(void)
 
 static void __init prcm_setup_regs(void)
 {
-   u32 omap3630_en_uart4_mask = cpu_is_omap3630() ?
-   OMAP3630_EN_UART4_MASK : 0;
u32 omap3630_grpsel_uart4_mask = cpu_is_omap3630() ?
OMAP3630_GRPSEL_UART4_MASK : 0;
 
@@ -562,13 +560,11 @@ static void __init prcm_setup_regs(void)
OMAP3430_DSS_MOD, PM_WKEN);
 
/* Enable wakeups in PER */
-   omap2_prm_write_mod_reg(omap3630_en_uart4_mask |
- OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK |
- OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK |
- OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK |
- OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
- OMAP3430_EN_MCBSP4_MASK,
- OMAP3430_PER_MOD, PM_WKEN);
+   omap2_prm_write_mod_reg(OMAP3430_EN_GPIO2_MASK |
+   OMAP3430_EN_GPIO3_MASK | OMAP3430_EN_GPIO4_MASK |
+   OMAP3430_EN_GPIO5_MASK | OMAP3430_EN_GPIO6_MASK |
+   OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
+   OMAP3430_EN_MCBSP4_MASK, OMAP3430_PER_MOD, PM_WKEN);
/* and allow them to wake up MPU */
omap2_prm_write_mod_reg(omap3630_grpsel_uart4_mask |
  OMAP3430_GRPSEL_GPIO2_MASK |
-- 
1.7.9

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


[PATCH] tty: omap-serial: Keep the wakeup mechanism enabled by default

2012-04-16 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The wakeups can be left enabled by default and should be disabled
only when disabled from sysfs and while entering suspend.

Thanks to Kevin Hilman khil...@ti.com for suggesting this.
Discussion References:
http://www.spinics.net/lists/linux-omap/msg67764.html
http://www.spinics.net/lists/linux-omap/msg67838.html

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 drivers/tty/serial/omap-serial.c |   30 +++---
 1 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index d00b38e..4a92447 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -930,13 +930,6 @@ serial_omap_pm(struct uart_port *port, unsigned int state,
serial_out(up, UART_EFR, efr);
serial_out(up, UART_LCR, 0);
 
-   if (!device_may_wakeup(up-pdev-dev)) {
-   if (!state)
-   pm_runtime_forbid(up-pdev-dev);
-   else
-   pm_runtime_allow(up-pdev-dev);
-   }
-
pm_runtime_put(up-pdev-dev);
 }
 
@@ -1184,10 +1177,16 @@ static struct uart_driver serial_omap_reg = {
 static int serial_omap_suspend(struct device *dev)
 {
struct uart_omap_port *up = dev_get_drvdata(dev);
+   struct omap_uart_port_info *pdata = dev-platform_data;
 
if (up) {
uart_suspend_port(serial_omap_reg, up-port);
flush_work_sync(up-qos_work);
+
+   if (!device_may_wakeup(dev)) {
+   pdata-enable_wakeup(up-pdev, false);
+   up-wakeups_enabled = false;
+   }
}
 
return 0;
@@ -1582,18 +1581,6 @@ static int serial_omap_runtime_suspend(struct device 
*dev)
if (pdata-get_context_loss_count)
up-context_loss_cnt = pdata-get_context_loss_count(dev);
 
-   if (device_may_wakeup(dev)) {
-   if (!up-wakeups_enabled) {
-   pdata-enable_wakeup(up-pdev, true);
-   up-wakeups_enabled = true;
-   }
-   } else {
-   if (up-wakeups_enabled) {
-   pdata-enable_wakeup(up-pdev, false);
-   up-wakeups_enabled = false;
-   }
-   }
-
/* Errata i291 */
if (up-use_dma  pdata-set_forceidle 
(up-errata  UART_ERRATA_i291_DMA_FORCEIDLE))
@@ -1618,6 +1605,11 @@ static int serial_omap_runtime_resume(struct device *dev)
serial_omap_restore_context(up);
}
 
+   if (!up-wakeups_enabled) {
+   pdata-enable_wakeup(up-pdev, true);
+   up-wakeups_enabled = true;
+   }
+
/* Errata i291 */
if (up-use_dma  pdata-set_noidle 
(up-errata  UART_ERRATA_i291_DMA_FORCEIDLE))
-- 
1.7.9

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


[PATCH 2/2] ARM: OMAP2+: omap_hwmod: Add api to enable/disable module level wakeup events

2012-04-16 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On 24xx/34xx/36xx Module level wakeup events are enabled/disabled using
PM_WKEN1_CORE/PM_WKEN_PER regs.

Add api to control the module level wakeup mechanism from info provided from
hwmod data. If module level wakeups are available from hwmod data then they
have to be enabled/disabled as per driver request.

omap_hwmod_enable/disable_wakeup is used from serial.c which should
act on those registers to enable or disable the module level wakeup

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c |   31 +++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2c27fdb..05576ae 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -382,6 +382,35 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 
autoidle,
 }
 
 /**
+ * _enable_module_level_wakeup - enable/disable module level wakeup on hwmod.
+ * @oh: struct omap_hwmod *
+ * @set_wake: bool value indicating to set (true) or clear (false) module level
+ * wakeup enable
+ *
+ * Set or clear the  module level wakeup capability the
+ * hwmod @oh. This function configures th PM_WKEN reg bits if they
+ * are available from hwmod. No return value
+ */
+static void _enable_module_level_wakeup(struct omap_hwmod *oh, bool set_wake)
+{
+   u32 v;
+
+   if (oh-prcm.omap2.module_wakeup_offs 
+   oh-prcm.omap2.module_wakeup_bit) {
+   v = omap2_prm_read_mod_reg(oh-prcm.omap2.module_offs,
+   oh-prcm.omap2.module_wakeup_offs);
+
+   if (set_wake)
+   v |= oh-prcm.omap2.module_wakeup_bit;
+   else
+   v = ~oh-prcm.omap2.module_wakeup_bit;
+
+   omap2_prm_write_mod_reg(v, oh-prcm.omap2.module_offs,
+   oh-prcm.omap2.module_wakeup_offs);
+   }
+}
+
+/**
  * _set_idle_ioring_wakeup - enable/disable IO pad wakeup on hwmod idle for mux
  * @oh: struct omap_hwmod *
  * @set_wake: bool value indicating to set (true) or clear (false) wakeup 
enable
@@ -2471,6 +2500,7 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, true);
_set_idle_ioring_wakeup(oh, true);
spin_unlock_irqrestore(oh-_lock, flags);
 
@@ -2504,6 +2534,7 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
}
 
+   _enable_module_level_wakeup(oh, false);
_set_idle_ioring_wakeup(oh, false);
spin_unlock_irqrestore(oh-_lock, flags);
 
-- 
1.7.9

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


[PATCH 0/2] ARM: omap_hwmod: add api to enable/disable module level wakeup

2012-04-16 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On omap2/3 module level wakeup is handled using PM_WKEN registers.
Expand the hwmod framework to handle the module level wakeup enable 
registers.

Tested on Beagle-xm by enabling and disabling uart wakeups from sysfs
Series depends on following patch for testing.
http://marc.info/?l=linux-omapm=133457952909998w=2

Govindraj.R (2):
  ARM: OMAP2+: omap_hwmod: Add interface to incorporate module level
wakeup
  ARM: OMAP2+: omap_hwmod: Add api to enable/disable module level
wakeup events

 arch/arm/mach-omap2/omap_hwmod.c |   31 ++
 arch/arm/mach-omap2/omap_hwmod_2420_data.c   |6 +
 arch/arm/mach-omap2/omap_hwmod_2430_data.c   |6 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c   |8 ++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |4 +++
 5 files changed, 55 insertions(+), 0 deletions(-)

-- 
1.7.9

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


[PATCH 1/2] ARM: OMAP2+: omap_hwmod: Add interface to incorporate module level wakeup

2012-04-16 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On 24xx/34xx/36xx Module level wakeup events are enabled/disabled using
PM_WKEN1_CORE/PM_WKEN_PER regs. The module level wakeups are enabled by
default from bootloader, however the wakeups can be enabled/disabled
using sysfs entry example for uart:
echo disabled  /sys/devices/platform/omap/omap_uart.X/power/wakeup
[X=0,1,2,3]

So expand omap2 prcm structure to incorporate the PM_WKEN reg offset
and bit mask to control the module level wakeup. This info from hwmod
data can be used hwmod framework omap_hwmod_enable/disable_wakeup.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod_2420_data.c   |6 ++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c   |6 ++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c   |8 
 arch/arm/plat-omap/include/plat/omap_hwmod.h |4 
 4 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c 
b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index a5409ce..676274b 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -791,6 +791,8 @@ static struct omap_hwmod omap2420_uart1_hwmod = {
.module_bit = OMAP24XX_EN_UART1_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART1_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART1_MASK,
},
},
.slaves = omap2420_uart1_slaves,
@@ -816,6 +818,8 @@ static struct omap_hwmod omap2420_uart2_hwmod = {
.module_bit = OMAP24XX_EN_UART2_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART2_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART2_MASK,
},
},
.slaves = omap2420_uart2_slaves,
@@ -841,6 +845,8 @@ static struct omap_hwmod omap2420_uart3_hwmod = {
.module_bit = OMAP24XX_EN_UART3_SHIFT,
.idlest_reg_id = 2,
.idlest_idle_bit = OMAP24XX_EN_UART3_SHIFT,
+   .module_wakeup_offs = OMAP24XX_PM_WKEN2,
+   .module_wakeup_bit = OMAP24XX_ST_UART3_MASK,
},
},
.slaves = omap2420_uart3_slaves,
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c 
b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index c4f56cb..94d4463 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -864,6 +864,8 @@ static struct omap_hwmod omap2430_uart1_hwmod = {
.module_bit = OMAP24XX_EN_UART1_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART1_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART1_MASK,
},
},
.slaves = omap2430_uart1_slaves,
@@ -889,6 +891,8 @@ static struct omap_hwmod omap2430_uart2_hwmod = {
.module_bit = OMAP24XX_EN_UART2_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP24XX_EN_UART2_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP24XX_ST_UART2_MASK,
},
},
.slaves = omap2430_uart2_slaves,
@@ -914,6 +918,8 @@ static struct omap_hwmod omap2430_uart3_hwmod = {
.module_bit = OMAP24XX_EN_UART3_SHIFT,
.idlest_reg_id = 2,
.idlest_idle_bit = OMAP24XX_EN_UART3_SHIFT,
+   .module_wakeup_offs = OMAP24XX_PM_WKEN2,
+   .module_wakeup_bit = OMAP24XX_ST_UART3_MASK,
},
},
.slaves = omap2430_uart3_slaves,
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 34b9766d..9ed038d 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -1248,6 +1248,8 @@ static struct omap_hwmod omap3xxx_uart1_hwmod = {
.module_bit = OMAP3430_EN_UART1_SHIFT,
.idlest_reg_id = 1,
.idlest_idle_bit = OMAP3430_EN_UART1_SHIFT,
+   .module_wakeup_offs = PM_WKEN1,
+   .module_wakeup_bit = OMAP3430_ST_UART1_MASK,
},
},
.slaves = omap3xxx_uart1_slaves,
@@ -1273,6 +1275,8 @@ static struct omap_hwmod omap3xxx_uart2_hwmod = {
.module_bit = OMAP3430_EN_UART2_SHIFT

[GIT PULL]: omap-serial updates for 3.4-rc

2012-04-10 Thread Govindraj.R
Hi Tony,

Please Pull the following omap uart changes.
Changes basically involves getting rid of cpu checks
for populating erratas and features and move the same
from serial.c to omap-serial.c, MVR reg is used to find
uart versions and errata flags are populated accordingly.

--
Thanks,
Govindraj.R

The following changes since commit 0034102808e0dbbf3a2394b82b1bb40b5778de9e:

  Linux 3.4-rc2 (2012-04-07 18:30:41 -0700)

are available in the git repository at:

  git://gitorious.org/linux-3-x/omap-serial.git for_3.4/uart_fixes

for you to fetch changes up to 6c34f211069409ea6d08b900eeaf86ef8efd0dca:

  OMAP2+: UART: replace omap34xx/omap4xx cpu checks with not omap24xx 
(2012-04-10 15:14:58 +0530)


Govindraj.R (3):
  OMAP2+: UART: Remove cpu checks for populating errata flags
  OMAP2+: UART: enable tx wakeup bit for wer reg
  OMAP2+: UART: replace omap34xx/omap4xx cpu checks with not omap24xx

 arch/arm/mach-omap2/serial.c  |   13 +---
 arch/arm/plat-omap/include/plat/omap-serial.h |9 +++-
 drivers/tty/serial/omap-serial.c  |   83 -
 3 files changed, 91 insertions(+), 14 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] OMAP2+: UART: Fix usage of default mux pads

2012-04-10 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

We populating default uart mux pins if no mux data is provided
by board files. But were not probing the availability of uart pins
in tx/rx mode i.e. mux mode0. If particular pin is used for any other
purpose then default pads were breaking those peripherals e.g. uart2
pin was used as gpio nreset pin ehci on beagle board.

So remove the default adding procedure and probe the pins before
using them as uart pins. Determine if uart pins are used in uart mux_mode0
then configure rx pin for wakeup capability.

Testing updates:
Boot tested on 3430SDP
Tested on beagle-xm with ehci module which needs uart pin muxed as gpio
line for nreset sequence.

RX pad wakeup after enabling off mode in cpu_idle path and suspend path
tested - 3430SDP  Beagle-XM

Govindraj.R (2):
  OMAP2+: UART: Fix incorrect population of default uart pads
  OMAP2+: UART: Add mechanism to probe uart pins and configure rx
wakeup

 arch/arm/mach-omap2/mux.c|3 +-
 arch/arm/mach-omap2/mux.h|   10 +++
 arch/arm/mach-omap2/serial.c |  164 +-
 3 files changed, 61 insertions(+), 116 deletions(-)

-- 
1.7.9

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


[PATCH 1/2] OMAP2+: UART: Fix incorrect population of default uart pads

2012-04-10 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The following commit:
(7496ba3  ARM: OMAP2+: UART: Add default mux for all uarts)
added default pads for all uarts. But not all boards tend to
use all uarts and most of unused uart pins are muxed for
other purpose. This commit breaks the modules which where trying
to use unused uart pins on their boards.

So remove the default pads adding.

Cc: Felipe Balbi ba...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Russ Dill russ.d...@gmail.com
Reported-by: Tony Lindgren t...@atomide.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |  116 --
 1 files changed, 0 insertions(+), 116 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index c9503a7..1554233 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -120,124 +120,8 @@ static void omap_uart_set_smartidle(struct 
platform_device *pdev) {}
 #endif /* CONFIG_PM */
 
 #ifdef CONFIG_OMAP_MUX
-static struct omap_device_pad default_uart1_pads[] __initdata = {
-   {
-   .name   = uart1_cts.uart1_cts,
-   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart1_rts.uart1_rts,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart1_tx.uart1_tx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart1_rx.uart1_rx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   .idle   = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   },
-};
-
-static struct omap_device_pad default_uart2_pads[] __initdata = {
-   {
-   .name   = uart2_cts.uart2_cts,
-   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart2_rts.uart2_rts,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart2_tx.uart2_tx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart2_rx.uart2_rx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   .idle   = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   },
-};
-
-static struct omap_device_pad default_uart3_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_tx_irtx.uart3_tx_irtx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart3_rx_irrx.uart3_rx_irrx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
-   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
-   },
-};
-
-static struct omap_device_pad default_omap36xx_uart4_pads[] __initdata = {
-   {
-   .name   = gpmc_wait2.uart4_tx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = gpmc_wait3.uart4_rx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
-   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
-   },
-};
-
-static struct omap_device_pad default_omap4_uart4_pads[] __initdata = {
-   {
-   .name   = uart4_tx.uart4_tx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart4_rx.uart4_rx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
-   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
-   },
-};
-
 static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
 {
-   switch (bdata-id) {
-   case 0:
-   bdata-pads = default_uart1_pads;
-   bdata-pads_cnt = ARRAY_SIZE(default_uart1_pads);
-   break;
-   case 1:
-   bdata-pads = default_uart2_pads;
-   bdata-pads_cnt = ARRAY_SIZE(default_uart2_pads);
-   break;
-   case 2:
-   bdata-pads = default_uart3_pads;
-   bdata-pads_cnt = ARRAY_SIZE(default_uart3_pads);
-   break;
-   case 3:
-   if (cpu_is_omap44xx()) {
-   bdata-pads = default_omap4_uart4_pads;
-   bdata-pads_cnt =
-   ARRAY_SIZE(default_omap4_uart4_pads);
-   } else

[PATCH 2/2] OMAP2+: UART: Add mechanism to probe uart pins and configure rx wakeup

2012-04-10 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Default pad populating procedure should first probe whether the uart
pins are available as uart tx/rx pins if yes then we can configure them
and use rx pin for wakeup capability.

Utilise the mux api available to probe the availability of mux pins
in uart mode.

Cc: Felipe Balbi ba...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Russ Dill russ.d...@gmail.com
Reported-by: Tony Lindgren t...@atomide.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/mux.c|3 +-
 arch/arm/mach-omap2/mux.h|   10 +++
 arch/arm/mach-omap2/serial.c |   56 -
 3 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 65c3391..d937ddd 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -217,8 +217,7 @@ static int __init _omap_mux_get_by_name(struct 
omap_mux_partition *partition,
return -ENODEV;
 }
 
-static int __init
-omap_mux_get_by_name(const char *muxname,
+int __init omap_mux_get_by_name(const char *muxname,
struct omap_mux_partition **found_partition,
struct omap_mux **found_mux)
 {
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 69fe060..68927f1 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -225,8 +225,18 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int 
nr_pads);
  */
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
 
+int omap_mux_get_by_name(const char *muxname,
+   struct omap_mux_partition **found_partition,
+   struct omap_mux **found_mux);
 #else
 
+static inline int omap_mux_get_by_name(const char *muxname,
+   struct omap_mux_partition **found_partition,
+   struct omap_mux **found_mux)
+{
+   return 0;
+}
+
 static inline int omap_mux_init_gpio(int gpio, int val)
 {
return 0;
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 1554233..7bb971e 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -120,11 +120,63 @@ static void omap_uart_set_smartidle(struct 
platform_device *pdev) {}
 #endif /* CONFIG_PM */
 
 #ifdef CONFIG_OMAP_MUX
-static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
+
+#define OMAP_UART_DEFAULT_PAD_NAME_LEN 28
+static char rx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN],
+   tx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN] __initdata;
+static struct omap_device_pad default_omap_uart_pads[2] __initdata;
+
+static void  __init omap_serial_fill_default_pads(struct omap_board_data 
*bdata)
 {
+   struct omap_mux_partition *tx_partition = NULL, *rx_partition = NULL;
+   struct omap_mux *rx_mux = NULL, *tx_mux = NULL;
+
+   if (bdata-id != 2) {
+   snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+uart%d_rx.uart%d_rx, bdata-id + 1, bdata-id + 1);
+   snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+uart%d_tx.uart%d_tx, bdata-id + 1, bdata-id + 1);
+   } else {
+   snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+   uart%d_rx_irrx.uart%d_rx_irrx, bdata-id + 1,
+   bdata-id + 1);
+   snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+   uart%d_tx_irtx.uart%d_tx_irtx, bdata-id + 1,
+   bdata-id + 1);
+   }
+
+   if (omap_mux_get_by_name(rx_pad_name, rx_partition, rx_mux) = 0 
+   omap_mux_get_by_name
+   (tx_pad_name, tx_partition, tx_mux) = 0) {
+   u16 tx_mode, rx_mode;
+
+   tx_mode = omap_mux_read(tx_partition, tx_mux-reg_offset);
+   rx_mode = omap_mux_read(rx_partition, rx_mux-reg_offset);
+
+   /*
+* Check if uart is used in default tx/rx mode i.e. in mux mode0
+* if yes then configure rx pin for wake up capability
+*/
+   if (!(rx_mode  0x07)  !(tx_mode  0x07)) {
+   default_omap_uart_pads[0].name = rx_pad_name;
+   default_omap_uart_pads[0].flags  =
+   OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP;
+   default_omap_uart_pads[0].enable = OMAP_PIN_INPUT |
+   OMAP_MUX_MODE0;
+   default_omap_uart_pads[0].idle = OMAP_PIN_INPUT |
+   OMAP_MUX_MODE0;
+
+   default_omap_uart_pads[1].name = tx_pad_name;
+   default_omap_uart_pads[1].enable = OMAP_PIN_OUTPUT |
+   OMAP_MUX_MODE0;
+   bdata-pads = default_omap_uart_pads

[PATCH v3] OMAP2+: UART: Remove cpu checks for populating errata flags

2012-04-03 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Currently the errata is populated based on cpu checks this can
be removed and replaced with module version check of uart ip block.
MVR reg is provided within the uart reg map use the same
to populate the errata and thus now errata population and handling
can be managed within the driver itself.

Cc: Jon Hunter jon-hun...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |8 ---
 arch/arm/plat-omap/include/plat/omap-serial.h |1 -
 drivers/tty/serial/omap-serial.c  |   74 -
 3 files changed, 73 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 0cdd359..6affdd4 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -355,14 +355,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
omap_up.dma_rx_poll_rate = info-dma_rx_poll_rate;
omap_up.autosuspend_timeout = info-autosuspend_timeout;
 
-   /* Enable the MDR1 Errata i202 for OMAP2430/3xxx/44xx */
-   if (!cpu_is_omap2420()  !cpu_is_ti816x())
-   omap_up.errata |= UART_ERRATA_i202_MDR1_ACCESS;
-
-   /* Enable DMA Mode Force Idle Errata i291 for omap34xx/3630 */
-   if (cpu_is_omap34xx() || cpu_is_omap3630())
-   omap_up.errata |= UART_ERRATA_i291_DMA_FORCEIDLE;
-
pdata = omap_up;
pdata_size = sizeof(struct omap_uart_port_info);
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 9ff..1a52725 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -65,7 +65,6 @@ struct omap_uart_port_info {
booldma_enabled;/* To specify DMA Mode */
unsigned intuartclk;/* UART clock rate */
upf_t   flags;  /* UPF_* flags */
-   u32 errata;
unsigned intdma_rx_buf_size;
unsigned intdma_rx_timeout;
unsigned intautosuspend_timeout;
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 0121486..0555c96 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -44,6 +44,13 @@
 #include plat/dmtimer.h
 #include plat/omap-serial.h
 
+#define UART_BUILD_REVISION(x, y)  (((x)  8) | (y))
+
+#define OMAP_UART_REV_42 0x0402
+#define OMAP_UART_REV_46 0x0406
+#define OMAP_UART_REV_52 0x0502
+#define OMAP_UART_REV_63 0x0603
+
 #define DEFAULT_CLK_SPEED 4800 /* 48Mhz*/
 
 /* SCR register bitmasks */
@@ -53,6 +60,17 @@
 #define OMAP_UART_FCR_RX_FIFO_TRIG_SHIFT   6
 #define OMAP_UART_FCR_RX_FIFO_TRIG_MASK(0x3  6)
 
+/* MVR register bitmasks */
+#define OMAP_UART_MVR_SCHEME_SHIFT 30
+
+#define OMAP_UART_LEGACY_MVR_MAJ_MASK  0xf0
+#define OMAP_UART_LEGACY_MVR_MAJ_SHIFT 4
+#define OMAP_UART_LEGACY_MVR_MIN_MASK  0x0f
+
+#define OMAP_UART_MVR_MAJ_MASK 0x700
+#define OMAP_UART_MVR_MAJ_SHIFT8
+#define OMAP_UART_MVR_MIN_MASK 0x3f
+
 static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
 /* Forward declaration of functions */
@@ -1346,6 +1364,59 @@ static void uart_tx_dma_callback(int lch, u16 ch_status, 
void *data)
return;
 }
 
+static void omap_serial_fill_features_erratas(struct uart_omap_port *up)
+{
+   u32 mvr, scheme;
+   u16 revision, major, minor;
+
+   mvr = serial_in(up, UART_OMAP_MVER);
+
+   /* Check revision register scheme */
+   scheme = mvr  OMAP_UART_MVR_SCHEME_SHIFT;
+
+   switch (scheme) {
+   case 0: /* Legacy Scheme: OMAP2/3 */
+   /* MINOR_REV[0:4], MAJOR_REV[4:7] */
+   major = (mvr  OMAP_UART_LEGACY_MVR_MAJ_MASK) 
+   OMAP_UART_LEGACY_MVR_MAJ_SHIFT;
+   minor = (mvr  OMAP_UART_LEGACY_MVR_MIN_MASK);
+   break;
+   case 1:
+   /* New Scheme: OMAP4+ */
+   /* MINOR_REV[0:5], MAJOR_REV[8:10] */
+   major = (mvr  OMAP_UART_MVR_MAJ_MASK) 
+   OMAP_UART_MVR_MAJ_SHIFT;
+   minor = (mvr  OMAP_UART_MVR_MIN_MASK);
+   break;
+   default:
+   dev_warn(up-pdev-dev,
+   Unknown %s revision, defaulting to highest\n,
+   up-name);
+   /* highest possible revision */
+   major = 0xff;
+   minor = 0xff;
+   }
+
+   /* normalize revision for the driver */
+   revision = UART_BUILD_REVISION(major, minor);
+
+   switch (revision) {
+   case OMAP_UART_REV_46:
+   up-errata |= (UART_ERRATA_i202_MDR1_ACCESS

[PATCH] omap2+: pm: fix compilation break.

2012-03-29 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Fix the compilation break observed on latest mainline.

Fixes below compilation break:

arch/arm/mach-omap2/pm.c: In function 'omap_pm_begin':
arch/arm/mach-omap2/pm.c:239: error: implicit declaration of function 
'disable_hlt'
arch/arm/mach-omap2/pm.c: In function 'omap_pm_end':
arch/arm/mach-omap2/pm.c:247: error: implicit declaration of function 
'enable_hlt'

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/pm.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index a7bdec6..70da4f7 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -16,6 +16,7 @@
 #include linux/opp.h
 #include linux/export.h
 #include linux/suspend.h
+#include asm/system_misc.h
 
 #include plat/omap-pm.h
 #include plat/omap_device.h
-- 
1.7.5.4

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


[RESEND PATCH] ARM :OMAP2+: UART: Remove some of uart default pads

2012-03-21 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

The following commit:
(7496ba3  ARM: OMAP2+: UART: Add default mux for all uarts)
added default pads for all uarts. But not all boards tend to
use all uarts and most of unused uart pins are muxed for
other purpose. This commit breaks the modules which where trying
to use unused uart pins on their boards.

So remove all default pads except uart1/3 as most boards
tend to use either uart1/3 as console port and use only tx/rx
lines, declare only those pads for uart1/3.
If any boards tend to use any other uart other uart1/3
the mux data should to passed from board file and init individual
uart port using omap_serial_init_port api.

These pads are needed not only for muxing but are also used to specify
pad wakeup capability for console uart, prior to commit specified we used
to do raw_write to mux pin to enable wakeup capability to uart1/2/3 now
with runtime changes we are using the hwmod/mux framework.

Cc: Felipe Balbi ba...@ti.com
Cc: Kevin Hilman khil...@ti.com
Reported-by: Tony Lindgren t...@atomide.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
Based on Linux 3.3
Tested on Beagle XM and Zoom3 board.

 arch/arm/mach-omap2/serial.c |   78 --
 1 files changed, 0 insertions(+), 78 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 83ab5a2..4dccf14 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -124,14 +124,6 @@ static void omap_uart_set_smartidle(struct platform_device 
*pdev) {}
 #ifdef CONFIG_OMAP_MUX
 static struct omap_device_pad default_uart1_pads[] __initdata = {
{
-   .name   = uart1_cts.uart1_cts,
-   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart1_rts.uart1_rts,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
.name   = uart1_tx.uart1_tx,
.enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
},
@@ -143,37 +135,8 @@ static struct omap_device_pad default_uart1_pads[] 
__initdata = {
},
 };
 
-static struct omap_device_pad default_uart2_pads[] __initdata = {
-   {
-   .name   = uart2_cts.uart2_cts,
-   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart2_rts.uart2_rts,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart2_tx.uart2_tx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart2_rx.uart2_rx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   .idle   = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
-   },
-};
-
 static struct omap_device_pad default_uart3_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_tx_irtx.uart3_tx_irtx,
.enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
},
@@ -185,32 +148,6 @@ static struct omap_device_pad default_uart3_pads[] 
__initdata = {
},
 };
 
-static struct omap_device_pad default_omap36xx_uart4_pads[] __initdata = {
-   {
-   .name   = gpmc_wait2.uart4_tx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = gpmc_wait3.uart4_rx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
-   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
-   },
-};
-
-static struct omap_device_pad default_omap4_uart4_pads[] __initdata = {
-   {
-   .name   = uart4_tx.uart4_tx,
-   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
-   },
-   {
-   .name   = uart4_rx.uart4_rx,
-   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
-   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
-   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
-   },
-};
-
 static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
 {
switch (bdata-id) {
@@ -218,25 +155,10 @@ static void omap_serial_fill_default_pads(struct 
omap_board_data *bdata)
bdata-pads = default_uart1_pads;
bdata-pads_cnt = ARRAY_SIZE(default_uart1_pads);
break;
-   case 1:
-   bdata-pads = default_uart2_pads;
-   bdata-pads_cnt = ARRAY_SIZE(default_uart2_pads);
-   break;
case 2:
bdata-pads = default_uart3_pads;
bdata-pads_cnt

[PATCH 0/3] OMAP2+: UART: Enable tx wakeup + remove cpu checks

2012-03-21 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Based on Linux-OMAP tree uart branch.
(git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
remotes/origin/uart)

* Removes the cpu checks wherever possible and use version reg
  for populating features and errata's
* enable tx wakeup available in wer reg for applicable
  module revision's

Govindraj.R (3):
  OMAP2+: UART: Remove cpu checks for populating errata flags
  OMAP2+: UART: enable tx wakeup bit for wer reg
  OMAP2+: UART: replace omap34xx/omap4xx cpu checks with not omap24xx

 arch/arm/mach-omap2/serial.c  |   13 +
 arch/arm/plat-omap/include/plat/omap-serial.h |8 +++-
 drivers/tty/serial/omap-serial.c  |   71 -
 3 files changed, 78 insertions(+), 14 deletions(-)

-- 
1.7.5.4

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


[PATCH 1/3] OMAP2+: UART: Remove cpu checks for populating errata flags

2012-03-21 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Currently the errata is populated based on cpu checks this can
be removed and replaced with module version check of uart ip block.
MVR reg is provided within the uart reg map use the same
to populate the errata and thus now errata population and handling
can be managed within the driver itself.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |8 ---
 arch/arm/plat-omap/include/plat/omap-serial.h |1 -
 drivers/tty/serial/omap-serial.c  |   62 -
 3 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index f590afc..330ee04 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -357,14 +357,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
omap_up.dma_rx_poll_rate = info-dma_rx_poll_rate;
omap_up.autosuspend_timeout = info-autosuspend_timeout;
 
-   /* Enable the MDR1 Errata i202 for OMAP2430/3xxx/44xx */
-   if (!cpu_is_omap2420()  !cpu_is_ti816x())
-   omap_up.errata |= UART_ERRATA_i202_MDR1_ACCESS;
-
-   /* Enable DMA Mode Force Idle Errata i291 for omap34xx/3630 */
-   if (cpu_is_omap34xx() || cpu_is_omap3630())
-   omap_up.errata |= UART_ERRATA_i291_DMA_FORCEIDLE;
-
pdata = omap_up;
pdata_size = sizeof(struct omap_uart_port_info);
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 9ff..1a52725 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -65,7 +65,6 @@ struct omap_uart_port_info {
booldma_enabled;/* To specify DMA Mode */
unsigned intuartclk;/* UART clock rate */
upf_t   flags;  /* UPF_* flags */
-   u32 errata;
unsigned intdma_rx_buf_size;
unsigned intdma_rx_timeout;
unsigned intautosuspend_timeout;
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index f809041..c7666d6 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -44,6 +44,13 @@
 #include plat/dmtimer.h
 #include plat/omap-serial.h
 
+#define UART_BUILD_REVISION(x, y)  (((x)  8) | (y))
+
+#define OMAP_UART_REV_42 0x0402
+#define OMAP_UART_REV_46 0x0406
+#define OMAP_UART_REV_52 0x0502
+#define OMAP_UART_REV_63 0x0603
+
 #define DEFAULT_CLK_SPEED 4800 /* 48Mhz*/
 
 /* SCR register bitmasks */
@@ -1346,6 +1353,58 @@ static void uart_tx_dma_callback(int lch, u16 ch_status, 
void *data)
return;
 }
 
+static void omap_serial_fill_features_erratas(struct uart_omap_port *up)
+{
+   u32 mvr, scheme;
+   u16 revision, major, minor;
+
+   mvr = serial_in(up, UART_OMAP_MVER);
+
+   /* Check revision register scheme */
+   scheme = mvr  (0x03  30);
+   scheme = 30;
+
+   switch (scheme) {
+   case 0: /* Legacy Scheme: OMAP2/3 */
+   /* MINOR_REV[0:4], MAJOR_REV[4:7] */
+   major = (mvr  0xf0)  4;
+   minor = (mvr  0x0f);
+   break;
+   case 1:
+   /* New Scheme: OMAP4+ */
+   /* MINOR_REV[0:5], MAJOR_REV[8:10] */
+   major = (mvr  0x7  8)  8;
+   minor = (mvr  0x3f);
+   break;
+   default:
+   dev_warn(up-pdev-dev,
+   Unknown %s revision, defaulting to highest\n,
+   up-name);
+   /* highest possible revision */
+   major = 0xff;
+   minor = 0xff;
+   }
+
+   /* normalize revision for the driver */
+   revision = UART_BUILD_REVISION(major, minor);
+
+   switch (revision) {
+   case OMAP_UART_REV_46:
+   up-errata |= (UART_ERRATA_i202_MDR1_ACCESS |
+   UART_ERRATA_i291_DMA_FORCEIDLE);
+   break;
+   case OMAP_UART_REV_52:
+   up-errata |= (UART_ERRATA_i202_MDR1_ACCESS |
+   UART_ERRATA_i291_DMA_FORCEIDLE);
+   break;
+   case OMAP_UART_REV_63:
+   up-errata |= UART_ERRATA_i202_MDR1_ACCESS;
+   break;
+   default:
+   break;
+   }
+}
+
 static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev)
 {
struct omap_uart_port_info *omap_up_info;
@@ -1443,7 +1502,6 @@ static int serial_omap_probe(struct platform_device *pdev)
%d\n, DEFAULT_CLK_SPEED);
}
up-uart_dma.uart_base = mem-start;
-   up-errata = omap_up_info-errata;
 
if (omap_up_info

[PATCH 3/3] OMAP2+: UART: replace omap34xx/omap4xx cpu checks with not omap24xx

2012-03-21 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Minor cleanup, replace all omap34xx/omap44xx cpu checks with
cpu is not omap24xx check.

Cc: Paul Walmsley p...@pwsan.com
Cc: Felipe Balbi ba...@ti.com
Cc: Kevin Hilman khil...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 330ee04..83ab5a2 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -377,8 +377,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
 
oh-dev_attr = uart;
 
-   if (((cpu_is_omap34xx() || cpu_is_omap44xx())  bdata-pads)
-!uart_debug)
+   if ((!cpu_is_omap24xx()  bdata-pads)  !uart_debug)
device_init_wakeup(pdev-dev, true);
 }
 
@@ -401,7 +400,7 @@ void __init omap_serial_board_init(struct 
omap_uart_port_info *info)
bdata.pads = NULL;
bdata.pads_cnt = 0;
 
-   if (cpu_is_omap44xx() || cpu_is_omap34xx())
+   if (!cpu_is_omap24xx())
omap_serial_fill_default_pads(bdata);
 
if (!info)
-- 
1.7.5.4

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


[PATCH 2/3] OMAP2+: UART: enable tx wakeup bit for wer reg

2012-03-21 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

From omap36xx onwards the module wakeup enable reg
wer has TX wakeup bit available enable the same
by populating the necessary tx wakeup flag for the
applicable module ip blocks and use the same
while configuaring wer reg.

Also wer is not context restored, restore wer when
context is lost.

Cc: Paul Walmsley p...@pwsan.com
Cc: Felipe Balbi ba...@ti.com
Cc: Kevin Hilman khil...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/plat-omap/include/plat/omap-serial.h |7 +++
 drivers/tty/serial/omap-serial.c  |9 -
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 1a52725..8a4ca5c 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -61,6 +61,11 @@
 #define UART_ERRATA_i202_MDR1_ACCESS   BIT(0)
 #define UART_ERRATA_i291_DMA_FORCEIDLE BIT(1)
 
+#define OMAP_UART_TX_WAKEUP_EN BIT(7)
+
+/* Feature flags */
+#define OMAP_UART_WER_HAS_TX_WAKEUPBIT(0)
+
 struct omap_uart_port_info {
booldma_enabled;/* To specify DMA Mode */
unsigned intuartclk;/* UART clock rate */
@@ -116,6 +121,7 @@ struct uart_omap_port {
unsigned char   dlh;
unsigned char   mdr1;
unsigned char   scr;
+   unsigned char   wer;
 
int use_dma;
/*
@@ -129,6 +135,7 @@ struct uart_omap_port {
unsigned long   port_activity;
u32 context_loss_cnt;
u32 errata;
+   u32 features;
u8  wakeups_enabled;
 
struct pm_qos_request   pm_qos_request;
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index c7666d6..20d568d 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -585,7 +585,11 @@ static int serial_omap_startup(struct uart_port *port)
serial_out(up, UART_IER, up-ier);
 
/* Enable module level wake up */
-   serial_out(up, UART_OMAP_WER, OMAP_UART_WER_MOD_WKUP);
+   up-wer = OMAP_UART_WER_MOD_WKUP;
+   if (up-features  OMAP_UART_WER_HAS_TX_WAKEUP)
+   up-wer |= OMAP_UART_TX_WAKEUP_EN;
+
+   serial_out(up, UART_OMAP_WER, up-wer);
 
pm_runtime_mark_last_busy(up-pdev-dev);
pm_runtime_put_autosuspend(up-pdev-dev);
@@ -1396,9 +1400,11 @@ static void omap_serial_fill_features_erratas(struct 
uart_omap_port *up)
case OMAP_UART_REV_52:
up-errata |= (UART_ERRATA_i202_MDR1_ACCESS |
UART_ERRATA_i291_DMA_FORCEIDLE);
+   up-features |= OMAP_UART_WER_HAS_TX_WAKEUP;
break;
case OMAP_UART_REV_63:
up-errata |= UART_ERRATA_i202_MDR1_ACCESS;
+   up-features |= OMAP_UART_WER_HAS_TX_WAKEUP;
break;
default:
break;
@@ -1629,6 +1635,7 @@ static void serial_omap_restore_context(struct 
uart_omap_port *up)
serial_omap_mdr1_errataset(up, up-mdr1);
else
serial_out(up, UART_OMAP_MDR1, up-mdr1);
+   serial_out(up, UART_OMAP_WER, up-wer);
 }
 
 static int serial_omap_runtime_suspend(struct device *dev)
-- 
1.7.5.4

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


[PATCH] omap_hwmod: Allow io_ring wakeup configuration for all modules.

2012-03-07 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Some modules doesn't have SYSC_HAS_ENAWAKEUP bit available
(ex: usb host uhh module) in absence of this flag
omap_hwmod_enable/disable_wakeup avoids configuring
pad mux wakeup capability.

Configure sysc if SYSC_HAS_ENAWAKEUP is available and for other cases
try enabling/disabling wakeup from mux_pad pins.

Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c |   30 --
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index eba6cd3..89582df 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2475,14 +2475,15 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
unsigned long flags;
u32 v;
 
-   if (!oh-class-sysc ||
-   !(oh-class-sysc-sysc_flags  SYSC_HAS_ENAWAKEUP))
-   return -EINVAL;
-
spin_lock_irqsave(oh-_lock, flags);
-   v = oh-_sysc_cache;
-   _enable_wakeup(oh, v);
-   _write_sysconfig(v, oh);
+
+   if (oh-class-sysc 
+   (oh-class-sysc-sysc_flags  SYSC_HAS_ENAWAKEUP)) {
+   v = oh-_sysc_cache;
+   _enable_wakeup(oh, v);
+   _write_sysconfig(v, oh);
+   }
+
_set_idle_ioring_wakeup(oh, true);
spin_unlock_irqrestore(oh-_lock, flags);
 
@@ -2506,14 +2507,15 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
unsigned long flags;
u32 v;
 
-   if (!oh-class-sysc ||
-   !(oh-class-sysc-sysc_flags  SYSC_HAS_ENAWAKEUP))
-   return -EINVAL;
-
spin_lock_irqsave(oh-_lock, flags);
-   v = oh-_sysc_cache;
-   _disable_wakeup(oh, v);
-   _write_sysconfig(v, oh);
+
+   if (oh-class-sysc ||
+   (oh-class-sysc-sysc_flags  SYSC_HAS_ENAWAKEUP)) {
+   v = oh-_sysc_cache;
+   _disable_wakeup(oh, v);
+   _write_sysconfig(v, oh);
+   }
+
_set_idle_ioring_wakeup(oh, false);
spin_unlock_irqrestore(oh-_lock, flags);
 
-- 
1.7.5.4

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


[PATCH] omap3_beagle: init uart2 for beagle rev AX/BX only

2012-03-06 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

All beagle boards rev  AX/BX have external usb hubs connected to ehci
interface, external hub/peripheral uses a nreset sequence for which
uart2_rx.gpio_147 pin in mux mode4(USB2HS_nRST) is used on all beagle
boards expect rev Ax/BX.
(Reference to all beagle boards rev schematics:
http://beagleboard.org/hardware/design)

Initialising uart2 will lead to serial init taking over uart2_rx pin
so init uart2_rx pin mux only for Beagle AX/BX rev boards.
Dont init uart2 for all other boards allowing usb_ehci functionality.

To initialise individual uart port by id utilise and modify the existing
available func. omap_serial_board_init.

Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Koen Kooi k...@dominion.thruhere.net
Tested-by: Peter Ujfalusi peter.ujfal...@ti.com
Tested-by: Robert Nelson robertcnel...@gmail.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/board-omap3beagle.c  |6 +++-
 arch/arm/mach-omap2/serial.c |   41 -
 arch/arm/plat-omap/include/plat/serial.h |3 +-
 3 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 7ffcd28..19d6fb5 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -126,6 +126,7 @@ static void __init omap3_beagle_init_rev(void)
beagle_config.mmc1_gpio_wp = 29;
beagle_config.reset_gpio = 170;
beagle_config.usr_button_gpio = 7;
+   omap_serial_board_init(NULL, 1);
break;
case 6:
printk(KERN_INFO OMAP3 Beagle Rev: C1/C2/C3\n);
@@ -528,7 +529,10 @@ static void __init omap3_beagle_init(void)
platform_add_devices(omap3_beagle_devices,
ARRAY_SIZE(omap3_beagle_devices));
omap_display_init(beagle_dss_data);
-   omap_serial_init();
+   omap_serial_board_init(NULL, 0);
+   omap_serial_board_init(NULL, 2);
+   omap_serial_board_init(NULL, 3);
+
omap_sdrc_init(mt46h32m32lf6_sdrc_params,
  mt46h32m32lf6_sdrc_params);
 
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index f590afc..e7c0462 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -393,30 +393,32 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
 /**
  * omap_serial_board_init() - initialize all supported serial ports
  * @info: platform specific data pointer
+ * @port_id: uart port number to be initialised
  *
- * Initializes all available UARTs as serial ports. Platforms
+ * Initializes individual UARTs as serial ports. Platforms
  * can call this function when they want to have default behaviour
- * for serial ports (e.g initialize them all as serial ports).
+ * for serial ports (e.g initialize individual serial ports based on port id).
  */
-void __init omap_serial_board_init(struct omap_uart_port_info *info)
+void __init omap_serial_board_init(struct omap_uart_port_info *info, u8 
port_id)
 {
struct omap_uart_state *uart;
struct omap_board_data bdata;
 
-   list_for_each_entry(uart, uart_list, node) {
-   bdata.id = uart-num;
-   bdata.flags = 0;
-   bdata.pads = NULL;
-   bdata.pads_cnt = 0;
-
-   if (cpu_is_omap44xx() || cpu_is_omap34xx())
-   omap_serial_fill_default_pads(bdata);
-
-   if (!info)
-   omap_serial_init_port(bdata, NULL);
-   else
-   omap_serial_init_port(bdata, info[uart-num]);
-   }
+   list_for_each_entry(uart, uart_list, node)
+   if (uart-num == port_id) {
+   bdata.id = uart-num;
+   bdata.flags = 0;
+   bdata.pads = NULL;
+   bdata.pads_cnt = 0;
+
+   if (!cpu_is_omap24xx())
+   omap_serial_fill_default_pads(bdata);
+
+   if (!info)
+   omap_serial_init_port(bdata, NULL);
+   else
+   omap_serial_init_port(bdata, info);
+   }
 }
 
 /**
@@ -428,5 +430,8 @@ void __init omap_serial_board_init(struct 
omap_uart_port_info *info)
  */
 void __init omap_serial_init(void)
 {
-   omap_serial_board_init(NULL);
+   struct omap_uart_state *uart;
+
+   list_for_each_entry(uart, uart_list, node)
+   omap_serial_board_init(NULL, uart-num);
 }
diff --git a/arch/arm/plat-omap/include/plat/serial.h 
b/arch/arm/plat-omap/include/plat/serial.h
index 198d1e6..043b251 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -111,7 +111,8 @@ struct omap_uart_port_info;
 
 extern void omap_serial_init

[PATCH] omap3_beagle: Init only uart3 used for console

2012-03-05 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On beagle some of uart mux lines are used for other
purpose so init only uart3.

Uart2 rx line clashes with gpio_147 used for usb ehci
phy reset. Initializing uart2 pad_mux lines can break
ehci module on beagle xm.
(gpio_147 is available on uart2_rx in mode4 reference 
mux34xx.c - uart2_rx.gpio_147)

Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Tested-by: Peter Ujfalusi peter.ujfal...@ti.com
Tested-by: Robert Nelson robertcnel...@gmail.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/board-omap3beagle.c |   50 ++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 817be06..a2e0052 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -493,6 +493,54 @@ static const struct usbhs_omap_board_data usbhs_bdata 
__initconst = {
 static struct omap_board_mux board_mux[] __initdata = {
{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
+
+static struct omap_device_pad uart3_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_tx_irtx.uart3_tx_irtx,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart3_rx_irrx.uart3_rx_irrx,
+   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
+   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+   },
+};
+
+static inline void board_serial_init(void)
+{
+   struct omap_board_data uart3_bdata;
+   uart3_bdata.flags = 0;
+   uart3_bdata.pads  = uart3_pads;
+   uart3_bdata.pads_cnt  = ARRAY_SIZE(uart3_pads);
+   uart3_bdata.id= 2;
+
+   /*
+* Init only uart3 used as console
+* don't init other uarts as uart mux lines
+* might be used for other purpose on beagle board
+* ex: uart2_rx used by gpio_147 for usb_ehci phy reset.
+*/
+   omap_serial_init_port(uart3_bdata, NULL);
+}
+#else
+
+/*
+ * If mux is disabled from kernel probably we
+ * are relying on boot-loaders so we init all uarts
+ */
+static inline void board_serial_init(void)
+{
+   omap_serial_init();
+}
 #endif
 
 static void __init beagle_opp_init(void)
@@ -549,7 +597,7 @@ static void __init omap3_beagle_init(void)
platform_add_devices(omap3_beagle_devices,
ARRAY_SIZE(omap3_beagle_devices));
omap_display_init(beagle_dss_data);
-   omap_serial_init();
+   board_serial_init();
omap_sdrc_init(mt46h32m32lf6_sdrc_params,
  mt46h32m32lf6_sdrc_params);
 
-- 
1.7.5.4

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


[PATCH 0/2] mfd: omap-usb-host: Minor omap-usb host fixes

2012-02-15 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Minor fixes, boot tested on panda with ehci enabled.
Patches based on 3.3-rc3

Govindraj.R (2):
  mfd: omap-usb-host: Remove magic numbers for dev dma mask
  mfd: omap-usb-host: Move usbhs init before allocing child dev

 drivers/mfd/omap-usb-host.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

-- 
1.7.5.4

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


[PATCH 1/2] mfd: omap-usb-host: Remove magic numbers for dev dma mask

2012-02-15 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

Remove the hardcoded magic values for dma mask and use the dma
mask macros available.

CC: Felipe Balbi ba...@ti.com
CC: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 drivers/mfd/omap-usb-host.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 68ac2c5..3109b0a 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -170,7 +170,7 @@ struct usbhs_hcd_omap {
 /*-*/
 
 const char usbhs_driver_name[] = USBHS_DRIVER_NAME;
-static u64 usbhs_dmamask = ~(u32)0;
+static u64 usbhs_dmamask = DMA_BIT_MASK(32);
 
 /*-*/
 
@@ -223,7 +223,7 @@ static struct platform_device *omap_usbhs_alloc_child(const 
char *name,
}
 
child-dev.dma_mask = usbhs_dmamask;
-   child-dev.coherent_dma_mask= 0x;
+   child-dev.coherent_dma_mask= DMA_BIT_MASK(32);
child-dev.parent   = dev;
 
ret = platform_device_add(child);
-- 
1.7.5.4

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


[PATCH 2/2] mfd: omap-usb-host: Move usbhs init before allocing child dev

2012-02-15 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

There could be possible race condition where the host dev's
are alloced and added to platform dev just before usbhs_init.
Just move usbhs_init before adding child dev.

CC: Felipe Balbi ba...@ti.com
CC: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 drivers/mfd/omap-usb-host.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 3109b0a..c5d48ce 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -799,14 +799,13 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
platform_set_drvdata(pdev, omap);
 
+   omap_usbhs_init(dev);
ret = omap_usbhs_alloc_children(pdev);
if (ret) {
dev_err(dev, omap_usbhs_alloc_children failed\n);
goto err_alloc;
}
 
-   omap_usbhs_init(dev);
-
goto end_probe;
 
 err_alloc:
-- 
1.7.5.4

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


[RFC PATCH] OMAP: UART: Enable tx wakeup bit in wer

2012-01-24 Thread Govindraj.R
From: Govindraj.R govindraj.r...@ti.com

On omap3630 onwards uart wer reg has bit 7
for tx wakeup enable.

Without this bit set some uart sluggishness might be seen
while printing data on console, response is better when
enabling this bit.
Tested with Beagle XM (OMAP3630)

Cc: Kevin Hilman khil...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
But on omap3430 the bit is not available.

 arch/arm/plat-omap/include/plat/omap-serial.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 9ff..0c22d8d 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -39,7 +39,7 @@
 /* WER = 0x7F
  * Enable module level wakeup in WER reg
  */
-#define OMAP_UART_WER_MOD_WKUP 0X7F
+#define OMAP_UART_WER_MOD_WKUP 0xFF
 
 /* Enable XON/XOFF flow control on output */
 #define OMAP_UART_SW_TX0x04
-- 
1.7.5.4

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


[PATCH v8 00/20] OMAP2+: UART: Runtime adaptation + cleanup

2011-11-11 Thread Govindraj.R
Converting uart driver to adapt to pm runtime API's.
Code re-org + cleanup.
Moving some functionality from serial.c to omap-serial.c

Changes involves:

1.) Cleaning up certain uart calls from sram_idle func.
2.) Removed all types of uart clock handling code from serial.c
3.) Using hwmod_mux API enable wakeup capability for uart pad during
   hwmod_idle state i.e., when uart clocks are disabled we can enable
   io-pad wakeup capability for uart if mux_data is available for
   given uart. Also during during resume from idle call to uart we need
   to enable clocks back conditionally and this can be done only when io-pad
   wakeup event bit is set for uart_rx pad. So we need a hwmod API
   which can probe the uart pad and let us know whether a uart wakeup
   happened. So omap_hmwod_pad_wakeup_status API is added to meet this
   requirement.
3.) Adapted omap-serial driver to use runtime API's.
4.) Modify serial_init calls to accept uart parameters from board file.
Like dma_usage, rx_timeout, dma_rx_pollrate, auto_suspend_timeout etc.
5.) Use the omap_prm driver with irq_chaining to wake up uart after clocks are
cut.

Patch series is based on 3.2-rc1.

Patch series depends on *Tero's v9 Irq_chaining patches*.
Dependent irq_chaining patches are as below.

89ac62b omap3+: add omap prm driver initialization
170431f OMAP3: pm: do not enable PRCM MPU interrupts manually
9aba1b0 omap3: pm: use prcm chain handler
435481f OMAP2+: mux: add support for PAD wakeup interrupts
5b2d361 mfd: omap-prm: added suspend prepare and complete callbacks
aa55c41 mfd: omap-prm: added chain interrupt handler
d1db904 mfd: omap-prm: add driver skeleton
31d056c TEMP: OMAP4xxx: hwmod data: add PRM hwmod
19ec3bc TEMP: OMAP3xxx: hwmod data: add PRM hwmod
9a89688 OMAP2+: hwmod: Add API to check IO PAD wakeup status
78e8b65 OMAP2+: hwmod: Add API to enable IO ring wakeup.

Same combination is hosted at:
git://gitorious.org/runtime_3-0/runtime_3-0.git 3.2-rc1_uart_runtime

Ensure CONFIG_OMAP_PRM is set while testing irq_chaining with uart.
And for pm_qos usage ensure CONFIG_CPU_IDLE is selected other wise
console might be sluggish.

Changes from v7:
---
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg57804.html
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg58209.html
http://www.spinics.net/lists/linux-omap/msg59978.html
http://www.spinics.net/lists/linux-serial/msg04772.html

Testing updates:

OMAP2420/2430SDP: Boot tested.

OMAP3430SDP:
retention, off_mode, system_wide suspend is tested.
(earlyprintk  no_console_suspend checked)

OMAP3630 - Zoom3:
pm-retention checked with quart/omap-uart3
[Also tested with uart3 as console uart and pm-ret checked]

BeagleBoard XM Rev C(3630):
retention, off_mode, system_wide suspend is tested.

Deepak K (1):
  OMAP2+: UART: Allow UART parameters to be configured from board file.

Govindraj.R (18):
  OMAP2+: UART: cleanup + remove uart pm specific API
  OMAP2+: UART: cleanup 8250 console driver support
  OMAP2+: UART: Cleanup part of clock gating mechanism for uart
  OMAP2+: UART: Add default mux for all uarts.
  OMAP2+: UART: Remove mapbase/membase fields from pdata.
  OMAP2+: UART: Add runtime pm support for omap-serial driver
  OMAP2+: UART: Remove context_save and move context restore to driver
  OMAP2+: UART: Ensure all reg values configured are available from
port structure
  OMAP2+: UART: Remove uart reset function.
  OMAP2+: UART: Get context loss count to context restore
  OMAP2+: UART: Move errata handling from serial.c to omap-serial
  OMAP2+: UART: Add wakeup mechanism for omap-uarts
  OMAP2+: UART: Remove old and unused clocks handling funcs
  OMAP2+: UART: remove temporary variable used to count uart instance
  OMAP2+: UART: Use custom activate func for console uart.
  OMAP2+: UART: Avoid uart idling on suspend for no_console_suspend
usecase
  OMAP2+: UART: Do not gate uart clocks if used for debug_prints
  OMAP2+: UART: Remove omap_uart_can_sleep and add pm_qos

Jon Hunter (1):
  OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART

 arch/arm/mach-omap2/board-3430sdp.c   |  100 +---
 arch/arm/mach-omap2/board-4430sdp.c   |   68 +--
 arch/arm/mach-omap2/board-n8x0.c  |6 +-
 arch/arm/mach-omap2/board-omap4panda.c|   68 +--
 arch/arm/mach-omap2/cpuidle34xx.c |5 -
 arch/arm/mach-omap2/pm24xx.c  |   20 -
 arch/arm/mach-omap2/pm34xx.c  |   42 --
 arch/arm/mach-omap2/serial.c  |  926 +++--
 arch/arm/plat-omap/include/plat/omap-serial.h |   36 +-
 arch/arm/plat-omap/include/plat/serial.h  |   10 +-
 drivers/tty/serial/omap-serial.c  |  341 --
 11 files changed, 607 insertions(+), 1015 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info

[PATCH v8 05/20] OMAP2+: UART: Remove mapbase/membase fields from pdata.

2011-11-11 Thread Govindraj.R
The mapbase (start_address), membase(io_remap cookie) part of
pdata struct omap_uart_port_info are removed as this should be
derived within driver.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |2 --
 arch/arm/plat-omap/include/plat/omap-serial.h |2 --
 drivers/tty/serial/omap-serial.c  |   10 --
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 0de1a56..beb46e8 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -605,8 +605,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
 
omap_up.dma_enabled = uart-dma_enabled;
omap_up.uartclk = OMAP24XX_BASE_BAUD * 16;
-   omap_up.mapbase = oh-slaves[0]-addr-pa_start;
-   omap_up.membase = omap_hwmod_get_mpu_rt_va(oh);
omap_up.flags = UPF_BOOT_AUTOCONF;
 
pdata = omap_up;
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 307cd6f..db9bda9 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -59,8 +59,6 @@
 struct omap_uart_port_info {
booldma_enabled;/* To specify DMA Mode */
unsigned intuartclk;/* UART clock rate */
-   void __iomem*membase;   /* ioremap cookie or NULL */
-   resource_size_t mapbase;/* resource base */
upf_t   flags;  /* UPF_* flags */
 };
 
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index be368cf7..31f0cbf 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1275,8 +1275,14 @@ static int serial_omap_probe(struct platform_device 
*pdev)
up-port.ops = serial_omap_pops;
up-port.line = pdev-id;
 
-   up-port.membase = omap_up_info-membase;
-   up-port.mapbase = omap_up_info-mapbase;
+   up-port.mapbase = mem-start;
+   up-port.membase = ioremap(mem-start, resource_size(mem));
+   if (!up-port.membase) {
+   dev_err(pdev-dev, can't ioremap UART\n);
+   ret = -ENOMEM;
+   goto err;
+   }
+
up-port.flags = omap_up_info-flags;
up-port.uartclk = omap_up_info-uartclk;
up-uart_dma.uart_base = mem-start;
-- 
1.7.4.1

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


[PATCH v8 02/20] OMAP2+: UART: cleanup 8250 console driver support

2011-11-11 Thread Govindraj.R
We had been using traditional 8250 driver as uart console driver
prior to omap-serial driver. Since we have omap-serial driver
in mainline kernel for some time now it has been used as default
uart console driver on omap2+ platforms. Remove 8250 support for
omap-uarts.

Serial_in and serial_out override for 8250 serial driver is also
removed. Empty fifo read fix is already taken care with omap-serial
driver with data ready bit check from LSR reg before reading RX fifo.
Also waiting for THRE(transmit hold reg empty) is done with wait_for_xmitr
in omap-serial driver.

Serial_in/out overrides are not neceesary for omap-serial driver
and things that are taken with omap-serial driver are removed here.

Remove headers that were necessary to support 8250 support
and remove all config bindings done to keep 8250 backward compatibility
while adding omap-serial driver. Remove omap_uart_reset needed for
8250 autoconf.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |   97 --
 1 files changed, 0 insertions(+), 97 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 8254067..8499f06 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -19,23 +19,17 @@
  */
 #include linux/kernel.h
 #include linux/init.h
-#include linux/serial_reg.h
 #include linux/clk.h
 #include linux/io.h
 #include linux/delay.h
 #include linux/platform_device.h
 #include linux/slab.h
-#include linux/serial_8250.h
 #include linux/pm_runtime.h
 #include linux/console.h
 
-#ifdef CONFIG_SERIAL_OMAP
 #include plat/omap-serial.h
-#endif
-
 #include plat/common.h
 #include plat/board.h
-#include plat/clock.h
 #include plat/dma.h
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
@@ -47,10 +41,8 @@
 #include control.h
 #include mux.h
 
-#define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV0x52
 #define UART_OMAP_WER  0x17/* Wake-up enable register */
 
-#define UART_ERRATA_FIFO_FULL_ABORT(0x1  0)
 #define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
 
 /*
@@ -533,41 +525,6 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 #define DEV_CREATE_FILE(dev, attr)
 #endif /* CONFIG_PM */
 
-#ifndef CONFIG_SERIAL_OMAP
-/*
- * Override the default 8250 read handler: mem_serial_in()
- * Empty RX fifo read causes an abort on omap3630 and omap4
- * This function makes sure that an empty rx fifo is not read on these silicons
- * (OMAP1/2/3430 are not affected)
- */
-static unsigned int serial_in_override(struct uart_port *up, int offset)
-{
-   if (UART_RX == offset) {
-   unsigned int lsr;
-   lsr = __serial_read_reg(up, UART_LSR);
-   if (!(lsr  UART_LSR_DR))
-   return -EPERM;
-   }
-
-   return __serial_read_reg(up, offset);
-}
-
-static void serial_out_override(struct uart_port *up, int offset, int value)
-{
-   unsigned int status, tmout = 1;
-
-   status = __serial_read_reg(up, UART_LSR);
-   while (!(status  UART_LSR_THRE)) {
-   /* Wait up to 10ms for the character(s) to be sent. */
-   if (--tmout == 0)
-   break;
-   udelay(1);
-   status = __serial_read_reg(up, UART_LSR);
-   }
-   __serial_write_reg(up, offset, value);
-}
-#endif
-
 static int __init omap_serial_early_init(void)
 {
int i = 0;
@@ -628,15 +585,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
void *pdata = NULL;
u32 pdata_size = 0;
char *name;
-#ifndef CONFIG_SERIAL_OMAP
-   struct plat_serial8250_port ports[2] = {
-   {},
-   {.flags = 0},
-   };
-   struct plat_serial8250_port *p = ports[0];
-#else
struct omap_uart_port_info omap_up;
-#endif
 
if (WARN_ON(!bdata))
return;
@@ -651,51 +600,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
 
oh = uart-oh;
uart-dma_enabled = 0;
-#ifndef CONFIG_SERIAL_OMAP
-   name = serial8250;
-
-   /*
-* !! 8250 driver does not use standard IORESOURCE* It
-* has it's own custom pdata that can be taken from
-* the hwmod resource data.  But, this needs to be
-* done after the build.
-*
-* ?? does it have to be done before the register ??
-* YES, because platform_device_data_add() copies
-* pdata, it does not use a pointer.
-*/
-   p-flags = UPF_BOOT_AUTOCONF;
-   p-iotype = UPIO_MEM;
-   p-regshift = 2;
-   p-uartclk = OMAP24XX_BASE_BAUD * 16;
-   p-irq = oh-mpu_irqs[0].irq;
-   p-mapbase = oh-slaves[0]-addr-pa_start;
-   p-membase = omap_hwmod_get_mpu_rt_va(oh);
-   p-irqflags = IRQF_SHARED;
-   p-private_data = uart;
-
-   /*
-* omap44xx, ti816x: Never read empty UART fifo
-* omap3xxx: Never read empty UART fifo on UARTs
-* with IP rev

[PATCH v8 08/20] OMAP2+: UART: Ensure all reg values configured are available from port structure

2011-11-11 Thread Govindraj.R
Add missing uart regs to uart_port structure which can be used in
context restore. Store dll, dlh, mdr1, scr, efr, lcr, mcr reg values
into uart_port structure while configuring individual port in termios
function.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/plat-omap/include/plat/omap-serial.h |4 ++
 drivers/tty/serial/omap-serial.c  |   43 +++--
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index db9bda9..70e7738 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -97,6 +97,10 @@ struct uart_omap_port {
unsigned char   mcr;
unsigned char   fcr;
unsigned char   efr;
+   unsigned char   dll;
+   unsigned char   dlh;
+   unsigned char   mdr1;
+   unsigned char   scr;
 
int use_dma;
/*
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index a834e91..5327ff0 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -466,8 +466,9 @@ static void serial_omap_set_mctrl(struct uart_port *port, 
unsigned int mctrl)
mcr |= UART_MCR_LOOP;
 
pm_runtime_get_sync(up-pdev-dev);
-   mcr |= up-mcr;
-   serial_out(up, UART_MCR, mcr);
+   up-mcr = serial_in(up, UART_MCR);
+   up-mcr |= mcr;
+   serial_out(up, UART_MCR, up-mcr);
pm_runtime_put(up-pdev-dev);
 }
 
@@ -616,8 +617,6 @@ static inline void
 serial_omap_configure_xonxoff
(struct uart_omap_port *up, struct ktermios *termios)
 {
-   unsigned char efr = 0;
-
up-lcr = serial_in(up, UART_LCR);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
up-efr = serial_in(up, UART_EFR);
@@ -627,8 +626,7 @@ serial_omap_configure_xonxoff
serial_out(up, UART_XOFF1, termios-c_cc[VSTOP]);
 
/* clear SW control mode bits */
-   efr = up-efr;
-   efr = OMAP_UART_SW_CLR;
+   up-efr = OMAP_UART_SW_CLR;
 
/*
 * IXON Flag:
@@ -636,7 +634,7 @@ serial_omap_configure_xonxoff
 * Transmit XON1, XOFF1
 */
if (termios-c_iflag  IXON)
-   efr |= OMAP_UART_SW_TX;
+   up-efr |= OMAP_UART_SW_TX;
 
/*
 * IXOFF Flag:
@@ -644,7 +642,7 @@ serial_omap_configure_xonxoff
 * Receiver compares XON1, XOFF1.
 */
if (termios-c_iflag  IXOFF)
-   efr |= OMAP_UART_SW_RX;
+   up-efr |= OMAP_UART_SW_RX;
 
serial_out(up, UART_EFR, up-efr | UART_EFR_ECB);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
@@ -667,7 +665,7 @@ serial_omap_configure_xonxoff
 * load the new software flow control mode IXON or IXOFF
 * and restore the UARTi.EFR_REG[4] ENHANCED_EN value.
 */
-   serial_out(up, UART_EFR, efr | UART_EFR_SCD);
+   serial_out(up, UART_EFR, up-efr | UART_EFR_SCD);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
 
serial_out(up, UART_MCR, up-mcr  ~UART_MCR_TCRTLR);
@@ -714,6 +712,10 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
baud = uart_get_baud_rate(port, termios, old, 0, port-uartclk/13);
quot = serial_omap_get_divisor(port, baud);
 
+   up-dll = quot  0xff;
+   up-dlh = quot  8;
+   up-mdr1 = UART_OMAP_MDR1_DISABLE;
+
up-fcr = UART_FCR_R_TRIG_01 | UART_FCR_T_TRIG_01 |
UART_FCR_ENABLE_FIFO;
if (up-use_dma)
@@ -767,6 +769,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
up-ier |= UART_IER_MSI;
serial_out(up, UART_IER, up-ier);
serial_out(up, UART_LCR, cval); /* reset DLAB */
+   up-lcr = cval;
 
/* FIFOs and DMA Settings */
 
@@ -793,17 +796,18 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
 
if (up-use_dma) {
serial_out(up, UART_TI752_TLR, 0);
-   serial_out(up, UART_OMAP_SCR,
-   (UART_FCR_TRIGGER_4 | UART_FCR_TRIGGER_8));
+   up-scr |= (UART_FCR_TRIGGER_4 | UART_FCR_TRIGGER_8);
}
 
+   serial_out(up, UART_OMAP_SCR, up-scr);
+
serial_out(up, UART_EFR, up-efr);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
serial_out(up, UART_MCR, up-mcr);
 
/* Protocol, Baud Rate, and Interrupt Settings */
 
-   serial_out(up, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
+   serial_out(up, UART_OMAP_MDR1, up-mdr1);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
up-efr = serial_in(up, UART_EFR);
@@ -813,8 +817,8 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_IER, 0);
serial_out(up, UART_LCR

[PATCH v8 03/20] OMAP2+: UART: Cleanup part of clock gating mechanism for uart

2011-11-11 Thread Govindraj.R
Currently we use a shared irq handler to identify uart activity and then
trigger a timer. By default the timeout value is zero and can be set or
modified from sysfs. If there was no uart activity for the period set
through sysfs, the timer will expire and call timer handler this will
set a flag can_sleep using which decision to gate uart clocks can be taken.

Since the clock gating mechanism is outside the uart driver, we currently
use this mechanism. In preparation to runtime implementation for omap-serial
driver we can cleanup this mechanism and use runtime API's to gate uart clocks.

Removes the following:
* timer related info from local uart_state struct
* the code used to set timeout value from sysfs.
* irqflags used to set shared irq handler.
* un-used function omap_uart_check_wakeup.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |  118 +
 arch/arm/plat-omap/include/plat/omap-serial.h |1 -
 arch/arm/plat-omap/include/plat/serial.h  |1 -
 drivers/tty/serial/omap-serial.c  |1 -
 4 files changed, 2 insertions(+), 119 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 8499f06..f6adb49 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -58,8 +58,6 @@
 struct omap_uart_state {
int num;
int can_sleep;
-   struct timer_list timer;
-   u32 timeout;
 
void __iomem *wk_st;
void __iomem *wk_en;
@@ -67,13 +65,9 @@ struct omap_uart_state {
u32 padconf;
u32 dma_enabled;
 
-   struct clk *ick;
-   struct clk *fck;
int clocked;
 
-   int irq;
int regshift;
-   int irqflags;
void __iomem *membase;
resource_size_t mapbase;
 
@@ -331,32 +325,6 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 
omap_uart_smart_idle_enable(uart, 0);
uart-can_sleep = 0;
-   if (uart-timeout)
-   mod_timer(uart-timer, jiffies + uart-timeout);
-   else
-   del_timer(uart-timer);
-}
-
-static void omap_uart_allow_sleep(struct omap_uart_state *uart)
-{
-   if (device_may_wakeup(uart-pdev-dev))
-   omap_uart_enable_wakeup(uart);
-   else
-   omap_uart_disable_wakeup(uart);
-
-   if (!uart-clocked)
-   return;
-
-   omap_uart_smart_idle_enable(uart, 1);
-   uart-can_sleep = 1;
-   del_timer(uart-timer);
-}
-
-static void omap_uart_idle_timer(unsigned long data)
-{
-   struct omap_uart_state *uart = (struct omap_uart_state *)data;
-
-   omap_uart_allow_sleep(uart);
 }
 
 int omap_uart_can_sleep(void)
@@ -380,35 +348,11 @@ int omap_uart_can_sleep(void)
return can_sleep;
 }
 
-/**
- * omap_uart_interrupt()
- *
- * This handler is used only to detect that *any* UART interrupt has
- * occurred.  It does _nothing_ to handle the interrupt.  Rather,
- * any UART interrupt will trigger the inactivity timer so the
- * UART will not idle or sleep for its timeout period.
- *
- **/
-/* static int first_interrupt; */
-static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
-{
-   struct omap_uart_state *uart = dev_id;
-
-   omap_uart_block_sleep(uart);
-
-   return IRQ_NONE;
-}
-
 static void omap_uart_idle_init(struct omap_uart_state *uart)
 {
int ret;
 
uart-can_sleep = 0;
-   uart-timeout = DEFAULT_TIMEOUT;
-   setup_timer(uart-timer, omap_uart_idle_timer,
-   (unsigned long) uart);
-   if (uart-timeout)
-   mod_timer(uart-timer, jiffies + uart-timeout);
omap_uart_smart_idle_enable(uart, 0);
 
if (cpu_is_omap34xx()  !cpu_is_ti816x()) {
@@ -470,51 +414,8 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
uart-wk_mask = 0;
uart-padconf = 0;
}
-
-   uart-irqflags |= IRQF_SHARED;
-   ret = request_threaded_irq(uart-irq, NULL, omap_uart_interrupt,
-  IRQF_SHARED, serial idle, (void *)uart);
-   WARN_ON(ret);
-}
-
-static ssize_t sleep_timeout_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct omap_device *odev = to_omap_device(pdev);
-   struct omap_uart_state *uart = odev-hwmods[0]-dev_attr;
-
-   return sprintf(buf, %u\n, uart-timeout / HZ);
 }
 
-static ssize_t sleep_timeout_store(struct device *dev,
-  struct device_attribute *attr,
-  const char *buf, size_t n)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct omap_device *odev = to_omap_device(pdev);
-   struct omap_uart_state *uart = odev-hwmods[0]-dev_attr;
-   unsigned int value;
-
-   if (sscanf(buf, %u, value) != 1

[PATCH v8 09/20] OMAP2+: UART: Remove uart reset function.

2011-11-11 Thread Govindraj.R
Remove the uart reset function which is configuring the
TX empty irq which can now be handled within omap-serial driver.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   14 --
 arch/arm/plat-omap/include/plat/omap-serial.h |2 ++
 drivers/tty/serial/omap-serial.c  |1 +
 3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 3d5df9a..06887d3 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -74,19 +74,6 @@ struct omap_uart_state {
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
-/*
- * Internal UARTs need to be initialized for the 8250 autoconfig to work
- * properly. Note that the TX watermark initialization may not be needed
- * once the 8250.c watermark handling code is merged.
- */
-
-static inline void __init omap_uart_reset(struct omap_uart_state *uart)
-{
-   serial_write_reg(uart, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
-   serial_write_reg(uart, UART_OMAP_SCR, 0x08);
-   serial_write_reg(uart, UART_OMAP_MDR1, UART_OMAP_MDR1_16X_MODE);
-}
-
 #if defined(CONFIG_PM)  defined(CONFIG_ARCH_OMAP3)
 
 /*
@@ -521,7 +508,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
 
omap_device_enable(uart-pdev);
omap_uart_idle_init(uart);
-   omap_uart_reset(uart);
omap_hwmod_enable_wakeup(uart-oh);
omap_device_idle(uart-pdev);
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 70e7738..5b913c7 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -33,6 +33,8 @@
 
 #define OMAP_MODE13X_SPEED 230400
 
+#define OMAP_UART_SCR_TX_EMPTY 0x08
+
 /* WER = 0x7F
  * Enable module level wakeup in WER reg
  */
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 5327ff0..f5a5ed6 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -770,6 +770,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_IER, up-ier);
serial_out(up, UART_LCR, cval); /* reset DLAB */
up-lcr = cval;
+   up-scr = OMAP_UART_SCR_TX_EMPTY;
 
/* FIFOs and DMA Settings */
 
-- 
1.7.4.1

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


[PATCH v8 07/20] OMAP2+: UART: Remove context_save and move context restore to driver

2011-11-11 Thread Govindraj.R
Remove context save function from serial.c and move context restore
function to omap-serial. Remove all regs stored in omap_uart_state
for contex_save/restore, reg read write funcs used in context_save/restore,
io_addresses populated for read/write funcs.

Clock gating mechanism was done in serial.c and had no info on uart state
thus we needed context save and restore in serial.c
With runtime conversion and clock gating done within uart driver
context restore can be done from regs value available from uart_omap_port
structure.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |  118 --
 drivers/tty/serial/omap-serial.c |   24 
 2 files changed, 24 insertions(+), 118 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index beb46e8..3d5df9a 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -41,8 +41,6 @@
 #include control.h
 #include mux.h
 
-#define UART_OMAP_WER  0x17/* Wake-up enable register */
-
 #define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
 
 /*
@@ -66,60 +64,16 @@ struct omap_uart_state {
 
int clocked;
 
-   int regshift;
-   void __iomem *membase;
-   resource_size_t mapbase;
-
struct list_head node;
struct omap_hwmod *oh;
struct platform_device *pdev;
 
u32 errata;
-#if defined(CONFIG_ARCH_OMAP3)  defined(CONFIG_PM)
-   int context_valid;
-
-   /* Registers to be saved/restored for OFF-mode */
-   u16 dll;
-   u16 dlh;
-   u16 ier;
-   u16 sysc;
-   u16 scr;
-   u16 wer;
-   u16 mcr;
-#endif
 };
 
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
-static inline unsigned int __serial_read_reg(struct uart_port *up,
-int offset)
-{
-   offset = up-regshift;
-   return (unsigned int)__raw_readb(up-membase + offset);
-}
-
-static inline unsigned int serial_read_reg(struct omap_uart_state *uart,
-  int offset)
-{
-   offset = uart-regshift;
-   return (unsigned int)__raw_readb(uart-membase + offset);
-}
-
-static inline void __serial_write_reg(struct uart_port *up, int offset,
-   int value)
-{
-   offset = up-regshift;
-   __raw_writeb(value, up-membase + offset);
-}
-
-static inline void serial_write_reg(struct omap_uart_state *uart, int offset,
-   int value)
-{
-   offset = uart-regshift;
-   __raw_writeb(value, uart-membase + offset);
-}
-
 /*
  * Internal UARTs need to be initialized for the 8250 autoconfig to work
  * properly. Note that the TX watermark initialization may not be needed
@@ -170,75 +124,6 @@ static void omap_uart_mdr1_errataset(struct 
omap_uart_state *uart, u8 mdr1_val,
}
 }
 
-static void omap_uart_save_context(struct omap_uart_state *uart)
-{
-   u16 lcr = 0;
-
-   if (!enable_off_mode)
-   return;
-
-   lcr = serial_read_reg(uart, UART_LCR);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_B);
-   uart-dll = serial_read_reg(uart, UART_DLL);
-   uart-dlh = serial_read_reg(uart, UART_DLM);
-   serial_write_reg(uart, UART_LCR, lcr);
-   uart-ier = serial_read_reg(uart, UART_IER);
-   uart-sysc = serial_read_reg(uart, UART_OMAP_SYSC);
-   uart-scr = serial_read_reg(uart, UART_OMAP_SCR);
-   uart-wer = serial_read_reg(uart, UART_OMAP_WER);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_A);
-   uart-mcr = serial_read_reg(uart, UART_MCR);
-   serial_write_reg(uart, UART_LCR, lcr);
-
-   uart-context_valid = 1;
-}
-
-static void omap_uart_restore_context(struct omap_uart_state *uart)
-{
-   u16 efr = 0;
-
-   if (!enable_off_mode)
-   return;
-
-   if (!uart-context_valid)
-   return;
-
-   uart-context_valid = 0;
-
-   if (uart-errata  UART_ERRATA_i202_MDR1_ACCESS)
-   omap_uart_mdr1_errataset(uart, UART_OMAP_MDR1_DISABLE, 0xA0);
-   else
-   serial_write_reg(uart, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
-
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_B);
-   efr = serial_read_reg(uart, UART_EFR);
-   serial_write_reg(uart, UART_EFR, UART_EFR_ECB);
-   serial_write_reg(uart, UART_LCR, 0x0); /* Operational mode */
-   serial_write_reg(uart, UART_IER, 0x0);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_B);
-   serial_write_reg(uart, UART_DLL, uart-dll);
-   serial_write_reg(uart, UART_DLM, uart-dlh);
-   serial_write_reg(uart, UART_LCR, 0x0); /* Operational mode */
-   serial_write_reg(uart, UART_IER, uart-ier);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_A);
-   serial_write_reg(uart, UART_MCR, uart-mcr);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_B);
-   serial_write_reg(uart, UART_EFR, efr

[PATCH v8 04/20] OMAP2+: UART: Add default mux for all uarts.

2011-11-11 Thread Govindraj.R
Padconf wakeup is used to wakeup uart after uart fclks/iclks are gated.
Rx-Pad wakeup was done by writing to rx-pad offset value populated in
serial.c idle_init. Remove the direct reading and writing into rx pad.
Remove the padconf field part of omap_uart_state struct and pad offsets
populated.

Now with mux framework support we can use mux_utilities
along with hmwod framework to handle io-pad configuration and enable rx-pad
wake-up mechanism.

To avoid breaking any board support add default mux data for all uart's
if mux info is not passed from board file.
With the default pads populated in serial.c wakeup capability for
rx pads is set, this can be used to enable uart_rx io-pad wakeup from
hwmod framework. The pad values in 3430sdp/4430sdp/omap4panda board file
are same as the default pad values populated in serial.c. Remove pad values
from 3430sdp/4430sdp/omap4panda board file and use the default pads
from serial.c file.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c|  100 +
 arch/arm/mach-omap2/board-4430sdp.c|   68 +--
 arch/arm/mach-omap2/board-omap4panda.c |   68 +--
 arch/arm/mach-omap2/serial.c   |  155 ++-
 4 files changed, 133 insertions(+), 258 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 77142c1..b80108b 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -475,106 +475,8 @@ static const struct usbhs_omap_board_data usbhs_bdata 
__initconst = {
 static struct omap_board_mux board_mux[] __initdata = {
{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
-
-static struct omap_device_pad serial1_pads[] __initdata = {
-   /*
-* Note that off output enable is an active low
-* signal. So setting this means pin is a
-* input enabled in off mode
-*/
-   OMAP_MUX_STATIC(uart1_cts.uart1_cts,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_rts.uart1_rts,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_rx.uart1_rx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_tx.uart1_tx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_device_pad serial2_pads[] __initdata = {
-   OMAP_MUX_STATIC(uart2_cts.uart2_cts,
-OMAP_PIN_INPUT_PULLUP |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_rts.uart2_rts,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_rx.uart2_rx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_tx.uart2_tx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_device_pad serial3_pads[] __initdata = {
-   OMAP_MUX_STATIC(uart3_cts_rctx.uart3_cts_rctx,
-OMAP_PIN_INPUT_PULLDOWN |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_rts_sd.uart3_rts_sd,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_rx_irrx.uart3_rx_irrx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_tx_irtx.uart3_tx_irtx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_board_data serial1_data __initdata = {
-   .id = 0,
-   .pads   = serial1_pads,
-   .pads_cnt   = ARRAY_SIZE(serial1_pads),
-};
-
-static struct omap_board_data serial2_data __initdata = {
-   .id = 1,
-   .pads   = serial2_pads,
-   .pads_cnt   = ARRAY_SIZE(serial2_pads),
-};
-
-static struct omap_board_data serial3_data __initdata = {
-   .id = 2,
-   .pads

[PATCH v8 06/20] OMAP2+: UART: Add runtime pm support for omap-serial driver

2011-11-11 Thread Govindraj.R
Adapts omap-serial driver to use pm_runtime API's.
Use runtime runtime API's to handle uart clocks and obtain
device_usage statics. Set runtime API's usage to irq_safe so that
we can use get_sync from irq context. Auto-suspend for port specific
activities and put for reg access. Moving suspend/resume hooks
to dev_pm_ops structure and bing with config_suspend to avoid any
compilation warning if config_suspend is disabled.

By default uart autosuspend delay is set to -1 to avoid character loss
if uart's are autoidled and woken up on rx pin.

After boot up UART's can be autoidled by setting autosuspend delay from sysfs.

echo 3000  /sys/devices/platform/omap/omap_uart.X/power/autosuspend_delay_ms
X=0,1,2,3 for UART1/2/3/4. Number of uarts available may vary across omap_soc.

Also if uart is not wakeup capable we can prevent runtime autosuspend by
forbiding runtime.

Acked-by: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 drivers/tty/serial/omap-serial.c |  122 ++
 1 files changed, 109 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 31f0cbf..f16ef4b9 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -37,11 +37,14 @@
 #include linux/clk.h
 #include linux/serial_core.h
 #include linux/irq.h
+#include linux/pm_runtime.h
 
 #include plat/dma.h
 #include plat/dmtimer.h
 #include plat/omap-serial.h
 
+#define OMAP_UART_AUTOSUSPEND_DELAY -1
+
 static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
 /* Forward declaration of functions */
@@ -102,6 +105,8 @@ static void serial_omap_stop_rxdma(struct uart_omap_port 
*up)
omap_free_dma(up-uart_dma.rx_dma_channel);
up-uart_dma.rx_dma_channel = OMAP_UART_DMA_CH_FREE;
up-uart_dma.rx_dma_used = false;
+   pm_runtime_mark_last_busy(up-pdev-dev);
+   pm_runtime_put_autosuspend(up-pdev-dev);
}
 }
 
@@ -110,8 +115,11 @@ static void serial_omap_enable_ms(struct uart_port *port)
struct uart_omap_port *up = (struct uart_omap_port *)port;
 
dev_dbg(up-port.dev, serial_omap_enable_ms+%d\n, up-pdev-id);
+
+   pm_runtime_get_sync(up-pdev-dev);
up-ier |= UART_IER_MSI;
serial_out(up, UART_IER, up-ier);
+   pm_runtime_put(up-pdev-dev);
 }
 
 static void serial_omap_stop_tx(struct uart_port *port)
@@ -129,23 +137,32 @@ static void serial_omap_stop_tx(struct uart_port *port)
omap_stop_dma(up-uart_dma.tx_dma_channel);
omap_free_dma(up-uart_dma.tx_dma_channel);
up-uart_dma.tx_dma_channel = OMAP_UART_DMA_CH_FREE;
+   pm_runtime_mark_last_busy(up-pdev-dev);
+   pm_runtime_put_autosuspend(up-pdev-dev);
}
 
+   pm_runtime_get_sync(up-pdev-dev);
if (up-ier  UART_IER_THRI) {
up-ier = ~UART_IER_THRI;
serial_out(up, UART_IER, up-ier);
}
+
+   pm_runtime_mark_last_busy(up-pdev-dev);
+   pm_runtime_put_autosuspend(up-pdev-dev);
 }
 
 static void serial_omap_stop_rx(struct uart_port *port)
 {
struct uart_omap_port *up = (struct uart_omap_port *)port;
 
+   pm_runtime_get_sync(up-pdev-dev);
if (up-use_dma)
serial_omap_stop_rxdma(up);
up-ier = ~UART_IER_RLSI;
up-port.read_status_mask = ~UART_LSR_DR;
serial_out(up, UART_IER, up-ier);
+   pm_runtime_mark_last_busy(up-pdev-dev);
+   pm_runtime_put_autosuspend(up-pdev-dev);
 }
 
 static inline void receive_chars(struct uart_omap_port *up, int *status)
@@ -262,7 +279,10 @@ static void serial_omap_start_tx(struct uart_port *port)
int ret = 0;
 
if (!up-use_dma) {
+   pm_runtime_get_sync(up-pdev-dev);
serial_omap_enable_ier_thri(up);
+   pm_runtime_mark_last_busy(up-pdev-dev);
+   pm_runtime_put_autosuspend(up-pdev-dev);
return;
}
 
@@ -272,6 +292,7 @@ static void serial_omap_start_tx(struct uart_port *port)
xmit = up-port.state-xmit;
 
if (up-uart_dma.tx_dma_channel == OMAP_UART_DMA_CH_FREE) {
+   pm_runtime_get_sync(up-pdev-dev);
ret = omap_request_dma(up-uart_dma.uart_dma_tx,
UART Tx DMA,
(void *)uart_tx_dma_callback, up,
@@ -354,9 +375,13 @@ static inline irqreturn_t serial_omap_irq(int irq, void 
*dev_id)
unsigned int iir, lsr;
unsigned long flags;
 
+   pm_runtime_get_sync(up-pdev-dev);
iir = serial_in(up, UART_IIR);
-   if (iir  UART_IIR_NO_INT)
+   if (iir  UART_IIR_NO_INT) {
+   pm_runtime_mark_last_busy(up-pdev-dev);
+   pm_runtime_put_autosuspend(up-pdev-dev);
return IRQ_NONE;
+   }
 
spin_lock_irqsave(up-port.lock, flags);
lsr = serial_in(up, UART_LSR

[PATCH v8 01/20] OMAP2+: UART: cleanup + remove uart pm specific API

2011-11-11 Thread Govindraj.R
In preparation to UART runtime conversion remove uart specific calls
from pm24xx/34xx files and their definition from serial.c
These func calls will no more be used with upcoming uart runtime design.

1.) omap_uart_prepare_suspend :- can be taken care with driver suspend hooks.
2.) omap_uart_enable_irqs :- Used to enable/disable uart irq's in suspend
path from PM code, this is removed as same is handled by
uart_suspend_port/uart_resume_port in omap-serial driver which will
do an port_shutdown on suspend freeing irq and port_startup on resume
enabling back irq.
3.) Remove prepare_idle/resume_idle calls used to gate uart clocks.
UART clocks can be gated within driver using runtime funcs
and be woken up using irq_chaining from omap_prm driver.
4.) Remove console_locking from idle path as clock gating is done withing
driver itself with runtime API. Remove is_suspending check used to acquire
console_lock.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/pm24xx.c |   18 
 arch/arm/mach-omap2/pm34xx.c |   32 ---
 arch/arm/mach-omap2/serial.c |   65 --
 arch/arm/plat-omap/include/plat/serial.h |4 --
 4 files changed, 0 insertions(+), 119 deletions(-)

diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index cf0c216..5ec2b43 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -30,7 +30,6 @@
 #include linux/irq.h
 #include linux/time.h
 #include linux/gpio.h
-#include linux/console.h
 
 #include asm/mach/time.h
 #include asm/mach/irq.h
@@ -126,27 +125,11 @@ static void omap2_enter_full_retention(void)
if (omap_irq_pending())
goto no_sleep;
 
-   /* Block console output in case it is on one of the OMAP UARTs */
-   if (!is_suspending())
-   if (!console_trylock())
-   goto no_sleep;
-
-   omap_uart_prepare_idle(0);
-   omap_uart_prepare_idle(1);
-   omap_uart_prepare_idle(2);
-
/* Jump to SRAM suspend code */
omap2_sram_suspend(sdrc_read_reg(SDRC_DLLA_CTRL),
   OMAP_SDRC_REGADDR(SDRC_DLLA_CTRL),
   OMAP_SDRC_REGADDR(SDRC_POWER));
 
-   omap_uart_resume_idle(2);
-   omap_uart_resume_idle(1);
-   omap_uart_resume_idle(0);
-
-   if (!is_suspending())
-   console_unlock();
-
 no_sleep:
omap2_gpio_resume_after_idle();
 
@@ -290,7 +273,6 @@ static int omap2_pm_suspend(void)
mir1 = omap_readl(0x480fe0a4);
omap_writel(1  5, 0x480fe0ac);
 
-   omap_uart_prepare_suspend();
omap2_enter_full_retention();
 
omap_writel(mir1, 0x480fe0a4);
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 9517203..2eb3215 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -28,7 +28,6 @@
 #include linux/clk.h
 #include linux/delay.h
 #include linux/slab.h
-#include linux/console.h
 #include linux/mfd/omap-prm.h
 #include trace/events/power.h
 
@@ -54,15 +53,6 @@
 
 #ifdef CONFIG_SUSPEND
 static suspend_state_t suspend_state = PM_SUSPEND_ON;
-static inline bool is_suspending(void)
-{
-   return (suspend_state != PM_SUSPEND_ON)  console_suspend_enabled;
-}
-#else
-static inline bool is_suspending(void)
-{
-   return false;
-}
 #endif
 
 /* pm34xx errata defined in pm.h */
@@ -337,20 +327,11 @@ void omap_sram_idle(void)
omap3_enable_io_chain();
}
 
-   /* Block console output in case it is on one of the OMAP UARTs */
-   if (!is_suspending())
-   if (per_next_state  PWRDM_POWER_ON ||
-   core_next_state  PWRDM_POWER_ON)
-   if (!console_trylock())
-   goto console_still_active;
-
pwrdm_pre_transition();
 
/* PER */
if (per_next_state  PWRDM_POWER_ON) {
per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
-   omap_uart_prepare_idle(2);
-   omap_uart_prepare_idle(3);
omap2_gpio_prepare_for_idle(per_going_off);
if (per_next_state == PWRDM_POWER_OFF)
omap3_per_save_context();
@@ -358,8 +339,6 @@ void omap_sram_idle(void)
 
/* CORE */
if (core_next_state  PWRDM_POWER_ON) {
-   omap_uart_prepare_idle(0);
-   omap_uart_prepare_idle(1);
if (core_next_state == PWRDM_POWER_OFF) {
omap3_core_save_context();
omap3_cm_save_context();
@@ -408,8 +387,6 @@ void omap_sram_idle(void)
omap3_sram_restore_context();
omap2_sms_restore_context();
}
-   omap_uart_resume_idle(0);
-   omap_uart_resume_idle(1);
if (core_next_state == PWRDM_POWER_OFF

[PATCH v8 10/20] OMAP2+: UART: Get context loss count to context restore

2011-11-11 Thread Govindraj.R
Avoid unconditional context restore every time we gate uart
clocks. Check whether context loss happened based on which
we can context restore uart regs from uart_port structure.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |2 ++
 arch/arm/plat-omap/include/plat/omap-serial.h |3 +++
 drivers/tty/serial/omap-serial.c  |   20 ++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 06887d3..98e2666 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -33,6 +33,7 @@
 #include plat/dma.h
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
+#include plat/omap-pm.h
 
 #include prm2xxx_3xxx.h
 #include pm.h
@@ -478,6 +479,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
omap_up.dma_enabled = uart-dma_enabled;
omap_up.uartclk = OMAP24XX_BASE_BAUD * 16;
omap_up.flags = UPF_BOOT_AUTOCONF;
+   omap_up.get_context_loss_count = omap_pm_get_dev_context_loss_count;
 
pdata = omap_up;
pdata_size = sizeof(struct omap_uart_port_info);
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 5b913c7..348c9ea 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -62,6 +62,8 @@ struct omap_uart_port_info {
booldma_enabled;/* To specify DMA Mode */
unsigned intuartclk;/* UART clock rate */
upf_t   flags;  /* UPF_* flags */
+
+   int (*get_context_loss_count)(struct device *);
 };
 
 struct uart_omap_dma {
@@ -114,6 +116,7 @@ struct uart_omap_port {
unsigned char   msr_saved_flags;
charname[20];
unsigned long   port_activity;
+   u32 context_loss_cnt;
 };
 
 #endif /* __OMAP_SERIAL_H__ */
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index f5a5ed6..ea4c24a 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1440,15 +1440,31 @@ static void serial_omap_restore_context(struct 
uart_omap_port *up)
 #ifdef CONFIG_PM_RUNTIME
 static int serial_omap_runtime_suspend(struct device *dev)
 {
+   struct uart_omap_port *up = dev_get_drvdata(dev);
+   struct omap_uart_port_info *pdata = dev-platform_data;
+
+   if (!up)
+   return -EINVAL;
+
+   if (pdata-get_context_loss_count)
+   up-context_loss_cnt = pdata-get_context_loss_count(dev);
+
return 0;
 }
 
 static int serial_omap_runtime_resume(struct device *dev)
 {
struct uart_omap_port *up = dev_get_drvdata(dev);
+   struct omap_uart_port_info *pdata = dev-platform_data;
 
-   if (up)
-   serial_omap_restore_context(up);
+   if (up) {
+   if (pdata-get_context_loss_count) {
+   u32 loss_cnt = pdata-get_context_loss_count(dev);
+
+   if (up-context_loss_cnt != loss_cnt)
+   serial_omap_restore_context(up);
+   }
+   }
 
return 0;
 }
-- 
1.7.4.1

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


[PATCH v8 11/20] OMAP2+: UART: Move errata handling from serial.c to omap-serial

2011-11-11 Thread Govindraj.R
Move the errata handling mechanism from serial.c to omap-serial file
and utilise the same func in driver file.

Errata i202, i291 are moved to be handled with omap-serial
Moving the errata macro from serial.c file to driver header file
as from on errata will be handled in driver file itself.
Corrected errata id from chapter reference 2.15 to errata id i291.

Removed errata and dma_enabled fields from omap_uart_state struct
as they are no more needed with errata handling done within omap-serial.

Acked-by: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   98 +++--
 arch/arm/plat-omap/include/plat/omap-serial.h |6 ++
 drivers/tty/serial/omap-serial.c  |   66 -
 3 files changed, 96 insertions(+), 74 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 98e2666..a52bd99 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -42,8 +42,6 @@
 #include control.h
 #include mux.h
 
-#define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
-
 /*
  * NOTE: By default the serial timeout is disabled as it causes lost characters
  * over the serial ports. This means that the UART clocks will stay on until
@@ -61,59 +59,17 @@ struct omap_uart_state {
void __iomem *wk_st;
void __iomem *wk_en;
u32 wk_mask;
-   u32 dma_enabled;
 
int clocked;
 
struct list_head node;
struct omap_hwmod *oh;
struct platform_device *pdev;
-
-   u32 errata;
 };
 
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
-#if defined(CONFIG_PM)  defined(CONFIG_ARCH_OMAP3)
-
-/*
- * Work Around for Errata i202 (3430 - 1.12, 3630 - 1.6)
- * The access to uart register after MDR1 Access
- * causes UART to corrupt data.
- *
- * Need a delay =
- * 5 L4 clock cycles + 5 UART functional clock cycle (@48MHz = ~0.2uS)
- * give 10 times as much
- */
-static void omap_uart_mdr1_errataset(struct omap_uart_state *uart, u8 mdr1_val,
-   u8 fcr_val)
-{
-   u8 timeout = 255;
-
-   serial_write_reg(uart, UART_OMAP_MDR1, mdr1_val);
-   udelay(2);
-   serial_write_reg(uart, UART_FCR, fcr_val | UART_FCR_CLEAR_XMIT |
-   UART_FCR_CLEAR_RCVR);
-   /*
-* Wait for FIFO to empty: when empty, RX_FIFO_E bit is 0 and
-* TX_FIFO_E bit is 1.
-*/
-   while (UART_LSR_THRE != (serial_read_reg(uart, UART_LSR) 
-   (UART_LSR_THRE | UART_LSR_DR))) {
-   timeout--;
-   if (!timeout) {
-   /* Should *never* happen. we warn and carry on */
-   dev_crit(uart-pdev-dev, Errata i202: timedout %x\n,
-   serial_read_reg(uart, UART_LSR));
-   break;
-   }
-   udelay(1);
-   }
-}
-
-#endif /* CONFIG_PM  CONFIG_ARCH_OMAP3 */
-
 static inline void omap_uart_enable_clocks(struct omap_uart_state *uart)
 {
if (uart-clocked)
@@ -156,27 +112,6 @@ static void omap_uart_disable_wakeup(struct 
omap_uart_state *uart)
}
 }
 
-static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
-  int enable)
-{
-   u8 idlemode;
-
-   if (enable) {
-   /**
-* Errata 2.15: [UART]:Cannot Acknowledge Idle Requests
-* in Smartidle Mode When Configured for DMA Operations.
-*/
-   if (uart-dma_enabled)
-   idlemode = HWMOD_IDLEMODE_FORCE;
-   else
-   idlemode = HWMOD_IDLEMODE_SMART;
-   } else {
-   idlemode = HWMOD_IDLEMODE_NO;
-   }
-
-   omap_hwmod_set_slave_idlemode(uart-oh, idlemode);
-}
-
 static void omap_uart_block_sleep(struct omap_uart_state *uart)
 {
omap_uart_enable_clocks(uart);
@@ -267,7 +202,28 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
}
 }
 
+/*
+ * Errata i291: [UART]:Cannot Acknowledge Idle Requests
+ * in Smartidle Mode When Configured for DMA Operations.
+ * WA: configure uart in force idle mode.
+ */
+static void omap_uart_set_noidle(struct platform_device *pdev)
+{
+   struct omap_device *od = to_omap_device(pdev);
+
+   omap_hwmod_set_slave_idlemode(od-hwmods[0], HWMOD_IDLEMODE_NO);
+}
+
+static void omap_uart_set_forceidle(struct platform_device *pdev)
+{
+   struct omap_device *od = to_omap_device(pdev);
+
+   omap_hwmod_set_slave_idlemode(od-hwmods[0], HWMOD_IDLEMODE_FORCE);
+}
+
 #else
+static void omap_uart_set_noidle(struct platform_device *pdev) {}
+static void omap_uart_set_forceidle(struct platform_device *pdev) {}
 static void omap_uart_block_sleep(struct omap_uart_state *uart)
 {
/* Needed to enable UART clocks when built without CONFIG_PM */
@@ -473,13 +429,19 @@ void __init omap_serial_init_port(struct

[PATCH v8 12/20] OMAP2+: UART: Add wakeup mechanism for omap-uarts

2011-11-11 Thread Govindraj.R
From the runtime callbacks enable hwmod wakeups for uart which will
internally enable io-pad wakeups for uarts if they have rx-pad pins
set as wakeup capabale.

Use the io-ring wakeup mechanism after uart clock gating and leave
the PM_WKST set for uart to default reset values cleanup the
code in serial.c which was handling PM_WKST reg.
Irq_chaing(PRM_DRIVER) is used to wakeup uart after uart clocks are gated
using pad wakeup mechanism.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   96 +++-
 arch/arm/plat-omap/include/plat/omap-serial.h |2 +
 drivers/tty/serial/omap-serial.c  |   15 
 3 files changed, 29 insertions(+), 84 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index a52bd99..d1d8b88 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -56,10 +56,6 @@ struct omap_uart_state {
int num;
int can_sleep;
 
-   void __iomem *wk_st;
-   void __iomem *wk_en;
-   u32 wk_mask;
-
int clocked;
 
struct list_head node;
@@ -92,26 +88,6 @@ static inline void omap_uart_disable_clocks(struct 
omap_uart_state *uart)
omap_device_idle(uart-pdev);
 }
 
-static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
-{
-   /* Set wake-enable bit */
-   if (uart-wk_en  uart-wk_mask) {
-   u32 v = __raw_readl(uart-wk_en);
-   v |= uart-wk_mask;
-   __raw_writel(v, uart-wk_en);
-   }
-}
-
-static void omap_uart_disable_wakeup(struct omap_uart_state *uart)
-{
-   /* Clear wake-enable bit */
-   if (uart-wk_en  uart-wk_mask) {
-   u32 v = __raw_readl(uart-wk_en);
-   v = ~uart-wk_mask;
-   __raw_writel(v, uart-wk_en);
-   }
-}
-
 static void omap_uart_block_sleep(struct omap_uart_state *uart)
 {
omap_uart_enable_clocks(uart);
@@ -141,65 +117,17 @@ int omap_uart_can_sleep(void)
return can_sleep;
 }
 
-static void omap_uart_idle_init(struct omap_uart_state *uart)
+static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
 {
-   int ret;
-
-   uart-can_sleep = 0;
-   omap_uart_smart_idle_enable(uart, 0);
+   struct omap_device *od = to_omap_device(pdev);
 
-   if (cpu_is_omap34xx()  !cpu_is_ti816x()) {
-   u32 mod = (uart-num  1) ? OMAP3430_PER_MOD : CORE_MOD;
-   u32 wk_mask = 0;
+   if (!od)
+   return;
 
-   /* XXX These PRM accesses do not belong here */
-   uart-wk_en = OMAP34XX_PRM_REGADDR(mod, PM_WKEN1);
-   uart-wk_st = OMAP34XX_PRM_REGADDR(mod, PM_WKST1);
-   switch (uart-num) {
-   case 0:
-   wk_mask = OMAP3430_ST_UART1_MASK;
-   break;
-   case 1:
-   wk_mask = OMAP3430_ST_UART2_MASK;
-   break;
-   case 2:
-   wk_mask = OMAP3430_ST_UART3_MASK;
-   break;
-   case 3:
-   wk_mask = OMAP3630_ST_UART4_MASK;
-   break;
-   }
-   uart-wk_mask = wk_mask;
-   } else if (cpu_is_omap24xx()) {
-   u32 wk_mask = 0;
-   u32 wk_en = PM_WKEN1, wk_st = PM_WKST1;
-
-   switch (uart-num) {
-   case 0:
-   wk_mask = OMAP24XX_ST_UART1_MASK;
-   break;
-   case 1:
-   wk_mask = OMAP24XX_ST_UART2_MASK;
-   break;
-   case 2:
-   wk_en = OMAP24XX_PM_WKEN2;
-   wk_st = OMAP24XX_PM_WKST2;
-   wk_mask = OMAP24XX_ST_UART3_MASK;
-   break;
-   }
-   uart-wk_mask = wk_mask;
-   if (cpu_is_omap2430()) {
-   uart-wk_en = OMAP2430_PRM_REGADDR(CORE_MOD, wk_en);
-   uart-wk_st = OMAP2430_PRM_REGADDR(CORE_MOD, wk_st);
-   } else if (cpu_is_omap2420()) {
-   uart-wk_en = OMAP2420_PRM_REGADDR(CORE_MOD, wk_en);
-   uart-wk_st = OMAP2420_PRM_REGADDR(CORE_MOD, wk_st);
-   }
-   } else {
-   uart-wk_en = NULL;
-   uart-wk_st = NULL;
-   uart-wk_mask = 0;
-   }
+   if (enable)
+   omap_hwmod_enable_wakeup(od-hwmods[0]);
+   else
+   omap_hwmod_disable_wakeup(od-hwmods[0]);
 }
 
 /*
@@ -222,6 +150,8 @@ static void omap_uart_set_forceidle(struct platform_device 
*pdev)
 }
 
 #else
+static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
+{}
 static void omap_uart_set_noidle(struct platform_device *pdev) {}
 static void omap_uart_set_forceidle(struct platform_device *pdev) {}
 static void omap_uart_block_sleep

[PATCH v8 13/20] OMAP2+: UART: Remove old and unused clocks handling funcs

2011-11-11 Thread Govindraj.R
With runtime adaptation done remove clock_enable/disbale API's

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |   36 
 1 files changed, 0 insertions(+), 36 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index d1d8b88..6d574f0 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -56,8 +56,6 @@ struct omap_uart_state {
int num;
int can_sleep;
 
-   int clocked;
-
struct list_head node;
struct omap_hwmod *oh;
struct platform_device *pdev;
@@ -66,36 +64,8 @@ struct omap_uart_state {
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
-static inline void omap_uart_enable_clocks(struct omap_uart_state *uart)
-{
-   if (uart-clocked)
-   return;
-
-   omap_device_enable(uart-pdev);
-   uart-clocked = 1;
-   omap_uart_restore_context(uart);
-}
-
 #ifdef CONFIG_PM
 
-static inline void omap_uart_disable_clocks(struct omap_uart_state *uart)
-{
-   if (!uart-clocked)
-   return;
-
-   omap_uart_save_context(uart);
-   uart-clocked = 0;
-   omap_device_idle(uart-pdev);
-}
-
-static void omap_uart_block_sleep(struct omap_uart_state *uart)
-{
-   omap_uart_enable_clocks(uart);
-
-   omap_uart_smart_idle_enable(uart, 0);
-   uart-can_sleep = 0;
-}
-
 int omap_uart_can_sleep(void)
 {
struct omap_uart_state *uart;
@@ -154,11 +124,6 @@ static void omap_uart_enable_wakeup(struct platform_device 
*pdev, bool enable)
 {}
 static void omap_uart_set_noidle(struct platform_device *pdev) {}
 static void omap_uart_set_forceidle(struct platform_device *pdev) {}
-static void omap_uart_block_sleep(struct omap_uart_state *uart)
-{
-   /* Needed to enable UART clocks when built without CONFIG_PM */
-   omap_uart_enable_clocks(uart);
-}
 #endif /* CONFIG_PM */
 
 #ifdef CONFIG_OMAP_MUX
@@ -404,7 +369,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
omap_device_enable(uart-pdev);
omap_device_idle(uart-pdev);
 
-   omap_uart_block_sleep(uart);
console_unlock();
 
if ((cpu_is_omap34xx() || cpu_is_omap44xx())  bdata-pads)
-- 
1.7.4.1

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


[PATCH v8 14/20] OMAP2+: UART: Allow UART parameters to be configured from board file.

2011-11-11 Thread Govindraj.R
From: Deepak K deepa...@ti.com

The following UART parameters are defined within the UART driver:

1). Whether the UART uses DMA (dma_enabled), by default set to 0
2). The size of dma buffer (set to 4096 bytes)
3). The time after which the dma should stop if no more data is received.
4). The auto suspend delay that will be passed for pm_runtime_autosuspend
where uart will be disabled after timeout

Different UARTs may be used for different purpose such as the console,
for interfacing bluetooth chip, for interfacing to a modem chip, etc.
Therefore, it is necessary to be able to customize the above settings
for a given board on a per UART basis.

This change allows these parameters to be configured from the board file
and allows the parameters to be configured for each UART independently.

If a board does not define its own custom parameters for the UARTs, then
use the default parameters in the structure omap_serial_default_info.
The default parameters are defined to be the same as the current settings
in the UART driver to avoid breaking the UART for any cuurnelty supported
boards. By default, make all boards use the default UART parameters.

Signed-off-by: Deepak K deepa...@ti.com
Signed-off-by: Jon Hunter jon-hun...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/board-n8x0.c  |6 +-
 arch/arm/mach-omap2/serial.c  |   56 -
 arch/arm/plat-omap/include/plat/omap-serial.h |7 ++-
 arch/arm/plat-omap/include/plat/serial.h  |5 ++-
 drivers/tty/serial/omap-serial.c  |8 +--
 5 files changed, 60 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index e9d5f4a..fbafa71 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -644,15 +644,15 @@ static inline void board_serial_init(void)
bdata.pads_cnt = 0;
 
bdata.id = 0;
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
bdata.id = 1;
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
bdata.id = 2;
bdata.pads = serial2_pads;
bdata.pads_cnt = ARRAY_SIZE(serial2_pads);
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 }
 
 #else
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 6d574f0..3eb2469 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -43,12 +43,12 @@
 #include mux.h
 
 /*
- * NOTE: By default the serial timeout is disabled as it causes lost characters
- * over the serial ports. This means that the UART clocks will stay on until
- * disabled via sysfs. This also causes that any deeper omap sleep states are
- * blocked. 
+ * NOTE: By default the serial auto_suspend timeout is disabled as it causes
+ * lost characters over the serial ports. This means that the UART clocks will
+ * stay on until power/autosuspend_delay is set for the uart from sysfs.
+ * This also causes that any deeper omap sleep states are blocked.
  */
-#define DEFAULT_TIMEOUT 0
+#define DEFAULT_AUTOSUSPEND_DELAY  -1
 
 #define MAX_UART_HWMOD_NAME_LEN16
 
@@ -64,6 +64,18 @@ struct omap_uart_state {
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
+#define DEFAULT_RXDMA_TIMEOUT  1   /* RX DMA polling rate (us) */
+#define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
+
+static struct omap_uart_port_info omap_serial_default_info[] __initdata = {
+   {
+   .dma_enabled= false,
+   .dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
+   .dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
+   .autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
+   },
+};
+
 #ifdef CONFIG_PM
 
 int omap_uart_can_sleep(void)
@@ -294,6 +306,7 @@ core_initcall(omap_serial_early_init);
 /**
  * omap_serial_init_port() - initialize single serial port
  * @bdata: port specific board data pointer
+ * @info: platform specific data pointer
  *
  * This function initialies serial driver for given port only.
  * Platforms can call this function instead of omap_serial_init()
@@ -302,7 +315,8 @@ core_initcall(omap_serial_early_init);
  * Don't mix calls to omap_serial_init_port() and omap_serial_init(),
  * use only one of the two.
  */
-void __init omap_serial_init_port(struct omap_board_data *bdata)
+void __init omap_serial_init_port(struct omap_board_data *bdata,
+   struct omap_uart_port_info *info)
 {
struct omap_uart_state *uart;
struct omap_hwmod *oh;
@@ -322,17 +336,22 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
list_for_each_entry(uart, uart_list, node)
if (bdata-id == uart-num)
break;
+   if (!info)
+   info = omap_serial_default_info;
 
oh = uart-oh;
name = DRIVER_NAME

[PATCH v8 16/20] OMAP2+: UART: remove temporary variable used to count uart instance

2011-11-11 Thread Govindraj.R
Reuse the num_uarts variable itself to count number of uarts.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 5c6c48f..4d65d00 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -266,15 +266,13 @@ static void omap_serial_fill_default_pads(struct 
omap_board_data *bdata) {}
 
 static int __init omap_serial_early_init(void)
 {
-   int i = 0;
-
do {
char oh_name[MAX_UART_HWMOD_NAME_LEN];
struct omap_hwmod *oh;
struct omap_uart_state *uart;
 
snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN,
-uart%d, i + 1);
+uart%d, num_uarts + 1);
oh = omap_hwmod_lookup(oh_name);
if (!oh)
break;
@@ -284,9 +282,8 @@ static int __init omap_serial_early_init(void)
return -ENODEV;
 
uart-oh = oh;
-   uart-num = i++;
+   uart-num = num_uarts++;
list_add_tail(uart-node, uart_list);
-   num_uarts++;
 
/*
 * NOTE: omap_hwmod_setup*() has not yet been called,
-- 
1.7.4.1

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


[PATCH v8 17/20] OMAP2+: UART: Use custom activate func for console uart.

2011-11-11 Thread Govindraj.R
Omap-uart can be used as console uart to print early boot
messages using earlyprintk so for console uart prevent
hwmod reset or idling during bootup.

Identify the console_uart set the id and use the custom
pm_latency ops for console uart for the first time
to idle console uart left enabled from bootup and then enable
them back and reset pm_latency ops to default ops.

Thanks to Kevin Hilman khil...@ti.com for suggesting
this approach.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |   86 +
 1 files changed, 61 insertions(+), 25 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 4d65d00..631d72a 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -61,8 +61,10 @@ struct omap_uart_state {
struct platform_device *pdev;
 };
 
+static struct omap_device_pm_latency *default_uart_latency;
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
+static u8 console_uart_id = -1;
 
 #define DEFAULT_RXDMA_POLLRATE 1   /* RX DMA polling rate (us) */
 #define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
@@ -78,6 +80,34 @@ static struct omap_uart_port_info omap_serial_default_info[] 
__initdata = {
},
 };
 
+static int console_uart_enable_hwmod(struct omap_device *od)
+{
+   console_lock();
+   /*
+* For early console we prevented hwmod reset and idle
+* So before we enable the uart clocks idle the console
+* uart clocks, then enable back the console uart hwmod.
+*/
+   omap_hwmod_idle(od-hwmods[0]);
+   omap_hwmod_enable(od-hwmods[0]);
+   console_unlock();
+
+   /*
+* Restore the default activate/deactivate funcs,
+* since now we have set the hwmod state machine right
+* with the idle/enable for console uart
+*/
+   od-pm_lats = default_uart_latency;
+
+   return 0;
+}
+
+static struct omap_device_pm_latency console_uart_latency[] = {
+   {
+   .activate_func   = console_uart_enable_hwmod,
+   },
+};
+
 #ifdef CONFIG_PM
 
 int omap_uart_can_sleep(void)
@@ -264,12 +294,20 @@ static void omap_serial_fill_default_pads(struct 
omap_board_data *bdata)
 static void omap_serial_fill_default_pads(struct omap_board_data *bdata) {}
 #endif
 
+char *cmdline_find_option(char *str)
+{
+   extern char *saved_command_line;
+
+   return strstr(saved_command_line, str);
+}
+
 static int __init omap_serial_early_init(void)
 {
do {
char oh_name[MAX_UART_HWMOD_NAME_LEN];
struct omap_hwmod *oh;
struct omap_uart_state *uart;
+   char uart_name[MAX_UART_HWMOD_NAME_LEN];
 
snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN,
 uart%d, num_uarts + 1);
@@ -284,18 +322,23 @@ static int __init omap_serial_early_init(void)
uart-oh = oh;
uart-num = num_uarts++;
list_add_tail(uart-node, uart_list);
+   snprintf(uart_name, MAX_UART_HWMOD_NAME_LEN,
+   %s%d, OMAP_SERIAL_NAME, uart-num);
+
+   if (cmdline_find_option(uart_name)) {
+   console_uart_id = uart-num;
+   /*
+* omap-uart can be used for earlyprintk logs
+* So if omap-uart is used as console then prevent
+* uart reset and idle to get logs from omap-uart
+* until uart console driver is available to take
+* care for console messages.
+* Idling or resetting omap-uart while printing logs
+* early boot logs can stall the boot-up.
+*/
+   oh-flags |= HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET;
+   }
 
-   /*
-* NOTE: omap_hwmod_setup*() has not yet been called,
-*   so no hwmod functions will work yet.
-*/
-
-   /*
-* During UART early init, device need to be probed
-* to determine SoC specific init before omap_device
-* is ready.  Therefore, don't allow idle here
-*/
-   uart-oh-flags |= HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET;
} while (1);
 
return 0;
@@ -324,6 +367,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
u32 pdata_size = 0;
char *name;
struct omap_uart_port_info omap_up;
+   struct omap_device *od;
 
if (WARN_ON(!bdata))
return;
@@ -369,6 +413,12 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
WARN(IS_ERR(pdev), Could not build omap_device for %s: %s.\n,
 name, oh-name);
 
+   if (console_uart_id == bdata-id) {
+   od

[PATCH v8 15/20] OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART

2011-11-11 Thread Govindraj.R
From: Jon Hunter jon-hun...@ti.com

When using DMA there are two timeouts defined. The first timeout,
rx_timeout, is really a polling rate in which software polls the
DMA status to see if the DMA has finished. This is necessary for
the RX side because we do not know how much data we will receive.
The secound timeout, RX_TIMEOUT, is a timeout after which the
DMA will be stopped if no more data is received. To make this
clearer, rename rx_timeout as rx_poll_rate and rename the
function serial_omap_rx_timeout() to serial_omap_rxdma_poll().

The OMAP-Serial driver defines an RX_TIMEOUT of 3 seconds that is
used to indicate when the DMA for UART can be stopped if no more
data is received. The value is a global definition that is applied
to all instances of the UART.

Each UART may be used for a different purpose and so the timeout
required may differ. Make this value configurable for each UART so
that this value can be optimised for power savings.

Acked-by: Kevin Hilman khil...@ti.com
Signed-off-by: Jon Hunter jon-hun...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |5 -
 arch/arm/plat-omap/include/plat/omap-serial.h |3 ++-
 drivers/tty/serial/omap-serial.c  |   15 ---
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 3eb2469..5c6c48f 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -64,13 +64,15 @@ struct omap_uart_state {
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
-#define DEFAULT_RXDMA_TIMEOUT  1   /* RX DMA polling rate (us) */
+#define DEFAULT_RXDMA_POLLRATE 1   /* RX DMA polling rate (us) */
 #define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
+#define DEFAULT_RXDMA_TIMEOUT  (3 * HZ)/* RX DMA timeout (jiffies) */
 
 static struct omap_uart_port_info omap_serial_default_info[] __initdata = {
{
.dma_enabled= false,
.dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
+   .dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
.dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
.autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
},
@@ -351,6 +353,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
omap_up.enable_wakeup = omap_uart_enable_wakeup;
omap_up.dma_rx_buf_size = info-dma_rx_buf_size;
omap_up.dma_rx_timeout = info-dma_rx_timeout;
+   omap_up.dma_rx_poll_rate = info-dma_rx_poll_rate;
omap_up.autosuspend_timeout = info-autosuspend_timeout;
 
/* Enable the MDR1 errata for OMAP2/3/4 */
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 84906e9..e05c8da 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -53,7 +53,6 @@
 
 #define OMAP_UART_DMA_CH_FREE  -1
 
-#define RX_TIMEOUT (3 * HZ)
 #define OMAP_MAX_HSUART_PORTS  4
 
 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
@@ -68,6 +67,7 @@ struct omap_uart_port_info {
unsigned intdma_rx_buf_size;
unsigned intdma_rx_timeout;
unsigned intautosuspend_timeout;
+   unsigned intdma_rx_poll_rate;
 
int (*get_context_loss_count)(struct device *);
void (*set_forceidle)(struct platform_device *);
@@ -97,6 +97,7 @@ struct uart_omap_dma {
/* timer to poll activity on rx dma */
struct timer_list   rx_timer;
unsigned intrx_buf_size;
+   unsigned intrx_poll_rate;
unsigned intrx_timeout;
 };
 
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 297fcec..be55a5d 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -47,7 +47,7 @@ static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
 /* Forward declaration of functions */
 static void uart_tx_dma_callback(int lch, u16 ch_status, void *data);
-static void serial_omap_rx_timeout(unsigned long uart_no);
+static void serial_omap_rxdma_poll(unsigned long uart_no);
 static int serial_omap_start_rxdma(struct uart_omap_port *up);
 static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);
 
@@ -542,7 +542,7 @@ static int serial_omap_startup(struct uart_port *port)
(dma_addr_t *)(up-uart_dma.tx_buf_dma_phys),
0);
init_timer((up-uart_dma.rx_timer));
-   up-uart_dma.rx_timer.function = serial_omap_rx_timeout;
+   up-uart_dma.rx_timer.function = serial_omap_rxdma_poll;
up-uart_dma.rx_timer.data = up-pdev-id;
/* Currently the buffer size is 4KB. Can increase it */
up-uart_dma.rx_buf = dma_alloc_coherent(NULL,
@@ -1160,7

[PATCH v8 19/20] OMAP2+: UART: Do not gate uart clocks if used for debug_prints

2011-11-11 Thread Govindraj.R
If OMAP UART is used as console uart and debug is enabled,
avoid gating of uart clocks to print all debug prints.

If uart clocks are gated then the debug prints from omap_device
framework or hwmod framework can cause uart to enter recursive
pm_runtime calls, which can cause a deadlock over power lock usage.

For example: Say, uart clocks are cut and we get a print from
omap_device_disable stating disabling uart clocks. This print
calls omap_uart driver console_write which will call runtime API
get_sync which means we enter from runtime API put context to
runtime API get context.

-- runtime put (take power lock)
-- print disabling uart clocks
-- call uart console write
-- call get_sync (try to take power lock)

Also any clock enable API call from uart driver should not call any uart
operation until clocks are enabled back. Like get_sync having debug print
calling uart console write even before clocks are enabled.

So to avoid these scenarios, identify from bootargs if OMAP_UART(ttyO) is used
in debug mode. If so, do not set device_may_wakeup. This will prevent
pm_runtime_enable in uart driver and will avoid uart clock gating.
Debug is enabled either by adding debug word in bootarg or by setting
loglevel=10

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 5d910ef..a5d9c9c 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -66,6 +66,7 @@ static LIST_HEAD(uart_list);
 static u8 num_uarts;
 static u8 console_uart_id = -1;
 static u8 no_console_suspend;
+static u8 uart_debug;
 
 #define DEFAULT_RXDMA_POLLRATE 1   /* RX DMA polling rate (us) */
 #define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
@@ -329,6 +330,13 @@ static int __init omap_serial_early_init(void)
if (cmdline_find_option(uart_name)) {
console_uart_id = uart-num;
 
+   if (console_loglevel = 10) {
+   uart_debug = true;
+   pr_info(%s used as console in debug mode
+uart%d clocks will not be
+gated, uart_name, uart-num);
+   }
+
if (cmdline_find_option(no_console_suspend))
no_console_suspend = true;
 
@@ -432,7 +440,8 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
 
oh-dev_attr = uart;
 
-   if ((cpu_is_omap34xx() || cpu_is_omap44xx())  bdata-pads)
+   if (((cpu_is_omap34xx() || cpu_is_omap44xx())  bdata-pads)
+!uart_debug)
device_init_wakeup(pdev-dev, true);
 }
 
-- 
1.7.4.1

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


[PATCH v8 18/20] OMAP2+: UART: Avoid uart idling on suspend for no_console_suspend usecase

2011-11-11 Thread Govindraj.R
If no_console_suspend is used we have prevent uart idling during suspend
to provide debug prints.

Power domain hooks can idle uarts if left enabled during system wide suspend
so re-use the omap_device_disable_idle_on_suspend API's to ensure console_uart
is not idled during suspend.

omap_device_disable_idle_on_suspend API was used on all uarts since the uart
driver was not runtime adapted, now with runtime adaptation we can re-use this
API only for no_console_suspend use cases.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 631d72a..5d910ef 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -65,6 +65,7 @@ static struct omap_device_pm_latency *default_uart_latency;
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 static u8 console_uart_id = -1;
+static u8 no_console_suspend;
 
 #define DEFAULT_RXDMA_POLLRATE 1   /* RX DMA polling rate (us) */
 #define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
@@ -327,6 +328,10 @@ static int __init omap_serial_early_init(void)
 
if (cmdline_find_option(uart_name)) {
console_uart_id = uart-num;
+
+   if (cmdline_find_option(no_console_suspend))
+   no_console_suspend = true;
+
/*
 * omap-uart can be used for earlyprintk logs
 * So if omap-uart is used as console then prevent
@@ -417,9 +422,10 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
od = to_omap_device(pdev);
default_uart_latency = od-pm_lats;
od-pm_lats = console_uart_latency;
+   if (no_console_suspend)
+   omap_device_disable_idle_on_suspend(pdev);
}
 
-   omap_device_disable_idle_on_suspend(pdev);
oh-mux = omap_hwmod_mux_init(bdata-pads, bdata-pads_cnt);
 
uart-pdev = pdev;
-- 
1.7.4.1

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


[PATCH v8 20/20] OMAP2+: UART: Remove omap_uart_can_sleep and add pm_qos

2011-11-11 Thread Govindraj.R
Omap_uart_can_sleep function blocks system wide low power state until
uart is active remove this func and add qos requests to prevent
MPU from transitioning.

Keep qos request to default value which will allow MPU to transition
and while uart baud rate is available calculate the latency value
from the baudrate and use the same to hold constraint while uart clocks
are enabled, and if uart is auto-idled the constraint is updated with
default constraint value allowing MPU to transition.

Qos requests are blocking notifier calls so put these requests to
work queue, also the driver uses irq_safe version of runtime API's
and callbacks can be called in interrupt disabled context.
So to avoid warn on slow path warning while using qos update
API's from runtime callbacks use the qos_work_queue.

During bootup the runtime_resume call backs might not be called and runtime
callback gets called only after uart is idled by setting the autosuspend
timeout. So qos_request from runtime resume callback might not activated during
boot if uart baudrate is calculated during bootup for console uart, so schedule
the qos_work queue once we calc_latency while configuring the uart port.

Flush and complete any pending qos jobs in work queue while suspending.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |5 ---
 arch/arm/mach-omap2/pm24xx.c  |2 -
 arch/arm/mach-omap2/pm34xx.c  |   10 ---
 arch/arm/mach-omap2/serial.c  |   22 ---
 arch/arm/plat-omap/include/plat/omap-serial.h |6 
 drivers/tty/serial/omap-serial.c  |   36 -
 6 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 1fe35c2..6b4ed89 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -243,11 +243,6 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
struct omap3_idle_statedata *cx;
int ret;
 
-   if (!omap3_can_sleep()) {
-   new_state_idx = drv-safe_state_index;
-   goto select_state;
-   }
-
/*
 * Prevent idle completely if CAM is active.
 * CAM does not have wakeup capability in OMAP3.
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 5ec2b43..3a9e80b 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -221,8 +221,6 @@ static int omap2_can_sleep(void)
 {
if (omap2_fclks_active())
return 0;
-   if (!omap_uart_can_sleep())
-   return 0;
if (osc_ck-usecount  1)
return 0;
if (omap_dma_running())
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 2eb3215..6edcca8 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -417,21 +417,11 @@ void omap_sram_idle(void)
clkdm_allow_idle(mpu_pwrdm-pwrdm_clkdms[0]);
 }
 
-int omap3_can_sleep(void)
-{
-   if (!omap_uart_can_sleep())
-   return 0;
-   return 1;
-}
-
 static void omap3_pm_idle(void)
 {
local_irq_disable();
local_fiq_disable();
 
-   if (!omap3_can_sleep())
-   goto out;
-
if (omap_irq_pending() || need_resched())
goto out;
 
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index a5d9c9c..cf7484a 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -111,28 +111,6 @@ static struct omap_device_pm_latency 
console_uart_latency[] = {
 };
 
 #ifdef CONFIG_PM
-
-int omap_uart_can_sleep(void)
-{
-   struct omap_uart_state *uart;
-   int can_sleep = 1;
-
-   list_for_each_entry(uart, uart_list, node) {
-   if (!uart-clocked)
-   continue;
-
-   if (!uart-can_sleep) {
-   can_sleep = 0;
-   continue;
-   }
-
-   /* This UART can now safely sleep. */
-   omap_uart_allow_sleep(uart);
-   }
-
-   return can_sleep;
-}
-
 static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
 {
struct omap_device *od = to_omap_device(pdev);
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index e05c8da..f685150 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -19,6 +19,7 @@
 
 #include linux/serial_core.h
 #include linux/platform_device.h
+#include linux/pm_qos.h
 
 #include plat/mux.h
 
@@ -129,6 +130,11 @@ struct uart_omap_port {
u32 context_loss_cnt;
u32 errata;
u8  wakeups_enabled;
+
+   struct pm_qos_request   pm_qos_request;
+   u32 latency;
+   u32

[PATCH] OMAP2+: Fix compilation break when cpuidle pm is selected

2011-11-10 Thread Govindraj.R
When cpuidle pm is selected the following compilation break is seen
fix the same.

arch/arm/mach-omap2/cpuidle34xx.c:312: error: 'THIS_MODULE' undeclared here 
(not in a function)
make[1]: *** [arch/arm/mach-omap2/cpuidle34xx.o] Error 1

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 6b4ed89..8ca1ddb 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -24,6 +24,7 @@
 
 #include linux/sched.h
 #include linux/cpuidle.h
+#include linux/module.h
 
 #include plat/prcm.h
 #include plat/irqs.h
-- 
1.7.4.1

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


[PATCH] OMAP2+: Fix Compilation error when omap_l3_noc built as module

2011-11-09 Thread Govindraj.R
Fix below compilation failure on mainline kernel 3.2-rc1
when omap_l3_noc.c is built as module.

arch/arm/mach-omap2/omap_l3_noc.c:240: error: expected ',' or ';' before 
'MODULE_DEVICE_TABLE'

Signed-off-by: Govindraj.R govindraj.r...@ti.com
Acked-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/omap_l3_noc.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_l3_noc.c 
b/arch/arm/mach-omap2/omap_l3_noc.c
index 6a66aa5..d15225f 100644
--- a/arch/arm/mach-omap2/omap_l3_noc.c
+++ b/arch/arm/mach-omap2/omap_l3_noc.c
@@ -237,7 +237,7 @@ static int __devexit omap4_l3_remove(struct platform_device 
*pdev)
 static const struct of_device_id l3_noc_match[] = {
{.compatible = ti,omap4-l3-noc, },
{},
-}
+};
 MODULE_DEVICE_TABLE(of, l3_noc_match);
 #else
 #define l3_noc_match NULL
-- 
1.7.4.1

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


[PATCH] OMAP2+: Fix Compilation break on current mainline

2011-11-07 Thread Govindraj.R
 defaults to 'int' in 
declaration of 'EXPORT_SYMBOL_GPL'
arch/arm/plat-omap/dmtimer.c:517: warning: parameter names (without types) in 
function declaration
arch/arm/plat-omap/dmtimer.c:534: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:534: warning: type defaults to 'int' in 
declaration of 'EXPORT_SYMBOL_GPL'
arch/arm/plat-omap/dmtimer.c:534: warning: parameter names (without types) in 
function declaration
arch/arm/plat-omap/dmtimer.c:549: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:549: warning: type defaults to 'int' in 
declaration of 'EXPORT_SYMBOL_GPL'
arch/arm/plat-omap/dmtimer.c:549: warning: parameter names (without types) in 
function declaration
arch/arm/plat-omap/dmtimer.c:561: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:561: warning: type defaults to 'int' in 
declaration of 'EXPORT_SYMBOL_GPL'
arch/arm/plat-omap/dmtimer.c:561: warning: parameter names (without types) in 
function declaration
arch/arm/plat-omap/dmtimer.c:572: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:572: warning: type defaults to 'int' in 
declaration of 'EXPORT_SYMBOL_GPL'
arch/arm/plat-omap/dmtimer.c:572: warning: parameter names (without types) in 
function declaration
arch/arm/plat-omap/dmtimer.c:587: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:587: warning: type defaults to 'int' in 
declaration of 'EXPORT_SYMBOL_GPL'
arch/arm/plat-omap/dmtimer.c:587: warning: parameter names (without types) in 
function declaration
arch/arm/plat-omap/dmtimer.c:604: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:604: warning: type defaults to 'int' in 
declaration of 'EXPORT_SYMBOL_GPL'
arch/arm/plat-omap/dmtimer.c:604: warning: parameter names (without types) in 
function declaration
arch/arm/plat-omap/dmtimer.c:746: error: expected declaration specifiers or 
'...' before string constant
arch/arm/plat-omap/dmtimer.c:746: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:746: warning: type defaults to 'int' in 
declaration of 'MODULE_DESCRIPTION'
arch/arm/plat-omap/dmtimer.c:746: warning: function declaration isn't a 
prototype
arch/arm/plat-omap/dmtimer.c:747: error: expected declaration specifiers or 
'...' before string constant
arch/arm/plat-omap/dmtimer.c:747: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:747: warning: type defaults to 'int' in 
declaration of 'MODULE_LICENSE'
arch/arm/plat-omap/dmtimer.c:747: warning: function declaration isn't a 
prototype
arch/arm/plat-omap/dmtimer.c:748: error: expected declaration specifiers or 
'...' before string constant
arch/arm/plat-omap/dmtimer.c:748: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:748: warning: type defaults to 'int' in 
declaration of 'MODULE_ALIAS'
arch/arm/plat-omap/dmtimer.c:748: warning: function declaration isn't a 
prototype
arch/arm/plat-omap/dmtimer.c:749: error: expected declaration specifiers or 
'...' before string constant
arch/arm/plat-omap/dmtimer.c:749: warning: data definition has no type or 
storage class
arch/arm/plat-omap/dmtimer.c:749: warning: type defaults to 'int' in 
declaration of 'MODULE_AUTHOR'
arch/arm/plat-omap/dmtimer.c:749: warning: function declaration isn't a 
prototype
make[1]: *** [arch/arm/plat-omap/dmtimer.o] Error 1
make: *** [arch/arm/plat-omap] Error 2
make: *** Waiting for unfinished jobs
arch/arm/mach-omap2/omap_l3_noc.c:240: error: expected ',' or ';' before 
'MODULE_DEVICE_TABLE'
arch/arm/mach-omap2/omap_l3_noc.c:250: error: 'THIS_MODULE' undeclared here 
(not in a function)
make[1]: *** [arch/arm/mach-omap2/omap_l3_noc.o] Error 1
make: *** [arch/arm/mach-omap2] Error 2

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
Sorry for the noise if this is already fixed.

 arch/arm/mach-omap2/omap_l3_noc.c |3 ++-
 arch/arm/plat-omap/dmtimer.c  |1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_l3_noc.c 
b/arch/arm/mach-omap2/omap_l3_noc.c
index c8b1bef..eacbe55 100644
--- a/arch/arm/mach-omap2/omap_l3_noc.c
+++ b/arch/arm/mach-omap2/omap_l3_noc.c
@@ -26,6 +26,7 @@
 #include linux/interrupt.h
 #include linux/kernel.h
 #include linux/slab.h
+#include linux/module.h
 
 #include omap_l3_noc.h
 
@@ -236,7 +237,7 @@ static int __devexit omap4_l3_remove(struct platform_device 
*pdev)
 static const struct of_device_id l3_noc_match[] = {
{.compatible = ti,omap4-l3-noc, },
{},
-}
+};
 MODULE_DEVICE_TABLE(of, l3_noc_match);
 #else
 #define l3_noc_match NULL
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 2def4e1..b9acaca 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -39,6 +39,7 @@
 #include linux/slab.h
 #include linux/err.h
 #include linux/pm_runtime.h
+#include linux

[PATCH] OMAP2+: Fix Compilation error on current mainline

2011-11-07 Thread Govindraj.R
Patch to fix below compilation error on latest mainline commit
b32fc0a0629bf5894b35f33554c118aacfd0d1e2 with omap2plus_defconfig.

arch/arm/mach-omap2/omap_l3_noc.c:250: error: 'THIS_MODULE' undeclared here 
(not in a function)
make[1]: *** [arch/arm/mach-omap2/omap_l3_noc.o] Error 1

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_l3_noc.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_l3_noc.c 
b/arch/arm/mach-omap2/omap_l3_noc.c
index c8b1bef..c2cc196 100644
--- a/arch/arm/mach-omap2/omap_l3_noc.c
+++ b/arch/arm/mach-omap2/omap_l3_noc.c
@@ -26,6 +26,7 @@
 #include linux/interrupt.h
 #include linux/kernel.h
 #include linux/slab.h
+#include linux/module.h
 
 #include omap_l3_noc.h
 
-- 
1.7.4.1

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


[PATCH v7 12/21] OMAP2+: UART: Add wakeup mechanism for omap-uarts

2011-10-18 Thread Govindraj.R
From the runtime callbacks enable hwmod wakeups for uart which will
internally enable io-pad wakeups for uarts if they have rx-pad pins
set as wakeup capabale.

Use the io-ring wakeup mechanism after uart clock gating and leave
the PM_WKST set for uart to default reset values cleanup the
code in serial.c which was handling PM_WKST reg.
Irq_chaing(PRM_DRIVER) is used to wakeup uart after uart clocks are gated
using pad wakeup mechanism.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   96 +++-
 arch/arm/plat-omap/include/plat/omap-serial.h |2 +
 drivers/tty/serial/omap-serial.c  |   15 
 3 files changed, 29 insertions(+), 84 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 8c6dc85..6b3f0bd 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -56,10 +56,6 @@ struct omap_uart_state {
int num;
int can_sleep;
 
-   void __iomem *wk_st;
-   void __iomem *wk_en;
-   u32 wk_mask;
-
int clocked;
 
struct list_head node;
@@ -114,26 +110,6 @@ static inline void omap_uart_disable_clocks(struct 
omap_uart_state *uart)
omap_device_idle(uart-pdev);
 }
 
-static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
-{
-   /* Set wake-enable bit */
-   if (uart-wk_en  uart-wk_mask) {
-   u32 v = __raw_readl(uart-wk_en);
-   v |= uart-wk_mask;
-   __raw_writel(v, uart-wk_en);
-   }
-}
-
-static void omap_uart_disable_wakeup(struct omap_uart_state *uart)
-{
-   /* Clear wake-enable bit */
-   if (uart-wk_en  uart-wk_mask) {
-   u32 v = __raw_readl(uart-wk_en);
-   v = ~uart-wk_mask;
-   __raw_writel(v, uart-wk_en);
-   }
-}
-
 static void omap_uart_block_sleep(struct omap_uart_state *uart)
 {
omap_uart_enable_clocks(uart);
@@ -163,65 +139,17 @@ int omap_uart_can_sleep(void)
return can_sleep;
 }
 
-static void omap_uart_idle_init(struct omap_uart_state *uart)
+static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
 {
-   int ret;
-
-   uart-can_sleep = 0;
-   omap_uart_smart_idle_enable(uart, 0);
+   struct omap_device *od = to_omap_device(pdev);
 
-   if (cpu_is_omap34xx()  !cpu_is_ti816x()) {
-   u32 mod = (uart-num  1) ? OMAP3430_PER_MOD : CORE_MOD;
-   u32 wk_mask = 0;
+   if (!od)
+   return;
 
-   /* XXX These PRM accesses do not belong here */
-   uart-wk_en = OMAP34XX_PRM_REGADDR(mod, PM_WKEN1);
-   uart-wk_st = OMAP34XX_PRM_REGADDR(mod, PM_WKST1);
-   switch (uart-num) {
-   case 0:
-   wk_mask = OMAP3430_ST_UART1_MASK;
-   break;
-   case 1:
-   wk_mask = OMAP3430_ST_UART2_MASK;
-   break;
-   case 2:
-   wk_mask = OMAP3430_ST_UART3_MASK;
-   break;
-   case 3:
-   wk_mask = OMAP3630_ST_UART4_MASK;
-   break;
-   }
-   uart-wk_mask = wk_mask;
-   } else if (cpu_is_omap24xx()) {
-   u32 wk_mask = 0;
-   u32 wk_en = PM_WKEN1, wk_st = PM_WKST1;
-
-   switch (uart-num) {
-   case 0:
-   wk_mask = OMAP24XX_ST_UART1_MASK;
-   break;
-   case 1:
-   wk_mask = OMAP24XX_ST_UART2_MASK;
-   break;
-   case 2:
-   wk_en = OMAP24XX_PM_WKEN2;
-   wk_st = OMAP24XX_PM_WKST2;
-   wk_mask = OMAP24XX_ST_UART3_MASK;
-   break;
-   }
-   uart-wk_mask = wk_mask;
-   if (cpu_is_omap2430()) {
-   uart-wk_en = OMAP2430_PRM_REGADDR(CORE_MOD, wk_en);
-   uart-wk_st = OMAP2430_PRM_REGADDR(CORE_MOD, wk_st);
-   } else if (cpu_is_omap2420()) {
-   uart-wk_en = OMAP2420_PRM_REGADDR(CORE_MOD, wk_en);
-   uart-wk_st = OMAP2420_PRM_REGADDR(CORE_MOD, wk_st);
-   }
-   } else {
-   uart-wk_en = NULL;
-   uart-wk_st = NULL;
-   uart-wk_mask = 0;
-   }
+   if (enable)
+   omap_hwmod_enable_wakeup(od-hwmods[0]);
+   else
+   omap_hwmod_disable_wakeup(od-hwmods[0]);
 }
 
 /*
@@ -244,6 +172,8 @@ static void omap_uart_set_forceidle(struct platform_device 
*pdev)
 }
 
 #else
+static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
+{}
 static void omap_uart_set_noidle(struct platform_device *pdev) {}
 static void omap_uart_set_forceidle(struct platform_device *pdev) {}
 static void omap_uart_block_sleep

[PATCH v7 16/21] OMAP2+: UART: Remove custom activate funcs and use generic funcs.

2011-10-18 Thread Govindraj.R
The custom hwmod activate and deactivate funcs does hwmod_enable
and idle same can be done with omap_device generic API's.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |   18 ++
 1 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 7c65410..7658a03 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -78,24 +78,10 @@ static struct omap_uart_port_info 
omap_serial_default_info[] __initdata = {
},
 };
 
-static int uart_idle_hwmod(struct omap_device *od)
-{
-   omap_hwmod_idle(od-hwmods[0]);
-
-   return 0;
-}
-
-static int uart_enable_hwmod(struct omap_device *od)
-{
-   omap_hwmod_enable(od-hwmods[0]);
-
-   return 0;
-}
-
 static struct omap_device_pm_latency omap_uart_latency[] = {
{
-   .deactivate_func = uart_idle_hwmod,
-   .activate_func   = uart_enable_hwmod,
+   .activate_func   = omap_device_enable_hwmods,
+   .deactivate_func = omap_device_idle_hwmods,
.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
},
 };
-- 
1.7.4.1

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


[PATCH v6 00/16] OMAP2+: UART: Runtime adaptation + cleanup

2011-09-30 Thread Govindraj.R
Converting uart driver to adapt to pm runtime API's.
Code re-org + cleanup.
Moving some functionality from serial.c to omap-serial.c

Changes involves:

1.) Cleaning up certain uart calls from sram_idle func.
2.) Removed all types of uart clock handling code from serial.c
3.) Using hwmod_mux API enable wakeup capability for uart pad during
   hwmod_idle state i.e., when uart clocks are disabled we can enable
   io-pad wakeup capability for uart if mux_data is available for
   given uart. Also during during resume from idle call to uart we need
   to enable clocks back conditionally and this can be done only when io-pad
   wakeup event bit is set for uart_rx pad. So we need a hwmod API
   which can probe the uart pad and let us know whether a uart wakeup
   happened. So omap_hmwod_pad_wakeup_status API is added to meet this
   requirement.
3.) Adapted omap-serial driver to use runtime API's.
4.) Modify serial_init calls to accept uart parameters from board file.
Like dma_usage, rx_timeout, dma_rx_pollrate, auto_suspend_timeout etc.
5.) Use the omap_prm driver with irq_chaining to wake up uart after clocks are
cut.

Patch series is based on 3.1.0-rc4 + omap_device fixes.
From Kevin's tree.
git://gitorious.org/khilman/linux-omap-pm.git for_3.2/omap_device

Also the patch series depends on Tero's v9 Irq_chaining patches.
Dependent irq_chaining patches are as below.

e9e7ae1 omap3+: add omap prm driver initialization
e52486f OMAP3: pm: do not enable PRCM MPU interrupts manually
ae5f2af omap3: pm: use prcm chain handler
61ad50f OMAP2+: mux: add support for PAD wakeup interrupts
cab47bf mfd: omap-prm: added suspend prepare and complete callbacks
8ed5bcd mfd: omap-prm: added chain interrupt handler
024f0e3 mfd: omap-prm: add driver skeleton
d285827 TEMP: OMAP4xxx: hwmod data: add PRM hwmod
da6f48f TEMP: OMAP3xxx: hwmod data: add PRM hwmod

Same combination is hosted at:
git://gitorious.org/runtime_3-0/runtime_3-0.git v6_uart_runtime

Ensure CONFIG_OMAP_PRM is set while testing irq_chaining with uart.

Changes from v5:
---
* Incorporating omap_uart_can_sleep function to avoid
  console sluglishness as reported by tero.
* fixing below comments adding omap4 for autosuspend and wakeup.
  http://www.mail-archive.com/linux-omap@vger.kernel.org/msg56221.html

  In addition cleaning up pads from omap4430sdp/panda board file
  to use default pads from serial.c

Changes from v4:
---

1.) Fixing v4 comments from Kevin.
Spilt into smaller logical patches.
2.) Using Irq_chaining OMAP_PRM driver for waking up uart.

Testing updates:

OMAP2420/2430SDP: Boot tested.

OMAP3430SDP:
retention, off_mode, system_wide suspend is tested.
(earlyprintk  no_console_suspend checked)

OMAP3630 - Zoom3:
pm-retention checked with quart/omap-uart3
[Also tested with uart3 as console uart and pm-ret checked]

BeagleBoard XM Rev C(3630):
retention, off_mode, system_wide suspend is tested.

OMAP4430-SDP/PANDA-4430/PANDA-4460: Boot tested.

Deepak K (1):
  OMAP2+: UART: Allow UART parameters to be configured from board file.

Govindraj.R (14):
  OMAP2+: hwmod: Add API to enable IO ring wakeup.
  OMAP2+: hwmod: Add API to check IO PAD wakeup status
  OMAP2+: UART: cleanup + remove uart pm specific API
  OMAP2+: UART: cleanup 8250 console driver support
  OMAP2+: UART: Cleanup part of clock gating mechanism for uart
  OMAP2+: UART: Remove certain feilds from omap_uart_state struct
  OMAP2+: UART: Add default mux for all uarts.
  OMAP2+: UART: Store certain reg values to port structure
  OMAP2+: UART: Add runtime pm support for omap-serial driver
  OMAP2+: UART: Modify omap_uart_can_sleep function
  OMAP2+: UART: Move errata handling from serial.c to omap-serial
  OMAP2+: UART: Take console_lock in suspend path if not taken
  OMAP2+: UART: Enable back uart clocks with runtime API for early
console
  OMAP2+: UART: Do not gate uart clocks if used for debug_prints

Jon Hunter (1):
  OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART

 arch/arm/mach-omap2/board-3430sdp.c   |  100 +---
 arch/arm/mach-omap2/board-4430sdp.c   |   68 +--
 arch/arm/mach-omap2/board-n8x0.c  |6 +-
 arch/arm/mach-omap2/board-omap4panda.c|   68 +--
 arch/arm/mach-omap2/mux.c |   30 +
 arch/arm/mach-omap2/mux.h |   13 +
 arch/arm/mach-omap2/omap_hwmod.c  |   66 ++
 arch/arm/mach-omap2/pm24xx.c  |   18 -
 arch/arm/mach-omap2/pm34xx.c  |   23 -
 arch/arm/mach-omap2/serial.c  |  937 +++--
 arch/arm/plat-omap/include/plat/omap-serial.h |   30 +-
 arch/arm/plat-omap/include/plat/omap_hwmod.h  |1 +
 arch/arm/plat-omap/include/plat/serial.h  |   10 +-
 drivers/tty/serial/omap-serial.c  |  305 +++--
 14 files changed, 660 insertions(+), 1015 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send

[PATCH v6 02/16] OMAP2+: hwmod: Add API to check IO PAD wakeup status

2011-09-30 Thread Govindraj.R
Add API to determine IO-PAD wakeup event status for a given
hwmod dynamic_mux pad.

Wake up event set will be cleared on pad mux_read.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/mux.c|   30 ++
 arch/arm/mach-omap2/mux.h|   13 +++
 arch/arm/mach-omap2/omap_hwmod.c |7 ++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |1 +
 4 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 655e948..fb75aae 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -351,6 +351,36 @@ err1:
return NULL;
 }
 
+/**
+ * omap_hwmod_mux_get_wake_status - omap hwmod check pad wakeup
+ * @hmux:  Pads for a hwmod
+ *
+ * Gets the wakeup status of given pad from omap-hwmod.
+ * Returns true if wakeup capability is set and wakeup event occurred.
+ * Returns false if wakeup event has not occurred or pads are not available.
+ */
+bool omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux)
+{
+   int i;
+   unsigned int val;
+   u8 ret = false;
+
+   for (i = 0; i  hmux-nr_pads; i++) {
+   struct omap_device_pad *pad = hmux-pads[i];
+
+   if (pad-flags  OMAP_DEVICE_PAD_WAKEUP) {
+   val = omap_mux_read(pad-partition,
+   pad-mux-reg_offset);
+   if (val  OMAP_WAKEUP_EVENT) {
+   ret = true;
+   break;
+   }
+   }
+   }
+
+   return ret;
+}
+
 /* Assumes the calling function takes care of locking */
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 {
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 2132308..8b2150a 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -225,8 +225,21 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int 
nr_pads);
  */
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
 
+/**
+ * omap_hwmod_mux_get_wake_status - omap hwmod check pad wakeup
+ * @hmux:  Pads for a hwmod
+ *
+ * Called only from omap_hwmod.c, do not use.
+ */
+bool omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux);
 #else
 
+static inline bool
+omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux)
+{
+   return 0;
+}
+
 static inline int omap_mux_init_gpio(int gpio, int val)
 {
return 0;
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index e751dd9..a8b24d7 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2724,3 +2724,10 @@ int omap_hwmod_no_setup_reset(struct omap_hwmod *oh)
 
return 0;
 }
+
+int omap_hwmod_pad_get_wakeup_status(struct omap_hwmod *oh)
+{
+   if (oh  oh-mux)
+   return omap_hwmod_mux_get_wake_status(oh-mux);
+   return -EINVAL;
+}
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h 
b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 0e329ca..9a6195c 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -607,6 +607,7 @@ u32 omap_hwmod_get_context_loss_count(struct omap_hwmod 
*oh);
 
 int omap_hwmod_no_setup_reset(struct omap_hwmod *oh);
 
+int omap_hwmod_pad_get_wakeup_status(struct omap_hwmod *oh);
 /*
  * Chip variant-specific hwmod init routines - XXX should be converted
  * to use initcalls once the initial boot ordering is straightened out
-- 
1.7.4.1

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


[PATCH v6 08/16] OMAP2+: UART: Store certain reg values to port structure

2011-09-30 Thread Govindraj.R
In preparation to runtime conversion add missing uart regs to
port structure which can be used in context restore.
Also ensuring all uart reg info's are part of port structure.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/plat-omap/include/plat/omap-serial.h |3 ++
 drivers/tty/serial/omap-serial.c  |   33 ++--
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 0f061b4..74822b3 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -99,6 +99,9 @@ struct uart_omap_port {
unsigned char   mcr;
unsigned char   fcr;
unsigned char   efr;
+   unsigned char   dll;
+   unsigned char   dlh;
+   unsigned char   mdr1;
 
int use_dma;
/*
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6c2ea54..9a0eac2 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -433,8 +433,9 @@ static void serial_omap_set_mctrl(struct uart_port *port, 
unsigned int mctrl)
if (mctrl  TIOCM_LOOP)
mcr |= UART_MCR_LOOP;
 
-   mcr |= up-mcr;
-   serial_out(up, UART_MCR, mcr);
+   up-mcr = serial_in(up, UART_MCR);
+   up-mcr |= mcr;
+   serial_out(up, UART_MCR, up-mcr);
 }
 
 static void serial_omap_break_ctl(struct uart_port *port, int break_state)
@@ -573,8 +574,6 @@ static inline void
 serial_omap_configure_xonxoff
(struct uart_omap_port *up, struct ktermios *termios)
 {
-   unsigned char efr = 0;
-
up-lcr = serial_in(up, UART_LCR);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
up-efr = serial_in(up, UART_EFR);
@@ -584,8 +583,7 @@ serial_omap_configure_xonxoff
serial_out(up, UART_XOFF1, termios-c_cc[VSTOP]);
 
/* clear SW control mode bits */
-   efr = up-efr;
-   efr = OMAP_UART_SW_CLR;
+   up-efr = OMAP_UART_SW_CLR;
 
/*
 * IXON Flag:
@@ -593,7 +591,7 @@ serial_omap_configure_xonxoff
 * Transmit XON1, XOFF1
 */
if (termios-c_iflag  IXON)
-   efr |= OMAP_UART_SW_TX;
+   up-efr |= OMAP_UART_SW_TX;
 
/*
 * IXOFF Flag:
@@ -601,7 +599,7 @@ serial_omap_configure_xonxoff
 * Receiver compares XON1, XOFF1.
 */
if (termios-c_iflag  IXOFF)
-   efr |= OMAP_UART_SW_RX;
+   up-efr |= OMAP_UART_SW_RX;
 
serial_out(up, UART_EFR, up-efr | UART_EFR_ECB);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
@@ -624,7 +622,7 @@ serial_omap_configure_xonxoff
 * load the new software flow control mode IXON or IXOFF
 * and restore the UARTi.EFR_REG[4] ENHANCED_EN value.
 */
-   serial_out(up, UART_EFR, efr | UART_EFR_SCD);
+   serial_out(up, UART_EFR, up-efr | UART_EFR_SCD);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
 
serial_out(up, UART_MCR, up-mcr  ~UART_MCR_TCRTLR);
@@ -671,6 +669,10 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
baud = uart_get_baud_rate(port, termios, old, 0, port-uartclk/13);
quot = serial_omap_get_divisor(port, baud);
 
+   up-dll = quot  0xff;
+   up-dlh = quot  8;
+   up-mdr1 = UART_OMAP_MDR1_DISABLE;
+
up-fcr = UART_FCR_R_TRIG_01 | UART_FCR_T_TRIG_01 |
UART_FCR_ENABLE_FIFO;
if (up-use_dma)
@@ -723,6 +725,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
up-ier |= UART_IER_MSI;
serial_out(up, UART_IER, up-ier);
serial_out(up, UART_LCR, cval); /* reset DLAB */
+   up-lcr = cval;
 
/* FIFOs and DMA Settings */
 
@@ -759,7 +762,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
 
/* Protocol, Baud Rate, and Interrupt Settings */
 
-   serial_out(up, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
+   serial_out(up, UART_OMAP_MDR1, up-mdr1);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
up-efr = serial_in(up, UART_EFR);
@@ -769,8 +772,8 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_IER, 0);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
-   serial_out(up, UART_DLL, quot  0xff);  /* LS of divisor */
-   serial_out(up, UART_DLM, quot  8);/* MS of divisor */
+   serial_out(up, UART_DLL, up-dll);  /* LS of divisor */
+   serial_out(up, UART_DLM, up-dlh);  /* MS of divisor */
 
serial_out(up, UART_LCR, 0);
serial_out(up, UART_IER, up-ier);
@@ -780,9 +783,11 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_LCR

[PATCH v6 01/16] OMAP2+: hwmod: Add API to enable IO ring wakeup.

2011-09-30 Thread Govindraj.R
Add API to enable IO pad wakeup capability based on mux dynamic pad and
wake_up enable flag available from hwmod_mux initialization.

Use the wakeup_enable flag and enable wakeup capability
for the given pads. Wakeup capability will be enabled/disabled
during hwmod idle transition based on whether wakeup_flag is
set or cleared.

Call the omap_hwmod_set_ioring_wakeup from hwmod_wakeup_enable/disable.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c |   59 ++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 84cc0bd..e751dd9 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2062,6 +2062,34 @@ static int __init omap_hwmod_setup_all(void)
 core_initcall(omap_hwmod_setup_all);
 
 /**
+ * omap_hwmod_set_ioring_wakeup - enable io pad wakeup flag.
+ * @oh: struct omap_hwmod *
+ * @set: bool value indicating to set or clear wakeup status.
+ *
+ * Set or Clear wakeup flag for the io_pad.
+ */
+static int omap_hwmod_set_ioring_wakeup(struct omap_hwmod *oh, bool set_wake)
+{
+   struct omap_device_pad *pad;
+   int ret = -EINVAL, j;
+
+   if (oh-mux  oh-mux-enabled) {
+   for (j = 0; j  oh-mux-nr_pads_dynamic; j++) {
+   pad = oh-mux-pads_dynamic[j];
+   if (pad-flags  OMAP_DEVICE_PAD_WAKEUP) {
+   if (set_wake)
+   pad-idle |= OMAP_WAKEUP_EN;
+   else
+   pad-idle = ~OMAP_WAKEUP_EN;
+   ret = 0;
+   }
+   }
+   }
+
+   return ret;
+}
+
+/**
  * omap_hwmod_enable - enable an omap_hwmod
  * @oh: struct omap_hwmod *
  *
@@ -2393,6 +2421,35 @@ int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh,
 {
return _del_initiator_dep(oh, init_oh);
 }
+/**
+ * omap_hwmod_enable_ioring_wakeup - Set wakeup flag for iopad.
+ * @oh: struct omap_hwmod *
+ *
+ * Traverse through dynamic pads, if pad is enabled then
+ * set wakeup enable bit flag for the mux pin. Wakeup pad bit
+ * will be set during hwmod idle transistion.
+ * Return error if pads are not enabled or not available.
+ */
+int omap_hwmod_enable_ioring_wakeup(struct omap_hwmod *oh)
+{
+   /* Enable pad wake-up capability */
+   return omap_hwmod_set_ioring_wakeup(oh, true);
+}
+
+/**
+ * omap_hwmod_disable_ioring_wakeup - Clear wakeup flag for iopad.
+ * @oh: struct omap_hwmod *
+ *
+ * Traverse through dynamic pads, if pad is enabled then
+ * clear wakeup enable bit flag for the mux pin. Wakeup pad bit
+ * will be set during hwmod idle transistion.
+ * Return error if pads are not enabled or not available.
+ */
+int omap_hwmod_disable_ioring_wakeup(struct omap_hwmod *oh)
+{
+   /* Disable pad wakeup capability */
+   return omap_hwmod_set_ioring_wakeup(oh, false);
+}
 
 /**
  * omap_hwmod_enable_wakeup - allow device to wake up the system
@@ -2419,6 +2476,7 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
v = oh-_sysc_cache;
_enable_wakeup(oh, v);
_write_sysconfig(v, oh);
+   omap_hwmod_enable_ioring_wakeup(oh);
spin_unlock_irqrestore(oh-_lock, flags);
 
return 0;
@@ -2449,6 +2507,7 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
v = oh-_sysc_cache;
_disable_wakeup(oh, v);
_write_sysconfig(v, oh);
+   omap_hwmod_disable_ioring_wakeup(oh);
spin_unlock_irqrestore(oh-_lock, flags);
 
return 0;
-- 
1.7.4.1

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


[PATCH v6 03/16] OMAP2+: UART: cleanup + remove uart pm specific API

2011-09-30 Thread Govindraj.R
In preparation to UART runtime conversion remove uart specific calls
from pm24xx/34xx files and their definition from serial.c
These func calls will no more be used with upcoming uart runtime design.

1.) omap_uart_prepare_suspend :- can be taken care with driver suspend hooks.
2.) omap_uart_enable_irqs :- Used to enable/disable uart irq's in suspend
path from PM code, this is removed as same is handled by
uart_suspend_port/uart_resume_port in omap-serial driver which will
do an port_shutdown on suspend freeing irq and port_startup on resume
enabling back irq.
3.) Remove prepare_idle/resume_idle calls used to gate uart clocks.
UART clocks can be gated within driver using runtime funcs
and be woken up using irq_chaining from omap_prm driver.
4.) Remove console_locking from idle path as clock gating is done withing
driver itself with runtime API.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/pm24xx.c |   18 
 arch/arm/mach-omap2/pm34xx.c |   23 --
 arch/arm/mach-omap2/serial.c |   65 --
 arch/arm/plat-omap/include/plat/serial.h |4 --
 4 files changed, 0 insertions(+), 110 deletions(-)

diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index bf089e7..a75f764 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -30,7 +30,6 @@
 #include linux/irq.h
 #include linux/time.h
 #include linux/gpio.h
-#include linux/console.h
 
 #include asm/mach/time.h
 #include asm/mach/irq.h
@@ -133,27 +132,11 @@ static void omap2_enter_full_retention(void)
if (omap_irq_pending())
goto no_sleep;
 
-   /* Block console output in case it is on one of the OMAP UARTs */
-   if (!is_suspending())
-   if (!console_trylock())
-   goto no_sleep;
-
-   omap_uart_prepare_idle(0);
-   omap_uart_prepare_idle(1);
-   omap_uart_prepare_idle(2);
-
/* Jump to SRAM suspend code */
omap2_sram_suspend(sdrc_read_reg(SDRC_DLLA_CTRL),
   OMAP_SDRC_REGADDR(SDRC_DLLA_CTRL),
   OMAP_SDRC_REGADDR(SDRC_POWER));
 
-   omap_uart_resume_idle(2);
-   omap_uart_resume_idle(1);
-   omap_uart_resume_idle(0);
-
-   if (!is_suspending())
-   console_unlock();
-
 no_sleep:
if (omap2_pm_debug) {
unsigned long long tmp;
@@ -317,7 +300,6 @@ static int omap2_pm_suspend(void)
mir1 = omap_readl(0x480fe0a4);
omap_writel(1  5, 0x480fe0ac);
 
-   omap_uart_prepare_suspend();
omap2_enter_full_retention();
 
omap_writel(mir1, 0x480fe0a4);
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 7255d9b..344d412 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -28,7 +28,6 @@
 #include linux/clk.h
 #include linux/delay.h
 #include linux/slab.h
-#include linux/console.h
 #include trace/events/power.h
 
 #include asm/suspend.h
@@ -379,18 +378,9 @@ void omap_sram_idle(void)
omap3_enable_io_chain();
}
 
-   /* Block console output in case it is on one of the OMAP UARTs */
-   if (!is_suspending())
-   if (per_next_state  PWRDM_POWER_ON ||
-   core_next_state  PWRDM_POWER_ON)
-   if (!console_trylock())
-   goto console_still_active;
-
/* PER */
if (per_next_state  PWRDM_POWER_ON) {
per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
-   omap_uart_prepare_idle(2);
-   omap_uart_prepare_idle(3);
omap2_gpio_prepare_for_idle(per_going_off);
if (per_next_state == PWRDM_POWER_OFF)
omap3_per_save_context();
@@ -398,8 +388,6 @@ void omap_sram_idle(void)
 
/* CORE */
if (core_next_state  PWRDM_POWER_ON) {
-   omap_uart_prepare_idle(0);
-   omap_uart_prepare_idle(1);
if (core_next_state == PWRDM_POWER_OFF) {
omap3_core_save_context();
omap3_cm_save_context();
@@ -446,8 +434,6 @@ void omap_sram_idle(void)
omap3_sram_restore_context();
omap2_sms_restore_context();
}
-   omap_uart_resume_idle(0);
-   omap_uart_resume_idle(1);
if (core_next_state == PWRDM_POWER_OFF)
omap2_prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF_MASK,
   OMAP3430_GR_MOD,
@@ -461,14 +447,8 @@ void omap_sram_idle(void)
omap2_gpio_resume_after_idle();
if (per_prev_state == PWRDM_POWER_OFF)
omap3_per_restore_context();
-   omap_uart_resume_idle(2);
-   omap_uart_resume_idle(3

[PATCH v6 06/16] OMAP2+: UART: Remove certain feilds from omap_uart_state struct

2011-09-30 Thread Govindraj.R
Removing some of the uart info that is maintained in omap_uart_state struct
used for UART PM in serial.c.

Remove omap_uart_state struct dependency from omap_serial_init,
omap_serial_init_port, omap_serial_early_init and omap_uart_idle_init functions.
And populate the same info in omap_uart_port_info struct used as pdata struct.

Added omap_uart_hwmod_lookup function to look up oh by name used
in serial_port_init and omap_serial_early_init functions.

A list of omap_uart_state was maintained one for each uart, the same is removed.
Number of uarts available is maintained in num_uarts field, re-use the same in
omap_serial_init func to register each uart.

Remove omap_info which used details from omap_uart_state and use
a pdata pointer to pass platform specific info to driver.

The mapbase (start_address), membase(io_remap cookie) maintained as part of
uart_state struct and pdata struct are removed as this is handled within
driver. Errata field is also moved to pdata. These changes are done
to cleanup serial.c file and prepare for runtime changes.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |  132 +---
 arch/arm/plat-omap/include/plat/omap-serial.h |4 +-
 drivers/tty/serial/omap-serial.c  |   12 ++-
 3 files changed, 61 insertions(+), 87 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index c98b9b4..8c43d1c 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -68,14 +68,6 @@ struct omap_uart_state {
int clocked;
 
int regshift;
-   void __iomem *membase;
-   resource_size_t mapbase;
-
-   struct list_head node;
-   struct omap_hwmod *oh;
-   struct platform_device *pdev;
-
-   u32 errata;
 #if defined(CONFIG_ARCH_OMAP3)  defined(CONFIG_PM)
int context_valid;
 
@@ -90,7 +82,6 @@ struct omap_uart_state {
 #endif
 };
 
-static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
 static int uart_idle_hwmod(struct omap_device *od)
@@ -143,7 +134,19 @@ static inline void serial_write_reg(struct omap_uart_state 
*uart, int offset,
__raw_writeb(value, uart-membase + offset);
 }
 
-#if defined(CONFIG_PM)  defined(CONFIG_ARCH_OMAP3)
+struct omap_hwmod *omap_uart_hwmod_lookup(int num)
+{
+   struct omap_hwmod *oh;
+   char oh_name[MAX_UART_HWMOD_NAME_LEN];
+
+   snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN, uart%d, num + 1);
+   oh = omap_hwmod_lookup(oh_name);
+   WARN(IS_ERR(oh), Could not lookup hmwod info for %s\n,
+   oh_name);
+   return oh;
+}
+
+#if defined(CONFIG_PM)
 
 /*
  * Work Around for Errata i202 (3430 - 1.12, 3630 - 1.6)
@@ -357,22 +360,17 @@ int omap_uart_can_sleep(void)
return can_sleep;
 }
 
-static void omap_uart_idle_init(struct omap_uart_state *uart)
+static void omap_uart_idle_init(struct omap_uart_port_info *uart,
+   unsigned short num)
 {
-   int ret;
-
-   uart-can_sleep = 0;
-   omap_uart_smart_idle_enable(uart, 0);
-
if (cpu_is_omap34xx()  !cpu_is_ti816x()) {
-   u32 mod = (uart-num  1) ? OMAP3430_PER_MOD : CORE_MOD;
+   u32 mod = (num  1) ? OMAP3430_PER_MOD : CORE_MOD;
u32 wk_mask = 0;
u32 padconf = 0;
 
-   /* XXX These PRM accesses do not belong here */
uart-wk_en = OMAP34XX_PRM_REGADDR(mod, PM_WKEN1);
uart-wk_st = OMAP34XX_PRM_REGADDR(mod, PM_WKST1);
-   switch (uart-num) {
+   switch (num) {
case 0:
wk_mask = OMAP3430_ST_UART1_MASK;
padconf = 0x182;
@@ -391,12 +389,11 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
break;
}
uart-wk_mask = wk_mask;
-   uart-padconf = padconf;
} else if (cpu_is_omap24xx()) {
u32 wk_mask = 0;
u32 wk_en = PM_WKEN1, wk_st = PM_WKST1;
 
-   switch (uart-num) {
+   switch (num) {
case 0:
wk_mask = OMAP24XX_ST_UART1_MASK;
break;
@@ -421,7 +418,6 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
uart-wk_en = NULL;
uart-wk_st = NULL;
uart-wk_mask = 0;
-   uart-padconf = 0;
}
 }
 
@@ -436,26 +432,13 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 
 static int __init omap_serial_early_init(void)
 {
-   int i = 0;
-
do {
-   char oh_name[MAX_UART_HWMOD_NAME_LEN];
struct omap_hwmod *oh;
-   struct omap_uart_state *uart;
 
-   snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN,
-uart%d, i + 1);
-   oh = omap_hwmod_lookup(oh_name);
+   oh = omap_uart_hwmod_lookup

[PATCH v6 07/16] OMAP2+: UART: Add default mux for all uarts.

2011-09-30 Thread Govindraj.R
Prior to this change rx-pad wakeup was done by writing to rx-pad offset value
populated in serial.c idle_init. Now with mux framework support we can use
mux_utilities along with hmwod framework to handle io-pad configuration and
enable rx-pad wake-up mechanism.

Add default mux data for all uart's if mux info is not passed from
board file to avoid breaking any board support.
With the default pads we have populated in serial.c wakeup capability for
rx pads are enabled, this can be used to enable uart_rx io-pad wakeup from
hwmod framework. The pad values in 3430sdp/4430sdp/omap4panda board file
are same as the default pad values populated in serial.c. Remove pad values
from 3430sdp/4430sdp/omap4panda board file and use the default pads
from serial.c file.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c|  100 +
 arch/arm/mach-omap2/board-4430sdp.c|   68 +---
 arch/arm/mach-omap2/board-omap4panda.c |   68 +---
 arch/arm/mach-omap2/serial.c   |  192 +---
 4 files changed, 131 insertions(+), 297 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index bd600cf..b12b38f 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -482,106 +482,8 @@ static const struct usbhs_omap_board_data usbhs_bdata 
__initconst = {
 static struct omap_board_mux board_mux[] __initdata = {
{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
-
-static struct omap_device_pad serial1_pads[] __initdata = {
-   /*
-* Note that off output enable is an active low
-* signal. So setting this means pin is a
-* input enabled in off mode
-*/
-   OMAP_MUX_STATIC(uart1_cts.uart1_cts,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_rts.uart1_rts,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_rx.uart1_rx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_tx.uart1_tx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_device_pad serial2_pads[] __initdata = {
-   OMAP_MUX_STATIC(uart2_cts.uart2_cts,
-OMAP_PIN_INPUT_PULLUP |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_rts.uart2_rts,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_rx.uart2_rx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_tx.uart2_tx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_device_pad serial3_pads[] __initdata = {
-   OMAP_MUX_STATIC(uart3_cts_rctx.uart3_cts_rctx,
-OMAP_PIN_INPUT_PULLDOWN |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_rts_sd.uart3_rts_sd,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_rx_irrx.uart3_rx_irrx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_tx_irtx.uart3_tx_irtx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_board_data serial1_data __initdata = {
-   .id = 0,
-   .pads   = serial1_pads,
-   .pads_cnt   = ARRAY_SIZE(serial1_pads),
-};
-
-static struct omap_board_data serial2_data __initdata = {
-   .id = 1,
-   .pads   = serial2_pads,
-   .pads_cnt   = ARRAY_SIZE(serial2_pads),
-};
-
-static struct omap_board_data serial3_data __initdata = {
-   .id = 2,
-   .pads   = serial3_pads,
-   .pads_cnt   = ARRAY_SIZE(serial3_pads),
-};
-
-static inline void board_serial_init(void)
-{
-   omap_serial_init_port(serial1_data

[PATCH v6 09/16] OMAP2+: UART: Add runtime pm support for omap-serial driver

2011-09-30 Thread Govindraj.R
Adapts omap-serial driver to use pm_runtime API's.

Use runtime runtime API's to handle uart clocks and obtain
device_usage statics. Set runtime API's usage to irq_safe so that
we can use get_sync from irq context. Auto-suspend for port specific
activities and put for reg access. Use device_may_wakeup to check
whether uart has wakeup capabilities and then enable uart runtime
usage for the uart.

Removing save_context/restore_context functions from serial.c
Adding context restore to .runtime_suspend and using reg values from port
structure to restore the uart port context based on context_loss_count.
Maintain internal state machine using wakeups_enabled field for avoiding
repeated enable/disable of uart port wakeup mechanism.

Remove omap_uart_disable_wakeup and modify omap_uart_enable_wakeup
to accept pdev and bool value to enable/disable the uart wakeup mechanism
after uart clock's are cut. omap_hwmod_enable_wakeup is used to set
pad wakeup for the uarts. PM_WKEN reg values are left to default.
Removed omap_uart_enable/disable_clocks in serial.c now clock handling
done with runtime API's.

By default uart autosuspend delay is set to -1 to avoid character loss
if uart's are autoidled and woken up on rx pin.

After boot up UART's can be autoidled by setting autosuspendi delay from sysfs.

echo 3000  /sys/devices/platform/omap/omap_uart.X/power/autosuspend_delay_ms
X=0,1,2,3 for UART1/2/3/4. Number of uarts available may vary across omap_soc.

Acked-by: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |  206 ++--
 arch/arm/plat-omap/include/plat/omap-serial.h |5 +
 drivers/tty/serial/omap-serial.c  |  169 +++--
 3 files changed, 179 insertions(+), 201 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index ca6807c..6725caf 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -33,6 +33,7 @@
 #include plat/dma.h
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
+#include plat/omap-pm.h
 
 #include prm2xxx_3xxx.h
 #include pm.h
@@ -41,8 +42,6 @@
 #include control.h
 #include mux.h
 
-#define UART_OMAP_WER  0x17/* Wake-up enable register */
-
 #define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
 
 /*
@@ -57,24 +56,7 @@
 
 struct omap_uart_state {
int num;
-   int can_sleep;
u32 dma_enabled;
-
-   int clocked;
-
-   int regshift;
-#if defined(CONFIG_ARCH_OMAP3)  defined(CONFIG_PM)
-   int context_valid;
-
-   /* Registers to be saved/restored for OFF-mode */
-   u16 dll;
-   u16 dlh;
-   u16 ier;
-   u16 sysc;
-   u16 scr;
-   u16 wer;
-   u16 mcr;
-#endif
 };
 
 static u8 num_uarts;
@@ -101,34 +83,6 @@ static struct omap_device_pm_latency omap_uart_latency[] = {
},
 };
 
-static inline unsigned int __serial_read_reg(struct uart_port *up,
-int offset)
-{
-   offset = up-regshift;
-   return (unsigned int)__raw_readb(up-membase + offset);
-}
-
-static inline unsigned int serial_read_reg(struct omap_uart_state *uart,
-  int offset)
-{
-   offset = uart-regshift;
-   return (unsigned int)__raw_readb(uart-membase + offset);
-}
-
-static inline void __serial_write_reg(struct uart_port *up, int offset,
-   int value)
-{
-   offset = up-regshift;
-   __raw_writeb(value, up-membase + offset);
-}
-
-static inline void serial_write_reg(struct omap_uart_state *uart, int offset,
-   int value)
-{
-   offset = uart-regshift;
-   __raw_writeb(value, uart-membase + offset);
-}
-
 struct omap_hwmod *omap_uart_hwmod_lookup(int num)
 {
struct omap_hwmod *oh;
@@ -177,134 +131,8 @@ static void omap_uart_mdr1_errataset(struct 
omap_uart_state *uart, u8 mdr1_val,
udelay(1);
}
 }
-
-static void omap_uart_save_context(struct omap_uart_state *uart)
-{
-   u16 lcr = 0;
-
-   if (!enable_off_mode)
-   return;
-
-   lcr = serial_read_reg(uart, UART_LCR);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_B);
-   uart-dll = serial_read_reg(uart, UART_DLL);
-   uart-dlh = serial_read_reg(uart, UART_DLM);
-   serial_write_reg(uart, UART_LCR, lcr);
-   uart-ier = serial_read_reg(uart, UART_IER);
-   uart-sysc = serial_read_reg(uart, UART_OMAP_SYSC);
-   uart-scr = serial_read_reg(uart, UART_OMAP_SCR);
-   uart-wer = serial_read_reg(uart, UART_OMAP_WER);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_A);
-   uart-mcr = serial_read_reg(uart, UART_MCR);
-   serial_write_reg(uart, UART_LCR, lcr);
-
-   uart-context_valid = 1;
-}
-
-static void omap_uart_restore_context(struct omap_uart_state *uart)
-{
-   u16 efr = 0;
-
-   if (!enable_off_mode)
-   return;
-
-   if (!uart

[PATCH v6 04/16] OMAP2+: UART: cleanup 8250 console driver support

2011-09-30 Thread Govindraj.R
We had been using traditional 8250 driver as uart console driver
prior to omap-serial driver. Since we have omap-serial driver
in mainline kernel for some time now it has been used as default
uart console driver on omap2+ platforms. Remove 8250 support for
omap-uarts.

Serial_in and serial_out override for 8250 serial driver is also
removed. Empty fifo read fix is already taken care with omap-serial
driver with data ready bit check from LSR reg before reading RX fifo.
Also waiting for THRE(transmit hold reg empty) is done with wait_for_xmitr
in omap-serial driver.

Remove headers that were necessary to support 8250 support
and remove all config bindings done to keep 8250 backward compatibility
while adding omap-serial driver. Remove omap_uart_reset needed for
8250 autoconf.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |  111 --
 1 files changed, 0 insertions(+), 111 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 62d15ad..4ab90bf 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -19,23 +19,17 @@
  */
 #include linux/kernel.h
 #include linux/init.h
-#include linux/serial_reg.h
 #include linux/clk.h
 #include linux/io.h
 #include linux/delay.h
 #include linux/platform_device.h
 #include linux/slab.h
-#include linux/serial_8250.h
 #include linux/pm_runtime.h
 #include linux/console.h
 
-#ifdef CONFIG_SERIAL_OMAP
 #include plat/omap-serial.h
-#endif
-
 #include plat/common.h
 #include plat/board.h
-#include plat/clock.h
 #include plat/dma.h
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
@@ -47,10 +41,8 @@
 #include control.h
 #include mux.h
 
-#define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV0x52
 #define UART_OMAP_WER  0x17/* Wake-up enable register */
 
-#define UART_ERRATA_FIFO_FULL_ABORT(0x1  0)
 #define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
 
 /*
@@ -157,19 +149,6 @@ static inline void serial_write_reg(struct omap_uart_state 
*uart, int offset,
__raw_writeb(value, uart-membase + offset);
 }
 
-/*
- * Internal UARTs need to be initialized for the 8250 autoconfig to work
- * properly. Note that the TX watermark initialization may not be needed
- * once the 8250.c watermark handling code is merged.
- */
-
-static inline void __init omap_uart_reset(struct omap_uart_state *uart)
-{
-   serial_write_reg(uart, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
-   serial_write_reg(uart, UART_OMAP_SCR, 0x08);
-   serial_write_reg(uart, UART_OMAP_MDR1, UART_OMAP_MDR1_16X_MODE);
-}
-
 #if defined(CONFIG_PM)  defined(CONFIG_ARCH_OMAP3)
 
 /*
@@ -555,41 +534,6 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 #define DEV_CREATE_FILE(dev, attr)
 #endif /* CONFIG_PM */
 
-#ifndef CONFIG_SERIAL_OMAP
-/*
- * Override the default 8250 read handler: mem_serial_in()
- * Empty RX fifo read causes an abort on omap3630 and omap4
- * This function makes sure that an empty rx fifo is not read on these silicons
- * (OMAP1/2/3430 are not affected)
- */
-static unsigned int serial_in_override(struct uart_port *up, int offset)
-{
-   if (UART_RX == offset) {
-   unsigned int lsr;
-   lsr = __serial_read_reg(up, UART_LSR);
-   if (!(lsr  UART_LSR_DR))
-   return -EPERM;
-   }
-
-   return __serial_read_reg(up, offset);
-}
-
-static void serial_out_override(struct uart_port *up, int offset, int value)
-{
-   unsigned int status, tmout = 1;
-
-   status = __serial_read_reg(up, UART_LSR);
-   while (!(status  UART_LSR_THRE)) {
-   /* Wait up to 10ms for the character(s) to be sent. */
-   if (--tmout == 0)
-   break;
-   udelay(1);
-   status = __serial_read_reg(up, UART_LSR);
-   }
-   __serial_write_reg(up, offset, value);
-}
-#endif
-
 static int __init omap_serial_early_init(void)
 {
int i = 0;
@@ -650,15 +594,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
void *pdata = NULL;
u32 pdata_size = 0;
char *name;
-#ifndef CONFIG_SERIAL_OMAP
-   struct plat_serial8250_port ports[2] = {
-   {},
-   {.flags = 0},
-   };
-   struct plat_serial8250_port *p = ports[0];
-#else
struct omap_uart_port_info omap_up;
-#endif
 
if (WARN_ON(!bdata))
return;
@@ -673,51 +609,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
 
oh = uart-oh;
uart-dma_enabled = 0;
-#ifndef CONFIG_SERIAL_OMAP
-   name = serial8250;
-
-   /*
-* !! 8250 driver does not use standard IORESOURCE* It
-* has it's own custom pdata that can be taken from
-* the hwmod resource data.  But, this needs to be
-* done after the build.
-*
-* ?? does it have to be done before the register ??
-* YES, because

[PATCH v6 05/16] OMAP2+: UART: Cleanup part of clock gating mechanism for uart

2011-09-30 Thread Govindraj.R
Currently we use a shared irq handler to identify uart activity and then
trigger a timer. Based the timeout value set from sysfs the timer used to
expire. If no uart-activity was detected timer-expiry func sets can_sleep
flag. Based on this we will disable the uart clocks in idle path.

Since the clock gating mechanism is outside the uart driver, we currently
use this mechanism. In preparation to runtime implementation for omap-serial
driver we can cleanup this mechanism and use runtime API's to gate uart clocks.

Also remove timer related info from local uart_state struct and remove
the code used to set timeout value from sysfs. Remove un-used function
omap_uart_check_wakeup.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |  116 +
 arch/arm/plat-omap/include/plat/omap-serial.h |1 -
 arch/arm/plat-omap/include/plat/serial.h  |1 -
 3 files changed, 1 insertions(+), 117 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 4ab90bf..c98b9b4 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -58,8 +58,6 @@
 struct omap_uart_state {
int num;
int can_sleep;
-   struct timer_list timer;
-   u32 timeout;
 
void __iomem *wk_st;
void __iomem *wk_en;
@@ -67,13 +65,9 @@ struct omap_uart_state {
u32 padconf;
u32 dma_enabled;
 
-   struct clk *ick;
-   struct clk *fck;
int clocked;
 
-   int irq;
int regshift;
-   int irqflags;
void __iomem *membase;
resource_size_t mapbase;
 
@@ -340,32 +334,6 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 
omap_uart_smart_idle_enable(uart, 0);
uart-can_sleep = 0;
-   if (uart-timeout)
-   mod_timer(uart-timer, jiffies + uart-timeout);
-   else
-   del_timer(uart-timer);
-}
-
-static void omap_uart_allow_sleep(struct omap_uart_state *uart)
-{
-   if (device_may_wakeup(uart-pdev-dev))
-   omap_uart_enable_wakeup(uart);
-   else
-   omap_uart_disable_wakeup(uart);
-
-   if (!uart-clocked)
-   return;
-
-   omap_uart_smart_idle_enable(uart, 1);
-   uart-can_sleep = 1;
-   del_timer(uart-timer);
-}
-
-static void omap_uart_idle_timer(unsigned long data)
-{
-   struct omap_uart_state *uart = (struct omap_uart_state *)data;
-
-   omap_uart_allow_sleep(uart);
 }
 
 int omap_uart_can_sleep(void)
@@ -389,35 +357,11 @@ int omap_uart_can_sleep(void)
return can_sleep;
 }
 
-/**
- * omap_uart_interrupt()
- *
- * This handler is used only to detect that *any* UART interrupt has
- * occurred.  It does _nothing_ to handle the interrupt.  Rather,
- * any UART interrupt will trigger the inactivity timer so the
- * UART will not idle or sleep for its timeout period.
- *
- **/
-/* static int first_interrupt; */
-static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
-{
-   struct omap_uart_state *uart = dev_id;
-
-   omap_uart_block_sleep(uart);
-
-   return IRQ_NONE;
-}
-
 static void omap_uart_idle_init(struct omap_uart_state *uart)
 {
int ret;
 
uart-can_sleep = 0;
-   uart-timeout = DEFAULT_TIMEOUT;
-   setup_timer(uart-timer, omap_uart_idle_timer,
-   (unsigned long) uart);
-   if (uart-timeout)
-   mod_timer(uart-timer, jiffies + uart-timeout);
omap_uart_smart_idle_enable(uart, 0);
 
if (cpu_is_omap34xx()  !cpu_is_ti816x()) {
@@ -479,51 +423,8 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
uart-wk_mask = 0;
uart-padconf = 0;
}
-
-   uart-irqflags |= IRQF_SHARED;
-   ret = request_threaded_irq(uart-irq, NULL, omap_uart_interrupt,
-  IRQF_SHARED, serial idle, (void *)uart);
-   WARN_ON(ret);
-}
-
-static ssize_t sleep_timeout_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct omap_device *odev = to_omap_device(pdev);
-   struct omap_uart_state *uart = odev-hwmods[0]-dev_attr;
-
-   return sprintf(buf, %u\n, uart-timeout / HZ);
 }
 
-static ssize_t sleep_timeout_store(struct device *dev,
-  struct device_attribute *attr,
-  const char *buf, size_t n)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct omap_device *odev = to_omap_device(pdev);
-   struct omap_uart_state *uart = odev-hwmods[0]-dev_attr;
-   unsigned int value;
-
-   if (sscanf(buf, %u, value) != 1) {
-   dev_err(dev, sleep_timeout_store: Invalid value\n);
-   return -EINVAL;
-   }
-
-   uart-timeout = value * HZ;
-   if (uart-timeout

[PATCH v6 10/16] OMAP2+: UART: Modify omap_uart_can_sleep function

2011-09-30 Thread Govindraj.R
Modify the omap_uart_can_sleep function to check uart is active
or not to be used by pm code to enter low power states.

Removing this check can cause console response little sluggish.
However no characters will be lost until uart clocks are gated
and woken up using rx-pad. UART interface clocks can be auto gated
this can make response on uart slower. This behaviour was observed
only on some of OMAP3 boards(beagleboard xm rev c).

Reported-by: Tero Kristo t-kri...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |   21 +
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 6725caf..ccf3550 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -156,23 +156,20 @@ static void omap_uart_smart_idle_enable(struct 
omap_uart_state *uart,
 
 int omap_uart_can_sleep(void)
 {
-   struct omap_uart_state *uart;
-   int can_sleep = 1;
-
-   list_for_each_entry(uart, uart_list, node) {
-   if (!uart-clocked)
-   continue;
+   struct omap_hwmod *oh;
+   u8 i, ret = true;
 
-   if (!uart-can_sleep) {
-   can_sleep = 0;
+   for (i = 0; i  num_uarts; i++) {
+   oh = omap_uart_hwmod_lookup(i);
+   if (!oh)
continue;
-   }
 
-   /* This UART can now safely sleep. */
-   omap_uart_allow_sleep(uart);
+   if (oh-od  oh-od-pdev 
+   !pm_runtime_suspended(oh-od-pdev-dev))
+   return false;
}
 
-   return can_sleep;
+   return ret;
 }
 
 #ifdef CONFIG_OMAP_MUX
-- 
1.7.4.1

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


[PATCH v6 15/16] OMAP2+: UART: Enable back uart clocks with runtime API for early console

2011-09-30 Thread Govindraj.R
For the early console probing we had avoided hwmod reset and idling
and uart was idled using hwmod API and enabled back using omap_device API
after omap_device registration.

Now since we are using runtime API's to enable back uart, move hwmod idling and
use runtime API to enable back UART.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   26 
 arch/arm/plat-omap/include/plat/omap-serial.h |1 +
 drivers/tty/serial/omap-serial.c  |1 +
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 24b5809..15d6c51 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -25,13 +25,11 @@
 #include linux/platform_device.h
 #include linux/slab.h
 #include linux/pm_runtime.h
-#include linux/console.h
 
 #include plat/omap-serial.h
 #include plat/common.h
 #include plat/board.h
 #include plat/dma.h
-#include plat/omap_hwmod.h
 #include plat/omap_device.h
 #include plat/omap-pm.h
 
@@ -275,10 +273,16 @@ static void omap_uart_set_forceidle(struct 
platform_device *pdev)
omap_hwmod_set_slave_idlemode(od-hwmods[0], HWMOD_IDLEMODE_FORCE);
 }
 
+static void omap_uart_hwmod_idle(struct platform_device *pdev)
+{
+   struct omap_device *od = to_omap_device(pdev);
+
+   omap_hwmod_idle(od-hwmods[0]);
+}
+
 #else
 static void omap_uart_set_forceidle(struct platform_device *pdev) {}
-static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
-{}
+static void omap_uart_hwmod_idle(struct platform_device *pdev) {}
 #endif /* CONFIG_PM */
 
 static int __init omap_serial_early_init(void)
@@ -357,6 +361,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
pdata-enable_wakeup = omap_uart_enable_wakeup;
pdata-get_context_loss_count = omap_pm_get_dev_context_loss_count;
pdata-set_force_idle = omap_uart_set_forceidle;
+   pdata-hwmod_idle = omap_uart_hwmod_idle;
pdata-dma_enabled = info-dma_enabled;
pdata-dma_rx_buf_size = info-dma_rx_buf_size;
pdata-dma_rx_poll_rate = info-dma_rx_poll_rate;
@@ -375,19 +380,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
 
oh-mux = omap_hwmod_mux_init(bdata-pads, bdata-pads_cnt);
 
-   console_lock(); /* in case the earlycon is on the UART */
-
-   /*
-* Because of early UART probing, UART did not get idled
-* on init.  Now that omap_device is ready, ensure full idle
-* before doing omap_device_enable().
-*/
-   omap_hwmod_idle(oh);
-
-   omap_device_enable(pdev);
-
-   console_unlock();
-
if ((cpu_is_omap34xx() || cpu_is_omap44xx())  bdata-pads)
device_init_wakeup(pdev-dev, true);
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index de8de87..800f215 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -71,6 +71,7 @@ struct omap_uart_port_info {
void (*enable_wakeup)(struct platform_device *, bool);
u32 (*get_context_loss_count)(struct device *);
void (*set_force_idle)(struct platform_device *);
+   void (*hwmod_idle)(struct platform_device *);
 };
 
 struct uart_omap_dma {
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 92a1f10..8125a89 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1394,6 +1394,7 @@ static int serial_omap_probe(struct platform_device *pdev)
pm_runtime_irq_safe(pdev-dev);
if (device_may_wakeup(pdev-dev)) {
pm_runtime_enable(pdev-dev);
+   omap_up_info-hwmod_idle(pdev);
pm_runtime_get_sync(pdev-dev);
}
 
-- 
1.7.4.1

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


[PATCH v6 16/16] OMAP2+: UART: Do not gate uart clocks if used for debug_prints

2011-09-30 Thread Govindraj.R
If OMAP UART is used as console uart and debug is enabled,
avoid gating of uart clocks to print all debug prints.

If uart clocks are gated then the debug prints from omap_device
framework or hwmod framework can cause uart to enter recursive pm_runtime calls,
which can cause a deadlock over power lock usage.

For example: Say, uart clocks are cut and we get a print from 
omap_device_disable
stating disabling uart clocks. This print calls omap_uart driver console_write
which will call runtime API get_sync which means we enter from runtime API put
context to runtime API get context.

-- runtime put (take power lock)
-- print disabling uart clocks
-- call uart console write
-- call get_sync (try to take power lock)

Also any clock enable API call from uart driver should not call any uart
operation until clocks are enabled back. Like get_sync having debug print
calling uart console write even before clocks are enabled.

So to avoid these scenarios, identify from bootargs  if OMAP_UART(ttyO) is used
in debug mode. If so, do not set device_may_wakeup. This will prevent
pm_runtime_enable in uart driver probe and will avoid uart clock gating.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
More details on this topic and experiments done listed here:
http://www.spinics.net/lists/linux-serial/msg04128.html

 arch/arm/mach-omap2/serial.c |   19 ++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 15d6c51..777f81c 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -285,8 +285,24 @@ static void omap_uart_set_forceidle(struct platform_device 
*pdev) {}
 static void omap_uart_hwmod_idle(struct platform_device *pdev) {}
 #endif /* CONFIG_PM */
 
+static int uart_debug;
+
+char *cmdline_find_option(char *str)
+{
+   extern char *saved_command_line;
+
+   return strstr(saved_command_line, str);
+}
+
 static int __init omap_serial_early_init(void)
 {
+   if (cmdline_find_option(debug) 
+   cmdline_find_option(OMAP_SERIAL_NAME)) {
+   uart_debug = true;
+   pr_info(OMAP UART used as console in debug mode
+uart clocks will not be gated);
+   }
+
do {
struct omap_hwmod *oh;
 
@@ -380,7 +396,8 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
 
oh-mux = omap_hwmod_mux_init(bdata-pads, bdata-pads_cnt);
 
-   if ((cpu_is_omap34xx() || cpu_is_omap44xx())  bdata-pads)
+   if (((cpu_is_omap34xx() || cpu_is_omap44xx())  bdata-pads)
+!uart_debug)
device_init_wakeup(pdev-dev, true);
 
kfree(pdata);
-- 
1.7.4.1

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


[PATCH v6 14/16] OMAP2+: UART: Take console_lock in suspend path if not taken

2011-09-30 Thread Govindraj.R
In suspend path the console_lock is taken by uart_port_suspend
however when no_console_suspend is used console_lock is not taken.

During system wide suspend omap_pwr_domain hooks cut all
clocks that are left enabled. So its unsafe to proceed printing after
clocks are cut by pwr_domain hooks. Also pm_runtime will be disabled after
dpm_suspend devices happens. So buffer all prints in suspend path by taking
console_lock and print them back safely after power domain hooks re-enable
clocks back.

Use CONFIG_SERIAL_OMAP_CONSOLE macro check to take console_lock since
console ops are available only if omap console is defined.
omap-serial can be built as module without console support.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/plat-omap/include/plat/omap-serial.h |1 +
 drivers/tty/serial/omap-serial.c  |   20 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 28abc6b..de8de87 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -126,6 +126,7 @@ struct uart_omap_port {
u32 context_loss_cnt;
u8  wakeups_enabled;
u32 errata;
+   u8  console_locked;
 
 };
 
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 64e4ab5..92a1f10 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1133,8 +1133,15 @@ static int serial_omap_suspend(struct device *dev)
 {
struct uart_omap_port *up = dev_get_drvdata(dev);
 
-   if (up)
+   if (up) {
uart_suspend_port(serial_omap_reg, up-port);
+#ifdef CONFIG_SERIAL_OMAP_CONSOLE
+   if (up-port.line == up-port.cons-index 
+   !is_console_locked())
+   up-console_locked = console_trylock();
+#endif
+   }
+
return 0;
 }
 
@@ -1142,8 +1149,17 @@ static int serial_omap_resume(struct device *dev)
 {
struct uart_omap_port *up = dev_get_drvdata(dev);
 
-   if (up)
+   if (up) {
uart_resume_port(serial_omap_reg, up-port);
+#ifdef CONFIG_SERIAL_OMAP_CONSOLE
+   if (up-port.line == up-port.cons-index 
+   up-console_locked) {
+   console_unlock();
+   up-console_locked = 0;
+   }
+#endif
+   }
+
return 0;
 }
 
-- 
1.7.4.1

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


[PATCH v6 13/16] OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART

2011-09-30 Thread Govindraj.R
From: Jon Hunter jon-hun...@ti.com

When using DMA there are two timeouts defined. The first timeout,
rx_timeout, is really a polling rate in which software polls the
DMA status to see if the DMA has finished. This is necessary for
the RX side because we do not know how much data we will receive.
The secound timeout, RX_TIMEOUT, is a timeout after which the
DMA will be stopped if no more data is received. To make this
clearer, rename rx_timeout as rx_poll_rate and rename the
function serial_omap_rx_timeout() to serial_omap_rxdma_poll().

The OMAP-Serial driver defines an RX_TIMEOUT of 3 seconds that is
used to indicate when the DMA for UART can be stopped if no more
data is received. The value is a global definition that is applied
to all instances of the UART.

Each UART may be used for a different purpose and so the timeout
required may differ. Make this value configurable for each UART so
that this value can be optimised for power savings.

Acked-by: Kevin Hilman khil...@ti.com
Signed-off-by: Jon Hunter jon-hun...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
This patch is derived from a custom 2.6.35 kernel
Available here:
http://git.omapzoom.org/?p=kernel/omap.git;a=commitdiff;
h=b47839fb84e68333ea29a327cf5aa694b71be7d6;
hp=f62f570e8580507be48ad004defc2ec714b6e05d

 arch/arm/mach-omap2/serial.c  |5 -
 arch/arm/plat-omap/include/plat/omap-serial.h |3 ++-
 drivers/tty/serial/omap-serial.c  |   15 ---
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 78f7051..24b5809 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -54,13 +54,15 @@
 
 static u8 num_uarts;
 
-#define DEFAULT_RXDMA_TIMEOUT  1   /* RX DMA polling rate (us) */
+#define DEFAULT_RXDMA_POLLRATE 1   /* RX DMA polling rate (us) */
 #define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
+#define DEFAULT_RXDMA_TIMEOUT  (3 * HZ)/* RX DMA timeout (jiffies) */
 
 static struct omap_uart_port_info omap_serial_default_info[] = {
{
.dma_enabled= 0,
.dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
+   .dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
.dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
.autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
},
@@ -357,6 +359,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
pdata-set_force_idle = omap_uart_set_forceidle;
pdata-dma_enabled = info-dma_enabled;
pdata-dma_rx_buf_size = info-dma_rx_buf_size;
+   pdata-dma_rx_poll_rate = info-dma_rx_poll_rate;
pdata-dma_rx_timeout = info-dma_rx_timeout;
pdata-autosuspend_timeout = info-autosuspend_timeout;
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index a40a41a..28abc6b 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -51,7 +51,6 @@
 
 #define OMAP_UART_DMA_CH_FREE  -1
 
-#define RX_TIMEOUT (3 * HZ)
 #define OMAP_MAX_HSUART_PORTS  4
 
 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
@@ -67,6 +66,7 @@ struct omap_uart_port_info {
unsigned intdma_rx_buf_size;
unsigned intdma_rx_timeout;
unsigned intautosuspend_timeout;
+   unsigned intdma_rx_poll_rate;
 
void (*enable_wakeup)(struct platform_device *, bool);
u32 (*get_context_loss_count)(struct device *);
@@ -95,6 +95,7 @@ struct uart_omap_dma {
/* timer to poll activity on rx dma */
struct timer_list   rx_timer;
unsigned intrx_buf_size;
+   unsigned intrx_poll_rate;
unsigned intrx_timeout;
 };
 
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 15e0655..64e4ab5 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -47,7 +47,7 @@ static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
 /* Forward declaration of functions */
 static void uart_tx_dma_callback(int lch, u16 ch_status, void *data);
-static void serial_omap_rx_timeout(unsigned long uart_no);
+static void serial_omap_rxdma_poll(unsigned long uart_no);
 static int serial_omap_start_rxdma(struct uart_omap_port *up);
 static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);
 
@@ -542,7 +542,7 @@ static int serial_omap_startup(struct uart_port *port)
(dma_addr_t *)(up-uart_dma.tx_buf_dma_phys),
0);
init_timer((up-uart_dma.rx_timer));
-   up-uart_dma.rx_timer.function = serial_omap_rx_timeout;
+   up-uart_dma.rx_timer.function = serial_omap_rxdma_poll;
up-uart_dma.rx_timer.data = up-pdev-id

[PATCH v6 11/16] OMAP2+: UART: Move errata handling from serial.c to omap-serial

2011-09-30 Thread Govindraj.R
Move the errata handling mechanism from serial.c to omap-serial file
and utilise the same func in driver file.

Errata i202, i291 are moved to be handled with omap-serial
Moving the errata macro from serial.c file to driver header file
as from on errata will be handled in driver file itself.

Corrected errata id from chapter reference 2.15 to errata id i291.

Acked-by: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   78 +
 arch/arm/plat-omap/include/plat/omap-serial.h |5 ++
 drivers/tty/serial/omap-serial.c  |   63 ++--
 3 files changed, 77 insertions(+), 69 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index ccf3550..0731575 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -42,8 +42,6 @@
 #include control.h
 #include mux.h
 
-#define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
-
 /*
  * NOTE: By default the serial timeout is disabled as it causes lost characters
  * over the serial ports. This means that the UART clocks will stay on until
@@ -54,11 +52,6 @@
 
 #define MAX_UART_HWMOD_NAME_LEN16
 
-struct omap_uart_state {
-   int num;
-   u32 dma_enabled;
-};
-
 static u8 num_uarts;
 
 static int uart_idle_hwmod(struct omap_device *od)
@@ -97,63 +90,6 @@ struct omap_hwmod *omap_uart_hwmod_lookup(int num)
 
 #if defined(CONFIG_PM)
 
-/*
- * Work Around for Errata i202 (3430 - 1.12, 3630 - 1.6)
- * The access to uart register after MDR1 Access
- * causes UART to corrupt data.
- *
- * Need a delay =
- * 5 L4 clock cycles + 5 UART functional clock cycle (@48MHz = ~0.2uS)
- * give 10 times as much
- */
-static void omap_uart_mdr1_errataset(struct omap_uart_state *uart, u8 mdr1_val,
-   u8 fcr_val)
-{
-   u8 timeout = 255;
-
-   serial_write_reg(uart, UART_OMAP_MDR1, mdr1_val);
-   udelay(2);
-   serial_write_reg(uart, UART_FCR, fcr_val | UART_FCR_CLEAR_XMIT |
-   UART_FCR_CLEAR_RCVR);
-   /*
-* Wait for FIFO to empty: when empty, RX_FIFO_E bit is 0 and
-* TX_FIFO_E bit is 1.
-*/
-   while (UART_LSR_THRE != (serial_read_reg(uart, UART_LSR) 
-   (UART_LSR_THRE | UART_LSR_DR))) {
-   timeout--;
-   if (!timeout) {
-   /* Should *never* happen. we warn and carry on */
-   dev_crit(uart-pdev-dev, Errata i202: timedout %x\n,
-   serial_read_reg(uart, UART_LSR));
-   break;
-   }
-   udelay(1);
-   }
-}
-#endif /* CONFIG_PM  CONFIG_ARCH_OMAP3 */
-
-static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
-  int enable)
-{
-   u8 idlemode;
-
-   if (enable) {
-   /**
-* Errata 2.15: [UART]:Cannot Acknowledge Idle Requests
-* in Smartidle Mode When Configured for DMA Operations.
-*/
-   if (uart-dma_enabled)
-   idlemode = HWMOD_IDLEMODE_FORCE;
-   else
-   idlemode = HWMOD_IDLEMODE_SMART;
-   } else {
-   idlemode = HWMOD_IDLEMODE_NO;
-   }
-
-   omap_hwmod_set_slave_idlemode(uart-oh, idlemode);
-}
-
 int omap_uart_can_sleep(void)
 {
struct omap_hwmod *oh;
@@ -313,7 +249,20 @@ static void omap_uart_enable_wakeup(struct platform_device 
*pdev, bool enable)
omap_hwmod_disable_wakeup(od-hwmods[0]);
 }
 
+/*
+ * Errata i291: [UART]:Cannot Acknowledge Idle Requests
+ * in Smartidle Mode When Configured for DMA Operations.
+ * WA: configure uart in force idle mode.
+ */
+static void omap_uart_set_forceidle(struct platform_device *pdev)
+{
+   struct omap_device *od = to_omap_device(pdev);
+
+   omap_hwmod_set_slave_idlemode(od-hwmods[0], HWMOD_IDLEMODE_FORCE);
+}
+
 #else
+static void omap_uart_set_forceidle(struct platform_device *pdev) {}
 static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
 {}
 #endif /* CONFIG_PM */
@@ -388,6 +337,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
pdata-flags = UPF_BOOT_AUTOCONF;
pdata-enable_wakeup = omap_uart_enable_wakeup;
pdata-get_context_loss_count = omap_pm_get_dev_context_loss_count;
+   pdata-set_force_idle = omap_uart_set_forceidle;
 
/* Enable the MDR1 errata for OMAP3 */
if (cpu_is_omap34xx()  !cpu_is_ti816x())
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 8ef81ce..12f5262 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -56,6 +56,8 @@
 
 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
 
+#define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
+
 struct

[PATCH v6 12/16] OMAP2+: UART: Allow UART parameters to be configured from board file.

2011-09-30 Thread Govindraj.R
From: Deepak K deepa...@ti.com

The following UART parameters are defined within the UART driver:

1). Whether the UART uses DMA (dma_enabled), by default set to 0
2). The size of dma buffer (set to 4096 bytes)
3). The time after which the dma should stop if no more data is received.
4). The auto suspend delay that will be passed for pm_runtime_autosuspend
where uart will be disabled after timeout

Different UARTs may be used for different purpose such as the console,
for interfacing bluetooth chip, for interfacing to a modem chip, etc.
Therefore, it is necessary to be able to customize the above settings
for a given board on a per UART basis.

This change allows these parameters to be configured from the board file
and allows the parameters to be configured for each UART independently.

If a board does not define its own custom parameters for the UARTs, then
use the default parameters in the structure omap_serial_default_info.
The default parameters are defined to be the same as the current settings
in the UART driver to avoid breaking the UART for any cuurnelty supported
boards. By default, make all boards use the default UART parameters.

Signed-off-by: Deepak K deepa...@ti.com
Signed-off-by: Jon Hunter jon-hun...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
This patch is derived and reworked from a custom 2.6.35 kernel
Available here:
http://git.omapzoom.org/?p=kernel/omap.git;
a=commitdiff;h=584ef316542f77312be7ba96a0f3013c8f64852b;
hp=7233a76cb362c0fc603f773274159adff91d3513

 arch/arm/mach-omap2/board-n8x0.c  |6 +-
 arch/arm/mach-omap2/serial.c  |   56 
 arch/arm/plat-omap/include/plat/omap-serial.h |7 ++-
 arch/arm/plat-omap/include/plat/serial.h  |5 ++-
 drivers/tty/serial/omap-serial.c  |8 +--
 5 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index e11f0c5..3408726 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -656,15 +656,15 @@ static inline void board_serial_init(void)
bdata.pads_cnt = 0;
 
bdata.id = 0;
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
bdata.id = 1;
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
bdata.id = 2;
bdata.pads = serial2_pads;
bdata.pads_cnt = ARRAY_SIZE(serial2_pads);
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 }
 
 #else
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 0731575..78f7051 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -43,17 +43,29 @@
 #include mux.h
 
 /*
- * NOTE: By default the serial timeout is disabled as it causes lost characters
- * over the serial ports. This means that the UART clocks will stay on until
- * disabled via sysfs. This also causes that any deeper omap sleep states are
- * blocked. 
+ * NOTE: By default the serial auto_suspend timeout is disabled as it causes
+ * lost characters over the serial ports. This means that the UART clocks will
+ * stay on until power/autosuspend_delay is set for the uart from sysfs.
+ * This also causes that any deeper omap sleep states are blocked.
  */
-#define DEFAULT_TIMEOUT 0
+#define DEFAULT_AUTOSUSPEND_DELAY  -1
 
 #define MAX_UART_HWMOD_NAME_LEN16
 
 static u8 num_uarts;
 
+#define DEFAULT_RXDMA_TIMEOUT  1   /* RX DMA polling rate (us) */
+#define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
+
+static struct omap_uart_port_info omap_serial_default_info[] = {
+   {
+   .dma_enabled= 0,
+   .dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
+   .dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
+   .autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
+   },
+};
+
 static int uart_idle_hwmod(struct omap_device *od)
 {
omap_hwmod_idle(od-hwmods[0]);
@@ -298,6 +310,7 @@ core_initcall(omap_serial_early_init);
 /**
  * omap_serial_init_port() - initialize single serial port
  * @bdata: port specific board data pointer
+ * @info: platform specific data pointer
  *
  * This function initialies serial driver for given port only.
  * Platforms can call this function instead of omap_serial_init()
@@ -306,7 +319,8 @@ core_initcall(omap_serial_early_init);
  * Don't mix calls to omap_serial_init_port() and omap_serial_init(),
  * use only one of the two.
  */
-void __init omap_serial_init_port(struct omap_board_data *bdata)
+void __init omap_serial_init_port(struct omap_board_data *bdata,
+   struct omap_uart_port_info *info)
 {
struct omap_hwmod *oh;
struct platform_device *pdev;
@@ -325,6 +339,9 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
if (!oh)
return;
 
+   if (info == NULL

[PATCH v5 00/15] OMAP2+: Serial: Runtime adaptation + cleanup

2011-09-21 Thread Govindraj.R
Converting uart driver to adapt to pm runtime API's.
Code re-org + cleanup.
Moving some functionality from serial.c to omap-serial.c

Changes involves:

1.) Cleaning up certain uart calls from sram_idle func.
2.) Removed all types of uart clock handling code from serial.c
3.) Using hwmod_mux API enable wakeup capability for uart pad during
   hwmod_idle state i.e., when uart clocks are disabled we can enable
   io-pad wakeup capability for uart if mux_data is available for
   given uart. Also during during resume from idle call to uart we need
   to enable clocks back conditionally and this can be done only when io-pad
   wakeup event bit is set for uart_rx pad. So we need a hwmod API
   which can probe the uart pad and let us know whether a uart wakeup
   happened. So omap_hmwod_pad_wakeup_status API is added to meet this
   requirement.
3.) Adapted omap-serial driver to use runtime API's.
4.) Modify serial_init calls to accept uart parameters from board file.
Like dma_usage, rx_timeout, dma_rx_pollrate, auto_suspend_timeout etc.
5.) Use the omap_prm driver with irq_chaining to wake up uart after clocks are
cut.

Patch series is based on 3.1.0-rc4 + omap_device fixes.
From Kevin's tree.
git://gitorious.org/khilman/linux-omap-pm.git for_3.2/omap_device

Also the patch series depends on Tero's Irq_chaining patches.
Dependent irq_chaining patches are as below.

3d5b543 omap3: pm: use prcm chain handler
c00b340 OMAP2+: mux: add support for PAD wakeup interrupts
db6397c power: omap-prm: added chain interrupt handler
b3f8628 TEMP: OMAP4xxx: hwmod data: add PRM hwmod
61ec0fc TEMP: OMAP3xxx: hwmod data: add PRM hwmod
a1ecf8c power: add omap prm driver skeleton

Same combination is hosted at:
git://gitorious.org/runtime_3-0/runtime_3-0.git v5_uart_irqchn

Ensure CONFIG_OMAP_PRM is set while testing irq_chaining with uart.

Changes from v4:
---

1.) Fixing v4 comments from Kevin.
Spilt into smaller logical patches.
2.) Using Irq_chaining OMAP_PRM driver for waking up uart.

Testing updates:

3430SDP:
retention, off_mode, system_wide suspend is tested.
(earlyprintk  no_console_suspend checked)

OMAP3630 - Zoom3:
pm-retention checked with quart/omap-uart3
[Also tested with uart3 as console uart and pm-ret checked]

OMAP4430-SDP: Boot tested.
OMAP2420/2430SDP: Boot tested.

Deepak K (1):
  OMAP2+: UART: Allow UART parameters to be configured from board file.

Govindraj.R (13):
  OMAP2+: hwmod: Add API to enable IO ring wakeup.
  OMAP2+: hwmod: Add API to check IO PAD wakeup status
  OMAP2+: UART: cleanup + remove uart pm specific API
  OMAP2+: UART: cleanup 8250 console driver support
  OMAP2+: UART: Cleanup part of clock gating mechanism for uart
  OMAP2+: UART: Remove certain feilds from omap_uart_state struct
  OMAP2+: UART: Add default mux for all uarts.
  OMAP2+: UART: Store certain reg values to port structure
  OMAP2+: UART: Add runtime pm support for omap-serial driver
  OMAP2+: UART: Move errata handling from serial.c to omap-serial
  OMAP2+: UART: Take console_lock in suspend path if not taken
  OMAP2+: UART: Enable back uart clocks with runtime API for early
console
  OMAP2+: UART: Do not gate uart clocks if used for debug_prints

Jon Hunter (1):
  OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART

 arch/arm/mach-omap2/board-3430sdp.c   |  100 +---
 arch/arm/mach-omap2/board-4430sdp.c   |8 +-
 arch/arm/mach-omap2/board-n8x0.c  |6 +-
 arch/arm/mach-omap2/board-omap4panda.c|8 +-
 arch/arm/mach-omap2/mux.c |   30 +
 arch/arm/mach-omap2/mux.h |   13 +
 arch/arm/mach-omap2/omap_hwmod.c  |   66 ++
 arch/arm/mach-omap2/pm24xx.c  |   19 -
 arch/arm/mach-omap2/pm34xx.c  |   24 -
 arch/arm/mach-omap2/serial.c  |  933 +++--
 arch/arm/plat-omap/include/plat/omap-serial.h |   30 +-
 arch/arm/plat-omap/include/plat/omap_hwmod.h  |1 +
 arch/arm/plat-omap/include/plat/serial.h  |   11 +-
 drivers/tty/serial/omap-serial.c  |  305 +++--
 14 files changed, 654 insertions(+), 900 deletions(-)

-- 
1.7.4.1

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


[PATCH v5 01/15] OMAP2+: hwmod: Add API to enable IO ring wakeup.

2011-09-21 Thread Govindraj.R
Add API to enable IO pad wakeup capability based on mux dynamic pad and
wake_up enable flag available from hwmod_mux initialization.

Use the wakeup_enable flag and enable wakeup capability
for the given pads. Wakeup capability will be enabled/disabled
during hwmod idle transition based on whether wakeup_flag is
set or cleared.

Call the omap_hwmod_set_ioring_wakeup from hwmod_wakeup_enable/disable.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c |   59 ++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 84cc0bd..e751dd9 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2062,6 +2062,34 @@ static int __init omap_hwmod_setup_all(void)
 core_initcall(omap_hwmod_setup_all);
 
 /**
+ * omap_hwmod_set_ioring_wakeup - enable io pad wakeup flag.
+ * @oh: struct omap_hwmod *
+ * @set: bool value indicating to set or clear wakeup status.
+ *
+ * Set or Clear wakeup flag for the io_pad.
+ */
+static int omap_hwmod_set_ioring_wakeup(struct omap_hwmod *oh, bool set_wake)
+{
+   struct omap_device_pad *pad;
+   int ret = -EINVAL, j;
+
+   if (oh-mux  oh-mux-enabled) {
+   for (j = 0; j  oh-mux-nr_pads_dynamic; j++) {
+   pad = oh-mux-pads_dynamic[j];
+   if (pad-flags  OMAP_DEVICE_PAD_WAKEUP) {
+   if (set_wake)
+   pad-idle |= OMAP_WAKEUP_EN;
+   else
+   pad-idle = ~OMAP_WAKEUP_EN;
+   ret = 0;
+   }
+   }
+   }
+
+   return ret;
+}
+
+/**
  * omap_hwmod_enable - enable an omap_hwmod
  * @oh: struct omap_hwmod *
  *
@@ -2393,6 +2421,35 @@ int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh,
 {
return _del_initiator_dep(oh, init_oh);
 }
+/**
+ * omap_hwmod_enable_ioring_wakeup - Set wakeup flag for iopad.
+ * @oh: struct omap_hwmod *
+ *
+ * Traverse through dynamic pads, if pad is enabled then
+ * set wakeup enable bit flag for the mux pin. Wakeup pad bit
+ * will be set during hwmod idle transistion.
+ * Return error if pads are not enabled or not available.
+ */
+int omap_hwmod_enable_ioring_wakeup(struct omap_hwmod *oh)
+{
+   /* Enable pad wake-up capability */
+   return omap_hwmod_set_ioring_wakeup(oh, true);
+}
+
+/**
+ * omap_hwmod_disable_ioring_wakeup - Clear wakeup flag for iopad.
+ * @oh: struct omap_hwmod *
+ *
+ * Traverse through dynamic pads, if pad is enabled then
+ * clear wakeup enable bit flag for the mux pin. Wakeup pad bit
+ * will be set during hwmod idle transistion.
+ * Return error if pads are not enabled or not available.
+ */
+int omap_hwmod_disable_ioring_wakeup(struct omap_hwmod *oh)
+{
+   /* Disable pad wakeup capability */
+   return omap_hwmod_set_ioring_wakeup(oh, false);
+}
 
 /**
  * omap_hwmod_enable_wakeup - allow device to wake up the system
@@ -2419,6 +2476,7 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
v = oh-_sysc_cache;
_enable_wakeup(oh, v);
_write_sysconfig(v, oh);
+   omap_hwmod_enable_ioring_wakeup(oh);
spin_unlock_irqrestore(oh-_lock, flags);
 
return 0;
@@ -2449,6 +2507,7 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
v = oh-_sysc_cache;
_disable_wakeup(oh, v);
_write_sysconfig(v, oh);
+   omap_hwmod_disable_ioring_wakeup(oh);
spin_unlock_irqrestore(oh-_lock, flags);
 
return 0;
-- 
1.7.4.1

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


[PATCH v5 02/15] OMAP2+: hwmod: Add API to check IO PAD wakeup status

2011-09-21 Thread Govindraj.R
Add API to determine IO-PAD wakeup event status for a given
hwmod dynamic_mux pad.

Wake up event set will be cleared on pad mux_read.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/mux.c|   30 ++
 arch/arm/mach-omap2/mux.h|   13 +++
 arch/arm/mach-omap2/omap_hwmod.c |7 ++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |1 +
 4 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 655e948..fb75aae 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -351,6 +351,36 @@ err1:
return NULL;
 }
 
+/**
+ * omap_hwmod_mux_get_wake_status - omap hwmod check pad wakeup
+ * @hmux:  Pads for a hwmod
+ *
+ * Gets the wakeup status of given pad from omap-hwmod.
+ * Returns true if wakeup capability is set and wakeup event occurred.
+ * Returns false if wakeup event has not occurred or pads are not available.
+ */
+bool omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux)
+{
+   int i;
+   unsigned int val;
+   u8 ret = false;
+
+   for (i = 0; i  hmux-nr_pads; i++) {
+   struct omap_device_pad *pad = hmux-pads[i];
+
+   if (pad-flags  OMAP_DEVICE_PAD_WAKEUP) {
+   val = omap_mux_read(pad-partition,
+   pad-mux-reg_offset);
+   if (val  OMAP_WAKEUP_EVENT) {
+   ret = true;
+   break;
+   }
+   }
+   }
+
+   return ret;
+}
+
 /* Assumes the calling function takes care of locking */
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 {
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 2132308..8b2150a 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -225,8 +225,21 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int 
nr_pads);
  */
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
 
+/**
+ * omap_hwmod_mux_get_wake_status - omap hwmod check pad wakeup
+ * @hmux:  Pads for a hwmod
+ *
+ * Called only from omap_hwmod.c, do not use.
+ */
+bool omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux);
 #else
 
+static inline bool
+omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux)
+{
+   return 0;
+}
+
 static inline int omap_mux_init_gpio(int gpio, int val)
 {
return 0;
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index e751dd9..a8b24d7 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2724,3 +2724,10 @@ int omap_hwmod_no_setup_reset(struct omap_hwmod *oh)
 
return 0;
 }
+
+int omap_hwmod_pad_get_wakeup_status(struct omap_hwmod *oh)
+{
+   if (oh  oh-mux)
+   return omap_hwmod_mux_get_wake_status(oh-mux);
+   return -EINVAL;
+}
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h 
b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 0e329ca..9a6195c 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -607,6 +607,7 @@ u32 omap_hwmod_get_context_loss_count(struct omap_hwmod 
*oh);
 
 int omap_hwmod_no_setup_reset(struct omap_hwmod *oh);
 
+int omap_hwmod_pad_get_wakeup_status(struct omap_hwmod *oh);
 /*
  * Chip variant-specific hwmod init routines - XXX should be converted
  * to use initcalls once the initial boot ordering is straightened out
-- 
1.7.4.1

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


[PATCH v5 05/15] OMAP2+: UART: Cleanup part of clock gating mechanism for uart

2011-09-21 Thread Govindraj.R
Currently we use a shared irq handler to identify uart activity and then
trigger a timer. Based the timeout value set from sysfs the timer used to
expire. If no uart-activity was detected timer-expiry func sets can_sleep
flag. Based on this we will disable the uart clocks in idle path.

Since the clock gating mechanism is outside the uart driver, we currently
use this mechanism. In preparation to runtime implementation for omap-serial
driver we can cleanup this mechanism and use runtime API's to gate uart clocks.

Also remove timer related info from local uart_state struct and remove
the code used to set timeout value from sysfs.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |  116 +
 arch/arm/plat-omap/include/plat/omap-serial.h |1 -
 2 files changed, 1 insertions(+), 116 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 784a8f9..3465fd7 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -57,8 +57,6 @@
 struct omap_uart_state {
int num;
int can_sleep;
-   struct timer_list timer;
-   u32 timeout;
 
void __iomem *wk_st;
void __iomem *wk_en;
@@ -66,13 +64,9 @@ struct omap_uart_state {
u32 padconf;
u32 dma_enabled;
 
-   struct clk *ick;
-   struct clk *fck;
int clocked;
 
-   int irq;
int regshift;
-   int irqflags;
void __iomem *membase;
resource_size_t mapbase;
 
@@ -339,51 +333,6 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 
omap_uart_smart_idle_enable(uart, 0);
uart-can_sleep = 0;
-   if (uart-timeout)
-   mod_timer(uart-timer, jiffies + uart-timeout);
-   else
-   del_timer(uart-timer);
-}
-
-static void omap_uart_allow_sleep(struct omap_uart_state *uart)
-{
-   if (device_may_wakeup(uart-pdev-dev))
-   omap_uart_enable_wakeup(uart);
-   else
-   omap_uart_disable_wakeup(uart);
-
-   if (!uart-clocked)
-   return;
-
-   omap_uart_smart_idle_enable(uart, 1);
-   uart-can_sleep = 1;
-   del_timer(uart-timer);
-}
-
-static void omap_uart_idle_timer(unsigned long data)
-{
-   struct omap_uart_state *uart = (struct omap_uart_state *)data;
-
-   omap_uart_allow_sleep(uart);
-}
-
-/**
- * omap_uart_interrupt()
- *
- * This handler is used only to detect that *any* UART interrupt has
- * occurred.  It does _nothing_ to handle the interrupt.  Rather,
- * any UART interrupt will trigger the inactivity timer so the
- * UART will not idle or sleep for its timeout period.
- *
- **/
-/* static int first_interrupt; */
-static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
-{
-   struct omap_uart_state *uart = dev_id;
-
-   omap_uart_block_sleep(uart);
-
-   return IRQ_NONE;
 }
 
 static void omap_uart_idle_init(struct omap_uart_state *uart)
@@ -391,11 +340,6 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
int ret;
 
uart-can_sleep = 0;
-   uart-timeout = DEFAULT_TIMEOUT;
-   setup_timer(uart-timer, omap_uart_idle_timer,
-   (unsigned long) uart);
-   if (uart-timeout)
-   mod_timer(uart-timer, jiffies + uart-timeout);
omap_uart_smart_idle_enable(uart, 0);
 
if (cpu_is_omap34xx()  !cpu_is_ti816x()) {
@@ -457,51 +401,8 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
uart-wk_mask = 0;
uart-padconf = 0;
}
-
-   uart-irqflags |= IRQF_SHARED;
-   ret = request_threaded_irq(uart-irq, NULL, omap_uart_interrupt,
-  IRQF_SHARED, serial idle, (void *)uart);
-   WARN_ON(ret);
-}
-
-static ssize_t sleep_timeout_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct omap_device *odev = to_omap_device(pdev);
-   struct omap_uart_state *uart = odev-hwmods[0]-dev_attr;
-
-   return sprintf(buf, %u\n, uart-timeout / HZ);
 }
 
-static ssize_t sleep_timeout_store(struct device *dev,
-  struct device_attribute *attr,
-  const char *buf, size_t n)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct omap_device *odev = to_omap_device(pdev);
-   struct omap_uart_state *uart = odev-hwmods[0]-dev_attr;
-   unsigned int value;
-
-   if (sscanf(buf, %u, value) != 1) {
-   dev_err(dev, sleep_timeout_store: Invalid value\n);
-   return -EINVAL;
-   }
-
-   uart-timeout = value * HZ;
-   if (uart-timeout)
-   mod_timer(uart-timer, jiffies + uart-timeout);
-   else
-   /* A zero value means disable timeout feature

[PATCH v5 04/15] OMAP2+: UART: cleanup 8250 console driver support

2011-09-21 Thread Govindraj.R
We had been using traditional 8250 driver as uart console driver
prior to omap-serial driver. Since we have omap-serial driver
in mainline kernel for some time now it has been used as default
uart console driver on omap2+ platforms. Remove 8250 support for
omap-uarts.

Serial_in and serial_out override for 8250 serial driver is also
removed. Empty fifo read fix is already taken care with omap-serial
driver with data ready bit check from LSR reg before reading RX fifo.
Also waiting for THRE(transmit hold reg empty) is done with wait_for_xmitr
in omap-serial driver.

Remove headers that were necessary to support 8250 support
and remove all config bindings done to keep 8250 backward compatibility
while adding omap-serial driver. Remove omap_uart_reset needed for
8250 autoconf.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |  111 --
 1 files changed, 0 insertions(+), 111 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 60108fd..784a8f9 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -19,22 +19,16 @@
  */
 #include linux/kernel.h
 #include linux/init.h
-#include linux/serial_reg.h
 #include linux/clk.h
 #include linux/io.h
 #include linux/delay.h
 #include linux/platform_device.h
 #include linux/slab.h
-#include linux/serial_8250.h
 #include linux/console.h
 
-#ifdef CONFIG_SERIAL_OMAP
 #include plat/omap-serial.h
-#endif
-
 #include plat/common.h
 #include plat/board.h
-#include plat/clock.h
 #include plat/dma.h
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
@@ -46,10 +40,8 @@
 #include control.h
 #include mux.h
 
-#define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV0x52
 #define UART_OMAP_WER  0x17/* Wake-up enable register */
 
-#define UART_ERRATA_FIFO_FULL_ABORT(0x1  0)
 #define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
 
 /*
@@ -156,19 +148,6 @@ static inline void serial_write_reg(struct omap_uart_state 
*uart, int offset,
__raw_writeb(value, uart-membase + offset);
 }
 
-/*
- * Internal UARTs need to be initialized for the 8250 autoconfig to work
- * properly. Note that the TX watermark initialization may not be needed
- * once the 8250.c watermark handling code is merged.
- */
-
-static inline void __init omap_uart_reset(struct omap_uart_state *uart)
-{
-   serial_write_reg(uart, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
-   serial_write_reg(uart, UART_OMAP_SCR, 0x08);
-   serial_write_reg(uart, UART_OMAP_MDR1, UART_OMAP_MDR1_16X_MODE);
-}
-
 #if defined(CONFIG_PM)  defined(CONFIG_ARCH_OMAP3)
 
 /*
@@ -533,41 +512,6 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 #define DEV_CREATE_FILE(dev, attr)
 #endif /* CONFIG_PM */
 
-#ifndef CONFIG_SERIAL_OMAP
-/*
- * Override the default 8250 read handler: mem_serial_in()
- * Empty RX fifo read causes an abort on omap3630 and omap4
- * This function makes sure that an empty rx fifo is not read on these silicons
- * (OMAP1/2/3430 are not affected)
- */
-static unsigned int serial_in_override(struct uart_port *up, int offset)
-{
-   if (UART_RX == offset) {
-   unsigned int lsr;
-   lsr = __serial_read_reg(up, UART_LSR);
-   if (!(lsr  UART_LSR_DR))
-   return -EPERM;
-   }
-
-   return __serial_read_reg(up, offset);
-}
-
-static void serial_out_override(struct uart_port *up, int offset, int value)
-{
-   unsigned int status, tmout = 1;
-
-   status = __serial_read_reg(up, UART_LSR);
-   while (!(status  UART_LSR_THRE)) {
-   /* Wait up to 10ms for the character(s) to be sent. */
-   if (--tmout == 0)
-   break;
-   udelay(1);
-   status = __serial_read_reg(up, UART_LSR);
-   }
-   __serial_write_reg(up, offset, value);
-}
-#endif
-
 static int __init omap_serial_early_init(void)
 {
int i = 0;
@@ -628,15 +572,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
void *pdata = NULL;
u32 pdata_size = 0;
char *name;
-#ifndef CONFIG_SERIAL_OMAP
-   struct plat_serial8250_port ports[2] = {
-   {},
-   {.flags = 0},
-   };
-   struct plat_serial8250_port *p = ports[0];
-#else
struct omap_uart_port_info omap_up;
-#endif
 
if (WARN_ON(!bdata))
return;
@@ -651,51 +587,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
 
oh = uart-oh;
uart-dma_enabled = 0;
-#ifndef CONFIG_SERIAL_OMAP
-   name = serial8250;
-
-   /*
-* !! 8250 driver does not use standard IORESOURCE* It
-* has it's own custom pdata that can be taken from
-* the hwmod resource data.  But, this needs to be
-* done after the build.
-*
-* ?? does it have to be done before the register ??
-* YES, because platform_device_data_add

[PATCH v5 03/15] OMAP2+: UART: cleanup + remove uart pm specific API

2011-09-21 Thread Govindraj.R
In preparation to UART runtime conversion remove uart specific calls
from pm24xx/34xx files and their definition from serial.c
These func calls will no more be used with upcoming uart runtime design.

1.) omap_uart_can_sleep :- currently used to set uart-can_sleep flag based
on which uart clocks can be gated, not needed further as driver can
autosuspend based on usage_count and autosuspend delay with runtime API's.
2.) omap_uart_prepare_suspend :- can be taken care with driver suspend hooks.
3.) omap_uart_enable_irqs :- Used to enable/disable uart irq's in suspend
path from PM code, this is removed as same is handled by
uart_suspend_port/uart_resume_port in omap-serial driver which will
do an port_shutdown on suspend freeing irq and port_startup on resume
enabling back irq.
4.) Remove prepare_idle/resume_idle calls used to gate uart clocks.
UART clocks can be gated within driver using runtime funcs
and be woken up using irq_chaining from omap_prm driver.
5.) Remove console_locking from idle path as clock gating is done withing
driver itself with runtime API.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/pm24xx.c |   19 ---
 arch/arm/mach-omap2/pm34xx.c |   24 
 arch/arm/mach-omap2/serial.c |   87 --
 arch/arm/plat-omap/include/plat/serial.h |5 --
 4 files changed, 0 insertions(+), 135 deletions(-)

diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index bf089e7..83a8b96 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -133,27 +133,11 @@ static void omap2_enter_full_retention(void)
if (omap_irq_pending())
goto no_sleep;
 
-   /* Block console output in case it is on one of the OMAP UARTs */
-   if (!is_suspending())
-   if (!console_trylock())
-   goto no_sleep;
-
-   omap_uart_prepare_idle(0);
-   omap_uart_prepare_idle(1);
-   omap_uart_prepare_idle(2);
-
/* Jump to SRAM suspend code */
omap2_sram_suspend(sdrc_read_reg(SDRC_DLLA_CTRL),
   OMAP_SDRC_REGADDR(SDRC_DLLA_CTRL),
   OMAP_SDRC_REGADDR(SDRC_POWER));
 
-   omap_uart_resume_idle(2);
-   omap_uart_resume_idle(1);
-   omap_uart_resume_idle(0);
-
-   if (!is_suspending())
-   console_unlock();
-
 no_sleep:
if (omap2_pm_debug) {
unsigned long long tmp;
@@ -265,8 +249,6 @@ static int omap2_can_sleep(void)
 {
if (omap2_fclks_active())
return 0;
-   if (!omap_uart_can_sleep())
-   return 0;
if (osc_ck-usecount  1)
return 0;
if (omap_dma_running())
@@ -317,7 +299,6 @@ static int omap2_pm_suspend(void)
mir1 = omap_readl(0x480fe0a4);
omap_writel(1  5, 0x480fe0ac);
 
-   omap_uart_prepare_suspend();
omap2_enter_full_retention();
 
omap_writel(mir1, 0x480fe0a4);
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 7255d9b..4ea6aa7 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -379,18 +379,9 @@ void omap_sram_idle(void)
omap3_enable_io_chain();
}
 
-   /* Block console output in case it is on one of the OMAP UARTs */
-   if (!is_suspending())
-   if (per_next_state  PWRDM_POWER_ON ||
-   core_next_state  PWRDM_POWER_ON)
-   if (!console_trylock())
-   goto console_still_active;
-
/* PER */
if (per_next_state  PWRDM_POWER_ON) {
per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
-   omap_uart_prepare_idle(2);
-   omap_uart_prepare_idle(3);
omap2_gpio_prepare_for_idle(per_going_off);
if (per_next_state == PWRDM_POWER_OFF)
omap3_per_save_context();
@@ -398,8 +389,6 @@ void omap_sram_idle(void)
 
/* CORE */
if (core_next_state  PWRDM_POWER_ON) {
-   omap_uart_prepare_idle(0);
-   omap_uart_prepare_idle(1);
if (core_next_state == PWRDM_POWER_OFF) {
omap3_core_save_context();
omap3_cm_save_context();
@@ -446,8 +435,6 @@ void omap_sram_idle(void)
omap3_sram_restore_context();
omap2_sms_restore_context();
}
-   omap_uart_resume_idle(0);
-   omap_uart_resume_idle(1);
if (core_next_state == PWRDM_POWER_OFF)
omap2_prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF_MASK,
   OMAP3430_GR_MOD,
@@ -461,14 +448,8 @@ void omap_sram_idle(void)
omap2_gpio_resume_after_idle();
if (per_prev_state

[PATCH v5 06/15] OMAP2+: UART: Remove certain feilds from omap_uart_state struct

2011-09-21 Thread Govindraj.R
Removing some of the uart info that is maintained in omap_uart_state struct
used for UART PM in serial.c.

Remove omap_uart_state struct dependency from omap_serial_init,
omap_serial_init_port, omap_serial_early_init and omap_uart_idle_init functions.
And populate the same info in omap_uart_port_info struct used as pdata struct.

Added omap_uart_hwmod_lookup function to look up oh by name used
in serial_port_init and omap_serial_early_init functions.

A list of omap_uart_state was maintained one for each uart, the same is removed.
Number of uarts available is maintained in num_uarts field, re-use the same in
omap_serial_init func to register each uart.

Remove omap_info which used details from omap_uart_state and use
a pdata pointer to pass platform specific info to driver.

The mapbase (start_address), membase(io_remap cookie) maintained as part of
uart_state struct and pdata struct are removed as this is handled within
driver. Errata field is also moved to pdata. These changes are done
to cleanup serial.c file and prepare for runtime changes.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |  132 +---
 arch/arm/plat-omap/include/plat/omap-serial.h |4 +-
 drivers/tty/serial/omap-serial.c  |   12 ++-
 3 files changed, 61 insertions(+), 87 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 3465fd7..fd0c345 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -67,14 +67,6 @@ struct omap_uart_state {
int clocked;
 
int regshift;
-   void __iomem *membase;
-   resource_size_t mapbase;
-
-   struct list_head node;
-   struct omap_hwmod *oh;
-   struct platform_device *pdev;
-
-   u32 errata;
 #if defined(CONFIG_ARCH_OMAP3)  defined(CONFIG_PM)
int context_valid;
 
@@ -89,7 +81,6 @@ struct omap_uart_state {
 #endif
 };
 
-static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
 static int uart_idle_hwmod(struct omap_device *od)
@@ -142,7 +133,7 @@ static inline void serial_write_reg(struct omap_uart_state 
*uart, int offset,
__raw_writeb(value, uart-membase + offset);
 }
 
-#if defined(CONFIG_PM)  defined(CONFIG_ARCH_OMAP3)
+#if defined(CONFIG_PM)
 
 /*
  * Work Around for Errata i202 (3430 - 1.12, 3630 - 1.6)
@@ -335,22 +326,17 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
uart-can_sleep = 0;
 }
 
-static void omap_uart_idle_init(struct omap_uart_state *uart)
+static void omap_uart_idle_init(struct omap_uart_port_info *uart,
+   unsigned short num)
 {
-   int ret;
-
-   uart-can_sleep = 0;
-   omap_uart_smart_idle_enable(uart, 0);
-
if (cpu_is_omap34xx()  !cpu_is_ti816x()) {
-   u32 mod = (uart-num  1) ? OMAP3430_PER_MOD : CORE_MOD;
+   u32 mod = (num  1) ? OMAP3430_PER_MOD : CORE_MOD;
u32 wk_mask = 0;
u32 padconf = 0;
 
-   /* XXX These PRM accesses do not belong here */
uart-wk_en = OMAP34XX_PRM_REGADDR(mod, PM_WKEN1);
uart-wk_st = OMAP34XX_PRM_REGADDR(mod, PM_WKST1);
-   switch (uart-num) {
+   switch (num) {
case 0:
wk_mask = OMAP3430_ST_UART1_MASK;
padconf = 0x182;
@@ -369,12 +355,11 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
break;
}
uart-wk_mask = wk_mask;
-   uart-padconf = padconf;
} else if (cpu_is_omap24xx()) {
u32 wk_mask = 0;
u32 wk_en = PM_WKEN1, wk_st = PM_WKST1;
 
-   switch (uart-num) {
+   switch (num) {
case 0:
wk_mask = OMAP24XX_ST_UART1_MASK;
break;
@@ -399,7 +384,6 @@ static void omap_uart_idle_init(struct omap_uart_state 
*uart)
uart-wk_en = NULL;
uart-wk_st = NULL;
uart-wk_mask = 0;
-   uart-padconf = 0;
}
 }
 
@@ -412,28 +396,27 @@ static void omap_uart_block_sleep(struct omap_uart_state 
*uart)
 }
 #endif /* CONFIG_PM */
 
-static int __init omap_serial_early_init(void)
+struct omap_hwmod *omap_uart_hwmod_lookup(int num)
 {
-   int i = 0;
+   struct omap_hwmod *oh;
+   char oh_name[MAX_UART_HWMOD_NAME_LEN];
+
+   snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN, uart%d, num + 1);
+   oh = omap_hwmod_lookup(oh_name);
+   WARN(IS_ERR(oh), Could not lookup hmwod info for %s\n,
+   oh_name);
+   return oh;
+}
 
+static int __init omap_serial_early_init(void)
+{
do {
-   char oh_name[MAX_UART_HWMOD_NAME_LEN];
struct omap_hwmod *oh;
-   struct omap_uart_state *uart;
 
-   snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN,
-uart

[PATCH v5 08/15] OMAP2+: UART: Store certain reg values to port structure

2011-09-21 Thread Govindraj.R
In preparation to runtime conversion add missing uart regs to
port structure which can be used in context restore.
Also ensuring all uart reg info's are part of port structure.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/plat-omap/include/plat/omap-serial.h |3 ++
 drivers/tty/serial/omap-serial.c  |   33 ++--
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 0f061b4..74822b3 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -99,6 +99,9 @@ struct uart_omap_port {
unsigned char   mcr;
unsigned char   fcr;
unsigned char   efr;
+   unsigned char   dll;
+   unsigned char   dlh;
+   unsigned char   mdr1;
 
int use_dma;
/*
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6c2ea54..9a0eac2 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -433,8 +433,9 @@ static void serial_omap_set_mctrl(struct uart_port *port, 
unsigned int mctrl)
if (mctrl  TIOCM_LOOP)
mcr |= UART_MCR_LOOP;
 
-   mcr |= up-mcr;
-   serial_out(up, UART_MCR, mcr);
+   up-mcr = serial_in(up, UART_MCR);
+   up-mcr |= mcr;
+   serial_out(up, UART_MCR, up-mcr);
 }
 
 static void serial_omap_break_ctl(struct uart_port *port, int break_state)
@@ -573,8 +574,6 @@ static inline void
 serial_omap_configure_xonxoff
(struct uart_omap_port *up, struct ktermios *termios)
 {
-   unsigned char efr = 0;
-
up-lcr = serial_in(up, UART_LCR);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
up-efr = serial_in(up, UART_EFR);
@@ -584,8 +583,7 @@ serial_omap_configure_xonxoff
serial_out(up, UART_XOFF1, termios-c_cc[VSTOP]);
 
/* clear SW control mode bits */
-   efr = up-efr;
-   efr = OMAP_UART_SW_CLR;
+   up-efr = OMAP_UART_SW_CLR;
 
/*
 * IXON Flag:
@@ -593,7 +591,7 @@ serial_omap_configure_xonxoff
 * Transmit XON1, XOFF1
 */
if (termios-c_iflag  IXON)
-   efr |= OMAP_UART_SW_TX;
+   up-efr |= OMAP_UART_SW_TX;
 
/*
 * IXOFF Flag:
@@ -601,7 +599,7 @@ serial_omap_configure_xonxoff
 * Receiver compares XON1, XOFF1.
 */
if (termios-c_iflag  IXOFF)
-   efr |= OMAP_UART_SW_RX;
+   up-efr |= OMAP_UART_SW_RX;
 
serial_out(up, UART_EFR, up-efr | UART_EFR_ECB);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
@@ -624,7 +622,7 @@ serial_omap_configure_xonxoff
 * load the new software flow control mode IXON or IXOFF
 * and restore the UARTi.EFR_REG[4] ENHANCED_EN value.
 */
-   serial_out(up, UART_EFR, efr | UART_EFR_SCD);
+   serial_out(up, UART_EFR, up-efr | UART_EFR_SCD);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
 
serial_out(up, UART_MCR, up-mcr  ~UART_MCR_TCRTLR);
@@ -671,6 +669,10 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
baud = uart_get_baud_rate(port, termios, old, 0, port-uartclk/13);
quot = serial_omap_get_divisor(port, baud);
 
+   up-dll = quot  0xff;
+   up-dlh = quot  8;
+   up-mdr1 = UART_OMAP_MDR1_DISABLE;
+
up-fcr = UART_FCR_R_TRIG_01 | UART_FCR_T_TRIG_01 |
UART_FCR_ENABLE_FIFO;
if (up-use_dma)
@@ -723,6 +725,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
up-ier |= UART_IER_MSI;
serial_out(up, UART_IER, up-ier);
serial_out(up, UART_LCR, cval); /* reset DLAB */
+   up-lcr = cval;
 
/* FIFOs and DMA Settings */
 
@@ -759,7 +762,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
 
/* Protocol, Baud Rate, and Interrupt Settings */
 
-   serial_out(up, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
+   serial_out(up, UART_OMAP_MDR1, up-mdr1);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
up-efr = serial_in(up, UART_EFR);
@@ -769,8 +772,8 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_IER, 0);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
-   serial_out(up, UART_DLL, quot  0xff);  /* LS of divisor */
-   serial_out(up, UART_DLM, quot  8);/* MS of divisor */
+   serial_out(up, UART_DLL, up-dll);  /* LS of divisor */
+   serial_out(up, UART_DLM, up-dlh);  /* MS of divisor */
 
serial_out(up, UART_LCR, 0);
serial_out(up, UART_IER, up-ier);
@@ -780,9 +783,11 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_LCR

[PATCH v5 07/15] OMAP2+: UART: Add default mux for all uarts.

2011-09-21 Thread Govindraj.R
Prior to this change rx-pad wakeup was done by writing to rx-pad offset value
populated in serial.c idle_init. Now with mux framework support we can use
mux_utilities along with hmwod framework to handle io-pad configuration and
enable rx-pad wake-up mechanism.

Add default mux data for all uart's if mux info is not passed from
board file to avoid breaking any board support.
With the default pads we have populated wakeup capability for rx pads
which can be used to enable uart_rx io-pad wakeup from hwmod framework.
The pad values in 3430 board file are same as the default pad values
populated in serial.c. Remove pad values from 3430 board file and use
the default pads from serial.c file.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c |  100 +--
 arch/arm/mach-omap2/serial.c|  190 +++
 2 files changed, 128 insertions(+), 162 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index bd600cf..b12b38f 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -482,106 +482,8 @@ static const struct usbhs_omap_board_data usbhs_bdata 
__initconst = {
 static struct omap_board_mux board_mux[] __initdata = {
{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
-
-static struct omap_device_pad serial1_pads[] __initdata = {
-   /*
-* Note that off output enable is an active low
-* signal. So setting this means pin is a
-* input enabled in off mode
-*/
-   OMAP_MUX_STATIC(uart1_cts.uart1_cts,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_rts.uart1_rts,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_rx.uart1_rx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart1_tx.uart1_tx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_device_pad serial2_pads[] __initdata = {
-   OMAP_MUX_STATIC(uart2_cts.uart2_cts,
-OMAP_PIN_INPUT_PULLUP |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_rts.uart2_rts,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_rx.uart2_rx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart2_tx.uart2_tx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_device_pad serial3_pads[] __initdata = {
-   OMAP_MUX_STATIC(uart3_cts_rctx.uart3_cts_rctx,
-OMAP_PIN_INPUT_PULLDOWN |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_rts_sd.uart3_rts_sd,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_rx_irrx.uart3_rx_irrx,
-OMAP_PIN_INPUT |
-OMAP_PIN_OFF_INPUT_PULLDOWN |
-OMAP_OFFOUT_EN |
-OMAP_MUX_MODE0),
-   OMAP_MUX_STATIC(uart3_tx_irtx.uart3_tx_irtx,
-OMAP_PIN_OUTPUT |
-OMAP_OFF_EN |
-OMAP_MUX_MODE0),
-};
-
-static struct omap_board_data serial1_data __initdata = {
-   .id = 0,
-   .pads   = serial1_pads,
-   .pads_cnt   = ARRAY_SIZE(serial1_pads),
-};
-
-static struct omap_board_data serial2_data __initdata = {
-   .id = 1,
-   .pads   = serial2_pads,
-   .pads_cnt   = ARRAY_SIZE(serial2_pads),
-};
-
-static struct omap_board_data serial3_data __initdata = {
-   .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

[PATCH v5 09/15] OMAP2+: UART: Add runtime pm support for omap-serial driver

2011-09-21 Thread Govindraj.R
Adapts omap-serial driver to use pm_runtime API's.

Use runtime runtime API's to handle uart clocks and obtain
device_usage statics. Set runtime API's usage to irq_safe so that
we can use get_sync from irq context. Auto-suspend for port specific
activities and put for reg access. Use device_may_wakeup to check
whether uart has wakeup capabilities and then enable uart runtime
usage for the uart.

Removing save_context/restore_context functions from serial.c
Adding context restore to .runtime_suspend and using reg values from port
structure to restore the uart port context based on context_loss_count.
Maintain internal state machine using wakeups_enabled field for avoiding
repeated enable/disable of uart port wakeup mechanism.

Remove omap_uart_disable_wakeup and modify omap_uart_enable_wakeup
to accept pdev and bool value to enable/disable the uart wakeup mechanism
after uart clock's are cut. omap_hwmod_enable_wakeup is used to set
pad wakeup for the uarts. PM_WKEN reg values are left to default.
Removed omap_uart_enable/disable_clocks in serial.c now clock handling
done with runtime API's.

By default uart autosuspend delay is set to -1 to avoid character loss
if uart's are autoidled and woken up on rx pin.

After boot up UART's can be autoidled by setting autosuspendi delay from sysfs.

echo 3000  /sys/devices/platform/omap/omap_uart.X/power/autosuspend_delay_ms
X=0,1,2,3 for UART1/2/3/4. Number of uarts available may vary across omap_soc.

Acked-by: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |  206 ++--
 arch/arm/plat-omap/include/plat/omap-serial.h |5 +
 drivers/tty/serial/omap-serial.c  |  169 +++--
 3 files changed, 179 insertions(+), 201 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 1561140..43d8f0d 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -32,6 +32,7 @@
 #include plat/dma.h
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
+#include plat/omap-pm.h
 
 #include prm2xxx_3xxx.h
 #include pm.h
@@ -40,8 +41,6 @@
 #include control.h
 #include mux.h
 
-#define UART_OMAP_WER  0x17/* Wake-up enable register */
-
 #define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
 
 /*
@@ -56,24 +55,7 @@
 
 struct omap_uart_state {
int num;
-   int can_sleep;
u32 dma_enabled;
-
-   int clocked;
-
-   int regshift;
-#if defined(CONFIG_ARCH_OMAP3)  defined(CONFIG_PM)
-   int context_valid;
-
-   /* Registers to be saved/restored for OFF-mode */
-   u16 dll;
-   u16 dlh;
-   u16 ier;
-   u16 sysc;
-   u16 scr;
-   u16 wer;
-   u16 mcr;
-#endif
 };
 
 static u8 num_uarts;
@@ -100,34 +82,6 @@ static struct omap_device_pm_latency omap_uart_latency[] = {
},
 };
 
-static inline unsigned int __serial_read_reg(struct uart_port *up,
-int offset)
-{
-   offset = up-regshift;
-   return (unsigned int)__raw_readb(up-membase + offset);
-}
-
-static inline unsigned int serial_read_reg(struct omap_uart_state *uart,
-  int offset)
-{
-   offset = uart-regshift;
-   return (unsigned int)__raw_readb(uart-membase + offset);
-}
-
-static inline void __serial_write_reg(struct uart_port *up, int offset,
-   int value)
-{
-   offset = up-regshift;
-   __raw_writeb(value, up-membase + offset);
-}
-
-static inline void serial_write_reg(struct omap_uart_state *uart, int offset,
-   int value)
-{
-   offset = uart-regshift;
-   __raw_writeb(value, uart-membase + offset);
-}
-
 #if defined(CONFIG_PM)
 
 /*
@@ -164,134 +118,8 @@ static void omap_uart_mdr1_errataset(struct 
omap_uart_state *uart, u8 mdr1_val,
udelay(1);
}
 }
-
-static void omap_uart_save_context(struct omap_uart_state *uart)
-{
-   u16 lcr = 0;
-
-   if (!enable_off_mode)
-   return;
-
-   lcr = serial_read_reg(uart, UART_LCR);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_B);
-   uart-dll = serial_read_reg(uart, UART_DLL);
-   uart-dlh = serial_read_reg(uart, UART_DLM);
-   serial_write_reg(uart, UART_LCR, lcr);
-   uart-ier = serial_read_reg(uart, UART_IER);
-   uart-sysc = serial_read_reg(uart, UART_OMAP_SYSC);
-   uart-scr = serial_read_reg(uart, UART_OMAP_SCR);
-   uart-wer = serial_read_reg(uart, UART_OMAP_WER);
-   serial_write_reg(uart, UART_LCR, UART_LCR_CONF_MODE_A);
-   uart-mcr = serial_read_reg(uart, UART_MCR);
-   serial_write_reg(uart, UART_LCR, lcr);
-
-   uart-context_valid = 1;
-}
-
-static void omap_uart_restore_context(struct omap_uart_state *uart)
-{
-   u16 efr = 0;
-
-   if (!enable_off_mode)
-   return;
-
-   if (!uart-context_valid)
-   return;
-
-   uart

[PATCH v5 11/15] OMAP2+: UART: Allow UART parameters to be configured from board file.

2011-09-21 Thread Govindraj.R
From: Deepak K deepa...@ti.com

The following UART parameters are defined within the UART driver:

1). Whether the UART uses DMA (dma_enabled), by default set to 0
2). The size of dma buffer (set to 4096 bytes)
3). The time after which the dma should stop if no more data is received.
4). The auto suspend delay that will be passed for pm_runtime_autosuspend
where uart will be disabled after timeout

Different UARTs may be used for different purpose such as the console,
for interfacing bluetooth chip, for interfacing to a modem chip, etc.
Therefore, it is necessary to be able to customize the above settings
for a given board on a per UART basis.

This change allows these parameters to be configured from the board file
and allows the parameters to be configured for each UART independently.

If a board does not define its own custom parameters for the UARTs, then
use the default parameters in the structure omap_serial_default_info.
The default parameters are defined to be the same as the current settings
in the UART driver to avoid breaking the UART for any cuurnelty supported
boards. By default, make all boards use the default UART parameters.

Signed-off-by: Deepak K deepa...@ti.com
Signed-off-by: Jon Hunter jon-hun...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
This patch is derived and reworked from a custom 2.6.35 kernel
Available here:
http://git.omapzoom.org/?p=kernel/omap.git;
a=commitdiff;h=584ef316542f77312be7ba96a0f3013c8f64852b;
hp=7233a76cb362c0fc603f773274159adff91d3513

 arch/arm/mach-omap2/board-4430sdp.c   |8 ++--
 arch/arm/mach-omap2/board-n8x0.c  |6 +-
 arch/arm/mach-omap2/board-omap4panda.c|8 ++--
 arch/arm/mach-omap2/serial.c  |   56 
 arch/arm/plat-omap/include/plat/omap-serial.h |7 ++-
 arch/arm/plat-omap/include/plat/serial.h  |6 ++-
 drivers/tty/serial/omap-serial.c  |8 +--
 7 files changed, 69 insertions(+), 30 deletions(-)

diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index c7cef44..41b43cb 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -743,11 +743,11 @@ static inline void board_serial_init(void)
bdata.pads_cnt  = 0;
bdata.id= 0;
/* pass dummy data for UART1 */
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
-   omap_serial_init_port(serial2_data);
-   omap_serial_init_port(serial3_data);
-   omap_serial_init_port(serial4_data);
+   omap_serial_init_port(serial2_data, NULL);
+   omap_serial_init_port(serial3_data, NULL);
+   omap_serial_init_port(serial4_data, NULL);
 }
 #else
 #define board_mux  NULL
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index e11f0c5..3408726 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -656,15 +656,15 @@ static inline void board_serial_init(void)
bdata.pads_cnt = 0;
 
bdata.id = 0;
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
bdata.id = 1;
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
bdata.id = 2;
bdata.pads = serial2_pads;
bdata.pads_cnt = ARRAY_SIZE(serial2_pads);
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 }
 
 #else
diff --git a/arch/arm/mach-omap2/board-omap4panda.c 
b/arch/arm/mach-omap2/board-omap4panda.c
index 9aaa960..fdfac0c 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -425,11 +425,11 @@ static inline void board_serial_init(void)
bdata.pads_cnt  = 0;
bdata.id= 0;
/* pass dummy data for UART1 */
-   omap_serial_init_port(bdata);
+   omap_serial_init_port(bdata, NULL);
 
-   omap_serial_init_port(serial2_data);
-   omap_serial_init_port(serial3_data);
-   omap_serial_init_port(serial4_data);
+   omap_serial_init_port(serial2_data, NULL);
+   omap_serial_init_port(serial3_data, NULL);
+   omap_serial_init_port(serial4_data, NULL);
 }
 #else
 #define board_mux  NULL
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 9fe248e..0e45d9a 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -42,17 +42,29 @@
 #include mux.h
 
 /*
- * NOTE: By default the serial timeout is disabled as it causes lost characters
- * over the serial ports. This means that the UART clocks will stay on until
- * disabled via sysfs. This also causes that any deeper omap sleep states are
- * blocked. 
+ * NOTE: By default the serial auto_suspend timeout is disabled as it causes
+ * lost characters over the serial ports. This means that the UART clocks will
+ * stay on until power/autosuspend_delay is set for the uart from sysfs.
+ * This also causes that any

[PATCH v5 10/15] OMAP2+: UART: Move errata handling from serial.c to omap-serial

2011-09-21 Thread Govindraj.R
Move the errata handling mechanism from serial.c to omap-serial file
and utilise the same func in driver file.

Errata i202, i291 are moved to be handled with omap-serial
Moving the errata macro from serial.c file to driver header file
as from on errata will be handled in driver file itself.

Corrected errata id from chapter reference 2.15 to errata id i291.

Acked-by: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   78 +
 arch/arm/plat-omap/include/plat/omap-serial.h |5 ++
 drivers/tty/serial/omap-serial.c  |   63 ++--
 3 files changed, 77 insertions(+), 69 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 43d8f0d..9fe248e 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -41,8 +41,6 @@
 #include control.h
 #include mux.h
 
-#define UART_ERRATA_i202_MDR1_ACCESS   (0x1  1)
-
 /*
  * NOTE: By default the serial timeout is disabled as it causes lost characters
  * over the serial ports. This means that the UART clocks will stay on until
@@ -53,11 +51,6 @@
 
 #define MAX_UART_HWMOD_NAME_LEN16
 
-struct omap_uart_state {
-   int num;
-   u32 dma_enabled;
-};
-
 static u8 num_uarts;
 
 static int uart_idle_hwmod(struct omap_device *od)
@@ -84,63 +77,6 @@ static struct omap_device_pm_latency omap_uart_latency[] = {
 
 #if defined(CONFIG_PM)
 
-/*
- * Work Around for Errata i202 (3430 - 1.12, 3630 - 1.6)
- * The access to uart register after MDR1 Access
- * causes UART to corrupt data.
- *
- * Need a delay =
- * 5 L4 clock cycles + 5 UART functional clock cycle (@48MHz = ~0.2uS)
- * give 10 times as much
- */
-static void omap_uart_mdr1_errataset(struct omap_uart_state *uart, u8 mdr1_val,
-   u8 fcr_val)
-{
-   u8 timeout = 255;
-
-   serial_write_reg(uart, UART_OMAP_MDR1, mdr1_val);
-   udelay(2);
-   serial_write_reg(uart, UART_FCR, fcr_val | UART_FCR_CLEAR_XMIT |
-   UART_FCR_CLEAR_RCVR);
-   /*
-* Wait for FIFO to empty: when empty, RX_FIFO_E bit is 0 and
-* TX_FIFO_E bit is 1.
-*/
-   while (UART_LSR_THRE != (serial_read_reg(uart, UART_LSR) 
-   (UART_LSR_THRE | UART_LSR_DR))) {
-   timeout--;
-   if (!timeout) {
-   /* Should *never* happen. we warn and carry on */
-   dev_crit(uart-pdev-dev, Errata i202: timedout %x\n,
-   serial_read_reg(uart, UART_LSR));
-   break;
-   }
-   udelay(1);
-   }
-}
-#endif /* CONFIG_PM  CONFIG_ARCH_OMAP3 */
-
-static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
-  int enable)
-{
-   u8 idlemode;
-
-   if (enable) {
-   /**
-* Errata 2.15: [UART]:Cannot Acknowledge Idle Requests
-* in Smartidle Mode When Configured for DMA Operations.
-*/
-   if (uart-dma_enabled)
-   idlemode = HWMOD_IDLEMODE_FORCE;
-   else
-   idlemode = HWMOD_IDLEMODE_SMART;
-   } else {
-   idlemode = HWMOD_IDLEMODE_NO;
-   }
-
-   omap_hwmod_set_slave_idlemode(uart-oh, idlemode);
-}
-
 #ifdef CONFIG_OMAP_MUX
 static struct omap_device_pad default_uart1_pads[] __initdata = {
{
@@ -282,7 +218,20 @@ static void omap_uart_enable_wakeup(struct platform_device 
*pdev, bool enable)
omap_hwmod_disable_wakeup(od-hwmods[0]);
 }
 
+/*
+ * Errata i291: [UART]:Cannot Acknowledge Idle Requests
+ * in Smartidle Mode When Configured for DMA Operations.
+ * WA: configure uart in force idle mode.
+ */
+static void omap_uart_set_forceidle(struct platform_device *pdev)
+{
+   struct omap_device *od = to_omap_device(pdev);
+
+   omap_hwmod_set_slave_idlemode(od-hwmods[0], HWMOD_IDLEMODE_FORCE);
+}
+
 #else
+static void omap_uart_set_forceidle(struct platform_device *pdev) {}
 static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
 {}
 #endif /* CONFIG_PM */
@@ -369,6 +318,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
pdata-flags = UPF_BOOT_AUTOCONF;
pdata-enable_wakeup = omap_uart_enable_wakeup;
pdata-get_context_loss_count = omap_pm_get_dev_context_loss_count;
+   pdata-set_force_idle = omap_uart_set_forceidle;
 
/* Enable the MDR1 errata for OMAP3 */
if (cpu_is_omap34xx()  !cpu_is_ti816x())
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 8ef81ce..12f5262 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -56,6 +56,8 @@
 
 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
 
+#define

[PATCH v5 13/15] OMAP2+: UART: Take console_lock in suspend path if not taken

2011-09-21 Thread Govindraj.R
In suspend path the console_lock is taken by uart_port_suspend
however when no_console_suspend is used console_lock is not taken.

During system wide suspend omap_pwr_domain hooks cut all
clocks that are left enabled. So its unsafe to proceed printing after
clocks are cut by pwr_domain hooks. Also pm_runtime will be disabled after
dpm_suspend devices happens. So buffer all prints in suspend path by taking
console_lock and print them back safely after power domain hooks re-enable
clocks back.

Use CONFIG_SERIAL_OMAP_CONSOLE macro check to take console_lock since
console ops are available only if omap console is defined.
omap-serial can be built as module without console support.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/plat-omap/include/plat/omap-serial.h |1 +
 drivers/tty/serial/omap-serial.c  |   20 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 28abc6b..de8de87 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -126,6 +126,7 @@ struct uart_omap_port {
u32 context_loss_cnt;
u8  wakeups_enabled;
u32 errata;
+   u8  console_locked;
 
 };
 
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 64e4ab5..92a1f10 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1133,8 +1133,15 @@ static int serial_omap_suspend(struct device *dev)
 {
struct uart_omap_port *up = dev_get_drvdata(dev);
 
-   if (up)
+   if (up) {
uart_suspend_port(serial_omap_reg, up-port);
+#ifdef CONFIG_SERIAL_OMAP_CONSOLE
+   if (up-port.line == up-port.cons-index 
+   !is_console_locked())
+   up-console_locked = console_trylock();
+#endif
+   }
+
return 0;
 }
 
@@ -1142,8 +1149,17 @@ static int serial_omap_resume(struct device *dev)
 {
struct uart_omap_port *up = dev_get_drvdata(dev);
 
-   if (up)
+   if (up) {
uart_resume_port(serial_omap_reg, up-port);
+#ifdef CONFIG_SERIAL_OMAP_CONSOLE
+   if (up-port.line == up-port.cons-index 
+   up-console_locked) {
+   console_unlock();
+   up-console_locked = 0;
+   }
+#endif
+   }
+
return 0;
 }
 
-- 
1.7.4.1

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


[PATCH v5 15/15] OMAP2+: UART: Do not gate uart clocks if used for debug_prints

2011-09-21 Thread Govindraj.R
If OMAP UART is used as console uart and debug is enabled,
avoid gating of uart clocks to print all debug prints.

If uart clocks are gated then the debug prints from omap_device
framework or hwmod framework can cause uart to enter recursive pm_runtime calls,
which can cause a deadlock over power lock usage.

For example: Say, uart clocks are cut and we get a print from 
omap_device_disable
stating disabling uart clocks. This print calls omap_uart driver console_write
which will call runtime API get_sync which means we enter from runtime API put
context to runtime API get context.

-- runtime put (take power lock)
-- print disabling uart clocks
-- call uart console write
-- call get_sync (try to take power lock)

Also any clock enable API call from uart driver should not call any uart
operation until clocks are enabled back. Like get_sync having debug print
calling uart console write even before clocks are enabled.

So to avoid these scenarios, identify from bootargs  if OMAP_UART(ttyO) is used
in debug mode. If so, do not set device_may_wakeup. This will prevent
pm_runtime_enable in uart driver probe and will avoid uart clock gating.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
More details on this topic and experiments done listed here:
http://www.spinics.net/lists/linux-serial/msg04128.html

 arch/arm/mach-omap2/serial.c |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 87696bf..3d92b77f 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -266,8 +266,24 @@ struct omap_hwmod *omap_uart_hwmod_lookup(int num)
return oh;
 }
 
+static int uart_debug;
+
+char *cmdline_find_option(char *str)
+{
+   extern char *saved_command_line;
+
+   return strstr(saved_command_line, str);
+}
+
 static int __init omap_serial_early_init(void)
 {
+   if (cmdline_find_option(debug) 
+   cmdline_find_option(OMAP_SERIAL_NAME)) {
+   uart_debug = true;
+   pr_info(OMAP UART used as console in debug mode
+uart clocks will not be gated);
+   }
+
do {
struct omap_hwmod *oh;
 
@@ -361,7 +377,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
 
oh-mux = omap_hwmod_mux_init(bdata-pads, bdata-pads_cnt);
 
-   if ((cpu_is_omap34xx()  bdata-pads))
+   if ((cpu_is_omap34xx()  bdata-pads)  !uart_debug)
device_init_wakeup(pdev-dev, true);
 
kfree(pdata);
-- 
1.7.4.1

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


[PATCH v5 14/15] OMAP2+: UART: Enable back uart clocks with runtime API for early console

2011-09-21 Thread Govindraj.R
For the early console probing we had avoided hwmod reset and idling
and uart was idled using hwmod API and enabled back using omap_device API
after omap_device registration.

Now since we are using runtime API's to enable back uart move hwmod idling and
use runtime API to enable back UART.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c  |   26 
 arch/arm/plat-omap/include/plat/omap-serial.h |1 +
 drivers/tty/serial/omap-serial.c  |1 +
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 57d063a..87696bf 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -24,13 +24,11 @@
 #include linux/delay.h
 #include linux/platform_device.h
 #include linux/slab.h
-#include linux/console.h
 
 #include plat/omap-serial.h
 #include plat/common.h
 #include plat/board.h
 #include plat/dma.h
-#include plat/omap_hwmod.h
 #include plat/omap_device.h
 #include plat/omap-pm.h
 
@@ -244,10 +242,16 @@ static void omap_uart_set_forceidle(struct 
platform_device *pdev)
omap_hwmod_set_slave_idlemode(od-hwmods[0], HWMOD_IDLEMODE_FORCE);
 }
 
+static void omap_uart_hwmod_idle(struct platform_device *pdev)
+{
+   struct omap_device *od = to_omap_device(pdev);
+
+   omap_hwmod_idle(od-hwmods[0]);
+}
+
 #else
 static void omap_uart_set_forceidle(struct platform_device *pdev) {}
-static void omap_uart_enable_wakeup(struct platform_device *pdev, bool enable)
-{}
+static void omap_uart_hwmod_idle(struct platform_device *pdev) {}
 #endif /* CONFIG_PM */
 
 struct omap_hwmod *omap_uart_hwmod_lookup(int num)
@@ -338,6 +342,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
pdata-enable_wakeup = omap_uart_enable_wakeup;
pdata-get_context_loss_count = omap_pm_get_dev_context_loss_count;
pdata-set_force_idle = omap_uart_set_forceidle;
+   pdata-hwmod_idle = omap_uart_hwmod_idle;
pdata-dma_enabled = info-dma_enabled;
pdata-dma_rx_buf_size = info-dma_rx_buf_size;
pdata-dma_rx_poll_rate = info-dma_rx_poll_rate;
@@ -356,19 +361,6 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
 
oh-mux = omap_hwmod_mux_init(bdata-pads, bdata-pads_cnt);
 
-   console_lock(); /* in case the earlycon is on the UART */
-
-   /*
-* Because of early UART probing, UART did not get idled
-* on init.  Now that omap_device is ready, ensure full idle
-* before doing omap_device_enable().
-*/
-   omap_hwmod_idle(oh);
-
-   omap_device_enable(pdev);
-
-   console_unlock();
-
if ((cpu_is_omap34xx()  bdata-pads))
device_init_wakeup(pdev-dev, true);
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index de8de87..800f215 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -71,6 +71,7 @@ struct omap_uart_port_info {
void (*enable_wakeup)(struct platform_device *, bool);
u32 (*get_context_loss_count)(struct device *);
void (*set_force_idle)(struct platform_device *);
+   void (*hwmod_idle)(struct platform_device *);
 };
 
 struct uart_omap_dma {
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 92a1f10..8125a89 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1394,6 +1394,7 @@ static int serial_omap_probe(struct platform_device *pdev)
pm_runtime_irq_safe(pdev-dev);
if (device_may_wakeup(pdev-dev)) {
pm_runtime_enable(pdev-dev);
+   omap_up_info-hwmod_idle(pdev);
pm_runtime_get_sync(pdev-dev);
}
 
-- 
1.7.4.1

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


[PATCH v5 12/15] OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART

2011-09-21 Thread Govindraj.R
From: Jon Hunter jon-hun...@ti.com

When using DMA there are two timeouts defined. The first timeout,
rx_timeout, is really a polling rate in which software polls the
DMA status to see if the DMA has finished. This is necessary for
the RX side because we do not know how much data we will receive.
The secound timeout, RX_TIMEOUT, is a timeout after which the
DMA will be stopped if no more data is received. To make this
clearer, rename rx_timeout as rx_poll_rate and rename the
function serial_omap_rx_timeout() to serial_omap_rxdma_poll().

The OMAP-Serial driver defines an RX_TIMEOUT of 3 seconds that is
used to indicate when the DMA for UART can be stopped if no more
data is received. The value is a global definition that is applied
to all instances of the UART.

Each UART may be used for a different purpose and so the timeout
required may differ. Make this value configurable for each UART so
that this value can be optimised for power savings.

Acked-by: Kevin Hilman khil...@ti.com
Signed-off-by: Jon Hunter jon-hun...@ti.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
This patch is derived from a custom 2.6.35 kernel
Available here:
http://git.omapzoom.org/?p=kernel/omap.git;a=commitdiff;
h=b47839fb84e68333ea29a327cf5aa694b71be7d6;
hp=f62f570e8580507be48ad004defc2ec714b6e05d

 arch/arm/mach-omap2/serial.c  |5 -
 arch/arm/plat-omap/include/plat/omap-serial.h |3 ++-
 drivers/tty/serial/omap-serial.c  |   15 ---
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 0e45d9a..57d063a 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -53,13 +53,15 @@
 
 static u8 num_uarts;
 
-#define DEFAULT_RXDMA_TIMEOUT  1   /* RX DMA polling rate (us) */
+#define DEFAULT_RXDMA_POLLRATE 1   /* RX DMA polling rate (us) */
 #define DEFAULT_RXDMA_BUFSIZE  4096/* RX DMA buffer size */
+#define DEFAULT_RXDMA_TIMEOUT  (3 * HZ)/* RX DMA timeout (jiffies) */
 
 static struct omap_uart_port_info omap_serial_default_info[] = {
{
.dma_enabled= 0,
.dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
+   .dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
.dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
.autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
},
@@ -338,6 +340,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata,
pdata-set_force_idle = omap_uart_set_forceidle;
pdata-dma_enabled = info-dma_enabled;
pdata-dma_rx_buf_size = info-dma_rx_buf_size;
+   pdata-dma_rx_poll_rate = info-dma_rx_poll_rate;
pdata-dma_rx_timeout = info-dma_rx_timeout;
pdata-autosuspend_timeout = info-autosuspend_timeout;
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index a40a41a..28abc6b 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -51,7 +51,6 @@
 
 #define OMAP_UART_DMA_CH_FREE  -1
 
-#define RX_TIMEOUT (3 * HZ)
 #define OMAP_MAX_HSUART_PORTS  4
 
 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
@@ -67,6 +66,7 @@ struct omap_uart_port_info {
unsigned intdma_rx_buf_size;
unsigned intdma_rx_timeout;
unsigned intautosuspend_timeout;
+   unsigned intdma_rx_poll_rate;
 
void (*enable_wakeup)(struct platform_device *, bool);
u32 (*get_context_loss_count)(struct device *);
@@ -95,6 +95,7 @@ struct uart_omap_dma {
/* timer to poll activity on rx dma */
struct timer_list   rx_timer;
unsigned intrx_buf_size;
+   unsigned intrx_poll_rate;
unsigned intrx_timeout;
 };
 
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 15e0655..64e4ab5 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -47,7 +47,7 @@ static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
 /* Forward declaration of functions */
 static void uart_tx_dma_callback(int lch, u16 ch_status, void *data);
-static void serial_omap_rx_timeout(unsigned long uart_no);
+static void serial_omap_rxdma_poll(unsigned long uart_no);
 static int serial_omap_start_rxdma(struct uart_omap_port *up);
 static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);
 
@@ -542,7 +542,7 @@ static int serial_omap_startup(struct uart_port *port)
(dma_addr_t *)(up-uart_dma.tx_buf_dma_phys),
0);
init_timer((up-uart_dma.rx_timer));
-   up-uart_dma.rx_timer.function = serial_omap_rx_timeout;
+   up-uart_dma.rx_timer.function = serial_omap_rxdma_poll;
up-uart_dma.rx_timer.data = up-pdev-id

[PATCH v4 08/11] Serial: OMAP2+: Move erratum handling from serial.c

2011-09-07 Thread Govindraj.R
Move the erratum handling mechanism from serial.c to driver file
and utilise the same func in driver file.

Acked-by: Alan Cox a...@linux.intel.com
Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 drivers/tty/serial/omap-serial.c |   58 ++---
 1 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 30bdd05..96fc860 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -52,6 +52,7 @@ static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 static void uart_tx_dma_callback(int lch, u16 ch_status, void *data);
 static void serial_omap_rx_timeout(unsigned long uart_no);
 static int serial_omap_start_rxdma(struct uart_omap_port *up);
+static void omap_uart_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);
 
 static inline unsigned int serial_in(struct uart_omap_port *up, int offset)
 {
@@ -805,7 +806,11 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
 
/* Protocol, Baud Rate, and Interrupt Settings */
 
-   serial_out(up, UART_OMAP_MDR1, up-mdr1);
+   if (up-errata  UART_ERRATA_i202_MDR1_ACCESS)
+   omap_uart_mdr1_errataset(up, up-mdr1);
+   else
+   serial_out(up, UART_OMAP_MDR1, up-mdr1);
+
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
up-efr = serial_in(up, UART_EFR);
@@ -830,7 +835,10 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
else
up-mdr1 = UART_OMAP_MDR1_16X_MODE;
 
-   serial_out(up, UART_OMAP_MDR1, up-mdr1);
+   if (up-errata  UART_ERRATA_i202_MDR1_ACCESS)
+   omap_uart_mdr1_errataset(up, up-mdr1);
+   else
+   serial_out(up, UART_OMAP_MDR1, up-mdr1);
 
/* Hardware Flow Control Configuration */
 
@@ -1424,9 +1432,47 @@ static int serial_omap_remove(struct platform_device 
*dev)
return 0;
 }
 
+/*
+ * Work Around for Errata i202 (3430 - 1.12, 3630 - 1.6)
+ * The access to uart register after MDR1 Access
+ * causes UART to corrupt data.
+ *
+ * Need a delay =
+ * 5 L4 clock cycles + 5 UART functional clock cycle (@48MHz = ~0.2uS)
+ * give 10 times as much
+ */
+static void omap_uart_mdr1_errataset(struct uart_omap_port *up, u8 mdr1)
+{
+   u8 timeout = 255;
+
+   serial_out(up, UART_OMAP_MDR1, mdr1);
+   udelay(2);
+   serial_out(up, UART_FCR, up-fcr | UART_FCR_CLEAR_XMIT |
+   UART_FCR_CLEAR_RCVR);
+   /*
+* Wait for FIFO to empty: when empty, RX_FIFO_E bit is 0 and
+* TX_FIFO_E bit is 1.
+*/
+   while (UART_LSR_THRE != (serial_in(up, UART_LSR) 
+   (UART_LSR_THRE | UART_LSR_DR))) {
+   timeout--;
+   if (!timeout) {
+   /* Should *never* happen. we warn and carry on */
+   dev_crit(up-pdev-dev, Errata i202: timedout %x\n,
+   serial_in(up, UART_LSR));
+   break;
+   }
+   udelay(1);
+   }
+}
+
 static void omap_uart_restore_context(struct uart_omap_port *up)
 {
-   serial_out(up, UART_OMAP_MDR1, up-mdr1);
+   if (up-errata  UART_ERRATA_i202_MDR1_ACCESS)
+   omap_uart_mdr1_errataset(up, UART_OMAP_MDR1_DISABLE);
+   else
+   serial_out(up, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
+
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); /* Config B mode */
serial_out(up, UART_EFR, UART_EFR_ECB);
serial_out(up, UART_LCR, 0x0); /* Operational mode */
@@ -1442,8 +1488,10 @@ static void omap_uart_restore_context(struct 
uart_omap_port *up)
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); /* Config B mode */
serial_out(up, UART_EFR, up-efr);
serial_out(up, UART_LCR, up-lcr);
-   /* UART 16x mode */
-   serial_out(up, UART_OMAP_MDR1, up-mdr1);
+   if (up-errata  UART_ERRATA_i202_MDR1_ACCESS)
+   omap_uart_mdr1_errataset(up, up-mdr1);
+   else
+   serial_out(up, UART_OMAP_MDR1, up-mdr1);
 }
 
 static int omap_serial_runtime_suspend(struct device *dev)
-- 
1.7.4.1

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


[PATCH v4 06/11] Serial: OMAP: Store certain reg values to port structure

2011-09-07 Thread Govindraj.R
In preparation to runtime conversion add missing uart regs to
port structure which can be used in context restore.
Also ensuring all uart reg info's are part of port structure.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/plat-omap/include/plat/omap-serial.h |3 ++
 drivers/tty/serial/omap-serial.c  |   33 ++--
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index f79a76f..06e3aa2 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -104,6 +104,9 @@ struct uart_omap_port {
unsigned char   mcr;
unsigned char   fcr;
unsigned char   efr;
+   unsigned char   dll;
+   unsigned char   dlh;
+   unsigned char   mdr1;
 
int use_dma;
/*
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 5e713d3..6ac0ade 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -433,8 +433,9 @@ static void serial_omap_set_mctrl(struct uart_port *port, 
unsigned int mctrl)
if (mctrl  TIOCM_LOOP)
mcr |= UART_MCR_LOOP;
 
-   mcr |= up-mcr;
-   serial_out(up, UART_MCR, mcr);
+   up-mcr = serial_in(up, UART_MCR);
+   up-mcr |= mcr;
+   serial_out(up, UART_MCR, up-mcr);
 }
 
 static void serial_omap_break_ctl(struct uart_port *port, int break_state)
@@ -573,8 +574,6 @@ static inline void
 serial_omap_configure_xonxoff
(struct uart_omap_port *up, struct ktermios *termios)
 {
-   unsigned char efr = 0;
-
up-lcr = serial_in(up, UART_LCR);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
up-efr = serial_in(up, UART_EFR);
@@ -584,8 +583,7 @@ serial_omap_configure_xonxoff
serial_out(up, UART_XOFF1, termios-c_cc[VSTOP]);
 
/* clear SW control mode bits */
-   efr = up-efr;
-   efr = OMAP_UART_SW_CLR;
+   up-efr = OMAP_UART_SW_CLR;
 
/*
 * IXON Flag:
@@ -593,7 +591,7 @@ serial_omap_configure_xonxoff
 * Transmit XON1, XOFF1
 */
if (termios-c_iflag  IXON)
-   efr |= OMAP_UART_SW_TX;
+   up-efr |= OMAP_UART_SW_TX;
 
/*
 * IXOFF Flag:
@@ -601,7 +599,7 @@ serial_omap_configure_xonxoff
 * Receiver compares XON1, XOFF1.
 */
if (termios-c_iflag  IXOFF)
-   efr |= OMAP_UART_SW_RX;
+   up-efr |= OMAP_UART_SW_RX;
 
serial_out(up, UART_EFR, up-efr | UART_EFR_ECB);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
@@ -624,7 +622,7 @@ serial_omap_configure_xonxoff
 * load the new software flow control mode IXON or IXOFF
 * and restore the UARTi.EFR_REG[4] ENHANCED_EN value.
 */
-   serial_out(up, UART_EFR, efr | UART_EFR_SCD);
+   serial_out(up, UART_EFR, up-efr | UART_EFR_SCD);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
 
serial_out(up, UART_MCR, up-mcr  ~UART_MCR_TCRTLR);
@@ -671,6 +669,10 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
baud = uart_get_baud_rate(port, termios, old, 0, port-uartclk/13);
quot = serial_omap_get_divisor(port, baud);
 
+   up-dll = quot  0xff;
+   up-dlh = quot  8;
+   up-mdr1 = UART_OMAP_MDR1_DISABLE;
+
up-fcr = UART_FCR_R_TRIG_01 | UART_FCR_T_TRIG_01 |
UART_FCR_ENABLE_FIFO;
if (up-use_dma)
@@ -723,6 +725,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
up-ier |= UART_IER_MSI;
serial_out(up, UART_IER, up-ier);
serial_out(up, UART_LCR, cval); /* reset DLAB */
+   up-lcr = cval;
 
/* FIFOs and DMA Settings */
 
@@ -759,7 +762,7 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
 
/* Protocol, Baud Rate, and Interrupt Settings */
 
-   serial_out(up, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE);
+   serial_out(up, UART_OMAP_MDR1, up-mdr1);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
up-efr = serial_in(up, UART_EFR);
@@ -769,8 +772,8 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_IER, 0);
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
 
-   serial_out(up, UART_DLL, quot  0xff);  /* LS of divisor */
-   serial_out(up, UART_DLM, quot  8);/* MS of divisor */
+   serial_out(up, UART_DLL, up-dll);  /* LS of divisor */
+   serial_out(up, UART_DLM, up-dlh);  /* MS of divisor */
 
serial_out(up, UART_LCR, 0);
serial_out(up, UART_IER, up-ier);
@@ -780,9 +783,11 @@ serial_omap_set_termios(struct uart_port *port, struct 
ktermios *termios,
serial_out(up, UART_LCR

[PATCH v4 05/11] OMAP2+: Serial: Add default mux for all uarts.

2011-09-07 Thread Govindraj.R
Add default mux data for all uart's if mux info is not passed from
board file to avoid breaking any board support.

Signed-off-by: Govindraj.R govindraj.r...@ti.com
---
 arch/arm/mach-omap2/serial.c |  132 ++
 1 files changed, 132 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index e732d6c..2e10357 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -62,6 +62,134 @@ static struct omap_device_pm_latency omap_uart_latency[] = {
},
 };
 
+#ifdef CONFIG_OMAP_MUX
+static struct omap_device_pad default_uart1_pads[] __initdata = {
+   {
+   .name   = uart1_cts.uart1_cts,
+   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart1_rts.uart1_rts,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart1_tx.uart1_tx,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart1_rx.uart1_rx,
+   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
+   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+   .idle   = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+   },
+};
+
+static struct omap_device_pad default_uart2_pads[] __initdata = {
+   {
+   .name   = uart2_cts.uart2_cts,
+   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart2_rts.uart2_rts,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart2_tx.uart2_tx,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart2_rx.uart2_rx,
+   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
+   .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+   .idle   = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
+   },
+};
+
+static struct omap_device_pad default_uart3_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_tx_irtx.uart3_tx_irtx,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart3_rx_irrx.uart3_rx_irrx,
+   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
+   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+   },
+};
+
+static struct omap_device_pad default_omap36xx_uart4_pads[] __initdata = {
+   {
+   .name   = gpmc_wait2.uart4_tx,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = gpmc_wait3.uart4_rx,
+   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
+   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
+   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
+   },
+};
+
+static struct omap_device_pad default_omap4_uart4_pads[] __initdata = {
+   {
+   .name   = uart4_tx.uart4_tx,
+   .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
+   },
+   {
+   .name   = uart4_rx.uart4_rx,
+   .flags  = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
+   .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+   .idle   = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
+   },
+};
+#else
+static struct omap_device_pad default_uart1_pads[] __initdata = {};
+static struct omap_device_pad default_uart2_pads[] __initdata = {};
+static struct omap_device_pad default_uart3_pads[] __initdata = {};
+static struct omap_device_pad default_omap36xx_uart4_pads[] __initdata = {};
+static struct omap_device_pad default_omap4_uart4_pads[] __initdata = {};
+#endif
+
+static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
+{
+   switch (bdata-id) {
+   case 0:
+   bdata-pads = default_uart1_pads;
+   bdata-pads_cnt = ARRAY_SIZE(default_uart1_pads);
+   break;
+   case 1:
+   bdata-pads = default_uart2_pads;
+   bdata-pads_cnt = ARRAY_SIZE(default_uart2_pads);
+   break;
+   case 2:
+   bdata-pads = default_uart3_pads;
+   bdata-pads_cnt = ARRAY_SIZE(default_uart3_pads);
+   break;
+   case 3:
+   if (cpu_is_omap44xx()) {
+   bdata-pads = default_omap4_uart4_pads;
+   bdata-pads_cnt =
+   ARRAY_SIZE(default_omap4_uart4_pads);
+   } else {
+   bdata-pads

  1   2   3   >