From patchwork Tue Mar 21 21:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 665556 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp1855348wrv; Tue, 21 Mar 2023 14:13:44 -0700 (PDT) X-Google-Smtp-Source: AK7set/tEkGYgIJHMN4sva/r9B+CpDuttVQVoOTjR/diu0sBmpBn0yVgmYGc5bDr6IwY6IZ+Ylny X-Received: by 2002:ac8:5e0b:0:b0:3e3:7d35:789d with SMTP id h11-20020ac85e0b000000b003e37d35789dmr1609804qtx.67.1679433224765; Tue, 21 Mar 2023 14:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679433224; cv=none; d=google.com; s=arc-20160816; b=PiW3nI72k+0114RzerEZAZxVX8f0DRYvDa6PiTrUUuJa09o5xUUI3f0kw++itHIXx0 FmAaXSRw9QrTjYLFJd7DMnTz4Ho9V60dvZqblejt0O61jntfQbDUqSo8Zc7aBCyXwzgR dVd8LhdZS2JhP7yxu/NeFdL+JAnMy4Mgj6dgtGF/mU/hUEtKZl+jPe6Gr5tr8LyNBknN IA+CfgBU7II3CA1TUGNhgoV7uWLTDy5M5rf9wait4Y92KkB17KITXHx/tYOVgjQf0yHb 15NLKXSgJQPeFrAmb4tRnfueSW2gt8QCVdgNh+vK5W4OxSC2iLkaT9h0ShaXKm/sEec0 VQLw== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NtNnY/w+bJJ1NBhAU8JMX6y/EE/4G0yjPvu/wgL3UBg=; b=QdyyG0LIpuM1POUkb6VQlzB0ChZV0S/SA1NozHKUL5pRtWwuanUVS6IkPjO3g3LVRW VrJcjFN5auaa0DcHV9JCNtIoA1RxN4GF4LbYU5OqCr3GZFbFJROB/OD9AcpQFfwYtJTy oMrQct5AD2/rX/D8X/pSc2FO/7wp5kRZxIDNo8+pCFUhpekxqbLl2eb9t24Lgwy0Ifgh GLra3AlDCXPMenIke2bevtYkaYjqjflkC62wOTzPkBcGnI76cG+VrsLNmKORyjJAdo2j 0t7Fn9Dl4jiX2WUR4Zyk516YNSOlwE4QGwUp0J7pk1u8bvd+xJF0onyD4H4jukzPLwQN ixKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pFd3y/2K"; 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 o9-20020a05620a2a0900b007461960b35fsi9757904qkp.161.2023.03.21.14.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 14:13:44 -0700 (PDT) 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="pFd3y/2K"; 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 39B4585C63; Tue, 21 Mar 2023 22:13:37 +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="pFd3y/2K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 98C6285C98; Tue, 21 Mar 2023 22:13:28 +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-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) (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 CAB2785C63 for ; Tue, 21 Mar 2023 22:13:21 +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-x22a.google.com with SMTP id e11so8294706lji.8 for ; Tue, 21 Mar 2023 14:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679433201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NtNnY/w+bJJ1NBhAU8JMX6y/EE/4G0yjPvu/wgL3UBg=; b=pFd3y/2K7lX0I9h/h35N26DJPuF2NI+sO4mzzSA9zIh7z4ZYrzW9Jp6Cutq6yaBq4p yoT5UT9P0fk9dIvNEkMnrlv9V4ZqEPL7AXrEXqOAjrX6eD5sZcA9vl+ktvOpPTZWmdPa s2J8SOdg87ufqqJwNyrTwvC6RtaJPFi1X3eAn/V11yvEHm7tX7qgOR07KtPATvtdJhhK rbU0GUsq/q2KNJLS2WqM0r8pWWcwJ7JaN1AkfxUUcynEK9jggwBp1Q/Jz14ebwcl/ej4 sVbpoCEpXXW0F27tRhrwHDS/GQYMMblPe3dNCqha1BHXyTPURfqePOVKxErn3LUPMhyG wnhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679433201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NtNnY/w+bJJ1NBhAU8JMX6y/EE/4G0yjPvu/wgL3UBg=; b=J+Wr/JOskULwmA5gMx1md634C09p+TGooeQGP58825FMF3jIf0+dy/ahVaDdGyIMSj cajh/jbYP60dauGt848T9xzzviVoiDIWsrJPvzYMqsm+nuvMN6a4RJ8Ze9bpNjBl1ayf hvYpZBb7FXfmrq2HYuNI6TbiJtDEu1V46b4svpFHgPXPBMTByE3TH+zsOUYXtwGYsPVq zqJsh1/9qJCH2/u1E9ZML9lk9ss6oCYSFJqGStQA2GD4dX3mvQSJVS3thxqRNCOyt9Xu ByG1MT/od8wXeqgM9mg+QhAEXvMZ2xlCG6UBMYhQdvPjgfPecbDMMh3gOnjnxIKrqX8g EtIQ== X-Gm-Message-State: AO0yUKX9mkPv8s/TAfIKNu46dHVUKY7v8xm0Y2mrge53kP5r2tN6zzgB QFwm8WinDiUJo+gHdqdVED40TiWOWdrQHD/v//0= X-Received: by 2002:a2e:95d5:0:b0:29b:2527:4d0f with SMTP id y21-20020a2e95d5000000b0029b25274d0fmr1314429ljh.18.1679433200839; Tue, 21 Mar 2023 14:13:20 -0700 (PDT) Received: from Fecusia.lan (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id p15-20020a2ea40f000000b00295a8d1ecc7sm2406630ljn.18.2023.03.21.14.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 14:13:20 -0700 (PDT) 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 v3 2/5] mtd: rawnand: nand_base: Handle algorithm selection Date: Tue, 21 Mar 2023 22:13:09 +0100 Message-Id: <20230321211312.503812-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230321211312.503812-1-linus.walleij@linaro.org> References: <20230321211312.503812-1-linus.walleij@linaro.org> 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. Reviewed-by: Michael Trimarchi Acked-by: William Zhang Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Collect review tags from Michael and William - Resend with the NorthStar enablement patches 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;