From patchwork Wed Mar 8 21:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 660470 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp548306wrb; Wed, 8 Mar 2023 13:29:32 -0800 (PST) X-Google-Smtp-Source: AK7set9IGvH+7QC5K2RzyZFmTFUsuI6WKmAWH8F53E/jubUqWWQVEMBi8bkSdNnYOjYaQkgsVDiF X-Received: by 2002:a05:6870:b14c:b0:176:2145:5e21 with SMTP id a12-20020a056870b14c00b0017621455e21mr12189678oal.46.1678310972473; Wed, 08 Mar 2023 13:29:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678310972; cv=none; d=google.com; s=arc-20160816; b=P1xjpAULx+GnvNC0lNiL42zulL/6W3TRiZeNjFyjaPlJuyK4BbqlkbDJbpbovuK0EA g9gcMbCtvULC59iKkICb+JCByQZYhxyJsUuB361Leikf4c/AHDJWMWw+9kJ9I7T6R7Qt mwZbvq0P/BYH90hYT+H6qF6mDfFdY89rETAWtaVXGgQ+0MFSgMDIOs+TedzLomNxRTpz 2H1r/y3D2ycQAnsznzW30H4hY0XPx7Z7RFDHEG6/KL3K9Nw5GKQqebh6XH5X+/TxfkYH Cs0zA77iza8ikqe19ruZ/twgqWr9e7D7X8UVvXcflkMhUmsGxG7XLtp9Zv59k68Zcvyg 8PSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=EZWSY2GlNs9ofJNifwBoiefrMVr8bhWWaijbhCELJa4=; b=ugSSN5a5vLkSd/zo/m+/bTXqsonGqMq/P2iYLba+bwi0tj1Bok+yT4uzzcfFS6nqyv Th+FaE50zHrdTjGfvEAwEkp37J+cbln3qkBt3ASvozzf382qwSZRetNNl7L4WxXYvqAD eRZwlOwueXc7xPN1ni6d9Hto9VzaX8EVnGDcNSrry7NK/ugTP3exNbcJouiuEqQQko2g o1lThq1vVC2soEW7CRMTrDOt4urBtqJUx7UyAajRUrefVGbP5JFkAKdzdILtxRJ0ku3p LVcuRwYyCbkcjj9f8fAybv7JAtWIPND4bj/hUup2kO90OGJ2S4eSGN/vZBb6svlQzuIl dbqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fDgOaUMh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id h21-20020a9d6015000000b0068bd2a915a4si14300356otj.228.2023.03.08.13.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 13:29:32 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fDgOaUMh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A4C8085DCF; Wed, 8 Mar 2023 22:29:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="fDgOaUMh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63C4A85918; Wed, 8 Mar 2023 22:29:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0897C85EC2 for ; Wed, 8 Mar 2023 22:29:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linus.walleij@linaro.org Received: by mail-lj1-x232.google.com with SMTP id by8so18009594ljb.7 for ; Wed, 08 Mar 2023 13:29:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678310950; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EZWSY2GlNs9ofJNifwBoiefrMVr8bhWWaijbhCELJa4=; b=fDgOaUMhQdwxTwKwm7CfYXBwDWNfOF0Y+kjfeD+XVr+JRbaXftPUKgdUECJ0dF4lOn AdmGZuB9sZOhSFNqsM7cI6RB66B0E260CcHgl49fIe5qvEVsZW2n6UYAFq3tf1kyHApk 6blqeTvdWdoGVZG1d933x5XB5mxViFubjOrLZx6cRip4cin0o2hOuywvmU9gxCeoWcju qrsVY5wPa4+QbBpE15xVHpkEiuyGFaIvTvuNp0L12nBPEllGPct8GiubNMVOF1eQKT5j D6H8ClwBCeo00EOimfgE5kq1KpMph1G+JT6Wn4pSGdrm9FJpDG9AUsrixyJVAnWEyMji Sd5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678310950; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EZWSY2GlNs9ofJNifwBoiefrMVr8bhWWaijbhCELJa4=; b=kmyrUFDe3rIh86jjoXXnokSwymT2JxQtE+n7O9kxj77S9Tfycjvd/ysDRw+INwc3kj YETgsB2rZmQV63zSHuntu/BMeHii5LuuQwAl1RUPBgT4/WbmWD0cp1ueEPWcopCmzsrL jlAOsOUgdUmgliaXTo6IU84zeMzJ1yaIxI3Op43CcAphYW+mK0bOH1V3l0qxuRVLi602 nhHck2PJb7rEJKavHA8IXq6Zvvlm2C+3GcutliOyPPv7x+Rbr12gKpL5pw5dI7/KM8RP +xQu7KpnQFg/znUX3updArAjY+4Ese1KdERtBmBoB0uUBXfp2ikUtDMNypy1d1NgBSdO Gj9Q== X-Gm-Message-State: AO0yUKW31si6NjMZABpsrZECY2qlemOg5KT5unqsxl0+W0GyG/zswEa5 u1yUZ6UbYY3XuADJqguRmdkRFK+i/3GJ6c0qUVg= X-Received: by 2002:a2e:2ac3:0:b0:294:697a:d6af with SMTP id q186-20020a2e2ac3000000b00294697ad6afmr5626985ljq.39.1678310949755; Wed, 08 Mar 2023 13:29:09 -0800 (PST) Received: from Fecusia.lan (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id l10-20020a2e908a000000b00295d82c6b84sm2687107ljg.138.2023.03.08.13.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 13:29:09 -0800 (PST) From: Linus Walleij To: u-boot@lists.denx.de, Tom Rini , Michael Nazzareno Trimarchi , William Zhang Cc: Anand Gore , Kursad Oney , Joel Peshkin , Philippe Reynes , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Linus Walleij Subject: [PATCH v2] mtd: rawnand: nand_base: Handle algorithm selection Date: Wed, 8 Mar 2023 22:28:51 +0100 Message-Id: <20230308212851.370939-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean For BRCMNAND with 1-bit BCH ECC (BCH-1) such as used on the D-Link DIR-885L and DIR-890L routers, we need to explicitly select the ECC like this in the device tree: nand-ecc-algo = "bch"; nand-ecc-strength = <1>; nand-ecc-step-size = <512>; This is handled by the Linux kernel but U-Boot core does not respect this. Fix it up by parsing the algorithm and preserve the behaviour using this property to select software BCH as far as possible. Signed-off-by: Linus Walleij Reviewed-by: Michael Trimarchi Acked-by: William Zhang --- ChangeLog v1->v2: - Drop pointless check for ecc_algo >= 0, it is always >= 0. --- drivers/mtd/nand/raw/nand_base.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 9eba360d55f3..c173fd09237a 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4487,6 +4487,7 @@ EXPORT_SYMBOL(nand_detect); static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode node) { int ret, ecc_mode = -1, ecc_strength, ecc_step; + int ecc_algo = NAND_ECC_UNKNOWN; const char *str; ret = ofnode_read_s32_default(node, "nand-bus-width", -1); @@ -4512,10 +4513,13 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod ecc_mode = NAND_ECC_SOFT_BCH; } - if (ecc_mode == NAND_ECC_SOFT) { - str = ofnode_read_string(node, "nand-ecc-algo"); - if (str && !strcmp(str, "bch")) + str = ofnode_read_string(node, "nand-ecc-algo"); + if (str && !strcmp(str, "bch")) { + ecc_algo = NAND_ECC_BCH; + if (ecc_mode == NAND_ECC_SOFT) ecc_mode = NAND_ECC_SOFT_BCH; + } else if (!strcmp(str, "hamming")) { + ecc_algo = NAND_ECC_HAMMING; } ecc_strength = ofnode_read_s32_default(node, @@ -4529,6 +4533,8 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod return -EINVAL; } + chip->ecc.algo = ecc_algo; + if (ecc_mode >= 0) chip->ecc.mode = ecc_mode;