Re: [PATCH v3 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-27 Thread Kevin Hilman
Govindraj  writes:

> On Sat, Jun 25, 2011 at 5:00 AM, Kevin Hilman  wrote:
>> "Govindraj.R"  writes:
>>
>>> Adapts omap-serial driver to use pm_runtime api's.
>>>
>>> 1.) Populate reg values to uart port which can be used for context restore.
>>
>> Please make this part a separate patch.
>>
>>> 2.) Moving context_restore func to driver from serial.c
>>> 3.) Adding port_enable/disable func to enable/disable given uart port.
>>>     enable port using get_sync and disable using autosuspend.
>>> 4.) using runtime irq safe api to make get_sync be called from irq context.
>>
>>>
>>> Acked-by: Alan Cox 
>>> Signed-off-by: Govindraj.R 
>>
>> This is great!  we're almost there.   Some minor comments below...
>>
>>> ---
>>>  arch/arm/mach-omap2/serial.c                  |   22 +++
>>>  arch/arm/plat-omap/include/plat/omap-serial.h |    2 +
>>>  drivers/tty/serial/omap-serial.c              |  212 
>>> ++---
>>>  3 files changed, 210 insertions(+), 26 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
>>> index 8c1a4c7..1651c2c 100644
>>> --- a/arch/arm/mach-omap2/serial.c
>>> +++ b/arch/arm/mach-omap2/serial.c
>>> @@ -189,6 +189,27 @@ static void omap_serial_fill_default_pads(struct 
>>> omap_board_data *bdata)
>>>       }
>>>  }
>>>
>>> +static void omap_uart_wakeup_enable(struct platform_device *pdev, bool 
>>> enable)
>>> +{
>>> +     struct omap_uart_port_info *up = pdev->dev.platform_data;
>>> +
>>> +     /* Set or clear wake-enable bit */
>>> +     if (up->wk_en && up->wk_mask) {
>>> +             u32 v = __raw_readl(up->wk_en);
>>> +             if (enable)
>>> +                     v |= up->wk_mask;
>>> +             else
>>> +                     v &= ~up->wk_mask;
>>> +             __raw_writel(v, up->wk_en);
>>> +     }
>>
>> I think I asked this in previous series, but can't remember the answer
>> now...  can't we enable bits in the WKEN registers once at init time,
>> and then just use omap_hwmod_[enable|disable]_wakeup() here?
>>
>
> by default all bits are enabled in WKEN,

where default is the PRCM init code, yes.

> I will use omap_hwmod_[enable|disable]_wakeup() api's
>
> if these API's take care of WKEN regs, then no issue
> using the same.

No, these APIs only affect the module-level wakeup bit in the modules
SYSCONFIG register (ENAWAKEUP bit.)

My question is assuming the PRCM WKEN bits are just left enabled, is
simply toggling the modules SYSCONFIG.ENAWAKEUP bit enough to
enable/disable module wakeups.  I assume so, but have not validated it.

>>> +     /* Enable or clear io-pad wakeup */
>>> +     if (enable)
>>> +             omap_device_enable_ioring_wakeup(pdev);
>>> +     else
>>> +             omap_device_disable_ioring_wakeup(pdev);
>>> +}
>>> +
>>>  static void omap_uart_idle_init(struct omap_uart_port_info *uart,
>>>                               unsigned short num)
>>>  {
>>> @@ -332,6 +353,7 @@ void __init omap_serial_init_port(struct 
>>> omap_board_data *bdata)
>>>
>>>       pdata->uartclk = OMAP24XX_BASE_BAUD * 16;
>>>       pdata->flags = UPF_BOOT_AUTOCONF;
>>> +     pdata->enable_wakeup = omap_uart_wakeup_enable;
>>>       if (bdata->id == omap_uart_con_id)
>>>               pdata->console_uart = true;
>>>
>>> diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
>>> b/arch/arm/plat-omap/include/plat/omap-serial.h
>>> index 2ca885b..ac30de8 100644
>>> --- a/arch/arm/plat-omap/include/plat/omap-serial.h
>>> +++ b/arch/arm/plat-omap/include/plat/omap-serial.h
>>> @@ -65,6 +65,7 @@ struct omap_uart_port_info {
>>>       unsigned int            errata;
>>>       unsigned int            console_uart;
>>>
>>> +     void (*enable_wakeup)(struct platform_device *, bool);
>>>       void __iomem *wk_st;
>>>       void __iomem *wk_en;
>>>       u32 wk_mask;
>>> @@ -120,6 +121,7 @@ struct uart_omap_port {
>>>       char                    name[20];
>>>       unsigned long           port_activity;
>>>       unsigned int            errata;
>>> +     void (*enable_wakeup)(struct platform_device *, bool);
>>>  };
>>>
>>>  #endif /* __OMAP_SERIAL_H__ */
>>> diff --git a/drivers/tty/serial/omap-serial.c 
>>> b/drivers/tty/serial/omap-serial.c
>>> index 47cadf4..897416f 100644
>>> --- a/drivers/tty/serial/omap-serial.c
>>> +++ b/drivers/tty/serial/omap-serial.c
>>> @@ -37,10 +37,14 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>> +
>>> +#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */
>>
>> As Jon already pointed out, the HZ here is wrong.  Please define this
>> value in msecs.
>>
>
> corrected.
>
>>>  static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
>>>
>>> @@ -94,6 +98,17 @@ serial_omap_get_divisor(struct uart_port *port, unsigned 
>>> int baud)
>>>       return port->uartclk/(baud * divisor);
>>>  }
>>>
>>> +static inline void serial_omap_port_disable(struct uart_omap_port *up)
>>> +{
>>> +     pm_runtime_mark_last_busy

Re: [PATCH v3 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-27 Thread Govindraj
On Sat, Jun 25, 2011 at 5:00 AM, Kevin Hilman  wrote:
> "Govindraj.R"  writes:
>
>> Adapts omap-serial driver to use pm_runtime api's.
>>
>> 1.) Populate reg values to uart port which can be used for context restore.
>
> Please make this part a separate patch.
>
>> 2.) Moving context_restore func to driver from serial.c
>> 3.) Adding port_enable/disable func to enable/disable given uart port.
>>     enable port using get_sync and disable using autosuspend.
>> 4.) using runtime irq safe api to make get_sync be called from irq context.
>
>>
>> Acked-by: Alan Cox 
>> Signed-off-by: Govindraj.R 
>
> This is great!  we're almost there.   Some minor comments below...
>
>> ---
>>  arch/arm/mach-omap2/serial.c                  |   22 +++
>>  arch/arm/plat-omap/include/plat/omap-serial.h |    2 +
>>  drivers/tty/serial/omap-serial.c              |  212 
>> ++---
>>  3 files changed, 210 insertions(+), 26 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
>> index 8c1a4c7..1651c2c 100644
>> --- a/arch/arm/mach-omap2/serial.c
>> +++ b/arch/arm/mach-omap2/serial.c
>> @@ -189,6 +189,27 @@ static void omap_serial_fill_default_pads(struct 
>> omap_board_data *bdata)
>>       }
>>  }
>>
>> +static void omap_uart_wakeup_enable(struct platform_device *pdev, bool 
>> enable)
>> +{
>> +     struct omap_uart_port_info *up = pdev->dev.platform_data;
>> +
>> +     /* Set or clear wake-enable bit */
>> +     if (up->wk_en && up->wk_mask) {
>> +             u32 v = __raw_readl(up->wk_en);
>> +             if (enable)
>> +                     v |= up->wk_mask;
>> +             else
>> +                     v &= ~up->wk_mask;
>> +             __raw_writel(v, up->wk_en);
>> +     }
>
> I think I asked this in previous series, but can't remember the answer
> now...  can't we enable bits in the WKEN registers once at init time,
> and then just use omap_hwmod_[enable|disable]_wakeup() here?
>

by default all bits are enabled in WKEN,

I will use omap_hwmod_[enable|disable]_wakeup() api's

if these API's take care of WKEN regs, then no issue
using the same.


>> +     /* Enable or clear io-pad wakeup */
>> +     if (enable)
>> +             omap_device_enable_ioring_wakeup(pdev);
>> +     else
>> +             omap_device_disable_ioring_wakeup(pdev);
>> +}
>> +
>>  static void omap_uart_idle_init(struct omap_uart_port_info *uart,
>>                               unsigned short num)
>>  {
>> @@ -332,6 +353,7 @@ void __init omap_serial_init_port(struct omap_board_data 
>> *bdata)
>>
>>       pdata->uartclk = OMAP24XX_BASE_BAUD * 16;
>>       pdata->flags = UPF_BOOT_AUTOCONF;
>> +     pdata->enable_wakeup = omap_uart_wakeup_enable;
>>       if (bdata->id == omap_uart_con_id)
>>               pdata->console_uart = true;
>>
>> diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
>> b/arch/arm/plat-omap/include/plat/omap-serial.h
>> index 2ca885b..ac30de8 100644
>> --- a/arch/arm/plat-omap/include/plat/omap-serial.h
>> +++ b/arch/arm/plat-omap/include/plat/omap-serial.h
>> @@ -65,6 +65,7 @@ struct omap_uart_port_info {
>>       unsigned int            errata;
>>       unsigned int            console_uart;
>>
>> +     void (*enable_wakeup)(struct platform_device *, bool);
>>       void __iomem *wk_st;
>>       void __iomem *wk_en;
>>       u32 wk_mask;
>> @@ -120,6 +121,7 @@ struct uart_omap_port {
>>       char                    name[20];
>>       unsigned long           port_activity;
>>       unsigned int            errata;
>> +     void (*enable_wakeup)(struct platform_device *, bool);
>>  };
>>
>>  #endif /* __OMAP_SERIAL_H__ */
>> diff --git a/drivers/tty/serial/omap-serial.c 
>> b/drivers/tty/serial/omap-serial.c
>> index 47cadf4..897416f 100644
>> --- a/drivers/tty/serial/omap-serial.c
>> +++ b/drivers/tty/serial/omap-serial.c
>> @@ -37,10 +37,14 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>> +
>> +#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */
>
> As Jon already pointed out, the HZ here is wrong.  Please define this
> value in msecs.
>

corrected.

>>  static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
>>
>> @@ -94,6 +98,17 @@ serial_omap_get_divisor(struct uart_port *port, unsigned 
>> int baud)
>>       return port->uartclk/(baud * divisor);
>>  }
>>
>> +static inline void serial_omap_port_disable(struct uart_omap_port *up)
>> +{
>> +     pm_runtime_mark_last_busy(&up->pdev->dev);
>> +     pm_runtime_put_autosuspend(&up->pdev->dev);
>> +}
>> +
>> +static inline void serial_omap_port_enable(struct uart_omap_port *up)
>> +{
>> +     pm_runtime_get_sync(&up->pdev->dev);
>> +}
>
> These inlines are not needed.  Please use runtime PM calls directly in
> the code.  For _enable(), this is straight forward.  For _disable()
> though, I don't think you want (or need) to _mark_last_busy() for every
> instance of omap_port_disable().  You only need to do this for ones
> TX/RX tra

Re: [PATCH v3 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-24 Thread Kevin Hilman
"Govindraj.R"  writes:

> Adapts omap-serial driver to use pm_runtime api's.
>
> 1.) Populate reg values to uart port which can be used for context restore.

Please make this part a separate patch.

> 2.) Moving context_restore func to driver from serial.c
> 3.) Adding port_enable/disable func to enable/disable given uart port.
> enable port using get_sync and disable using autosuspend.
> 4.) using runtime irq safe api to make get_sync be called from irq context.

>
> Acked-by: Alan Cox 
> Signed-off-by: Govindraj.R 

This is great!  we're almost there.   Some minor comments below...

> ---
>  arch/arm/mach-omap2/serial.c  |   22 +++
>  arch/arm/plat-omap/include/plat/omap-serial.h |2 +
>  drivers/tty/serial/omap-serial.c  |  212 
> ++---
>  3 files changed, 210 insertions(+), 26 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
> index 8c1a4c7..1651c2c 100644
> --- a/arch/arm/mach-omap2/serial.c
> +++ b/arch/arm/mach-omap2/serial.c
> @@ -189,6 +189,27 @@ static void omap_serial_fill_default_pads(struct 
> omap_board_data *bdata)
>   }
>  }
>  
> +static void omap_uart_wakeup_enable(struct platform_device *pdev, bool 
> enable)
> +{
> + struct omap_uart_port_info *up = pdev->dev.platform_data;
> +
> + /* Set or clear wake-enable bit */
> + if (up->wk_en && up->wk_mask) {
> + u32 v = __raw_readl(up->wk_en);
> + if (enable)
> + v |= up->wk_mask;
> + else
> + v &= ~up->wk_mask;
> + __raw_writel(v, up->wk_en);
> + }

I think I asked this in previous series, but can't remember the answer
now...  can't we enable bits in the WKEN registers once at init time,
and then just use omap_hwmod_[enable|disable]_wakeup() here?

> + /* Enable or clear io-pad wakeup */
> + if (enable)
> + omap_device_enable_ioring_wakeup(pdev);
> + else
> + omap_device_disable_ioring_wakeup(pdev);
> +}
> +
>  static void omap_uart_idle_init(struct omap_uart_port_info *uart,
>   unsigned short num)
>  {
> @@ -332,6 +353,7 @@ void __init omap_serial_init_port(struct omap_board_data 
> *bdata)
>  
>   pdata->uartclk = OMAP24XX_BASE_BAUD * 16;
>   pdata->flags = UPF_BOOT_AUTOCONF;
> + pdata->enable_wakeup = omap_uart_wakeup_enable;
>   if (bdata->id == omap_uart_con_id)
>   pdata->console_uart = true;
>  
> diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
> b/arch/arm/plat-omap/include/plat/omap-serial.h
> index 2ca885b..ac30de8 100644
> --- a/arch/arm/plat-omap/include/plat/omap-serial.h
> +++ b/arch/arm/plat-omap/include/plat/omap-serial.h
> @@ -65,6 +65,7 @@ struct omap_uart_port_info {
>   unsigned interrata;
>   unsigned intconsole_uart;
>  
> + void (*enable_wakeup)(struct platform_device *, bool);
>   void __iomem *wk_st;
>   void __iomem *wk_en;
>   u32 wk_mask;
> @@ -120,6 +121,7 @@ struct uart_omap_port {
>   charname[20];
>   unsigned long   port_activity;
>   unsigned interrata;
> + void (*enable_wakeup)(struct platform_device *, bool);
>  };
>  
>  #endif /* __OMAP_SERIAL_H__ */
> diff --git a/drivers/tty/serial/omap-serial.c 
> b/drivers/tty/serial/omap-serial.c
> index 47cadf4..897416f 100644
> --- a/drivers/tty/serial/omap-serial.c
> +++ b/drivers/tty/serial/omap-serial.c
> @@ -37,10 +37,14 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
>  #include 
> +#include 
> +
> +#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */

As Jon already pointed out, the HZ here is wrong.  Please define this
value in msecs.

>  static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
>  
> @@ -94,6 +98,17 @@ serial_omap_get_divisor(struct uart_port *port, unsigned 
> int baud)
>   return port->uartclk/(baud * divisor);
>  }
>  
> +static inline void serial_omap_port_disable(struct uart_omap_port *up)
> +{
> + pm_runtime_mark_last_busy(&up->pdev->dev);
> + pm_runtime_put_autosuspend(&up->pdev->dev);
> +}
> +
> +static inline void serial_omap_port_enable(struct uart_omap_port *up)
> +{
> + pm_runtime_get_sync(&up->pdev->dev);
> +}

These inlines are not needed.  Please use runtime PM calls directly in
the code.  For _enable(), this is straight forward.  For _disable()
though, I don't think you want (or need) to _mark_last_busy() for every
instance of omap_port_disable().  You only need to do this for ones
TX/RX transactions...

>  static void serial_omap_stop_rxdma(struct uart_omap_port *up)
>  {
>   if (up->uart_dma.rx_dma_used) {
> @@ -110,8 +125,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);
> +
> + serial_o

Re: [PATCH v3 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-09 Thread Jon Hunter



On 06/09/2011 03:49 PM, Jon Hunter wrote:

Hi Govindraj

On 06/08/2011 11:35 PM, Govindraj wrote:

On Thu, Jun 9, 2011 at 2:09 AM, Jon Hunter wrote:

Hi Govindraj,

On 6/8/2011 6:23 AM, Govindraj.R wrote:

[snip]


+
+#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */


[snip]


@@ -1295,18 +1381,36 @@ static int serial_omap_probe(struct
platform_device *pdev)
up->uart_dma.rx_dma_channel = OMAP_UART_DMA_CH_FREE;
}

+ pm_runtime_use_autosuspend(&pdev->dev);
+ pm_runtime_set_autosuspend_delay(&pdev->dev,
+ OMAP_UART_AUTOSUSPEND_DELAY);


Something is weird here...DEFAULT_AUTOSUSPEND_DELAY is defined as
(30*HZ)
which would appear to be jiffies (ticks per second) and NOT msecs.
However,
pm_runtime_set_autosuspend is clearly expecting msecs. So this seems to
conflict. By default 30*HZ for omap would be 30*128 = 3840ms so not
quite 4
seconds.

What were you intending here?


Intention is to get approx 3 secs timeout for autosuspend.


In that case you should just define DEFAULT_AUTOSUSPEND_DELAY as 3.
The above is just confusing as you are mixing time types and hence, it
is not clear what you intend the default timeout to be.


Sorry, I meant 3000 and not 3 above, if you want 3 secs.

Jon
--
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


Re: [PATCH v3 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-09 Thread Jon Hunter

Hi Govindraj

On 06/08/2011 11:35 PM, Govindraj wrote:

On Thu, Jun 9, 2011 at 2:09 AM, Jon Hunter  wrote:

Hi Govindraj,

On 6/8/2011 6:23 AM, Govindraj.R wrote:

[snip]


+
+#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */


[snip]


@@ -1295,18 +1381,36 @@ static int serial_omap_probe(struct
platform_device *pdev)
up->uart_dma.rx_dma_channel = OMAP_UART_DMA_CH_FREE;
}

+   pm_runtime_use_autosuspend(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev,
+   OMAP_UART_AUTOSUSPEND_DELAY);


Something is weird here...DEFAULT_AUTOSUSPEND_DELAY is defined as (30*HZ)
which would appear to be jiffies (ticks per second) and NOT msecs. However,
pm_runtime_set_autosuspend is clearly expecting msecs. So this seems to
conflict. By default 30*HZ for omap would be 30*128 = 3840ms so not quite 4
seconds.

What were you intending here?


Intention is to get approx 3 secs timeout for autosuspend.


In that case you should just define DEFAULT_AUTOSUSPEND_DELAY as 3. 
The above is just confusing as you are mixing time types and hence, it 
is not clear what you intend the default timeout to be.


Jon
--
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


Re: [PATCH v3 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-08 Thread Govindraj
On Thu, Jun 9, 2011 at 2:09 AM, Jon Hunter  wrote:
> Hi Govindraj,
>
> On 6/8/2011 6:23 AM, Govindraj.R wrote:
>
> [snip]
>
>> +
>> +#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */
>
> [snip]
>
>> @@ -1295,18 +1381,36 @@ static int serial_omap_probe(struct
>> platform_device *pdev)
>>                up->uart_dma.rx_dma_channel = OMAP_UART_DMA_CH_FREE;
>>        }
>>
>> +       pm_runtime_use_autosuspend(&pdev->dev);
>> +       pm_runtime_set_autosuspend_delay(&pdev->dev,
>> +                       OMAP_UART_AUTOSUSPEND_DELAY);
>
> Something is weird here...DEFAULT_AUTOSUSPEND_DELAY is defined as (30*HZ)
> which would appear to be jiffies (ticks per second) and NOT msecs. However,
> pm_runtime_set_autosuspend is clearly expecting msecs. So this seems to
> conflict. By default 30*HZ for omap would be 30*128 = 3840ms so not quite 4
> seconds.
>
> What were you intending here?

Intention is to get approx 3 secs timeout for autosuspend.

--
Thanks,
Govindraj.R

>
> Cheers
> Jon
> --
> To unsubscribe from this list: send the line "unsubscribe linux-serial" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
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


Re: [PATCH v3 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-08 Thread Jon Hunter

Hi Govindraj,

On 6/8/2011 6:23 AM, Govindraj.R wrote:

[snip]


+
+#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */


[snip]


@@ -1295,18 +1381,36 @@ static int serial_omap_probe(struct platform_device 
*pdev)
up->uart_dma.rx_dma_channel = OMAP_UART_DMA_CH_FREE;
}

+   pm_runtime_use_autosuspend(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev,
+   OMAP_UART_AUTOSUSPEND_DELAY);


Something is weird here...DEFAULT_AUTOSUSPEND_DELAY is defined as 
(30*HZ) which would appear to be jiffies (ticks per second) and NOT 
msecs. However, pm_runtime_set_autosuspend is clearly expecting msecs. 
So this seems to conflict. By default 30*HZ for omap would be 30*128 = 
3840ms so not quite 4 seconds.


What were you intending here?

Cheers
Jon
--
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 04/12] Serial: OMAP: Add runtime pm support for omap-serial driver

2011-06-08 Thread Govindraj.R
Adapts omap-serial driver to use pm_runtime api's.

1.) Populate reg values to uart port which can be used for context restore.
2.) Moving context_restore func to driver from serial.c
3.) Adding port_enable/disable func to enable/disable given uart port.
enable port using get_sync and disable using autosuspend.
4.) using runtime irq safe api to make get_sync be called from irq context.

