From patchwork Wed Jan 18 12:10:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastien Decourriere X-Patchwork-Id: 716611 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v3QmW08XMz9sf9 for ; Wed, 18 Jan 2017 23:11:07 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jIuK8byR"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cTp4w-0005WM-IJ; Wed, 18 Jan 2017 12:11:02 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTp4t-0005UN-6D for linux-mtd@lists.infradead.org; Wed, 18 Jan 2017 12:11:00 +0000 Received: by mail-wm0-x242.google.com with SMTP id r126so3601479wmr.3 for ; Wed, 18 Jan 2017 04:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+yZK+udrb20r3JQLVEDlmnKB8CXSbjH/85IkOhXworE=; b=jIuK8byRNZVimYmBYZyldpFxGEXBeb1vEn9DhUauzGkf1g0RngphtOA8mfZGTMKa+4 k6VLpkHnd1UlvHRD7zaezTxEhN4aE7JQXrHwz/SLePvxkeS0yAvCwmEWQP4FZordCjD5 z7UM6gfdb8Wyf91U7vfWqqgNVNlWlQOpyGeRURoafkZ8ACLupub+EMrC2O0atOYtRgYN bts4WkkV8nhnnHc+kFwnDkZlFU4E3v8tCGscEJtHMeWCOQWWLwMdZMYXkO4R26EOHydl 9wtO+/JOHCixaWIV1uSCDKqnToD1lBG3yqcpR1nJTnXqJxJf7K5+KqJnDTRjJaI7LJXB y9Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+yZK+udrb20r3JQLVEDlmnKB8CXSbjH/85IkOhXworE=; b=NceSxJZejMhDyYfFmy6kFqVkNtPp6W87hEAx2iY2gftz7R5y5DBYuWWFwDVMJwvx/P zDVrK16ua/klmXK/+45BeziDvYC0QZcn2g79n7Cwg/DGX/KTkeu58+rj3fgZ2mw6XnOL 2Z34TcV1t3Yv1+P48xGfeh2gaJvtPMwsJ9CLxCi75sKnPBcXoRsBRsvh6ijDLX+uAVhE yjE+joRIaZDZ7bN3YD/9DXAB+WhNczuXBCQciVh+h/a1ST3K2FU2bb4w/TMZaV+dqqMJ sDEQ4Crl4bd8nNTWl7SWtkhGEh29+C8uVPQIyUfQuIjuwcDs+RUPh0VO0jCrhQmWQqyN nv0w== X-Gm-Message-State: AIkVDXJQ0Wjrex7Mft68QjUFOB12LzN7l/Z29ChpcktClkYMvbyRL8mFZrBGmmQIhf9HmA== X-Received: by 10.28.129.147 with SMTP id c141mr22078994wmd.12.1484741436901; Wed, 18 Jan 2017 04:10:36 -0800 (PST) Received: from serveurQA.phonesystems.net ([62.39.136.157]) by smtp.gmail.com with ESMTPSA id c81sm4402922wmf.22.2017.01.18.04.10.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jan 2017 04:10:36 -0800 (PST) From: Sebastien Decourriere To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: maps: lantiq-flash: Check if the EBU endianness swap is enabled Date: Wed, 18 Jan 2017 13:10:52 +0100 Message-Id: <1484741452-27141-1-git-send-email-sebtx452@gmail.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170118_041059_393254_CFE8E0C1 X-CRM114-Status: GOOD ( 11.81 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:242 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (sebtx452[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (sebtx452[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Sebastien Decourriere MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The purpose of this patch is to enable the software address endianness swapping only when the in SoC EBU endianness swapping is disabled. To perform this check, I look at Bit 30 of the EBU_CON_0 register. Actually, the driver expects that the in SoC swapping is disabled. This is the case with current bootloaders shuch as U-boot. But, I have a router which uses a proprietary bootloader which keeps the in SoC swapping enabled. The SoC in this router is a vrx200 v1.2. In this SoC version, I can keep the in SoC swapping without any problem. Signed-off-by: Sebastien Decourriere --- drivers/mtd/maps/lantiq-flash.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c index c8febb3..a091efa 100644 --- a/drivers/mtd/maps/lantiq-flash.c +++ b/drivers/mtd/maps/lantiq-flash.c @@ -151,6 +151,11 @@ ltq_mtd_probe(struct platform_device *pdev) ltq_mtd->map->copy_to = ltq_copy_to; ltq_mtd->map->map_priv_1 = LTQ_NOR_PROBING; + /* We swap the addresses only if the EBU endianness swap is disabled */ + if (ltq_ebu_r32(LTQ_EBU_BUSCON0) & BIT(30)) + ltq_mtd->map[i].map_priv_1 = LTQ_NOR_NORMAL; + else + ltq_mtd->map[i].map_priv_1 = LTQ_NOR_PROBING; ltq_mtd->mtd = do_map_probe("cfi_probe", ltq_mtd->map); ltq_mtd->map->map_priv_1 = LTQ_NOR_NORMAL; @@ -163,8 +168,11 @@ ltq_mtd_probe(struct platform_device *pdev) mtd_set_of_node(ltq_mtd->mtd, pdev->dev.of_node); cfi = ltq_mtd->map->fldrv_priv; - cfi->addr_unlock1 ^= 1; - cfi->addr_unlock2 ^= 1; + /* We swap the addresses only if the EBU endianness swap is disabled */ + if (!(ltq_ebu_r32(LTQ_EBU_BUSCON0) & BIT(30))) { + cfi->addr_unlock1 ^= 1; + cfi->addr_unlock2 ^= 1; + } err = mtd_device_register(ltq_mtd->mtd, NULL, 0); if (err) {