linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC/NOT FOR MERGING 2/3] serial: omap: remove hwmod dependency
Date: Thu, 14 Feb 2013 09:12:53 -0800	[thread overview]
Message-ID: <20130214171253.GC7144@atomide.com> (raw)
In-Reply-To: <1360840554-26901-2-git-send-email-balbi@ti.com>

* Felipe Balbi <balbi@ti.com> [130214 03:19]:
> Currently the omap-serial driver will not
> work properly if booted via DT with CPUIDLE
> enabled because it depends on function pointers
> provided by hwmod to change its own SYSCONFIG
> register.
> 
> Remove that relyance on hwmod by moving SYSCONFIG
> handling to driver itself. Note that this also
> fixes a possible corner case bug where we could
> be putting UART in Force Idle mode if we called
> omap_serial_enable_wakeup(up, false) after setting
> NOIDLE to the idle mode. This is because hwmod
> has no protection against that situation.

I agree the sysconfig stuff should be handled in the drivers.
But considering that we need to also reset or idle hardware
that may not have a driver loaded, it's best to put the
reset/idle function in to the driver specific header as
an inline function.

This way the hwmod code can idle or reset the unclaimed
hardware in a late_initcall.

And probably the handling of sysconfig bits should be
done using a common header in include/linux/omap-hwmod.h
or something so it can be shared between drivers.

Regards,

Tony
 
