From nobody Sat Nov 23 02:54:49 2024 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D970B1D514B for ; Fri, 15 Nov 2024 13:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731678262; cv=none; b=XlnJiTyd/D2EbfXAI0owzhRtK2o7bGP0wJbSuMLfFg23ymJfuOXNlW3Dd3UZNFOOIxOVCrtjy2M5JSr7b/gmI6cXuHN3+V/DkzMsvoeqAEssyb7A6UKK4DQKh7dEgg0xpgi6fZ4VAdnl37aCbOVS8bmCtrUXUQ75b1cGFMefgho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731678262; c=relaxed/simple; bh=cvXLylORKw894oxYTuEZeViXynITomEuscveNdNCxgQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C5NkfSqutHBkSRz61yjfFH/j9ps9FfTSz5cDvWQ1DMnIPAmYXXPEOp1e/sRkzsUcevYfTMyJMAHT9cL0CsQYvyUgy0t98XRtTw9cBPbA0T7aFLP/dE6pi8/jPcimklfqdS3DjyDtN9n5a83oF5v//De/OIYgtVhEZOLTd2uqkCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=keO9F3W+; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="keO9F3W+" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-43162cf1eaaso19674615e9.0 for ; Fri, 15 Nov 2024 05:44:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1731678256; x=1732283056; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QflYe9Uttnm4Ku+Zy3VUc0FNhJJkvv+YuMrekm3fOjY=; b=keO9F3W+nVGZMNuY9V21Pj8J3bkho7f9utN5jPPVrY2g9srF3vAgjhXs7ZnLKVb7qN GMGzYuClPBl+WGjPcqmSGTZDCghwYsV7P2U/9vbzEfv1vg6Yz4Sbl6oENNKszIlXKsnw JJ+r9HVVBkQeMYDOHuQQMXiSxA1J8TOvqIJdEXsiHhYq7J13VVOda6RBiMPWnNC6GG90 fIrX3BGV3pWaSqpTv8dVt3ZY6EiDBVtBAc0fjNuEBe4G/aMnNrkQ2ef4lzagcmw8XZlZ DcI2BcPdR4anOiJcVDEJCvH2qx88lXffgL3HPylpMjvRG4escJAWsW6IzUp/u0lJr3id USBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731678256; x=1732283056; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QflYe9Uttnm4Ku+Zy3VUc0FNhJJkvv+YuMrekm3fOjY=; b=ZP3+/lNFgYvia+y/CHNS/vdoIcu4+BI07v9dCeQMHYOH3GHUPVWc7/M9gaC9r7PScF G82nDXuG3mHAI24JLkFMYVzav94G9jSoJfOyKbBdF4q/D3BNqz7Y3N+Rr0vszy/6OCT2 R8fTCPjYh7M5rVvd1STiDAftcBuEz6j0hEq4peEYl5h3gbDnYkYI41MpVeJxoy9v6XKF 7LSQRfGzRwOFqJ9aQx9daDmKT3zLHAefY5DLg2AkYT7rhifPRoWaCKlvsIS7/TKRhzEi r7ruXYFoPARJP41954nwC1CA6m+50kAa8eLyVX+hTYVzSpwBUWsIPJ3FwcpljLqsdjVu RYIw== X-Forwarded-Encrypted: i=1; AJvYcCXqCtFrGnw6WKI3RQxC4CQrmdPnAyC3R+C+kKq0THJr6+wkMFAEHU28KoZG9K0pFrjWoql4bISMad/Njuo=@vger.kernel.org X-Gm-Message-State: AOJu0YwdA04z43ummbPMGy6+rSE1wGX0WjVduSEJUQMbd0ZvD2CVzRL8 wzNpVAd+KTZn72DdqzLe75/s0Zl7jrLXuNzYMO+q1goxpPww2xmQv+8pCXqtAMk= X-Google-Smtp-Source: AGHT+IEsR7G1hgK+fmAed/LYpCR8sEfBfQmvxReRtCLi1L0/hyDVglC8dL6z2/8gYOyTa/fuZVe4iw== X-Received: by 2002:a05:6000:18af:b0:37d:7e71:67a0 with SMTP id ffacd0b85a97d-38225a21d40mr2940930f8f.9.1731678256207; Fri, 15 Nov 2024 05:44:16 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ada3fc9sm4378016f8f.20.2024.11.15.05.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 05:44:15 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, magnus.damm@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, p.zabel@pengutronix.de, lethal@linux-sh.org, g.liakhovetski@gmx.de Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-serial@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v3 3/8] serial: sh-sci: Update the suspend/resume support Date: Fri, 15 Nov 2024 15:43:56 +0200 Message-Id: <20241115134401.3893008-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241115134401.3893008-1-claudiu.beznea.uj@bp.renesas.com> References: <20241115134401.3893008-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The Renesas RZ/G3S supports a power saving mode where power to most of the SoC components is turned off. When returning from this power saving mode, SoC components need to be re-configured. The SCIFs on the Renesas RZ/G3S need to be re-configured as well when returning from this power saving mode. The sh-sci code already configures the SCIF clocks, power domain and registers by calling uart_resume_port() in sci_resume(). On suspend path the SCIF UART ports are suspended accordingly (by calling uart_suspend_port() in sci_suspend()). The only missing setting is the reset signal. For this assert/de-assert the reset signal on driver suspend/resume. In case the no_console_suspend is specified by the user, the registers need to be saved on suspend path and restore on resume path. To do this the sci_console_setup() function was added. There is no need to cache/restore the status or FIFO registers. Only the control registers. To differentiate b/w these, the struct sci_port_params::regs was updated with a new member that specifies if the register needs to be chached on suspend. Only the RZ_SCIFA instances were updated with this new support as the hardware for the rest of variants was missing for testing. Signed-off-by: Claudiu Beznea --- Changes in v3: - none Changes in v2: - rebased on top of the update version of patch 2/8 from this series drivers/tty/serial/sh-sci.c | 53 ++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ade151ff39d2..e53496d2708e 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -101,7 +101,7 @@ enum SCI_CLKS { if ((_port)->sampling_rate_mask & SCI_SR((_sr))) =20 struct plat_sci_reg { - u8 offset, size; + u8 offset, size, suspend_cacheable; }; =20 struct sci_port_params { @@ -134,6 +134,8 @@ struct sci_port { struct dma_chan *chan_tx; struct dma_chan *chan_rx; =20 + struct reset_control *rstc; + #ifdef CONFIG_SERIAL_SH_SCI_DMA struct dma_chan *chan_tx_saved; struct dma_chan *chan_rx_saved; @@ -153,6 +155,7 @@ struct sci_port { int rx_trigger; struct timer_list rx_fifo_timer; int rx_fifo_timeout; + unsigned int console_cached_regs[SCIx_NR_REGS]; u16 hscif_tot; =20 bool has_rtscts; @@ -298,17 +301,17 @@ static const struct sci_port_params sci_port_params[S= CIx_NR_REGTYPES] =3D { */ [SCIx_RZ_SCIFA_REGTYPE] =3D { .regs =3D { - [SCSMR] =3D { 0x00, 16 }, - [SCBRR] =3D { 0x02, 8 }, - [SCSCR] =3D { 0x04, 16 }, + [SCSMR] =3D { 0x00, 16, 1 }, + [SCBRR] =3D { 0x02, 8, 1 }, + [SCSCR] =3D { 0x04, 16, 1 }, [SCxTDR] =3D { 0x06, 8 }, [SCxSR] =3D { 0x08, 16 }, [SCxRDR] =3D { 0x0A, 8 }, - [SCFCR] =3D { 0x0C, 16 }, + [SCFCR] =3D { 0x0C, 16, 1 }, [SCFDR] =3D { 0x0E, 16 }, - [SCSPTR] =3D { 0x10, 16 }, + [SCSPTR] =3D { 0x10, 16, 1 }, [SCLSR] =3D { 0x12, 16 }, - [SEMR] =3D { 0x14, 8 }, + [SEMR] =3D { 0x14, 8, 1 }, }, .fifosize =3D 16, .overrun_reg =3D SCLSR, @@ -3380,6 +3383,7 @@ static struct plat_sci_port *sci_parse_dt(struct plat= form_device *pdev, } =20 sp =3D &sci_ports[id]; + sp->rstc =3D rstc; *dev_id =3D id; =20 p->type =3D SCI_OF_TYPE(data); @@ -3507,13 +3511,34 @@ static int sci_probe(struct platform_device *dev) return 0; } =20 +static void sci_console_setup(struct sci_port *s, bool save) +{ + for (u16 i =3D 0; i < SCIx_NR_REGS; i++) { + struct uart_port *port =3D &s->port; + + if (!s->params->regs[i].suspend_cacheable) + continue; + + if (save) + s->console_cached_regs[i] =3D sci_serial_in(port, i); + else + sci_serial_out(port, i, s->console_cached_regs[i]); + } +} + static __maybe_unused int sci_suspend(struct device *dev) { struct sci_port *sport =3D dev_get_drvdata(dev); =20 - if (sport) + if (sport) { uart_suspend_port(&sci_uart_driver, &sport->port); =20 + if (!console_suspend_enabled && uart_console(&sport->port)) + sci_console_setup(sport, true); + else + return reset_control_assert(sport->rstc); + } + return 0; } =20 @@ -3521,8 +3546,18 @@ static __maybe_unused int sci_resume(struct device *= dev) { struct sci_port *sport =3D dev_get_drvdata(dev); =20 - if (sport) + if (sport) { + if (!console_suspend_enabled && uart_console(&sport->port)) { + sci_console_setup(sport, false); + } else { + int ret =3D reset_control_deassert(sport->rstc); + + if (ret) + return ret; + } + uart_resume_port(&sci_uart_driver, &sport->port); + } =20 return 0; } --=20 2.39.2