Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbdFMD1X (ORCPT ); Mon, 12 Jun 2017 23:27:23 -0400 Received: from mail-db5eur01on0088.outbound.protection.outlook.com ([104.47.2.88]:29408 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751753AbdFMD1W (ORCPT ); Mon, 12 Jun 2017 23:27:22 -0400 From: "A.s. Dong" To: Andy Duan , "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" 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: AQHS45HRmvUGOw43skqHZVUzSPMHF6IiHbeAgAAELbA= Date: Tue, 13 Jun 2017 03:27:18 +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: 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: [192.158.241.86] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM5PR0401MB2530;7:VqifVgDLbeKhgxHAxVf7u9UB43bJ8zJxuvyo57zeFyNxrRQ5cYOpyYbuO3DefrYqdsFvM5CEi4e/MRm9/g8tj8y+mcGOcsNn1aYMClOdVyoTgGzf8m87qhmHzRTbJ+jKHNQPgGuOoKpJYnkS1gFdcj7++PtGqKrEX96iSE6LqJMZkuzyyoEVCK++BaUdr7he4z+LgUSkfYyrhrY0UHJ7Ox02CZkOQBGHpaBEEGBkk1ZvJ7H8gkYXzW96TOgxwqB08lPsXsOMrQa/TfHqUz7DZse0IH7w3/n448fdth0Tw3+ty71eT/ZQiOx35zxwoWd6/V60pmJW6h3+8qS5KMkZXA== x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39410400002)(39840400002)(39850400002)(39860400002)(39400400002)(13464003)(54534003)(377454003)(14454004)(53546009)(7736002)(9686003)(6506006)(8676002)(2906002)(81166006)(189998001)(25786009)(54906002)(55016002)(99286003)(305945005)(5250100002)(2900100001)(478600001)(33656002)(3280700002)(2501003)(53936002)(5660300001)(54356999)(6246003)(76176999)(3660700001)(50986999)(74316002)(38730400002)(3846002)(39060400002)(4326008)(7696004)(229853002)(8936002)(6116002)(86362001)(6436002)(2950100002)(66066001)(102836003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0401MB2530;H:AM3PR04MB306.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; x-ms-traffictypediagnostic: AM5PR0401MB2530: x-ms-office365-filtering-correlation-id: 49c64671-8b9b-46c4-7ac1-08d4b20c189c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075);SRVR:AM5PR0401MB2530; 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)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM5PR0401MB2530;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM5PR0401MB2530; 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:27:18.6467 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2530 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 v5D3Rdvu009595 Content-Length: 6893 Lines: 196 > -----Original Message----- > From: Andy Duan > Sent: Tuesday, June 13, 2017 11:09 AM > 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 > > 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 ? > UPIO_MEM32 and UPIO_MEM32BE are serial core definitions. If we use one macro for it, then the macro seems be better in serial core. But I don't think it's quite necessary. Explicit using also make the code look clearer. Regards Dong Aisheng > > 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