Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3318992imu; Sun, 11 Nov 2018 12:16:04 -0800 (PST) X-Google-Smtp-Source: AJdET5dqiyjjfHYGB2nG/k8/xjiGX49C2ABnyZuUmHwZHAqFEJ9tE8MagQI6fyPj5ElIZMd9dKP2 X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr17297095pln.340.1541967364207; Sun, 11 Nov 2018 12:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967364; cv=none; d=google.com; s=arc-20160816; b=QWBjhL2KyHKnlXzUKiqkvrdNOb4RlMQJlgze11qb0MD70YZ/JgOfqJJZHvX0MjOHbJ gr8KL5SKNdb249r5R1pWOkSLtGd90ZnUIPxfXXjaobPs4t1rk+aOtO/tFsqLc3mO0DSe Os1JseNNUjMLTrBK1kTmgSmI1MDNKWaLlASXnxSXny00Ln7WjRV9TnbNZhC5qsHDo4iA yIeOr9k+n7EzWC+tQLxe9joHLOgcREZKcC5+eM+iQwBr4WTE+xcnFLYJjXknMFHmEajG jKk14Qgg6gZJcq4X6w4R38vR+9wIA1eI4aZuPbTrXELd/NUYH8tbbzJk5Zh6gkWgRp3c NIJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=/DuNhpylwvoLu0RpBnta7BYaVN6ZR5LgPjmD8WO513Q=; b=FzdmtKANXUMYA5JBC2TGGRh0p66pvb0ctGLkrg8EHk1VcC5ymfAndN0avfW0Z6YNT6 RaI8kvqpX5O9Mn9r3uN5PsFjhnbCYcBo59+uF1cOWusEStUHYJy1G+D+W19+uONkK27b Dv+8uBx6w03IrRFKRd0+FP/K5eJbddYN+8M3/aBKCWY21zmrwpUkYsdkEqzbvs7CqQ+4 VATJUBQsRIg32jWCM1BVom19xOB0JqiftA4dr0/MjAz548HpOZnARKyP0vrewBD1eRkB Tg0ZsxB8WBztx06Kv7XJbFgHQEG0XlKGZ03oihP6MqFUuvEW0MVc5lIZY/QHeJi533cg ZkXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t126-v6si16728509pfd.133.2018.11.11.12.15.48; Sun, 11 Nov 2018 12:16:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731760AbeKLGE7 (ORCPT + 99 others); Mon, 12 Nov 2018 01:04:59 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:53006 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729567AbeKLGE6 (ORCPT ); Mon, 12 Nov 2018 01:04:58 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsz-0000oP-OM; Sun, 11 Nov 2018 19:59:09 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsS-0001Z8-OO; Sun, 11 Nov 2018 19:58:36 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Boris Brezillon" , "Martin Kaiser" , "Sascha Hauer" , "Miquel Raynal" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 152/366] mtd: rawnand: mxc: set spare area size register explicitly In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Martin Kaiser commit 3f77f244d8ec28e3a0a81240ffac7d626390060c upstream. The v21 version of the NAND flash controller contains a Spare Area Size Register (SPAS) at offset 0x10. Its setting defaults to the maximum spare area size of 218 bytes. The size that is set in this register is used by the controller when it calculates the ECC bytes internally in hardware. Usually, this register is updated from settings in the IIM fuses when the system is booting from NAND flash. For other boot media, however, the SPAS register remains at the default setting, which may not work for the particular flash chip on the board. The same goes for flash chips whose configuration cannot be set in the IIM fuses (e.g. chips with 2k sector size and 128 bytes spare area size can't be configured in the IIM fuses on imx25 systems). Set the SPAS register explicitly during the preset operation. Derive the register value from mtd->oobsize that was detected during probe by decoding the flash chip's ID bytes. While at it, rename the define for the spare area register's offset to NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is different from the register on v21 controllers. Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset") Signed-off-by: Martin Kaiser Reviewed-by: Sascha Hauer Reviewed-by: Miquel Raynal Signed-off-by: Boris Brezillon [bwh: Backported to 3.16: adjust filename] Signed-off-by: Ben Hutchings --- drivers/mtd/nand/mxc_nand.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -49,7 +49,7 @@ #define NFC_V1_V2_CONFIG (host->regs + 0x0a) #define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c) #define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e) -#define NFC_V1_V2_RSLTSPARE_AREA (host->regs + 0x10) +#define NFC_V21_RSLTSPARE_AREA (host->regs + 0x10) #define NFC_V1_V2_WRPROT (host->regs + 0x12) #define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14) #define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16) @@ -958,6 +958,9 @@ static void preset_v2(struct mtd_info *m writew(config1, NFC_V1_V2_CONFIG1); /* preset operation */ + /* spare area size in 16-bit half-words */ + writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA); + /* Unlock the internal RAM Buffer */ writew(0x2, NFC_V1_V2_CONFIG);