> NYET-Signed-off-by: Felipe Balbi <balbi@ti.com>
> ---
>  drivers/tty/serial/omap-serial.c | 67 +++++++++++++++++++---------------------
>  1 file changed, 32 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
> index 57d6b29..078beb1 100644
> --- a/drivers/tty/serial/omap-serial.c
> +++ b/drivers/tty/serial/omap-serial.c
> @@ -96,6 +96,18 @@
>  
>  #define OMAP_UART_TCR_TRIG	0x0F
>  
> +#define OMAP_UART_SYSC		0x54
> +#define OMAP_UART_AUTOIDLE	(1 << 0)
> +#define OMAP_UART_SOFTRESET	(1 << 1)
> +#define OMAP_UART_ENAWAKEUP	(1 << 2)
> +
> +#define OMAP_UART_IDLEMODE(n)	(((n) & 3) << 3)
> +#define OMAP_UART_FORCE_IDLE	OMAP_UART_IDLEMODE(0)
> +#define OMAP_UART_NO_IDLE	OMAP_UART_IDLEMODE(1)
> +#define OMAP_UART_SMART_IDLE	OMAP_UART_IDLEMODE(2)
> +#define OMAP_UART_SMART_IDLE_WKUP OMAP_UART_IDLEMODE(3)
> +#define OMAP_UART_IDLEMODE_MASK	OMAP_UART_SMART_IDLE_WKUP
> +
>  struct uart_omap_dma {
>  	u8			uart_dma_tx;
>  	u8			uart_dma_rx;
> @@ -191,44 +203,39 @@ static inline void serial_omap_clear_fifos(struct uart_omap_port *up)
>  	serial_out(up, UART_FCR, 0);
>  }
>  
> -static int serial_omap_get_context_loss_count(struct uart_omap_port *up)
> -{
> -	struct omap_uart_port_info *pdata = up->dev->platform_data;
> -
> -	if (!pdata || !pdata->get_context_loss_count)
> -		return 0;
> -
> -	return pdata->get_context_loss_count(up->dev);
> -}
> -
>  static void serial_omap_set_forceidle(struct uart_omap_port *up)
>  {
> -	struct omap_uart_port_info *pdata = up->dev->platform_data;
> -
> -	if (!pdata || !pdata->set_forceidle)
> -		return;
> +	u32 reg;
>  
> -	pdata->set_forceidle(up->dev);
> +	reg = serial_in(up, OMAP_UART_SYSC);
> +	reg &= ~OMAP_UART_IDLEMODE_MASK;
> +	reg |= OMAP_UART_FORCE_IDLE;
> +	serial_out(up, OMAP_UART_SYSC, reg);
>  }
>  
>  static void serial_omap_set_noidle(struct uart_omap_port *up)
>  {
> -	struct omap_uart_port_info *pdata = up->dev->platform_data;
> +	u32 reg;
>  
> -	if (!pdata || !pdata->set_noidle)
> -		return;
> -
> -	pdata->set_noidle(up->dev);
> +	reg = serial_in(up, OMAP_UART_SYSC);
> +	reg &= ~OMAP_UART_IDLEMODE_MASK;
> +	reg |= OMAP_UART_NO_IDLE;
> +	serial_out(up, OMAP_UART_SYSC, reg);
>  }
>  
>  static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable)
>  {
> -	struct omap_uart_port_info *pdata = up->dev->platform_data;
> +	u32 reg;
>  
> -	if (!pdata || !pdata->enable_wakeup)
> -		return;
> +	reg = serial_in(up, OMAP_UART_SYSC);
> +	reg &= ~OMAP_UART_IDLEMODE_MASK;
> +
> +	if (enable)
> +		reg |= OMAP_UART_SMART_IDLE_WKUP;
> +	else
> +		reg |= OMAP_UART_SMART_IDLE;
>  
> -	pdata->enable_wakeup(up->dev, enable);
> +	serial_out(up, OMAP_UART_SYSC, reg);
>  }
>  
>  /*
> @@ -1596,8 +1603,6 @@ static int serial_omap_runtime_suspend(struct device *dev)
>  	if (!pdata)
>  		return 0;
>  
> -	up->context_loss_cnt = serial_omap_get_context_loss_count(up);
> -
>  	if (device_may_wakeup(dev)) {
>  		if (!up->wakeups_enabled) {
>  			serial_omap_enable_wakeup(up, true);
> @@ -1620,15 +1625,7 @@ static int serial_omap_runtime_resume(struct device *dev)
>  {
>  	struct uart_omap_port *up = dev_get_drvdata(dev);
>  
> -	int loss_cnt = serial_omap_get_context_loss_count(up);
> -
> -	if (loss_cnt < 0) {
> -		dev_err(dev, "serial_omap_get_context_loss_count failed : %d\n",
> -			loss_cnt);
> -		serial_omap_restore_context(up);
> -	} else if (up->context_loss_cnt != loss_cnt) {
> -		serial_omap_restore_context(up);
> -	}
> +	serial_omap_restore_context(up);
>  	up->latency = up->calc_latency;
>  	schedule_work(&up->qos_work);
>  
> -- 
> 1.8.1.rc1.5.g7e0651a
> 

  parent reply	other threads:[~2013-02-14 17:12 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 11:15 [RFC/NOT FOR MERGING 1/3] arm: omap: use generic implementation if !od Felipe Balbi
2013-02-14 11:20 ` Russell King - ARM Linux
2013-02-14 17:57   ` Felipe Balbi
2013-02-15 15:28 ` Kevin Hilman
2013-02-15 16:04   ` Felipe Balbi
     [not found] ` <1360840554-26901-2-git-send-email-balbi@ti.com>
2013-02-14 17:12   ` Tony Lindgren [this message]
2013-02-14 17:56     ` [RFC/NOT FOR MERGING 2/3] serial: omap: remove hwmod dependency Felipe Balbi
2013-02-14 18:12       ` Tony Lindgren
2013-02-14 19:27         ` Felipe Balbi
2013-02-14 19:39           ` Tony Lindgren
2013-02-14 20:47             ` Paul Walmsley
2013-02-14 21:40               ` Paul Walmsley
2013-02-14 22:47                 ` Tony Lindgren
2013-02-15  6:46                   ` Felipe Balbi
2013-02-15  7:29                     ` Santosh Shilimkar
2013-02-19 15:30                   ` Paul Walmsley
2013-02-19 15:45                     ` Russell King - ARM Linux
2013-02-19 16:30                       ` Tony Lindgren
2013-02-19 18:22                         ` Russell King - ARM Linux
2013-02-19 19:31                           ` Tony Lindgren
2013-02-19 19:43                             ` hwmod data duplication (was: Re: [RFC/NOT FOR MERGING 2/3] serial: omap: remove hwmod dependency) Felipe Balbi
2013-02-19 22:09                               ` Tony Lindgren
2013-02-19 22:22                                 ` Felipe Balbi
2013-02-19 22:31                                   ` Tony Lindgren
2013-02-19 22:51                                     ` Felipe Balbi
2013-02-15 10:26                 ` [RFC/NOT FOR MERGING 2/3] serial: omap: remove hwmod dependency Russell King - ARM Linux
2013-02-14 21:56               ` Paul Walmsley
2013-02-14 22:22               ` Tony Lindgren
2013-02-15  6:53                 ` Felipe Balbi
2013-02-15  7:27                   ` Bedia, Vaibhav
2013-02-19 15:27                 ` Paul Walmsley
2013-02-19 16:38                   ` Tony Lindgren
2013-02-19 16:57                     ` Felipe Balbi
2013-02-19 17:43                       ` Tony Lindgren
2013-02-19 18:34                         ` Felipe Balbi
2013-02-19 19:16                     ` Kevin Hilman
2013-02-19 19:32                       ` Felipe Balbi
2013-02-19 19:50                         ` Kevin Hilman
2013-02-19 20:10                           ` OMAP reset requirements (was: Re: [RFC/NOT FOR MERGING 2/3] serial: omap: remove hwmod dependency)^[:x Felipe Balbi
2013-02-19 20:25                             ` OMAP reset requirements Kevin Hilman
2013-02-20  6:26                       ` [RFC/NOT FOR MERGING 2/3] serial: omap: remove hwmod dependency Santosh Shilimkar
2013-02-15  6:44               ` Felipe Balbi
2013-02-15  7:27                 ` Bedia, Vaibhav
2013-02-20 17:38                 ` Paul Walmsley
2013-02-20 19:16                   ` Felipe Balbi
2013-02-20 20:03                     ` Paul Walmsley
2013-02-20 20:37                     ` Russell King - ARM Linux
2013-02-21 10:16                     ` Peter De Schrijver
2013-02-21 12:09                       ` Peter Korsgaard
2013-02-15 10:16               ` Russell King - ARM Linux
2013-02-15 13:26                 ` Santosh Shilimkar
2013-02-15 13:27                   ` Russell King - ARM Linux
2013-02-15 13:31                     ` Santosh Shilimkar
2013-02-15 16:30                       ` Tony Lindgren
2013-02-15 16:42                         ` Felipe Balbi
2013-02-16  6:01                           ` Santosh Shilimkar
2013-02-16  8:55                             ` Felipe Balbi
2013-02-16  9:17                               ` Santosh Shilimkar
2013-02-16  9:22                                 ` Felipe Balbi
2013-02-16  9:31                                   ` Santosh Shilimkar
2013-02-18 15:27                               ` Kevin Hilman
2013-02-16  5:31                         ` Santosh Shilimkar
2013-02-16  5:36                         ` Nicolas Pitre
2013-02-16  5:48                           ` Santosh Shilimkar
2013-02-18  8:08                             ` Bedia, Vaibhav
2013-02-18  8:28                               ` Santosh Shilimkar
2013-02-15 15:40   ` Kevin Hilman
2013-02-15 16:03     ` Felipe Balbi
2013-02-16  4:59     ` Santosh Shilimkar
2013-02-18 14:52       ` Kevin Hilman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130214171253.GC7144@atomide.com \
    --to=tony@atomide.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).