Acked-by: Alan Cox 
Signed-off-by: Govindraj.R 
---
 arch/arm/mach-omap2/serial.c  |   22 +++
 arch/arm/plat-omap/include/plat/omap-serial.h |2 +
 drivers/tty/serial/omap-serial.c  |  212 ++---
 3 files changed, 210 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 8c1a4c7..1651c2c 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -189,6 +189,27 @@ static void omap_serial_fill_default_pads(struct 
omap_board_data *bdata)
}
 }
 
+static void omap_uart_wakeup_enable(struct platform_device *pdev, bool enable)
+{
+   struct omap_uart_port_info *up = pdev->dev.platform_data;
+
+   /* Set or clear wake-enable bit */
+   if (up->wk_en && up->wk_mask) {
+   u32 v = __raw_readl(up->wk_en);
+   if (enable)
+   v |= up->wk_mask;
+   else
+   v &= ~up->wk_mask;
+   __raw_writel(v, up->wk_en);
+   }
+
+   /* Enable or clear io-pad wakeup */
+   if (enable)
+   omap_device_enable_ioring_wakeup(pdev);
+   else
+   omap_device_disable_ioring_wakeup(pdev);
+}
+
 static void omap_uart_idle_init(struct omap_uart_port_info *uart,
unsigned short num)
 {
@@ -332,6 +353,7 @@ void __init omap_serial_init_port(struct omap_board_data 
*bdata)
 
pdata->uartclk = OMAP24XX_BASE_BAUD * 16;
pdata->flags = UPF_BOOT_AUTOCONF;
+   pdata->enable_wakeup = omap_uart_wakeup_enable;
if (bdata->id == omap_uart_con_id)
pdata->console_uart = true;
 
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
b/arch/arm/plat-omap/include/plat/omap-serial.h
index 2ca885b..ac30de8 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -65,6 +65,7 @@ struct omap_uart_port_info {
unsigned interrata;
unsigned intconsole_uart;
 
+   void (*enable_wakeup)(struct platform_device *, bool);
void __iomem *wk_st;
void __iomem *wk_en;
u32 wk_mask;
@@ -120,6 +121,7 @@ struct uart_omap_port {
charname[20];
unsigned long   port_activity;
unsigned interrata;
+   void (*enable_wakeup)(struct platform_device *, bool);
 };
 
 #endif /* __OMAP_SERIAL_H__ */
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 47cadf4..897416f 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -37,10 +37,14 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
+#include 
+
+#define OMAP_UART_AUTOSUSPEND_DELAY (30 * HZ) /* Value is msecs */
 
 static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
@@ -94,6 +98,17 @@ serial_omap_get_divisor(struct uart_port *port, unsigned int 
baud)
return port->uartclk/(baud * divisor);
 }
 
+static inline void serial_omap_port_disable(struct uart_omap_port *up)
+{
+   pm_runtime_mark_last_busy(&up->pdev->dev);
+   pm_runtime_put_autosuspend(&up->pdev->dev);
+}
+
+static inline void serial_omap_port_enable(struct uart_omap_port *up)
+{
+   pm_runtime_get_sync(&up->pdev->dev);
+}
+
 static void serial_omap_stop_rxdma(struct uart_omap_port *up)
 {
if (up->uart_dma.rx_dma_used) {
@@ -110,8 +125,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);
+
+   serial_omap_port_enable(up);
up->ier |= UART_IER_MSI;
serial_out(up, UART_IER, up->ier);
+   serial_omap_port_disable(up);
 }
 
 static void serial_omap_stop_tx(struct uart_port *port)
@@ -131,21 +149,26 @@ static void serial_omap_stop_tx(struct uart_port *port)
up->uart_dma.tx_dma_channel = OMAP_UART_DMA_CH_FREE;
}
 
+   serial_omap_port_enable(up);
if (up->ier & UART_IER_THRI) {
up->ier &= ~UART_IER_THRI;
serial_out(up, UART_IER, up->ier);
}
+
+   serial_omap_port_disable(up);
 }
 
 static void serial_omap_stop_rx(struct uart_port *port)
 {
struct uart_omap_port *up = (struct uart_omap_port *)port;
 
+   serial_omap_port_enable(up);
if (up->use_dma)
serial_omap_stop_rxdma(up);
up->ier &= ~UART_IER_RLSI;
up->port.read_status_mask &= ~UA