Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754975AbdFLQUH (ORCPT ); Mon, 12 Jun 2017 12:20:07 -0400 Received: from mail-dm3nam03on0048.outbound.protection.outlook.com ([104.47.41.48]:51584 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754873AbdFLPhv (ORCPT ); Mon, 12 Jun 2017 11:37:51 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Dong Aisheng To: CC: , , , , , , , , , , , Dong Aisheng Subject: [PATCH V3 2/7] tty: serial: lpuart: refactor lpuart32_{read|write} prototype Date: Mon, 12 Jun 2017 23:37:23 +0800 Message-ID: <1497281848-12995-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497281848-12995-1-git-send-email-aisheng.dong@nxp.com> References: <1497281848-12995-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131417554493190022;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39850400002)(39860400002)(39840400002)(39380400002)(39450400003)(39410400002)(39400400002)(2980300002)(1110001)(1109001)(339900001)(189002)(54534003)(199003)(9170700003)(54906002)(86362001)(85426001)(2351001)(81166006)(2950100002)(4326008)(50226002)(36756003)(8676002)(356003)(47776003)(106466001)(53936002)(189998001)(39060400002)(33646002)(8656002)(305945005)(7416002)(2906002)(498600001)(50986999)(5660300001)(110136004)(8936002)(50466002)(76176999)(48376002)(6916009)(105606002)(5003940100001)(77096006)(104016004)(38730400002);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR03MB166;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;MX:1;A:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11OLC004;1:1Umi24PbQpB2UWVsXqX+dAatiJDralWWhtlfGTtKudA+dkM/MRYPHdJIssnEvenDxyEQD0fFMb2+jHUgXfekbVLMfAabWWJ+Srl7qOmel3wjxhKydP+75ngGsk6JIisSC1o1ptTxUS+QF8OTt4/qc6Cr0hlJnqlYImRHHdqYuoog/L7yZkTiEmJYNSicQ8QZtsSxHEmFL02UruNbB9/nA2J5LL60fy++Brw9fBue9tuGGuvfSWJVCnKlZy/kW+qr+FAV9oDm05LfrdCIFTiwdDK2eI027lE0frZb7jp6lxhJ5ewIKpZK4KvbSFfpO04ndxpAcYoHhK/V15xC3pSkjJ6c1ATv7SJZBZYvIuxqBp1B45hIA85MH47Ba3D+350tokrbKw41mC1fJdDLKGwRQyoP71UheL21vFobty2gReQjxtAviKGepNpejbsog8exiVoUaXO6ZpekBTQ07kdZGViR6IVRue1aRbe2UTaDI4lOlJOKBtZ7jtX4QOIk6G4y0YxjSXsmp7p9I6MdAeL5IvpNclzI+2XTTkoxGKti/CXwwW3LUR6CAER8SAVd2/ipMwypsZX8+bXAFaD04Vw3245mD4VdhNaxDwqgiWsqbO1P1UdaH7yZOrQaQsAkZdpSa53kDrw93JfAGS+crV2uFJ/0LSiYWGE53WwDc8IQeXjddETnv4+t4Y699rbUgHxF MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLUPR03MB166: X-MS-Office365-Filtering-Correlation-Id: d672f0aa-8137-4fde-6ccc-08d4b1a8ef43 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:BLUPR03MB166; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB166;3:f4qERCya8V7Ja+Himw/OcSiuy6BxkDjEd07SNxI+hUEQiA12Q9+jdzNoGlhGjAhh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cdiL2ovZFUjUPrYcuABDXDx2thf+HGUl1bF75mMdscWdMR2X1tPWqoUz+0hav3MIg5JxpeNNdGnb1zqL8RKg4B0nsLcJguVsUvz5+TkebUfzmaoob8Fg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(13018025)(13016025)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123559100)(20161123556025)(20161123561025)(20161123563025)(20161123565025)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BLUPR03MB166;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BLUPR03MB166; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR03MB166;4:F96jYzpoVeWVAgPv+rqazu3CvGZjHNxjM1I+oDLGwK0?= =?us-ascii?Q?iq/kY0GGC6Gmh7lwJHfuLwmtuyvnYUv2KOzouS0VMHm50t3ShP0LY+ru1Ihg?= =?us-ascii?Q?wF8oQd1uzrTCRrE74UJT2h//4ibK2mGVq4r8uY1gmC4TVk6Qjv1LJyiJv7s5?= =?us-ascii?Q?9R5NAZqOhQlj/+DJmJu1p8Ksh58pCdYx57pQOteegbJ7CHOtJtXy7JWq1o4U?= =?us-ascii?Q?jcQKfauhJudJNE/wKL5YI+d+c9FCNLhJWW/ODV90H8P5/B1qDK8sY32/6PAN?= =?us-ascii?Q?WGQ/ECcqQgoyJ4b4IAGdMFESGG62Kjzr/2qoy7fI9/7p+MveMCjZlnBvsP86?= =?us-ascii?Q?DHIC4k1+AwEqvMzsVSq1N3gz/tcq0P2oMkfWZhHx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5XFYNCCeuaeAx?= X-Forefront-PRVS: 03361FCC43 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR03MB166;23:LRQhk8oFq1vlgczn4g9DpCL031znh9C9v856PqiLmj?= =?us-ascii?Q?cuGiGdb2VsQqGduD2w/9Yj4aTBoJlqdIdLpYtaQ4PEw+cOzDplCXq+AD80Ys?= =?us-ascii?Q?gUcNalCP1DEYNOOZeONgny8vIauQcza22SL++WbWtx5g8aVuEaPUlz3eNa5Z?= =?us-ascii?Q?UsGFL/qsxCXQZ3Iou58ssHAAc1bZadsWnKLMrp0l5e4S1w72KmM9WnCa2Fwi?= =?us-ascii?Q?DhAYB9+h/QzzByPJDPkwYgA6yFD8JM6No2S3qpY18/G0d/DXq4OD4CwqFN9Y?= =?us-ascii?Q?4uEa57PPv4AqovuN7mcD0NGqxHSjpIiMV41bCoIE723n/9p2pf2AQxPIw6SL?= =?us-ascii?Q?h+HAIMKUJJc+PUlBeMY0PCRsnMjCMHAuQDPG/ae/zu/5Jxlr6AWh2vyC44nA?= =?us-ascii?Q?6oEAC9kOdZfCxRInK86eZ4BVclvGmtrhIHCHF2xheQxyRLpMZ1srS2x5LMC1?= =?us-ascii?Q?fIDhQRqwFPbfhN3h0/Blal3YVhD4iWaxOlo6DE6LF2OR1VPuh7VoY26mwEJM?= =?us-ascii?Q?zB4QE0UxNdrYJGXSAZE652GKDi77OUVZ7lK+sm1QzXFGiU6Ae2cB0F1pMZ7k?= =?us-ascii?Q?/nz8j6fxKYcYVMzLTp3DAlOTJ5uxicEZh/j0y0AbW240XTxaAX86SOilV+LS?= =?us-ascii?Q?KB2zkKya4cYQpEeueg7/DPkHBJXl0QSFj+pp4UWQZr1B9wrqn9bo8DDNdtJj?= =?us-ascii?Q?KWIB8f7ms8eplQPNcrkQHzvgbMF9vMducxJK4ZA77VEsJL6H2GjFpajZEcB1?= =?us-ascii?Q?yaa2fu394ntlMfZP0tUowVDTw/vUAhSMGkgf6z52B9x0ChpueTCtk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Kq5XRkBeOvNJGzfvv6hO4ymBcBcnZccWgFV04yb96amqBu8u0CylwZLnPMofVi1vZbS+BOefRsOrIH0+i31P73jDd7g/TtkTY3XQWcupuFzfAE0OXUP/D3Zew== X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB166;5:YVu1Hbu2wHMVnJLnfmWopBjWlejrJLZG569kfXYllsi/9crxV/EYhLfe5xUB8vzqbDo3hzc//iJ+mVeiM8ruOE/AuoMDyUYqjH1z6gFqheVYUG2k4n2uiaVnXMfhddL38Q88fvBJBL0G2Dt6NsJUWTg8zJ2QvHF56nVGvF1hvCbcCxR7y+Tfnl5H8T1rpig8l256n7osPAHbZNEAxG7SZVwAU+FRd9KiCvXcmDAfIu8i66C/ylfk9WIsAvW31kcIELYLWW0m23UGSDcfHxvsm243YHiTogb5KT5rn7AT+0lNaBGVNgF/wkLfoDHWNa1M/16zJYIJ+rYU45x2kjVLyQhNTaadrR3mArr+SiNEvqyYUPHz+O2h55XbV1cdK215fXkVCw0/tm5RditTcLJQq55zckFrflziff/pjjdK0PCWmPahQMZR2jE0FTQU9u6uc6L+eSxOyNeJKS3p+ckq5fpOr0X3jBbuNSiuxzy0m9SxCNBgJQt3p42OVR6zAf/nxzz2iKMLS0RLYIydgVs7DQ==;24:GUkaclUJ6HmzhHyzUbVg82jbt9fvRrFxzShdGeG1iHf3lkUgReofC5WcBbzeNipxXtv/R1xZfACL3r2WF9I8g3EYzP1aOu/PcP7L9kVvOjU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB166;7:Vpz7hc2uMESWKkzDjHYFkIx0DT6d1Fr+NkDAPwkeJcCihc4vMJH06uf13fK9CnK4CloJ25sz4BAoVw9BTXeO/8oa39x8YeVKfHd3Iyj/vztblgcg4HzW/UGrWhtGqxTUhQUNBas+b8fTDkLHwHgUuqqNB85ekHv4PXexaeCqQUFZjbYe2Qars6Lj5iMy4GInGEvpCUtB39fjCXcjMHM/CtKwFGpFZeXKbsqEaTqilcdhKt53D8SpfZ6ZQ8ChTCx02oLS/sBbSq3gpmDCW0ULXa2nm+g8V1t8oX2oxRmk/sXSPnCuCZkeD0T+EBvSk936Thx2ueEUIMuTX8X3fKZSdg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2017 15:37:29.1162 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB166 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14893 Lines: 403 Due to the original lpuart32_read/write takes no port specific information arguments, it's hard to distinguish port difference within the API. Although it works before, but not suitable anymore when adding more new chips support. So let's convert it to accept a new struct uart_port argument to make it be able to retrieve more port specific information. This is a preparation for the later adding new chips support more easily. No functions changes. Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Stefan Agner Cc: Mingkai Hu Cc: Yangbo Lu Cc: Fugang Duan Signed-off-by: Dong Aisheng --- ChangeLog: v2->v3: * newly introduced --- drivers/tty/serial/fsl_lpuart.c | 123 ++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 4daabc6..ed9db2f 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -280,14 +280,15 @@ MODULE_DEVICE_TABLE(of, lpuart_dt_ids); /* Forward declare this for the dma callbacks*/ static void lpuart_dma_tx_complete(void *arg); -static u32 lpuart32_read(void __iomem *addr) +static inline u32 lpuart32_read(struct uart_port *port, u32 reg_off) { - return ioread32be(addr); + return ioread32be(port->membase + reg_off); } -static void lpuart32_write(u32 val, void __iomem *addr) +static inline void lpuart32_write(struct uart_port *port, u32 val, + u32 reg_off) { - iowrite32be(val, addr); + iowrite32be(val, port->membase + reg_off); } static void lpuart_stop_tx(struct uart_port *port) @@ -303,9 +304,9 @@ static void lpuart32_stop_tx(struct uart_port *port) { unsigned long temp; - temp = lpuart32_read(port->membase + UARTCTRL); + temp = lpuart32_read(port, UARTCTRL); temp &= ~(UARTCTRL_TIE | UARTCTRL_TCIE); - lpuart32_write(temp, port->membase + UARTCTRL); + lpuart32_write(port, temp, UARTCTRL); } static void lpuart_stop_rx(struct uart_port *port) @@ -320,8 +321,8 @@ static void lpuart32_stop_rx(struct uart_port *port) { unsigned long temp; - temp = lpuart32_read(port->membase + UARTCTRL); - lpuart32_write(temp & ~UARTCTRL_RE, port->membase + UARTCTRL); + temp = lpuart32_read(port, UARTCTRL); + lpuart32_write(port, temp & ~UARTCTRL_RE, UARTCTRL); } static void lpuart_dma_tx(struct lpuart_port *sport) @@ -520,14 +521,14 @@ static inline void lpuart32_transmit_buffer(struct lpuart_port *sport) struct circ_buf *xmit = &sport->port.state->xmit; unsigned long txcnt; - txcnt = lpuart32_read(sport->port.membase + UARTWATER); + txcnt = lpuart32_read(&sport->port, UARTWATER); txcnt = txcnt >> UARTWATER_TXCNT_OFF; txcnt &= UARTWATER_COUNT_MASK; while (!uart_circ_empty(xmit) && (txcnt < sport->txfifo_size)) { - lpuart32_write(xmit->buf[xmit->tail], sport->port.membase + UARTDATA); + lpuart32_write(&sport->port, xmit->buf[xmit->tail], UARTDATA); xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); sport->port.icount.tx++; - txcnt = lpuart32_read(sport->port.membase + UARTWATER); + txcnt = lpuart32_read(&sport->port, UARTWATER); txcnt = txcnt >> UARTWATER_TXCNT_OFF; txcnt &= UARTWATER_COUNT_MASK; } @@ -563,10 +564,10 @@ static void lpuart32_start_tx(struct uart_port *port) struct lpuart_port *sport = container_of(port, struct lpuart_port, port); unsigned long temp; - temp = lpuart32_read(port->membase + UARTCTRL); - lpuart32_write(temp | UARTCTRL_TIE, port->membase + UARTCTRL); + temp = lpuart32_read(port, UARTCTRL); + lpuart32_write(port, temp | UARTCTRL_TIE, UARTCTRL); - if (lpuart32_read(port->membase + UARTSTAT) & UARTSTAT_TDRE) + if (lpuart32_read(port, UARTSTAT) & UARTSTAT_TDRE) lpuart32_transmit_buffer(sport); } @@ -589,7 +590,7 @@ static unsigned int lpuart_tx_empty(struct uart_port *port) static unsigned int lpuart32_tx_empty(struct uart_port *port) { - return (lpuart32_read(port->membase + UARTSTAT) & UARTSTAT_TC) ? + return (lpuart32_read(port, UARTSTAT) & UARTSTAT_TC) ? TIOCSER_TEMT : 0; } @@ -602,7 +603,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) - lpuart32_write(sport->port.x_char, sport->port.membase + UARTDATA); + lpuart32_write(&sport->port, sport->port.x_char, UARTDATA); else writeb(sport->port.x_char, sport->port.membase + UARTDR); goto out; @@ -702,15 +703,15 @@ static irqreturn_t lpuart32_rxint(int irq, void *dev_id) spin_lock_irqsave(&sport->port.lock, flags); - while (!(lpuart32_read(sport->port.membase + UARTFIFO) & UARTFIFO_RXEMPT)) { + while (!(lpuart32_read(&sport->port, UARTFIFO) & UARTFIFO_RXEMPT)) { flg = TTY_NORMAL; sport->port.icount.rx++; /* * to clear the FE, OR, NF, FE, PE flags, * read STAT then read DATA reg */ - sr = lpuart32_read(sport->port.membase + UARTSTAT); - rx = lpuart32_read(sport->port.membase + UARTDATA); + sr = lpuart32_read(&sport->port, UARTSTAT); + rx = lpuart32_read(&sport->port, UARTDATA); rx &= 0x3ff; if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) @@ -777,18 +778,18 @@ static irqreturn_t lpuart32_int(int irq, void *dev_id) struct lpuart_port *sport = dev_id; unsigned long sts, rxcount; - sts = lpuart32_read(sport->port.membase + UARTSTAT); - rxcount = lpuart32_read(sport->port.membase + UARTWATER); + sts = lpuart32_read(&sport->port, UARTSTAT); + rxcount = lpuart32_read(&sport->port, UARTWATER); rxcount = rxcount >> UARTWATER_RXCNT_OFF; if (sts & UARTSTAT_RDRF || rxcount > 0) lpuart32_rxint(irq, dev_id); if ((sts & UARTSTAT_TDRE) && - !(lpuart32_read(sport->port.membase + UARTBAUD) & UARTBAUD_TDMAE)) + !(lpuart32_read(&sport->port, UARTBAUD) & UARTBAUD_TDMAE)) lpuart_txint(irq, dev_id); - lpuart32_write(sts, sport->port.membase + UARTSTAT); + lpuart32_write(&sport->port, sts, UARTSTAT); return IRQ_HANDLED; } @@ -1049,7 +1050,7 @@ static unsigned int lpuart32_get_mctrl(struct uart_port *port) unsigned int temp = 0; unsigned long reg; - reg = lpuart32_read(port->membase + UARTMODIR); + reg = lpuart32_read(port, UARTMODIR); if (reg & UARTMODIR_TXCTSE) temp |= TIOCM_CTS; @@ -1084,7 +1085,7 @@ static void lpuart32_set_mctrl(struct uart_port *port, unsigned int mctrl) { unsigned long temp; - temp = lpuart32_read(port->membase + UARTMODIR) & + temp = lpuart32_read(port, UARTMODIR) & ~(UARTMODIR_RXRTSE | UARTMODIR_TXCTSE); if (mctrl & TIOCM_RTS) @@ -1093,7 +1094,7 @@ static void lpuart32_set_mctrl(struct uart_port *port, unsigned int mctrl) if (mctrl & TIOCM_CTS) temp |= UARTMODIR_TXCTSE; - lpuart32_write(temp, port->membase + UARTMODIR); + lpuart32_write(port, temp, UARTMODIR); } static void lpuart_break_ctl(struct uart_port *port, int break_state) @@ -1112,12 +1113,12 @@ static void lpuart32_break_ctl(struct uart_port *port, int break_state) { unsigned long temp; - temp = lpuart32_read(port->membase + UARTCTRL) & ~UARTCTRL_SBK; + temp = lpuart32_read(port, UARTCTRL) & ~UARTCTRL_SBK; if (break_state != 0) temp |= UARTCTRL_SBK; - lpuart32_write(temp, port->membase + UARTCTRL); + lpuart32_write(port, temp, UARTCTRL); } static void lpuart_setup_watermark(struct lpuart_port *sport) @@ -1157,24 +1158,24 @@ static void lpuart32_setup_watermark(struct lpuart_port *sport) unsigned long val, ctrl; unsigned long ctrl_saved; - ctrl = lpuart32_read(sport->port.membase + UARTCTRL); + ctrl = lpuart32_read(&sport->port, UARTCTRL); ctrl_saved = ctrl; ctrl &= ~(UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_TE | UARTCTRL_RIE | UARTCTRL_RE); - lpuart32_write(ctrl, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, ctrl, UARTCTRL); /* enable FIFO mode */ - val = lpuart32_read(sport->port.membase + UARTFIFO); + val = lpuart32_read(&sport->port, UARTFIFO); val |= UARTFIFO_TXFE | UARTFIFO_RXFE; val |= UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH; - lpuart32_write(val, sport->port.membase + UARTFIFO); + lpuart32_write(&sport->port, val, UARTFIFO); /* set the watermark */ val = (0x1 << UARTWATER_RXWATER_OFF) | (0x0 << UARTWATER_TXWATER_OFF); - lpuart32_write(val, sport->port.membase + UARTWATER); + lpuart32_write(&sport->port, val, UARTWATER); /* Restore cr2 */ - lpuart32_write(ctrl_saved, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, ctrl_saved, UARTCTRL); } static void rx_dma_timer_init(struct lpuart_port *sport) @@ -1250,7 +1251,7 @@ static int lpuart32_startup(struct uart_port *port) unsigned long temp; /* determine FIFO size */ - temp = lpuart32_read(sport->port.membase + UARTFIFO); + temp = lpuart32_read(&sport->port, UARTFIFO); sport->txfifo_size = 0x1 << (((temp >> UARTFIFO_TXSIZE_OFF) & UARTFIFO_FIFOSIZE_MASK) - 1); @@ -1267,10 +1268,10 @@ static int lpuart32_startup(struct uart_port *port) lpuart32_setup_watermark(sport); - temp = lpuart32_read(sport->port.membase + UARTCTRL); + temp = lpuart32_read(&sport->port, UARTCTRL); temp |= (UARTCTRL_RIE | UARTCTRL_TIE | UARTCTRL_RE | UARTCTRL_TE); temp |= UARTCTRL_ILIE; - lpuart32_write(temp, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, temp, UARTCTRL); spin_unlock_irqrestore(&sport->port.lock, flags); return 0; @@ -1319,10 +1320,10 @@ static void lpuart32_shutdown(struct uart_port *port) spin_lock_irqsave(&port->lock, flags); /* disable Rx/Tx and interrupts */ - temp = lpuart32_read(port->membase + UARTCTRL); + temp = lpuart32_read(port, UARTCTRL); temp &= ~(UARTCTRL_TE | UARTCTRL_RE | UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE); - lpuart32_write(temp, port->membase + UARTCTRL); + lpuart32_write(port, temp, UARTCTRL); spin_unlock_irqrestore(&port->lock, flags); @@ -1497,9 +1498,9 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios, unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; unsigned int sbr; - ctrl = old_ctrl = lpuart32_read(sport->port.membase + UARTCTRL); - bd = lpuart32_read(sport->port.membase + UARTBAUD); - modem = lpuart32_read(sport->port.membase + UARTMODIR); + ctrl = old_ctrl = lpuart32_read(&sport->port, UARTCTRL); + bd = lpuart32_read(&sport->port, UARTBAUD); + modem = lpuart32_read(&sport->port, UARTMODIR); /* * only support CS8 and CS7, and for CS7 must enable PE. * supported mode: @@ -1585,21 +1586,21 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios, uart_update_timeout(port, termios->c_cflag, baud); /* wait transmit engin complete */ - while (!(lpuart32_read(sport->port.membase + UARTSTAT) & UARTSTAT_TC)) + while (!(lpuart32_read(&sport->port, UARTSTAT) & UARTSTAT_TC)) barrier(); /* disable transmit and receive */ - lpuart32_write(old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE), - sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE), + UARTCTRL); sbr = sport->port.uartclk / (16 * baud); bd &= ~UARTBAUD_SBR_MASK; bd |= sbr & UARTBAUD_SBR_MASK; bd |= UARTBAUD_BOTHEDGE; bd &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE); - lpuart32_write(bd, sport->port.membase + UARTBAUD); - lpuart32_write(modem, sport->port.membase + UARTMODIR); - lpuart32_write(ctrl, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, bd, UARTBAUD); + lpuart32_write(&sport->port, modem, UARTMODIR); + lpuart32_write(&sport->port, ctrl, UARTCTRL); /* restore control register */ spin_unlock_irqrestore(&sport->port.lock, flags); @@ -1702,10 +1703,10 @@ static void lpuart_console_putchar(struct uart_port *port, int ch) static void lpuart32_console_putchar(struct uart_port *port, int ch) { - while (!(lpuart32_read(port->membase + UARTSTAT) & UARTSTAT_TDRE)) + while (!(lpuart32_read(port, UARTSTAT) & UARTSTAT_TDRE)) barrier(); - lpuart32_write(ch, port->membase + UARTDATA); + lpuart32_write(port, ch, UARTDATA); } static void @@ -1753,18 +1754,18 @@ lpuart32_console_write(struct console *co, const char *s, unsigned int count) spin_lock_irqsave(&sport->port.lock, flags); /* first save CR2 and then disable interrupts */ - cr = old_cr = lpuart32_read(sport->port.membase + UARTCTRL); + cr = old_cr = lpuart32_read(&sport->port, UARTCTRL); cr |= (UARTCTRL_TE | UARTCTRL_RE); cr &= ~(UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE); - lpuart32_write(cr, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, cr, UARTCTRL); uart_console_write(&sport->port, s, count, lpuart32_console_putchar); /* wait for transmitter finish complete and restore CR2 */ - while (!(lpuart32_read(sport->port.membase + UARTSTAT) & UARTSTAT_TC)) + while (!(lpuart32_read(&sport->port, UARTSTAT) & UARTSTAT_TC)) barrier(); - lpuart32_write(old_cr, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, old_cr, UARTCTRL); if (locked) spin_unlock_irqrestore(&sport->port.lock, flags); @@ -1830,14 +1831,14 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud, unsigned long cr, bd; unsigned int sbr, uartclk, baud_raw; - cr = lpuart32_read(sport->port.membase + UARTCTRL); + cr = lpuart32_read(&sport->port, UARTCTRL); cr &= UARTCTRL_TE | UARTCTRL_RE; if (!cr) return; /* ok, the port was enabled */ - cr = lpuart32_read(sport->port.membase + UARTCTRL); + cr = lpuart32_read(&sport->port, UARTCTRL); *parity = 'n'; if (cr & UARTCTRL_PE) { @@ -1852,7 +1853,7 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud, else *bits = 8; - bd = lpuart32_read(sport->port.membase + UARTBAUD); + bd = lpuart32_read(&sport->port, UARTBAUD); bd &= UARTBAUD_SBR_MASK; sbr = bd; uartclk = clk_get_rate(sport->clk); @@ -2096,9 +2097,9 @@ static int lpuart_suspend(struct device *dev) if (sport->port.iotype & UPIO_MEM32BE) { /* disable Rx/Tx and interrupts */ - temp = lpuart32_read(sport->port.membase + UARTCTRL); + temp = lpuart32_read(&sport->port, UARTCTRL); temp &= ~(UARTCTRL_TE | UARTCTRL_TIE | UARTCTRL_TCIE); - lpuart32_write(temp, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, temp, UARTCTRL); } else { /* disable Rx/Tx and interrupts */ temp = readb(sport->port.membase + UARTCR2); @@ -2147,10 +2148,10 @@ static int lpuart_resume(struct device *dev) if (sport->port.iotype & UPIO_MEM32BE) { lpuart32_setup_watermark(sport); - temp = lpuart32_read(sport->port.membase + UARTCTRL); + temp = lpuart32_read(&sport->port, UARTCTRL); temp |= (UARTCTRL_RIE | UARTCTRL_TIE | UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE); - lpuart32_write(temp, sport->port.membase + UARTCTRL); + lpuart32_write(&sport->port, temp, UARTCTRL); } else { lpuart_setup_watermark(sport); temp = readb(sport->port.membase + UARTCR2); -- 2.7.4