From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753293AbdEIHvc (ORCPT ); Tue, 9 May 2017 03:51:32 -0400 Received: from mail-by2nam03on0088.outbound.protection.outlook.com ([104.47.42.88]:3232 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752864AbdEIHv0 (ORCPT ); Tue, 9 May 2017 03:51:26 -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 4/6] tty: serial: lpuart: add imx7ulp support Date: Tue, 9 May 2017 15:50:46 +0800 Message-ID: <1494316248-24052-5-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494316248-24052-1-git-send-email-aisheng.dong@nxp.com> References: <1494316248-24052-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131387898829839235;(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)(39450400003)(39860400002)(39850400002)(39840400002)(39410400002)(39380400002)(39400400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(9170700003)(5003940100001)(85426001)(5660300001)(189998001)(54906002)(76176999)(8656002)(81166006)(50986999)(7416002)(47776003)(50226002)(498600001)(8676002)(4326008)(48376002)(356003)(36756003)(104016004)(86362001)(77096006)(50466002)(6916009)(6666003)(2950100002)(305945005)(105606002)(106466001)(8936002)(53936002)(38730400002)(33646002)(110136004)(2906002)(2351001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0301MB0899;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD045;1:F+5A+b18qQFab6WANYrQ3AkgeHPg9QObod6p44xcyggZkHO7q5tToiNPaxqLbQ4hnike4+CfcfcmvirfKdVOSGsmFumOSm0RawU3TFHFdu7732gWqzHsJOArd2UuOBJy2W5idWJZA+VyhC7wPmyfwV0POahhZWHkpp5exj8XNeP5N3Hr3T+yXyja0U+wJKsoh/xOIWPqBkbq58EHFpAXdOjMBGmtydbqEEthDQFF5Lx+9Q8AqHK3+rI5w3e7zGHY05p0Ec7mgRCdydUWL5g20wA5UDty+DdQPDUPmOPSaIfNrTyGBbx3J/4uq+a58RValRbt/niiZspqCooRg+F/d+cTcJ5q5fQeh086Na6uIszPr862haOVH/ET3LzCMNmIHuJ/c4JGUa6WauRt5dZ4X1uk+aWtgCe56q6ZzUNHkLUlyOgGrZ//Ir8W1LXENfp7mdlsbY89+Gjvt5PaNyzpBdx350iehj3PxdgTX6bCB1aXZFDrH5StukzhV/2N6LxnfBitAYFNHGbM/U9Ajqjs3RTzTCw4gmH5AXQByKK+Q4kbSmGiGYV76ELg4vAP5ExlKwSZlcFRf1aUYgryEKT48YIky6dv7t9YXDtBuCJ9eu8TgpW6gPWY63mq4WH1n2JReIFuVorTWx78y8AqEz8Tw9+iiVrahPJgb+HAlpbuFW638ZD7qGK6Xmi5gk2VVLJTU44uypKK/a85DYw1NHzu+z9aVEfhrFSmP6oatwverpc= MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4a4a9726-fe73-4d0c-9093-08d496b02fed X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:BN3PR0301MB0899; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB0899;3:9RH9lNso6FKOX0kJq6KcToiwvs4sP8jt4/gQ/jAJ899Lt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KzQpXwytISS9aLefSLOxmQuN26l4ufDFwT7HauJUC9N5Ubf0Jllx0hy1faOdQ6msTae9gMxXEFkvwcYlwHF31sS3UuOaPJaJ/7BgeBNJOZ8t96sMdFcohWas= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(13023025)(13024025)(8121501046)(13018025)(5005006)(13015025)(13017025)(93006095)(93001095)(3002001)(10201501046)(6055026)(6096035)(20161123556025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123559100)(20161123565025)(20161123561025)(20161123563025);SRVR:BN3PR0301MB0899;BCL:0;PCL:0;RULEID:(400006);SRVR:BN3PR0301MB0899; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0301MB0899;4:ec0+dtFsUAKf1QtI6uHg+MmPKFP1QPlR2qJEEbyt?= =?us-ascii?Q?z6N5ZznHNvtRn/bMQnyNYKBn1Gs23mDtdHyjjFiuSW8mTYbpanCey5cgHzz8?= =?us-ascii?Q?l1wHHPBlXwSL3OyBRld/1u3mf3UMMGjXKwZYWZRoaZtxngzDAykS9XmuW5iE?= =?us-ascii?Q?/dcgDgkZpvr5RU51iX5LtXIA/PQ+hrnRzLUiVYOybFWa49A1qn799vQWmb6n?= =?us-ascii?Q?DhfLS8/z7sSAIfj/yUqcvcuVaEJSodFXY+QlK+6Q9ZTHgWfSH4kclmw4bCOz?= =?us-ascii?Q?YcRe3tt9aaJsYg/OhTSHXnCbWBPvbjcDzT/60wB2tdsYUUB9TW1fxlKVFG1J?= =?us-ascii?Q?J6SHLiYSDmBsSddR1U4kA7fhrWjmaD/sXptWFAm2XZHq8wd0/9SFhToImfUb?= =?us-ascii?Q?yCCKfvACTvK3IBL2H/0hAr7hhEj3uqzsnayP7iWDdhmS7ufEm8xPo+6P8MIk?= =?us-ascii?Q?h0NnAAUdVB2KXaUDSzOTxBlgrwpAec7OZznZyQPh/cH94pPe/lJZsgLn8i4K?= =?us-ascii?Q?kItN3WiVVYL+Fb0Tip8ywbth6BwYOR4V58RFcEtPsVPM01YZ1OBwiLhBuZ83?= =?us-ascii?Q?IUurLXEx1Uv5msyB20GG7PztZfjAYUWXOc4nyYTy/yngNx5nAZt27/VY5ZPG?= =?us-ascii?Q?/sagS5cKDquycor+RZXGciiJ1/QylNg1wXiK1ELOjv5LOzKVdA6HWoDWhLnA?= =?us-ascii?Q?vlLibK7bfD2SYkaz8UzKr0mcRJTh1baqEJoPaxnFwekJBq9pO3v5Q0Des9Ay?= =?us-ascii?Q?FuQ1IsvY2301tQe9vi2i7ZhosFjfR+zwyZ/5vhY68pfLDQjMSpTa2SspW/6X?= =?us-ascii?Q?cdFxxdkcDpCjR7ajBb/Hkp7yzWEvdih5bgBtzaeq6R+wRiRc1yMb71msStXK?= =?us-ascii?Q?QJWncSZMryIpm8o7cS/tUC0ouqvqh5rXV7EkU6dQsiua/3ASZw8CG69mvBIt?= =?us-ascii?Q?Wyd7hCsZEzG+mSZvM1AmxRB/HXVnsA6Xpd5uEQxZqA=3D=3D?= X-Forefront-PRVS: 0302D4F392 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0301MB0899;23:/prtHQELz0WiCssF+iPY5KJFG0LWg3LDYQdn9OD?= =?us-ascii?Q?idZm12TUKZsixs/yROe7Aa7CDbLcJlNNPw43Nd2jhNJRLesBKvf2WZDVfFYU?= =?us-ascii?Q?zXGsSATzt9KZlo56Z0sJjqg+yQbSRR/BycHZMDYRgaKfxBQ/DAwmOveTg2Dd?= =?us-ascii?Q?k6rr8wCXapXJh1uutSAhc1li5++TELgrQ5IXhIoDYL1J8uAipLH7/61edWom?= =?us-ascii?Q?7DJdPJuFQc40tpLv9kmdPYgt71FFi/QVQrIRCOucJmtBiJtemr7raEdHfEL5?= =?us-ascii?Q?3y1IXs7pDEeNDKneTNxwr4Lw+XC3TQOlPmJaVfZwjDHMqC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zwpCJOLEQfx95ijleLjWpMuZKaVqHwjGLJU4vrW6SAGuwzi2qIaBw?= =?us-ascii?Q?wxtVNyChe8Kmt9LL8Miw=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB0899;6:0QlPAyy+qRzKA888Ra/s/fd7HbwSSto9mq+BSh8OOm8Zf+dgISzzU9qxhqstqUoBdPWtDR4NZtrMNOnwB06M9NV0KsywO9bvnXJ//8w2TzUzQBKvVeRyWMkUFnKTRXBoguafdv/9flDmQfKHfjYAlF/UzRb+20TQjENbCsBoDo6tCzl1HfGzxRl7bAxw4rD8fN6ueO8chNuHfcsu/lTnYyiGXYSFtf/EuV75diyCCJHCchccvTXKYqfAM4WAroihR9A+rZc7nwZn+3D8LLO+ONv6aUVpGS2+IvLkRkzgwyhpVwybrHhAyA1k1m1wBetcLIEwizqINZ/5dGpf0mrXZwXif0EmMhOjgpNpH40lxoiYnE2qsKuwytK0jRPfEKjQMYqOEJr4g+XY095RJ5dxvpuyWJB6IPqwHvszAsYs23h6eG71upiW2Jopy1+ERGv6bRThfvND7H+1E6mxFC/DSUhIkNfw+Imtj/kr2zXmBcED9qNX2DUEGh9YIuiQUygx;5:kCAEfkVHD3jIIffl5syhfTzQjqxdE7M3+wDo0eNAoD6tTYsXhypOHPW29CemAdZ65DZ7njHwA3jBFl6gaHcC1JqMFpKhm7LNyS5ebvjPg+jlfYIbT1CPc09VUBjYt1b0LIzBByfrDGTQpbvDfnoaHhF3g3IceK3w1GZgeIY/nr+8+qf0uER63AvVDMiKUKcw;24:hZZeuWRIYLHsACsziZwfLauyB5/PZrri0Awv++AEaLIoKrGagCxqKnq9dAhs43EAGFffjh9aG14HyjzawnnEJYfanEJRFhc45AKhSws1q7o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB0899;7:R+DwjUwqtX14iGr2rVeciirGJVnkb2C1gCQT6fNNhN70KXB0gUevhWmSIhiOJKWrazw6YUQQXPeWferND3tF93JZv7y0cUjPsG5lFXlvX7lKjZczBBHc57BYhoVV089qVgnLvku0XH+tgpr1rMUPEJnIUe4wagFwieWFdxdHp4jmQ7gBHpnMUBjOC2zsvA+m5Qd3JtNBhnZkIpxJVi6XPvZ5onfPvPsYGRRKnVTCDCsunDV9bRH2BcFB9UaWwTSkWKa54UItBF2QAAW6tT1URcIxC2gL59tQkvAoBjMePdn0TAYBoao0P7NxJsEpqcUYLsOhiDEWjznPqOybtTf7BA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2017 07:51:19.1307 (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: BN3PR0301MB0899 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The lpuart of imx7ulp is basically the same as ls1021a. It's also 32 bit width register, but unlike ls1021a, it's little endian. Besides that, imx7ulp lpuart has a minor different register layout from ls1021a that it has four extra registers (verid, param, global, pincfg) located at the beginning of register map, which are currently not used by the driver and less to be used later. To ease the register difference handling, we add a reg_off member in lpuart_soc_data structure to represent if the normal lpuart32_{read|write} requires plus a offset to hide the issue. Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Fugang Duan Cc: Stefan Agner Cc: Mingkai Hu Cc: Yangbo Lu Signed-off-by: Dong Aisheng --- drivers/tty/serial/fsl_lpuart.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index bddd041..1cdb3f9 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -231,7 +231,11 @@ #define DEV_NAME "ttyLP" #define UART_NR 6 +/* IMX lpuart has four extra unused regs located at the beginning */ +#define IMX_REG_OFF 0x10 + static bool lpuart_is_be; +static u8 lpuart_reg_off; struct lpuart_port { struct uart_port port; @@ -263,6 +267,7 @@ struct lpuart_port { struct lpuart_soc_data { bool is_32; bool is_be; + u8 reg_off; }; static struct lpuart_soc_data vf_data = { @@ -272,11 +277,19 @@ static struct lpuart_soc_data vf_data = { static struct lpuart_soc_data ls_data = { .is_32 = true, .is_be = true, + .reg_off = 0x0, +}; + +static struct lpuart_soc_data imx_data = { + .is_32 = true, + .is_be = false, + .reg_off = IMX_REG_OFF, }; static const struct of_device_id lpuart_dt_ids[] = { { .compatible = "fsl,vf610-lpuart", .data = &vf_data, }, { .compatible = "fsl,ls1021a-lpuart", .data = &ls_data, }, + { .compatible = "fsl,imx7ulp-lpuart", .data = &imx_data, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, lpuart_dt_ids); @@ -286,15 +299,16 @@ static void lpuart_dma_tx_complete(void *arg); static u32 lpuart32_read(void __iomem *addr) { - return lpuart_is_be ? ioread32be(addr) : readl(addr); + return lpuart_is_be ? ioread32be(addr + lpuart_reg_off) : + readl(addr + lpuart_reg_off); } static void lpuart32_write(u32 val, void __iomem *addr) { if (lpuart_is_be) - iowrite32be(val, addr); + iowrite32be(val, addr + lpuart_reg_off); else - writel(val, addr); + writel(val, addr + lpuart_reg_off); } static void lpuart_stop_tx(struct uart_port *port) @@ -2008,6 +2022,7 @@ static int lpuart_probe(struct platform_device *pdev) sport->port.line = ret; sport->lpuart32 = sdata->is_32; lpuart_is_be = sdata->is_be; + lpuart_reg_off = sdata->reg_off; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sport->port.membase = devm_ioremap_resource(&pdev->dev, res); -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dong Aisheng Subject: [PATCH 4/6] tty: serial: lpuart: add imx7ulp support Date: Tue, 9 May 2017 15:50:46 +0800 Message-ID: <1494316248-24052-5-git-send-email-aisheng.dong@nxp.com> References: <1494316248-24052-1-git-send-email-aisheng.dong@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1494316248-24052-1-git-send-email-aisheng.dong@nxp.com> Sender: linux-kernel-owner@vger.kernel.org To: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org, jslaby@suse.com, fugang.duan@nxp.com, stefan@agner.ch, Mingkai.Hu@nxp.com, yangbo.lu@nxp.com, Dong Aisheng List-Id: linux-serial@vger.kernel.org The lpuart of imx7ulp is basically the same as ls1021a. It's also 32 bit width register, but unlike ls1021a, it's little endian. Besides that, imx7ulp lpuart has a minor different register layout from ls1021a that it has four extra registers (verid, param, global, pincfg) located at the beginning of register map, which are currently not used by the driver and less to be used later. To ease the register difference handling, we add a reg_off member in lpuart_soc_data structure to represent if the normal lpuart32_{read|write} requires plus a offset to hide the issue. Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Fugang Duan Cc: Stefan Agner Cc: Mingkai Hu Cc: Yangbo Lu Signed-off-by: Dong Aisheng --- drivers/tty/serial/fsl_lpuart.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index bddd041..1cdb3f9 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -231,7 +231,11 @@ #define DEV_NAME "ttyLP" #define UART_NR 6 +/* IMX lpuart has four extra unused regs located at the beginning */ +#define IMX_REG_OFF 0x10 + static bool lpuart_is_be; +static u8 lpuart_reg_off; struct lpuart_port { struct uart_port port; @@ -263,6 +267,7 @@ struct lpuart_port { struct lpuart_soc_data { bool is_32; bool is_be; + u8 reg_off; }; static struct lpuart_soc_data vf_data = { @@ -272,11 +277,19 @@ static struct lpuart_soc_data vf_data = { static struct lpuart_soc_data ls_data = { .is_32 = true, .is_be = true, + .reg_off = 0x0, +}; + +static struct lpuart_soc_data imx_data = { + .is_32 = true, + .is_be = false, + .reg_off = IMX_REG_OFF, }; static const struct of_device_id lpuart_dt_ids[] = { { .compatible = "fsl,vf610-lpuart", .data = &vf_data, }, { .compatible = "fsl,ls1021a-lpuart", .data = &ls_data, }, + { .compatible = "fsl,imx7ulp-lpuart", .data = &imx_data, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, lpuart_dt_ids); @@ -286,15 +299,16 @@ static void lpuart_dma_tx_complete(void *arg); static u32 lpuart32_read(void __iomem *addr) { - return lpuart_is_be ? ioread32be(addr) : readl(addr); + return lpuart_is_be ? ioread32be(addr + lpuart_reg_off) : + readl(addr + lpuart_reg_off); } static void lpuart32_write(u32 val, void __iomem *addr) { if (lpuart_is_be) - iowrite32be(val, addr); + iowrite32be(val, addr + lpuart_reg_off); else - writel(val, addr); + writel(val, addr + lpuart_reg_off); } static void lpuart_stop_tx(struct uart_port *port) @@ -2008,6 +2022,7 @@ static int lpuart_probe(struct platform_device *pdev) sport->port.line = ret; sport->lpuart32 = sdata->is_32; lpuart_is_be = sdata->is_be; + lpuart_reg_off = sdata->reg_off; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sport->port.membase = devm_ioremap_resource(&pdev->dev, res); -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: aisheng.dong@nxp.com (Dong Aisheng) Date: Tue, 9 May 2017 15:50:46 +0800 Subject: [PATCH 4/6] tty: serial: lpuart: add imx7ulp support In-Reply-To: <1494316248-24052-1-git-send-email-aisheng.dong@nxp.com> References: <1494316248-24052-1-git-send-email-aisheng.dong@nxp.com> Message-ID: <1494316248-24052-5-git-send-email-aisheng.dong@nxp.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org The lpuart of imx7ulp is basically the same as ls1021a. It's also 32 bit width register, but unlike ls1021a, it's little endian. Besides that, imx7ulp lpuart has a minor different register layout from ls1021a that it has four extra registers (verid, param, global, pincfg) located at the beginning of register map, which are currently not used by the driver and less to be used later. To ease the register difference handling, we add a reg_off member in lpuart_soc_data structure to represent if the normal lpuart32_{read|write} requires plus a offset to hide the issue. Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Fugang Duan Cc: Stefan Agner Cc: Mingkai Hu Cc: Yangbo Lu Signed-off-by: Dong Aisheng --- drivers/tty/serial/fsl_lpuart.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index bddd041..1cdb3f9 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -231,7 +231,11 @@ #define DEV_NAME "ttyLP" #define UART_NR 6 +/* IMX lpuart has four extra unused regs located at the beginning */ +#define IMX_REG_OFF 0x10 + static bool lpuart_is_be; +static u8 lpuart_reg_off; struct lpuart_port { struct uart_port port; @@ -263,6 +267,7 @@ struct lpuart_port { struct lpuart_soc_data { bool is_32; bool is_be; + u8 reg_off; }; static struct lpuart_soc_data vf_data = { @@ -272,11 +277,19 @@ static struct lpuart_soc_data vf_data = { static struct lpuart_soc_data ls_data = { .is_32 = true, .is_be = true, + .reg_off = 0x0, +}; + +static struct lpuart_soc_data imx_data = { + .is_32 = true, + .is_be = false, + .reg_off = IMX_REG_OFF, }; static const struct of_device_id lpuart_dt_ids[] = { { .compatible = "fsl,vf610-lpuart", .data = &vf_data, }, { .compatible = "fsl,ls1021a-lpuart", .data = &ls_data, }, + { .compatible = "fsl,imx7ulp-lpuart", .data = &imx_data, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, lpuart_dt_ids); @@ -286,15 +299,16 @@ static void lpuart_dma_tx_complete(void *arg); static u32 lpuart32_read(void __iomem *addr) { - return lpuart_is_be ? ioread32be(addr) : readl(addr); + return lpuart_is_be ? ioread32be(addr + lpuart_reg_off) : + readl(addr + lpuart_reg_off); } static void lpuart32_write(u32 val, void __iomem *addr) { if (lpuart_is_be) - iowrite32be(val, addr); + iowrite32be(val, addr + lpuart_reg_off); else - writel(val, addr); + writel(val, addr + lpuart_reg_off); } static void lpuart_stop_tx(struct uart_port *port) @@ -2008,6 +2022,7 @@ static int lpuart_probe(struct platform_device *pdev) sport->port.line = ret; sport->lpuart32 = sdata->is_32; lpuart_is_be = sdata->is_be; + lpuart_reg_off = sdata->reg_off; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sport->port.membase = devm_ioremap_resource(&pdev->dev, res); -- 2.7.4