Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751882AbdFMDJX (ORCPT ); Mon, 12 Jun 2017 23:09:23 -0400 Received: from mail-eopbgr20075.outbound.protection.outlook.com ([40.107.2.75]:57878 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751753AbdFMDJV (ORCPT ); Mon, 12 Jun 2017 23:09:21 -0400 From: Andy Duan To: "A.s. Dong" , "linux-serial@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "gregkh@linuxfoundation.org" , "jslaby@suse.com" , "stefan@agner.ch" , Mingkai Hu , "Y.b. Lu" , "nikita.yoush@cogentembedded.com" , "andy.shevchenko@gmail.com" , "dongas86@gmail.com" , "A.s. Dong" Subject: RE: [PATCH V3 3/7] tty: serial: lpuart: add little endian 32 bit register support Thread-Topic: [PATCH V3 3/7] tty: serial: lpuart: add little endian 32 bit register support Thread-Index: AQHS45HOaIfNJRl5wk6tyL0S+0VD9KIiHX/g Date: Tue, 13 Jun 2017 03:09:11 +0000 Message-ID: References: <1497281848-12995-1-git-send-email-aisheng.dong@nxp.com> <1497281848-12995-4-git-send-email-aisheng.dong@nxp.com> In-Reply-To: <1497281848-12995-4-git-send-email-aisheng.dong@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [199.59.230.102] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0401MB2544;7:5l6i79GQ0HvHUSghA/ZEmo7xUFzTlZTUZcW7A+skm70NyG+itrr6pddjY8E+mPX8thq0/wEKYSRuJUOpHoOrcyljQImnkfrnMiJ2YGoVt0AkMMeLO41oRQCxL7yE1Btj7Qa4BfHCUqymLp4VWrEuL2g3prDV3QaPNlhMI/7AT7tL5A0T9KDNb0aL38YXRsD7HmJdhyxNJFyz1qMorHXXKpJ45KwXGD0NMdMWKNWdAUOiE0HwyUxpinhBdg1LghWFC+lND9QDbafavBfYaayM/yap8aIC9s/LArZab83UoU8zfQaQyb6bn4CIjv3FbAy1HMGGaajRWZ3EEdZhLe1tsA== x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(39450400003)(39840400002)(39410400002)(39400400002)(39850400002)(377454003)(54534003)(478600001)(189998001)(7736002)(74316002)(2501003)(305945005)(50986999)(54356999)(53936002)(5250100002)(76176999)(81166006)(5660300001)(2900100001)(8936002)(39060400002)(86362001)(38730400002)(2950100002)(66066001)(3280700002)(55016002)(3660700001)(54906002)(99286003)(9686003)(229853002)(6246003)(6436002)(4326008)(102836003)(6116002)(25786009)(14454004)(3846002)(33656002)(2906002)(8676002)(7696004)(6506006);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB2544;H:AM4PR0401MB2260.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; x-ms-traffictypediagnostic: VI1PR0401MB2544: x-ms-office365-filtering-correlation-id: 285d98ed-3af4-4c89-984a-08d4b209906e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075);SRVR:VI1PR0401MB2544; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197)(258649278758335); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0401MB2544;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0401MB2544; x-forefront-prvs: 0337AFFE9A spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2017 03:09:11.2605 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2544 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v5D39X2Q007814 Content-Length: 5812 Lines: 167 From: Dong Aisheng Sent: Monday, June 12, 2017 11:37 PM >To: linux-serial@vger.kernel.org >Cc: linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; >gregkh@linuxfoundation.org; jslaby@suse.com; Andy Duan >; stefan@agner.ch; Mingkai Hu >; Y.b. Lu ; >nikita.yoush@cogentembedded.com; andy.shevchenko@gmail.com; >dongas86@gmail.com; A.S. Dong >Subject: [PATCH V3 3/7] tty: serial: lpuart: add little endian 32 bit register >support > >Use standard port->iotype to distinguish endian difference. Note as we >read/write register by checking iotype dynamically, we need to initialize the >iotype correctly for earlycon as well to avoid a break. > >Cc: Greg Kroah-Hartman >Cc: Jiri Slaby (supporter:TTY LAYER) >Cc: Stefan Agner >Cc: Mingkai Hu >Cc: Yangbo Lu >Cc: Fugang Duan >Signed-off-by: Dong Aisheng > >ChangeLog: >v2->v3: > * Instead of using global var, use standard port->iotype to distinguish > endian difference. >v1->v2: > * No changes >--- > drivers/tty/serial/fsl_lpuart.c | 43 +++++++++++++++++++++++++++---------- >---- > 1 file changed, 29 insertions(+), 14 deletions(-) > >diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index >ed9db2f..bbf47a0 100644 >--- a/drivers/tty/serial/fsl_lpuart.c >+++ b/drivers/tty/serial/fsl_lpuart.c >@@ -280,15 +280,29 @@ MODULE_DEVICE_TABLE(of, lpuart_dt_ids); > /* Forward declare this for the dma callbacks*/ static void >lpuart_dma_tx_complete(void *arg); > >-static inline u32 lpuart32_read(struct uart_port *port, u32 reg_off) -{ >- return ioread32be(port->membase + reg_off); >+static inline u32 lpuart32_read(struct uart_port *port, u32 off) { >+ switch (port->iotype) { >+ case UPIO_MEM32: >+ return readl(port->membase + off); >+ case UPIO_MEM32BE: >+ return ioread32be(port->membase + off); >+ default: >+ return 0; >+ }; > } > > static inline void lpuart32_write(struct uart_port *port, u32 val, >- u32 reg_off) >+ u32 off) > { >- iowrite32be(val, port->membase + reg_off); >+ switch (port->iotype) { >+ case UPIO_MEM32: >+ writel(val, port->membase + off); >+ break; >+ case UPIO_MEM32BE: >+ iowrite32be(val, port->membase + off); >+ break; >+ }; > } > > static void lpuart_stop_tx(struct uart_port *port) @@ -602,7 +616,7 @@ >static irqreturn_t lpuart_txint(int irq, void *dev_id) > > spin_lock_irqsave(&sport->port.lock, flags); > if (sport->port.x_char) { >- if (sport->port.iotype & UPIO_MEM32BE) >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) > lpuart32_write(&sport->port, sport->port.x_char, >UARTDATA); > else > writeb(sport->port.x_char, sport->port.membase + >UARTDR); @@ -610,14 +624,14 @@ static irqreturn_t lpuart_txint(int irq, void >*dev_id) > } > > if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) { >- if (sport->port.iotype & UPIO_MEM32BE) >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) Can use one macro instead of sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE ? > lpuart32_stop_tx(&sport->port); > else > lpuart_stop_tx(&sport->port); > goto out; > } > >- if (sport->port.iotype & UPIO_MEM32BE) >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) > lpuart32_transmit_buffer(sport); > else > lpuart_transmit_buffer(sport); >@@ -1890,12 +1904,12 @@ static int __init lpuart_console_setup(struct >console *co, char *options) > if (options) > uart_parse_options(options, &baud, &parity, &bits, &flow); > else >- if (sport->port.iotype & UPIO_MEM32BE) >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) > lpuart32_console_get_options(sport, &baud, &parity, >&bits); > else > lpuart_console_get_options(sport, &baud, &parity, >&bits); > >- if (sport->port.iotype & UPIO_MEM32BE) >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) > lpuart32_setup_watermark(sport); > else > lpuart_setup_watermark(sport); >@@ -1954,6 +1968,7 @@ static int __init lpuart32_early_console_setup(struct >earlycon_device *device, > if (!device->port.membase) > return -ENODEV; > >+ device->port.iotype = UPIO_MEM32BE; > device->con->write = lpuart32_early_write; > return 0; > } >@@ -2015,7 +2030,7 @@ static int lpuart_probe(struct platform_device *pdev) > } > sport->port.irq = ret; > sport->port.iotype = sdata->iotype; >- if (sport->port.iotype & UPIO_MEM32BE) >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) > sport->port.ops = &lpuart32_pops; > else > sport->port.ops = &lpuart_pops; >@@ -2042,7 +2057,7 @@ static int lpuart_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, &sport->port); > >- if (sport->port.iotype & UPIO_MEM32BE) >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) > lpuart_reg.cons = LPUART32_CONSOLE; > else > lpuart_reg.cons = LPUART_CONSOLE; >@@ -2095,7 +2110,7 @@ static int lpuart_suspend(struct device *dev) > struct lpuart_port *sport = dev_get_drvdata(dev); > unsigned long temp; > >- if (sport->port.iotype & UPIO_MEM32BE) { >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) { > /* disable Rx/Tx and interrupts */ > temp = lpuart32_read(&sport->port, UARTCTRL); > temp &= ~(UARTCTRL_TE | UARTCTRL_TIE | UARTCTRL_TCIE); >@@ -2146,7 +2161,7 @@ static int lpuart_resume(struct device *dev) > if (sport->port.suspended && !sport->port.irq_wake) > clk_prepare_enable(sport->clk); > >- if (sport->port.iotype & UPIO_MEM32BE) { >+ if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) { > lpuart32_setup_watermark(sport); > temp = lpuart32_read(&sport->port, UARTCTRL); > temp |= (UARTCTRL_RIE | UARTCTRL_TIE | UARTCTRL_RE | >-- >2.7.4