@@ -104,6 +104,15 @@ struct plat_sci_reg {
u8 offset, size;
};
+struct sci_suspend_regs {
+ u16 scsmr;
+ u16 scscr;
+ u16 scfcr;
+ u16 scsptr;
+ u8 scbrr;
+ u8 semr;
+};
+
struct sci_port_params {
const struct plat_sci_reg regs[SCIx_NR_REGS];
unsigned int fifosize;
@@ -134,6 +143,8 @@ struct sci_port {
struct dma_chan *chan_tx;
struct dma_chan *chan_rx;
+ struct reset_control *rstc;
+
#ifdef CONFIG_SERIAL_SH_SCI_DMA
struct dma_chan *chan_tx_saved;
struct dma_chan *chan_rx_saved;
@@ -153,6 +164,7 @@ struct sci_port {
int rx_trigger;
struct timer_list rx_fifo_timer;
int rx_fifo_timeout;
+ struct sci_suspend_regs suspend_regs;
u16 hscif_tot;
bool has_rtscts;
@@ -3374,6 +3386,7 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
}
sp = &sci_ports[id];
+ sp->rstc = rstc;
*dev_id = id;
p->type = SCI_OF_TYPE(data);
@@ -3546,13 +3559,41 @@ static int sci_probe(struct platform_device *dev)
return 0;
}
+static void sci_console_save_restore(struct sci_port *s, bool save)
+{
+ struct sci_suspend_regs *regs = &s->suspend_regs;
+ struct uart_port *port = &s->port;
+
+ if (save) {
+ regs->scsmr = sci_serial_in(port, SCSMR);
+ regs->scscr = sci_serial_in(port, SCSCR);
+ regs->scfcr = sci_serial_in(port, SCFCR);
+ regs->scsptr = sci_serial_in(port, SCSPTR);
+ regs->scbrr = sci_serial_in(port, SCBRR);
+ regs->semr = sci_serial_in(port, SEMR);
+ } else {
+ sci_serial_out(port, SCSMR, regs->scsmr);
+ sci_serial_out(port, SCSCR, regs->scscr);
+ sci_serial_out(port, SCFCR, regs->scfcr);
+ sci_serial_out(port, SCSPTR, regs->scsptr);
+ sci_serial_out(port, SCBRR, regs->scbrr);
+ sci_serial_out(port, SEMR, regs->semr);
+ }
+}
+
static __maybe_unused int sci_suspend(struct device *dev)
{
struct sci_port *sport = dev_get_drvdata(dev);
- if (sport)
+ if (sport) {
uart_suspend_port(&sci_uart_driver, &sport->port);
+ if (!console_suspend_enabled && uart_console(&sport->port))
+ sci_console_save_restore(sport, true);
+ else
+ return reset_control_assert(sport->rstc);
+ }
+
return 0;
}
@@ -3560,8 +3601,18 @@ static __maybe_unused int sci_resume(struct device *dev)
{
struct sci_port *sport = dev_get_drvdata(dev);
- if (sport)
+ if (sport) {
+ if (!console_suspend_enabled && uart_console(&sport->port)) {
+ sci_console_save_restore(sport, false);
+ } else {
+ int ret = reset_control_deassert(sport->rstc);
+
+ if (ret)
+ return ret;
+ }
+
uart_resume_port(&sci_uart_driver, &sport->port);
+ }
return 0;
}