From patchwork Tue Aug 8 13:48:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 109662 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2974912qge; Tue, 8 Aug 2017 06:50:37 -0700 (PDT) X-Received: by 10.84.215.204 with SMTP id g12mr4762112plj.397.1502200237571; Tue, 08 Aug 2017 06:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502200237; cv=none; d=google.com; s=arc-20160816; b=ho21Iy3wjK5kH84WtosItE2ISrdT6kHvk9PPmH+ajnrNh+/VES7paGmB9gHHDtEAdu K4t3mfWNoAAdRdNIl5KQv3TBtWbzSvCcpcx7prClAGwGH4yQHXpVDxcrAQJhWNC95SgK cJWTlBduju9RYjUdORr+hbB7TnZTZe4U90rmK9beEoz7ojDyE7NXY1yCvH2N2jFbZdBJ hUM+511rw8axYCmprOQGGdSJ/a3HaqwAXXcRZDLEt9TnyBB04SLgcWDeIZ0JjLrDWF09 marOe+wRW3fD8Gj94Zs5u0/Z3ad1Nx2G6uedBRySngKk1wrqiz1FBNAYyfoqdl/xonvn eYSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=TD7haFq2H+BfKfnMYM+1QMIYrzyoEAlL+Zqu0/as2ow=; b=WeSV9QdsBg6er7l7HQheDi7nYAjuNvQppKI0Sac70JFiI0IVhy5pwadZQDJotihsx/ xVJoR6FuA3x5ipMRRdsTNDjKIXSgaV9kI4s/AvqxeyZAO53647Q1MzOgJSGnOeJeXCjh MXPuijufOdTOBKeY0x2ETex9CCVhRqwUkROJMIXHIAKN2TMM/JA4FEEKP9gdBzEpMdWt Dan3h9n9iocQZefj4GS7BFd8OceYcKxD6vLGJZSBrl24yr0+KllIixH5KWX9Ab8ve1UE fRGqxlGhwvVrqMNahFNRUO8/0GM/Xhs79hihC1xPr0R6CoScauCwpD6bH+sC1QPVzS/P LAUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=T3hnm2p5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 y126si836396pgb.152.2017.08.08.06.50.37; Tue, 08 Aug 2017 06:50:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@nifty.com header.s=dec2015msa header.b=T3hnm2p5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752278AbdHHNuc (ORCPT + 25 others); Tue, 8 Aug 2017 09:50:32 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:61491 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752070AbdHHNu3 (ORCPT ); Tue, 8 Aug 2017 09:50:29 -0400 Received: from localhost.localdomain (pw126245200194.16.panda-world.ne.jp [126.245.200.194]) (authenticated) by conuserg-09.nifty.com with ESMTP id v78DnDns010873; Tue, 8 Aug 2017 22:49:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v78DnDns010873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1502200155; bh=TD7haFq2H+BfKfnMYM+1QMIYrzyoEAlL+Zqu0/as2ow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3hnm2p5yCeMkYIInOt0xa0tiOik9pRRgNowGMS2S/VJFYxfEneEwkVrCotQyTxfM ooXwFqNtZn+IW2cUv0jlICHuQPK89syB8Ip3+EuDIolSA51RctxGTMWvskdyxbFjnv 7N9oHWYu4NX+/MjvPWgBjzZ4agmCYzKEecWE5dmYyDE/BS4zBFxKfrPNd32j30C/tS qp3s41sJYbD05h4XFcvIoSpPH5S+H2z5vGC6/svrST3d+saTuLoJqIUhWw7bCRjTll OuK5d0HnaUdmrvayPvU66B1gC8Sr8wRwGdP4cCEDQL+TsroCd0+JzxlcnCbuLX91AQ DAN2zPWKMikvw== X-Nifty-SrcIP: [126.245.200.194] From: Masahiro Yamada To: linux-serial@vger.kernel.org Cc: Masami Hiramatsu , Jassi Brar , Masahiro Yamada , Jiri Slaby , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] serial: 8250_uniphier: fix serial port index in private data Date: Tue, 8 Aug 2017 22:48:41 +0900 Message-Id: <1502200123-2558-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> References: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org serial8250_register_8250_port() may allocate a different port index than requested. The driver needs to remember the returned value of serial8250_register_8250_port() for later use. Otherwise, the .remove hook may unregister a different port. Fixes: 1a8d2903cb6a ("serial: 8250_uniphier: add UniPhier serial driver") Signed-off-by: Masahiro Yamada --- drivers/tty/serial/8250/8250_uniphier.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c index 746680ebf90c..633ac378b7f2 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c @@ -169,7 +169,7 @@ static int uniphier_of_serial_setup(struct device *dev, struct uart_port *port, dev_err(dev, "failed to get alias id\n"); return ret; } - port->line = priv->line = ret; + port->line = ret; /* Get clk rate through clk driver */ priv->clk = devm_clk_get(dev, NULL); @@ -249,8 +249,8 @@ static int uniphier_uart_probe(struct platform_device *pdev) up.dl_read = uniphier_serial_dl_read; up.dl_write = uniphier_serial_dl_write; - ret = serial8250_register_8250_port(&up); - if (ret < 0) { + priv->line = serial8250_register_8250_port(&up); + if (priv->line < 0) { dev_err(dev, "failed to register 8250 port\n"); clk_disable_unprepare(priv->clk); return ret; From patchwork Tue Aug 8 13:48:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 109664 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2975479qge; Tue, 8 Aug 2017 06:51:09 -0700 (PDT) X-Received: by 10.99.24.85 with SMTP id 21mr4155948pgy.108.1502200269579; Tue, 08 Aug 2017 06:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502200269; cv=none; d=google.com; s=arc-20160816; b=J2bMYmex/sm1/KMJ3lyVgoydy7XcAaihTu+SxfmdKPOdg5DxX6xLU5gu/TIm0MC2lB ZSwWaOnvNdeBlRGlMqi+lo94USz4TQLmIN5fyc0dvmXuOx0nMn6lSFUjP6tcSAI13L+x gn14TbybnseKwcp8PNH53V71ssR/o19lAr3Qu2T41g+PuJyVZjb3jV2XZYA0o95goVk8 kE+nmzrFC8juFVp5dxM6bfp+OGLlHyayE952JD0q8uYI2NoMMxIZo/OioVNTKJJackAz oZeuq6VDI/C27HHkwTM5qTitnpxCukuEy4bnh0hoa5L1ptIGaWq1BYHeSkLYkRN5LGjz 1Twg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=XfA4HuTZGJgUT3G75a1aqJNpaJaFor3VtB7jRg31qRA=; b=KTTCB82k1blLz760mlmx9jZddHE4HoDANb6xDPFfqUSkPJ1ISN0fepR1x5Y18dLjnZ zA00fFSw+mN2HujV3RUnJzc34yURAbz6h0xO8WQNumchbmzK0H2xaiXhDMJlmdmn6ws6 +M8IKTCt3f9Osvx6NtgL2pUd5/HmAO4ClchbNvlCR7BslOra+9L8LtqI1Cm7qEF6BD4/ f8HDNyiQmiPD/6y51ofLanZ8MBEnXiaJC+X+g0I07pcVoP454XMdJxuvVOwJsXna+4wu qjhe7ThShlXaxdLDItW2vhhyHn3Ahn764M9JoujL43F1lz701xb15Z9Z428HIhQ0cwge S+NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=zwN4f4qy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 e89si910745pfd.341.2017.08.08.06.51.09; Tue, 08 Aug 2017 06:51:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@nifty.com header.s=dec2015msa header.b=zwN4f4qy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752360AbdHHNvG (ORCPT + 25 others); Tue, 8 Aug 2017 09:51:06 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:61512 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752084AbdHHNua (ORCPT ); Tue, 8 Aug 2017 09:50:30 -0400 Received: from localhost.localdomain (pw126245200194.16.panda-world.ne.jp [126.245.200.194]) (authenticated) by conuserg-09.nifty.com with ESMTP id v78DnDnt010873; Tue, 8 Aug 2017 22:49:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v78DnDnt010873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1502200156; bh=XfA4HuTZGJgUT3G75a1aqJNpaJaFor3VtB7jRg31qRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwN4f4qyIrMYNpTd2rt+mrGhvWhGY4Hcaj56W1UIqvGiEf0PO4H4x9Z+pLiUEhh3n +Lj9n0H2dSA1ZkETQQD/WpI3tDSywmKZFOAg24X6uCCZqcStYoIhgjzwxfgtdQDMeY yTezH3ucM3F/sf3sNmZ0nEGc1iZjy4svI+fBoaPNlvDlvGcahzZqBUqOuHXheuUSPl Jc+gKZu2PdHhbCBWzQDuqD2zoaJcMUsa1F4rEOviwk2g5HogNGG1bk9ZMoiZTLUH8U /qZE19wrvqDiVm/OfdslA0D8ry6ixp1kDOn8+ouhrG/ppaHBNt6TnZSN+TRrydHrJc 2/M2GvKhCPFOQ== X-Nifty-SrcIP: [126.245.200.194] From: Masahiro Yamada To: linux-serial@vger.kernel.org Cc: Masami Hiramatsu , Jassi Brar , Masahiro Yamada , Jiri Slaby , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] serial: 8250_uniphier: use CHAR register for canary to detect power-off Date: Tue, 8 Aug 2017 22:48:42 +0900 Message-Id: <1502200123-2558-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> References: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 8250 core uses the SCR as a canary to discover if the console has been powered-off. This hardware does not have SCR at offset 7, but an unused register CHAR at a different offset. As long as the character interrupt is disabled, the register access has no impact, so it is useful as an alternative scratch register. Signed-off-by: Masahiro Yamada --- drivers/tty/serial/8250/8250_uniphier.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c index 633ac378b7f2..97a45b798fcd 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c @@ -29,12 +29,13 @@ * - MMIO32 (regshift = 2) * - FCR is not at 2, but 3 * - LCR and MCR are not at 3 and 4, they share 4 + * - No SCR (Instead, CHAR can be used as a scratch register) * - Divisor latch at 9, no divisor latch access bit */ #define UNIPHIER_UART_REGSHIFT 2 -/* bit[15:8] = CHAR (not used), bit[7:0] = FCR */ +/* bit[15:8] = CHAR, bit[7:0] = FCR */ #define UNIPHIER_UART_CHAR_FCR (3 << (UNIPHIER_UART_REGSHIFT)) /* bit[15:8] = LCR, bit[7:0] = MCR */ #define UNIPHIER_UART_LCR_MCR (4 << (UNIPHIER_UART_REGSHIFT)) @@ -72,13 +73,18 @@ OF_EARLYCON_DECLARE(uniphier, "socionext,uniphier-uart", /* * The register map is slightly different from that of 8250. - * IO callbacks must be overridden for correct access to FCR, LCR, and MCR. + * IO callbacks must be overridden for correct access to FCR, LCR, MCR and SCR. */ static unsigned int uniphier_serial_in(struct uart_port *p, int offset) { unsigned int valshift = 0; switch (offset) { + case UART_SCR: + /* No SCR for this hardware. Use CHAR as a scratch register */ + valshift = 8; + offset = UNIPHIER_UART_CHAR_FCR; + break; case UART_LCR: valshift = 8; /* fall through */ @@ -91,8 +97,8 @@ static unsigned int uniphier_serial_in(struct uart_port *p, int offset) } /* - * The return value must be masked with 0xff because LCR and MCR reside - * in the same register that must be accessed by 32-bit write/read. + * The return value must be masked with 0xff because some registers + * share the same offset that must be accessed by 32-bit write/read. * 8 or 16 bit access to this hardware result in unexpected behavior. */ return (readl(p->membase + offset) >> valshift) & 0xff; @@ -101,9 +107,13 @@ static unsigned int uniphier_serial_in(struct uart_port *p, int offset) static void uniphier_serial_out(struct uart_port *p, int offset, int value) { unsigned int valshift = 0; - bool normal = true; + bool normal = false; switch (offset) { + case UART_SCR: + /* No SCR for this hardware. Use CHAR as a scratch register */ + valshift = 8; + /* fall through */ case UART_FCR: offset = UNIPHIER_UART_CHAR_FCR; break; @@ -114,10 +124,10 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value) /* fall through */ case UART_MCR: offset = UNIPHIER_UART_LCR_MCR; - normal = false; break; default: offset <<= UNIPHIER_UART_REGSHIFT; + normal = true; break; } From patchwork Tue Aug 8 13:48:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 109661 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2974850qge; Tue, 8 Aug 2017 06:50:34 -0700 (PDT) X-Received: by 10.84.224.206 with SMTP id k14mr4754232pln.429.1502200234827; Tue, 08 Aug 2017 06:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502200234; cv=none; d=google.com; s=arc-20160816; b=gT6vHexEbl7xYNLkOWEAWo5lwzIyIahPnEdBzfLARshKKcaRDkOlssavMn0tRilrK9 SNr9FyhWllz08ZgbcmAfLgsoPV82SOflOGP0tpln++S9mr7YD5iokaWXZNZxhL60HIF0 g2pFSGiTxqHXfD5NjhRlXTGtxMkOMSXv/+BiPffWKBf9PMMo2vq3UgvUonbsqnCPXz/V SlnpEti5Vlu90ZdJ4VJzA0Iiuqn6sUbTBz7JFio8fklJ0HD44eq/3dLFj5JKkJvxL4fc SAjHEfUiUvFAiKbHJIWMNNReHYAmOaqIgb17/G3MWS8dJcdmqqZu975Tx/Si/4kmIp2L KtHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=xdPYMkMtaSewvzrB0y6L1L44gKdUsJ1mnpYecjdJ9iM=; b=D+FsmXM1MDi/b8/yT/y1jF43McWiDTrHVIg9Zi/hHd4eEchoatVueKkdxtpr4ia5ym XtECVGbhNtiCp6N7JaXHV5E+ac9Qmz/Y70RY8fJMnW02h5bYtIa0Wy+dTJeaHJUa0W0q klaEn1H5SzufIzplbeeU5/UmMCRXelUFyZRXYMBSY+G5GxZTGMOhUIgMueg/rQ9o2uSP s5woeyVyqxL5cAG9Wk6YRJmINHi0SiqURIBzQ5DFr6WZGv3YM2DjFBXD5i7+LVXD3aY4 WJ3eMdGOl31cUgcGhJ+gxfhmQe+cwS2StskhQE2Q5+HyJ4TqthtI7UZbYHyTIQm3DtLo zqnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xGK7CCxU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 y126si836396pgb.152.2017.08.08.06.50.34; Tue, 08 Aug 2017 06:50:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@nifty.com header.s=dec2015msa header.b=xGK7CCxU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752241AbdHHNuc (ORCPT + 25 others); Tue, 8 Aug 2017 09:50:32 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:61485 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752062AbdHHNu3 (ORCPT ); Tue, 8 Aug 2017 09:50:29 -0400 Received: from localhost.localdomain (pw126245200194.16.panda-world.ne.jp [126.245.200.194]) (authenticated) by conuserg-09.nifty.com with ESMTP id v78DnDnu010873; Tue, 8 Aug 2017 22:49:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v78DnDnu010873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1502200157; bh=xdPYMkMtaSewvzrB0y6L1L44gKdUsJ1mnpYecjdJ9iM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xGK7CCxUNdHopNLhO8rs1d8y45UNagLpdo6kU0UiiedvOHg5xn+f2f4P56yBBgrhr a3nN2mjCQk2B9ytMTiqWV+NZ1D1EkahSDYePfuDqekBo9Wz1ZMu33xhNEsK+DaP27L TjO17qA39V+NNPRQ3SlH5YaqI/+dbNk+7QS6snOad5m5VgWMd9DnAB87V72EcQyHsd 794tmmH1gVoa8KbAJCUkzCY7VZzC5LkFLuX9k+uNbzI+8s6tVO+ivotHAbjYshqVPF mmzY0LcvFliUlCg5P+zcY90lt4HBlAgDo5ZgDzDRAGwo/A+yenAYPn55qDQemmPJYx 1FR7/nVqMFtSQ== X-Nifty-SrcIP: [126.245.200.194] From: Masahiro Yamada To: linux-serial@vger.kernel.org Cc: Masami Hiramatsu , Jassi Brar , Masahiro Yamada , Jiri Slaby , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] serial: 8250_uniphier: add suspend/resume support Date: Tue, 8 Aug 2017 22:48:43 +0900 Message-Id: <1502200123-2558-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> References: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add suspend/resume support for UniPhier serial driver. Signed-off-by: Masahiro Yamada --- drivers/tty/serial/8250/8250_uniphier.c | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.7.4 diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c index 97a45b798fcd..8a10b10e27aa 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c @@ -281,6 +281,40 @@ static int uniphier_uart_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused uniphier_uart_suspend(struct device *dev) +{ + struct uniphier8250_priv *priv = dev_get_drvdata(dev); + struct uart_8250_port *up = serial8250_get_port(priv->line); + + serial8250_suspend_port(priv->line); + + if (!uart_console(&up->port) || console_suspend_enabled) + clk_disable_unprepare(priv->clk); + + return 0; +} + +static int __maybe_unused uniphier_uart_resume(struct device *dev) +{ + struct uniphier8250_priv *priv = dev_get_drvdata(dev); + struct uart_8250_port *up = serial8250_get_port(priv->line); + int ret; + + if (!uart_console(&up->port) || console_suspend_enabled) { + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; + } + + serial8250_resume_port(priv->line); + + return 0; +} + +static const struct dev_pm_ops uniphier_uart_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(uniphier_uart_suspend, uniphier_uart_resume) +}; + static const struct of_device_id uniphier_uart_match[] = { { .compatible = "socionext,uniphier-uart" }, { /* sentinel */ } @@ -293,6 +327,7 @@ static struct platform_driver uniphier_uart_platform_driver = { .driver = { .name = "uniphier-uart", .of_match_table = uniphier_uart_match, + .pm = &uniphier_uart_pm_ops, }, }; module_platform_driver(uniphier_uart_platform_driver);