From patchwork Tue Sep 23 17:18:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 4958511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A9E2D9F32F for ; Tue, 23 Sep 2014 17:22:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E87A20149 for ; Tue, 23 Sep 2014 17:22:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A40A42013A for ; Tue, 23 Sep 2014 17:22:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWTl2-0005Ip-Ke; Tue, 23 Sep 2014 17:20:08 +0000 Received: from xes-mad.com ([216.165.139.218]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWTky-00042H-A7 for linux-arm-kernel@lists.infradead.org; Tue, 23 Sep 2014 17:20:05 +0000 Received: from zimbra.xes-mad.com (zimbra.xes-mad.com [10.52.0.127]) by xes-mad.com (8.13.8/8.13.8) with ESMTP id s8NHIeAo001507; Tue, 23 Sep 2014 12:18:40 -0500 Date: Tue, 23 Sep 2014 12:18:40 -0500 (CDT) From: Aaron Sierra To: Imre Kaloz , Krzysztof Halasa Message-ID: <719460394.273364.1411492720358.JavaMail.zimbra@xes-inc.com> In-Reply-To: <786499164.272880.1411492623841.JavaMail.zimbra@xes-inc.com> Subject: [RFT PATCH] mtd: ixp4xx: Unrequire CONFIG_MTD_CFI_BE_BYTE_SWAP MIME-Version: 1.0 X-Originating-IP: [10.52.16.65] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF31 (Linux)/8.0.6_GA_5922) Thread-Topic: ixp4xx: Unrequire CONFIG_MTD_CFI_BE_BYTE_SWAP Thread-Index: 4TWoZKeBa4AIVmOj5YA4S6qGqjDG9Q== X-Virus-Scanned: clamav-milter 0.96 at mail X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140923_102004_584143_B4028523 X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: 0.0 (/) Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The .swap member of the map_info structure is provided for situations where a mapping must always be big or little-endian regardless of the endianness of the system performing the access. Signed-off-by: Aaron Sierra --- drivers/mtd/maps/ixp4xx.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c index 6a589f1..decaefe 100644 --- a/drivers/mtd/maps/ixp4xx.c +++ b/drivers/mtd/maps/ixp4xx.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -48,43 +49,24 @@ * | C | D | 2 * +---+---+ * This means that on LE systems each 16 bit word must be swapped. Note that - * this requires CONFIG_MTD_CFI_BE_BYTE_SWAP to be enabled to 'unswap' the CFI - * data and other flash commands which are always in D7-D0. + * this is accounted for by defining map_info.swap to be CFI_BIG_ENDIAN to + * 'unswap' the CFI commands and using cpu_to_be16/be16_to_cpu to 'unswap' + * the data. */ -#ifndef __ARMEB__ -#ifndef CONFIG_MTD_CFI_BE_BYTE_SWAP -# error CONFIG_MTD_CFI_BE_BYTE_SWAP required -#endif static inline u16 flash_read16(void __iomem *addr) { - return be16_to_cpu(__raw_readw((void __iomem *)((unsigned long)addr ^ 0x2))); + return be16_to_cpu(__raw_readw(addr)); } static inline void flash_write16(u16 d, void __iomem *addr) { - __raw_writew(cpu_to_be16(d), (void __iomem *)((unsigned long)addr ^ 0x2)); + __raw_writew(cpu_to_be16(d), addr); } #define BYTE0(h) ((h) & 0xFF) #define BYTE1(h) (((h) >> 8) & 0xFF) -#else - -static inline u16 flash_read16(const void __iomem *addr) -{ - return __raw_readw(addr); -} - -static inline void flash_write16(u16 d, void __iomem *addr) -{ - __raw_writew(d, addr); -} - -#define BYTE0(h) (((h) >> 8) & 0xFF) -#define BYTE1(h) ((h) & 0xFF) -#endif - static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs) { map_word val; @@ -200,6 +182,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev) * Tell the MTD layer we're not 1:1 mapped so that it does * not attempt to do a direct access on us. */ + info->map.swap = CFI_BIG_ENDIAN; info->map.phys = NO_XIP; info->map.size = resource_size(dev->resource);