Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2025668imm; Tue, 10 Jul 2018 11:50:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcnq+iPX6PFNuSUaJ9wyjJrL4rsdsBzNyJoSl3aUxUIxa+cRwT7fh9QKdkpRuUBYps7Oloc X-Received: by 2002:a17:902:700a:: with SMTP id y10-v6mr26329651plk.249.1531248648601; Tue, 10 Jul 2018 11:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248648; cv=none; d=google.com; s=arc-20160816; b=vDXO+fPZH0R1xhs4W3jHs41ojMSeDJdsOPcE1hGRIMVVMJ9q47kTwyJbMcXfbY0r3x hsT3lEYK8WW5C3m4uKbcu/vulJcP343qlyCM8yk87/WI2tlZWuDMLj2ZWmhKARdEchjT AzlH+Bor10ljEERsWP0i2fovfEsvP8P1GzR2/7dpF3NzSvXbR2iaWNStw5dUE7RqlYls K57OR4n0QoNK86drDQll4xmrjPMyRASqR5mZXuKWFOU4VNRKwKGiZLAe8DV01pAgPKhX 5SdVfg2DTiVHMVWoCIETLm6fs3ZLVVsPObD5U4zKY22l+pU8aPoZwtuiiljuobvKDkPQ zLVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hqTx14jw451CZeTXZgxYmJ0bSpvdKpCsEbYtcPUARQQ=; b=wqgKZWI3PGQ9+69VmIm+tO3tECVmjzbrjpeFavV7LPT43DhDTZmOddqHEY+C6zFC4X x3m4/bCFQLUaxjzaNSvLAcGKAkmvdUuk2+9WghCRVv2KzzXhpuBB9MoNfPIVkM+6g8TC D9bp9ii3EkarXgcEOsjea5+WJJau6eEj/qoMdiFoo94cRjRt2XFKuCb+8Ka3/tHMzxdw Xr9okVwNUedqseQmKN6Y+G7EZ74AbqZnPc8GaCCZx0Xmk007n2h70LyhsHeGnJjBkZxz CKO9pdzw5sAxDgYkh4qLm/rUz6wPlxI9m3HuMbIau9rjGrvy//DmWtOQhrJhV6547zTr vjqA== 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 d4-v6si15818901pgq.411.2018.07.10.11.50.10; Tue, 10 Jul 2018 11:50:48 -0700 (PDT) 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 S2388300AbeGJSbN (ORCPT + 99 others); Tue, 10 Jul 2018 14:31:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45744 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732920AbeGJSbM (ORCPT ); Tue, 10 Jul 2018 14:31:12 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3EBF9EC2; Tue, 10 Jul 2018 18:31:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Kaiser , Sascha Hauer , Miquel Raynal , Boris Brezillon Subject: [PATCH 4.9 46/52] mtd: rawnand: mxc: set spare area size register explicitly Date: Tue, 10 Jul 2018 20:25:14 +0200 Message-Id: <20180710182453.634860195@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable 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") Cc: stable@vger.kernel.org Signed-off-by: Martin Kaiser Reviewed-by: Sascha Hauer Reviewed-by: Miquel Raynal Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- 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 @@ -48,7 +48,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) @@ -1121,6 +1121,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);