From patchwork Sat Jan 21 23:43:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 645067 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1510075pvb; Sat, 21 Jan 2023 15:44:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtCyg6nNuzRS2v+BIy6jS14wRvBP91tqRgW1ZFB+PJAQ5cCfzhoNV4Qg5/RU7o9zxGYc5vY X-Received: by 2002:aca:120a:0:b0:35e:a9d4:30d6 with SMTP id 10-20020aca120a000000b0035ea9d430d6mr20154574ois.44.1674344648913; Sat, 21 Jan 2023 15:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674344648; cv=none; d=google.com; s=arc-20160816; b=yA9wAUFrIPm/N20PUkLYcn42lsHe/NBC/W+xz9pkcEtNQxF7e0lzjtvPiEc0QNY++q B64wf5/o6dM9u8j9+mi1Sp28B2u8/GJiHRDRz0XfSsUhE4YuekRkEIvZNPAJc7nGhpla 4bsWdzNgetQEd5O/Pr8+anVQ0Zlqw2Io9WxYCR6LBKNeLU77aXyJH3P1jz4dOYzfvgx1 TVhbrvzBCCyxlRBmXXAR7EyFtBWoBLMkv6prhr+R8Z9NjyuYDw71YfqvAMzdqsIsj9/2 AwkiyKJMvShZQG62R7P30ZKrKusOoB8+uH0Naogv7AgvYwMUX2pdaiaLYZLq7QGY+b3Q YHrA== 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=wsDTZK+YuqBg+Rm2/BJyPDagWBrxHwKkLp/H8/rP6dQ=; b=xPKDhT4TgUr4apiOGmZWeYlaI3DXvvn4gdfCwmDTLhzDB30RLM3gjU1oEy/C0I9eMz gZySLZzfZCYvZ/WJu/P2u4qPlv5FPhgFxEmqIFV3zec6z7wWNS3psrTG3lmXS//EKYkd lQQIi/FXl5XY7GibRhGz3n314pk2o6OqLaCjNlbB3gN27Mcmy7Uiuwhy4CTAel1IaC/v YMLga1KiGdVBkCrJO8rS9/wYLhZadkJRzgzOVbdGKYRKZl94H7bsWzSKN6aEyjL2Mzl1 B3aHQXVLPtmRGGLcYPh3SjwysuhqT9TN2rL+mF4Qf/I70r69+rJAyuW9CfKWi0F4ksy1 wS6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Es1ix4Tz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id t13-20020a056808158d00b0035edcb946d5si22143142oiw.157.2023.01.21.15.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 15:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Es1ix4Tz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 687E685162; Sun, 22 Jan 2023 00:44:02 +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="Es1ix4Tz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BD4285321; Sun, 22 Jan 2023 00:44:00 +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-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 D3AEB84474 for ; Sun, 22 Jan 2023 00:43:56 +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-ed1-x52e.google.com with SMTP id v13so10671900eda.11 for ; Sat, 21 Jan 2023 15:43:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wsDTZK+YuqBg+Rm2/BJyPDagWBrxHwKkLp/H8/rP6dQ=; b=Es1ix4TzHVH3extQV4jLbtTn0ZPe94wzsKxOpcyYORvestInQUPlGF23fcPRD83bTa JgigWc74+Xy60Z03KZ5fWHG9PwKFBjgrhevw5bUpdq5qZ2ibdfSV4jlVq4866R0Sn4tE CMUPg+4F/FhzVYt9EjO400avUFjGmQJGuLbY3tJ0FZNSOSK0eOleoWpFb7JTLa6RyQYJ GJHD213DvxwaX2AWhBLq+nQZRvNnKn4JDY6UXTuczRkeohCObencPYwD4kmijp4+2cum 6wyDPjgSx2w2pcYHWQnhIhOsrFFDUePPkzbqaK0cUJ4RK8rW03Few2NA/Zac4ZHPkY4G Vd3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=wsDTZK+YuqBg+Rm2/BJyPDagWBrxHwKkLp/H8/rP6dQ=; b=JcrotS22MzhwBQP6HjpBiA5oK5XywX+A0taDz3vFdMsFStdhIwXX/Lsz3douC8XB6b ix50+lpuILSNb2k0t8uh3FOq1VW9Jxa85j8RKuZNeOR2+ojeUYA2Un9EeSneSFy5hcf9 /Zv7uzKFje7XsPgHuZVuyfdzytAWBeYtgSghBGqihhocJz4hJ4NtfBpIKSKqqyY8n2rH Py3ENzKTozNmsxn/PdQWLSeyHWe7XGh3Y2KGn+UJnek/rJewdjhcK1+WVA883vpcyx8i uDRMM1qWlnh61RDeVd95VTT+S1pMHJOl2awGQHZmh3HvbR4u7gAPZZLpXnPZsaLWVY3C Gu+g== X-Gm-Message-State: AFqh2kofXiwTWYjPZw7AFfY68X/blwPRlbew2HA15OqmEj7vZFLY635o oCMelsUpdCaUFymI6EtsO0eUFCcmkwkY21Xt X-Received: by 2002:a05:6402:2484:b0:497:233d:3ef5 with SMTP id q4-20020a056402248400b00497233d3ef5mr23293748eda.23.1674344636119; Sat, 21 Jan 2023 15:43:56 -0800 (PST) Received: from localhost.localdomain (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id f11-20020a056402194b00b0048eb0886b00sm10508904edz.42.2023.01.21.15.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 15:43:55 -0800 (PST) From: Linus Walleij To: u-boot@lists.denx.de, Tom Rini Cc: Anand Gore , William Zhang , Kursad Oney , Joel Peshkin , Philippe Reynes , Linus Walleij Subject: [PATCH] mtd: rawnand: nand_base: Handle algorithm selection Date: Sun, 22 Jan 2023 00:43:38 +0100 Message-Id: <20230121234338.2242486-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.39.0 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.6 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 --- drivers/mtd/nand/raw/nand_base.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 9eba360d55f3..872b58ec5f23 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,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod return -EINVAL; } + if (ecc_algo >= 0) + chip->ecc.algo = ecc_algo; + if (ecc_mode >= 0) chip->ecc.mode = ecc_mode;