* [PATCH] serial: sh-sci: console Runtime PM support
@ 2011-08-03 3:47 Magnus Damm
2011-08-04 1:04 ` Simon Horman
2011-08-04 2:09 ` Magnus Damm
0 siblings, 2 replies; 3+ messages in thread
From: Magnus Damm @ 2011-08-03 3:47 UTC (permalink / raw)
To: linux-sh
From: Magnus Damm <damm@opensource.se>
Add Runtime PM context save/restore support to
the SCIF driver. Tested on the AP4EVB console.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
Rebased version of prototype patch sent 20110630.
drivers/tty/serial/sh-sci.c | 68 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 58 insertions(+), 10 deletions(-)
--- 0003/drivers/tty/serial/sh-sci.c
+++ work/drivers/tty/serial/sh-sci.c 2011-08-03 11:58:53.000000000 +0900
@@ -96,6 +96,12 @@ struct sci_port {
#endif
struct notifier_block freq_transition;
+
+#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
+ unsigned short saved_smr;
+ unsigned short saved_fcr;
+ unsigned char saved_brr;
+#endif
};
/* Function prototypes */
@@ -1634,11 +1640,25 @@ static unsigned int sci_scbrr_calc(unsig
return ((freq + 16 * bps) / (32 * bps) - 1);
}
+static void sci_reset(struct uart_port *port)
+{
+ unsigned int status;
+
+ do {
+ status = sci_in(port, SCxSR);
+ } while (!(status & SCxSR_TEND(port)));
+
+ sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
+
+ if (port->type != PORT_SCI)
+ sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
+}
+
static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
struct sci_port *s = to_sci_port(port);
- unsigned int status, baud, smr_val, max_baud;
+ unsigned int baud, smr_val, max_baud;
int t = -1;
u16 scfcr = 0;
@@ -1658,14 +1678,7 @@ static void sci_set_termios(struct uart_
sci_port_enable(s);
- do {
- status = sci_in(port, SCxSR);
- } while (!(status & SCxSR_TEND(port)));
-
- sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
-
- if (port->type != PORT_SCI)
- sci_out(port, SCFCR, scfcr | SCFCR_RFRST | SCFCR_TFRST);
+ sci_reset(port);
smr_val = sci_in(port, SCSMR) & 3;
@@ -2037,7 +2050,8 @@ static int __devinit serial_console_setu
if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
- /* TODO: disable clock */
+ sci_port_disable(sci_port);
+
return uart_set_options(port, co, baud, parity, bits, flow);
}
@@ -2080,6 +2094,36 @@ static int __devinit sci_probe_earlyprin
return 0;
}
+#define uart_console(port) ((port)->cons->index = (port)->line)
+
+static int sci_runtime_suspend(struct device *dev)
+{
+ struct sci_port *sci_port = dev_get_drvdata(dev);
+ struct uart_port *port = &sci_port->port;
+
+ if (uart_console(port)) {
+ sci_port->saved_smr = sci_in(port, SCSMR);
+ sci_port->saved_brr = sci_in(port, SCBRR);
+ sci_port->saved_fcr = sci_in(port, SCFCR);
+ }
+ return 0;
+}
+
+static int sci_runtime_resume(struct device *dev)
+{
+ struct sci_port *sci_port = dev_get_drvdata(dev);
+ struct uart_port *port = &sci_port->port;
+
+ if (uart_console(port)) {
+ sci_reset(port);
+ sci_out(port, SCSMR, sci_port->saved_smr);
+ sci_out(port, SCBRR, sci_port->saved_brr);
+ sci_out(port, SCFCR, sci_port->saved_fcr);
+ sci_out(port, SCSCR, sci_port->cfg->scscr);
+ }
+ return 0;
+}
+
#define SCI_CONSOLE (&serial_console)
#else
@@ -2089,6 +2133,8 @@ static inline int __devinit sci_probe_ea
}
#define SCI_CONSOLE NULL
+#define sci_runtime_suspend NULL
+#define sci_runtime_resume NULL
#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
@@ -2204,6 +2250,8 @@ static int sci_resume(struct device *dev
}
static const struct dev_pm_ops sci_dev_pm_ops = {
+ .runtime_suspend = sci_runtime_suspend,
+ .runtime_resume = sci_runtime_resume,
.suspend = sci_suspend,
.resume = sci_resume,
};
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] serial: sh-sci: console Runtime PM support
2011-08-03 3:47 [PATCH] serial: sh-sci: console Runtime PM support Magnus Damm
@ 2011-08-04 1:04 ` Simon Horman
2011-08-04 2:09 ` Magnus Damm
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2011-08-04 1:04 UTC (permalink / raw)
To: linux-sh
On Wed, Aug 03, 2011 at 12:47:36PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
>
> Add Runtime PM context save/restore support to
> the SCIF driver. Tested on the AP4EVB console.
Hi Magnus,
could you explain in a little more detail how this was tested?
Also, is this likely to work on other boards? E.g the AP4 Mackerel?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] serial: sh-sci: console Runtime PM support
2011-08-03 3:47 [PATCH] serial: sh-sci: console Runtime PM support Magnus Damm
2011-08-04 1:04 ` Simon Horman
@ 2011-08-04 2:09 ` Magnus Damm
1 sibling, 0 replies; 3+ messages in thread
From: Magnus Damm @ 2011-08-04 2:09 UTC (permalink / raw)
To: linux-sh
Hi Simon,
On Thu, Aug 4, 2011 at 10:04 AM, Simon Horman <horms@verge.net.au> wrote:
> On Wed, Aug 03, 2011 at 12:47:36PM +0900, Magnus Damm wrote:
>> From: Magnus Damm <damm@opensource.se>
>>
>> Add Runtime PM context save/restore support to
>> the SCIF driver. Tested on the AP4EVB console.
>
> Hi Magnus,
>
> could you explain in a little more detail how this was tested?
This has been tested on AP4EVB with and without power domain support.
For sh7372 the serial ports are located in the A3SP power domain which
has experimental software support through some prototype patches
earlier posted to the linux-sh list. I intend to up-port these
prototype patches to 3.1-rc in the not so distant future.
> Also, is this likely to work on other boards? E.g the AP4 Mackerel?
The Runtime PM support provided by this patch should work with any
SCI/SCIF/SCIFA/SCIFB hardware block regardless of SoC type. So yes,
both AP4EVB and Mackerel should work just fine.
Thanks,
/ magnus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-04 2:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-03 3:47 [PATCH] serial: sh-sci: console Runtime PM support Magnus Damm
2011-08-04 1:04 ` Simon Horman
2011-08-04 2:09 ` Magnus Damm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox