From patchwork Sun May 10 14:47:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Zhiqiang X-Patchwork-Id: 6371801 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 00B37BEEE1 for ; Sun, 10 May 2015 14:51:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 130FE203AB for ; Sun, 10 May 2015 14:51:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E0404203A9 for ; Sun, 10 May 2015 14:51:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751288AbbEJOvV (ORCPT ); Sun, 10 May 2015 10:51:21 -0400 Received: from mail-by2on0103.outbound.protection.outlook.com ([207.46.100.103]:27465 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750906AbbEJOvU (ORCPT ); Sun, 10 May 2015 10:51:20 -0400 Received: from BLUPR0301CA0038.namprd03.prod.outlook.com (25.162.113.176) by BY1PR0301MB1256.namprd03.prod.outlook.com (25.161.203.28) with Microsoft SMTP Server (TLS) id 15.1.148.16; Sun, 10 May 2015 14:51:18 +0000 Received: from BL2FFO11FD010.protection.gbl (2a01:111:f400:7c09::100) by BLUPR0301CA0038.outlook.office365.com (2a01:111:e400:5259::48) with Microsoft SMTP Server (TLS) id 15.1.160.16 via Frontend Transport; Sun, 10 May 2015 14:51:17 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD010.mail.protection.outlook.com (10.173.161.16) with Microsoft SMTP Server (TLS) id 15.1.160.8 via Frontend Transport; Sun, 10 May 2015 14:51:17 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t4AEpACa023336; Sun, 10 May 2015 07:51:15 -0700 From: Zhiqiang Hou To: CC: , , Hou Zhiqiang Subject: [PATCH 3/3] spi/fsl-espi: Add the 4Byte address width device support Date: Sun, 10 May 2015 22:47:33 +0800 Message-ID: <1431269253-22890-3-git-send-email-B48286@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1431269253-22890-1-git-send-email-B48286@freescale.com> References: <1431269253-22890-1-git-send-email-B48286@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(77096005)(85426001)(110136002)(5001960100002)(2351001)(19580395003)(92566002)(36756003)(46102003)(19580405001)(107886002)(50466002)(105606002)(50226001)(77156002)(62966003)(48376002)(229853001)(106466001)(87936001)(47776003)(104016003)(189998001)(2950100001)(6806004)(575784001)(50986999)(86362001)(76176999)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR0301MB1256; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1256; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY1PR0301MB1256; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0301MB1256; X-Forefront-PRVS: 05724A8921 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2015 14:51:17.7138 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB1256 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hou Zhiqiang Get the address width information from the spi_message to correct the address to operate. when the one-time transfer length exceed the max limited length of eSPI controller 0xFFFF, for the subsequent transfer, the address to operate need to be corrected. Signed-off-by: Hou Zhiqiang --- drivers/spi/spi-fsl-espi.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index d0a73a0..59931d3 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -250,19 +250,31 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) return mpc8xxx_spi->count; } -static inline void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) +static inline void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd, u8 addr_width) { if (cmd) { - cmd[1] = (u8)(addr >> 16); - cmd[2] = (u8)(addr >> 8); - cmd[3] = (u8)(addr >> 0); + if (addr_width == 3) { + cmd[1] = (u8)(addr >> 16); + cmd[2] = (u8)(addr >> 8); + cmd[3] = (u8)(addr >> 0); + } else if (addr_width == 4) { + cmd[1] = (u8)(addr >> 24); + cmd[2] = (u8)(addr >> 16); + cmd[3] = (u8)(addr >> 8); + cmd[4] = (u8)(addr >> 0); + } } } -static inline unsigned int fsl_espi_cmd2addr(u8 *cmd) +static inline unsigned int fsl_espi_cmd2addr(u8 *cmd, u8 addr_width) { - if (cmd) - return cmd[1] << 16 | cmd[2] << 8 | cmd[3] << 0; + if (cmd) { + if (addr_width == 3) + return cmd[1] << 16 | cmd[2] << 8 | cmd[3] << 0; + else if (addr_width == 4) + return cmd[1] << 24 | cmd[2] << 16 + | cmd[3] << 8 | cmd[4] << 0; + } return 0; } @@ -367,7 +379,9 @@ static void fsl_espi_rw_trans(struct spi_message *m, unsigned int trans_len; unsigned int addr; int i, pos, loop; + u8 addr_width; + addr_width = m->addr_width; local_buf = kzalloc(SPCOM_TRANLEN_MAX, GFP_KERNEL); if (!local_buf) { espi_trans->status = -ENOMEM; @@ -388,9 +402,9 @@ static void fsl_espi_rw_trans(struct spi_message *m, } if (pos > 0) { - addr = fsl_espi_cmd2addr(local_buf); + addr = fsl_espi_cmd2addr(local_buf, addr_width); addr += pos; - fsl_espi_addr2cmd(addr, local_buf); + fsl_espi_addr2cmd(addr, local_buf, addr_width); } espi_trans->n_tx = n_tx;