From patchwork Tue Jun 4 08:55:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erwan Le Ray X-Patchwork-Id: 165728 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5576760ili; Tue, 4 Jun 2019 02:12:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyExRGZphPMUGaLwxBrnD9vM3h4ON2i7dm07fUucax82WuSgOdefBiZlnZv1kxyFpshrVL2 X-Received: by 2002:a62:51c2:: with SMTP id f185mr36114356pfb.16.1559639562446; Tue, 04 Jun 2019 02:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639562; cv=none; d=google.com; s=arc-20160816; b=Mw6vkfzkpDXrqZn74n0C1vVTom+3qOrE1s7sd7uQSZlD2QDCi9oEjC+ZuR0Oo16Nws QYwRfgbj33ARvmp7gS7NOUeWUXjhGXy4xKIZWnskrKmkMurOhEOMrCpkwYzdPkIsKYuZ GDs6N1mE9/cWhn0iBNMo+TuFI8IrPSJSaH8ntiLYe4gxIpQJtbSGaFiHul3NKjwHpe85 dQZfY9mw1utpCe2dHRImumyFffYmuucjJXgMr4ubOX4E1JCwiwKtV/4FAp3jpvoKquAl kK1Mhjnuv4sWmmwGKGtpuCA/BV4m5icEjPJ89elkiqs6GogqS+/+qaj35tcnwNsvkr6t kFDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=PlxzoaxTpT7xfTSaFEe7rJyo9NUlAGqUd0kCqJ49OI4=; b=e3Wq31k4llIpSZQX9fZ/cm3URUbILBT4y/2kG8W3L4qUDCV2Uirx/7gjqQSa2lZsq3 eVg3n9yRqFdIWhnGoaojL++/pEBdwbBsIPzMd9q0IO/xu1vTPJYSME/iTT3cSjnTTpYW VMuxOnfpICP6LBCmEPJprOn1Dl2SLSmpSAwkfTWmT0maolttIVDjBUkT45LBs6VUKoxF PXlYcl0wLXuvhlsWHFwijPpcrUSjXeJQCx+rZLwnhm0+MyO83Ed5mALV92u0P2AD+BXL jyqrGK/p5mcdrMo7kM1twtE47E0l/T/QxCV9dIgTymkkDRWf1BEjJjeXy2YowxMTXH9A SIHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=XtvRF2Je; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l27si19707507pgm.172.2019.06.04.02.12.42; Tue, 04 Jun 2019 02:12:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=XtvRF2Je; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727140AbfFDJMl (ORCPT + 1 other); Tue, 4 Jun 2019 05:12:41 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:12896 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726877AbfFDJMl (ORCPT ); Tue, 4 Jun 2019 05:12:41 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5498qNp019707; Tue, 4 Jun 2019 11:12:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=PlxzoaxTpT7xfTSaFEe7rJyo9NUlAGqUd0kCqJ49OI4=; b=XtvRF2JeKJZfffjpzMNle1ULSUh/rkODDI4QXRECKKUHrDNwTzdSSsQFalGKpEzaX7c3 zbdFycHJK0pK41AqKzt8HzxEPeS/R+NpLHPnwFNRl+7fEQVvJqCiJsIrVkqlJfVWsnw1 s5bpON+O+iCT3GTVpXsG7jkXTbOmwlAUSL/01gpJykwL6Wtd4/6Csdo3M31y9DgD7eKy AH6xJxvjR27XMZDahEE5uOf/NctnBrvnWp3k38bh1ahoRPF5DZImMR1hba6fMdZRVj75 ESMRxem/Yf4Nl6StAyVjtmij9zLMHceFLYD4i6RGUtKC/rJVtwgTyKLX4G4QEwZ26t7R NQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2sunmefkt6-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 04 Jun 2019 11:12:20 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9F70A17E; Tue, 4 Jun 2019 08:55:41 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5B858250C; Tue, 4 Jun 2019 08:55:41 +0000 (GMT) Received: from SAFEX1HUBCAS22.st.com (10.75.90.93) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 4 Jun 2019 10:55:41 +0200 Received: from localhost (10.201.23.31) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 4 Jun 2019 10:55:39 +0200 From: Erwan Le Ray To: Greg Kroah-Hartman , Jiri Slaby , Maxime Coquelin , "Alexandre Torgue" , Rob Herring , "Mark Rutland" CC: , , , , , Erwan Le Ray , "Fabrice Gasnier" , Bich Hemon Subject: [PATCH 06/10] serial: stm32: add support for no_console_suspend Date: Tue, 4 Jun 2019 10:55:15 +0200 Message-ID: <1559638519-6128-7-git-send-email-erwan.leray@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1559638519-6128-1-git-send-email-erwan.leray@st.com> References: <1559638519-6128-1-git-send-email-erwan.leray@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.31] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-04_07:, , signatures=0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org In order to display console messages in low power mode, console pins must be kept active after suspend call. Signed-off-by: Bich Hemon Signed-off-by: Erwan Le Ray -- 1.9.1 diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index aa3da1c..573eae1 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -802,6 +804,7 @@ static int stm32_init_port(struct stm32_port *stm32port, { struct uart_port *port = &stm32port->port; struct resource *res; + struct pinctrl *uart_pinctrl; int ret; port->iotype = UPIO_MEM; @@ -816,6 +819,24 @@ static int stm32_init_port(struct stm32_port *stm32port, stm32port->wakeirq = platform_get_irq(pdev, 1); stm32port->fifoen = stm32port->info->cfg.has_fifo; + uart_pinctrl = devm_pinctrl_get(&pdev->dev); + if (IS_ERR(uart_pinctrl)) { + ret = PTR_ERR(uart_pinctrl); + if (ret != -ENODEV) { + dev_err(&pdev->dev, "Can't get pinctrl, error %d\n", + ret); + return ret; + } + stm32port->console_pins = ERR_PTR(-ENODEV); + } else { + stm32port->console_pins = pinctrl_lookup_state + (uart_pinctrl, "no_console_suspend"); + } + + if (IS_ERR(stm32port->console_pins) && PTR_ERR(stm32port->console_pins) + != -ENODEV) + return PTR_ERR(stm32port->console_pins); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); port->membase = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(port->membase)) @@ -1228,6 +1249,7 @@ static void __maybe_unused stm32_serial_enable_wakeup(struct uart_port *port, static int __maybe_unused stm32_serial_suspend(struct device *dev) { struct uart_port *port = dev_get_drvdata(dev); + struct stm32_port *stm32_port = to_stm32_port(port); uart_suspend_port(&stm32_usart_driver, port); @@ -1236,7 +1258,19 @@ static int __maybe_unused stm32_serial_suspend(struct device *dev) else stm32_serial_enable_wakeup(port, false); - pinctrl_pm_select_sleep_state(dev); + if (uart_console(port) && !console_suspend_enabled) { + if (IS_ERR(stm32_port->console_pins)) { + dev_err(dev, "no_console_suspend pinctrl not found\n"); + return PTR_ERR(stm32_port->console_pins); + } + + pinctrl_select_state(dev->pins->p, stm32_port->console_pins); + } else { + if (device_may_wakeup(dev)) + pinctrl_pm_select_idle_state(dev); + else + pinctrl_pm_select_sleep_state(dev); + } return 0; } diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index 6f294e2..6957d50 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -261,6 +261,7 @@ struct stm32_port { bool hw_flow_control; bool fifoen; int wakeirq; + struct pinctrl_state *console_pins; }; static struct stm32_port stm32_ports[STM32_MAX_PORTS];