From patchwork Wed Jul 27 09:37:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2262 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B7E853F330 for ; Wed, 27 Jul 2022 11:37:53 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id s17-20020a056402521100b0043ade613038sf10456138edd.17 for ; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914673; cv=pass; d=google.com; s=arc-20160816; b=uU4fsW2Qpo8irfwoqyLPsQFcJMWzDRvUQoeE/cg3mV9GVHh2CCcXKsHz4IDGQBxo1k QjRs8d4ibHol+o9TF9sOAzTsbdn8OQxxZX40aozp8I2WQjAcx/Wd9+H0HQ0tvj4eE0u/ 4KtMZBmEGVrxE3LlhoB9dMZ1He/S7+UIRjXkkI1nzhIZGuroGCMu7NYI6PXXl+2k9SbK qQiufwLyKP7tPC+4bAoK6/MH14bDJOGgubd/Ob7QB7H5IS890IB9Cdzoktk6TSLtIxrY Xw6Why4+WgOHIRhyNrwtOIk9BZCj7vxC3/j5fNRYAEtu3rujhFsYEXMaer5bkxu+k7n8 ljLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=2tbxa91Yh0yPwEX15BYzd1dsBsVx02OnGcAhzxd5NOc=; b=Z4KaXJE8bCTtt/f20QC/ethn8rbkJzYMy43ALwLK/XFm1k7s9SVmkzkDXIX40MXbNd keYxauac0cvi38qH0jhHf/2VPRKMmHfPN9U4jQqLSvuNBEMyjbTxU2JZX7oVnH08H9xK Wrh4m58tJvsSPrqawOBENM14tmrapMGcWuTI/Nj1GM/XYzFNTfBjz5VNhReIpMMMG0Qr Q1URsbp6WZf3o8lYFCxWrawFaV0EuMEBbRj8GatcMMr2OB3Ex22gGTbh9mJQGbI0PxMe UxbfnJjbOHi8S28b31fTkzfgt4HzjnA2pzJNWdX6aJhl94CEbsUSH0aieDfTvsCtcSst QLfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jmeQOnnq; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=2tbxa91Yh0yPwEX15BYzd1dsBsVx02OnGcAhzxd5NOc=; b=RAYOEC0oF81I4YcukxwIE/NxXYGu3yzTLtSYY0RDogRFK/gi3r5yaQ3U4XUl+iVwf+ 0jmYYJzpEwYRXZS0y3CWklgWcre60nMAL8zb+RdtHUzKXGe0WZwzsRnnRXA/BQtygFo0 YoOwcQZa5R9ZAjG7Flk8lcdVda3oqkgXuWCLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=2tbxa91Yh0yPwEX15BYzd1dsBsVx02OnGcAhzxd5NOc=; b=JSxrI6d+hhHUKD4ePTVjO257E1KQZD8+VtJP9Ag8x8qeEHvfjQnOCm33ILd6th4zMF FbRyJgPfmVddiv7Qklgy5Uhsnm52wd4XIG55lv97gfcyMbgczsTtVw8ZaBJyhIrD95WS RiufpV2p344UyJopKd8JolOKGWHQMJdIzGo5rqtnLMM5XnzLd9q94ldG73qPg56tVobs CADBV0B0RJXGFi18KUmNTXehkLK9xdEBgpeRy3qkfzFmWZqbXdw1C/ZjNDgqp9+lK1lq niXbOuCzHB4YTs6iFzdrrTfYiP/H4K/WnnQm0q2Ll5xHbfgLJXdrXLB401k/1iIDAiyv 4EfQ== X-Gm-Message-State: AJIora+XP91iIHgOd+d/CqIr1CK7WDlm1Nxw2Pac6R1dfpuPLOrL9fTA c9CzTuZy24ZMBjX5QBi5M0jUOvij X-Google-Smtp-Source: AGRyM1s4mTvfdtReMKa5qPk2jdkpAd8TOHQ+DrpeA0MlfOpEwDi5Ll7dBMmk7xdqlqotxeNhEkeLRg== X-Received: by 2002:a17:907:d08:b0:72f:b107:c07a with SMTP id gn8-20020a1709070d0800b0072fb107c07amr17291628ejc.340.1658914673480; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:40c6:b0:43a:7c1c:8981 with SMTP id z6-20020a05640240c600b0043a7c1c8981ls314017edb.0.-pod-prod-gmail; Wed, 27 Jul 2022 02:37:52 -0700 (PDT) X-Received: by 2002:a05:6402:b72:b0:43c:81c2:dd3f with SMTP id cb18-20020a0564020b7200b0043c81c2dd3fmr6017573edb.19.1658914672142; Wed, 27 Jul 2022 02:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914672; cv=none; d=google.com; s=arc-20160816; b=DLavDGPjNV7L073fIYC/I7EW36Nqvv7UmHRTXOna3G6cigKpRSahN9kpHfI0OZWNeI 5ksFUjO3PQ5WUvDlNpzuX10FMm34MoBd29nY0UlG8NXZcHBhw+8z+sVFA/C6fJOOChxq bMV6lZhKD3YVoM4MMwqV1YAXE3bbCuoaXcokbo7/Gpd9okFvzBBl3Mos4dKiHUuUZG1j rFGGozM1PyApgKRgJWcxJKLIEy/os10u3/EUY7luz6u/j4F8fyK6VsgyUC1azwcFn0Yz kuKzQnluSSzYhoN8AU+rRQHXR8EcYb7srLm1c2tTrXczj4VMLr9mHsigjZBu6z7DFoWn prig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=tk8uGCl/AQK6CR0J7gwTH8fpzG0EUmFDf2etUFxcmfk=; b=tqNKiIRAJSQZGIWrR6PJWbtZmkGTp6Wzz2sFMHcR7ELeuSaloKZ0vDkJd9xTPIR5aU /Kw/pI51V4U6vSyQU3ZMADqHQ0wLotgbkDPqV/CyDthmW23JV9BmeQF7yBpXtJ+9mmYy grky64FBVevdvSNIjmJ5z95JDUTBpyNt+18pKKmlIG9/35No6APcpIyNVjJlHFZgVWTG loA0CB/Z3miYCZBhSyFHqXXA2NJ3Jsg51I76xwrvle9uzF2JZ03iUGcO/TGnMW6NiHUi UcYBbC0tS2g8Xf5IIMbBn2ZUPnOOBQS9AozXHygXe4yn6i3ehc+Thbu9fCweve5ldeMz p/2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jmeQOnnq; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id o12-20020a50c90c000000b0043983c28330sor8007960edh.67.2022.07.27.02.37.52 for (Google Transport Security); Wed, 27 Jul 2022 02:37:52 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:2804:b0:439:83c2:8be2 with SMTP id h4-20020a056402280400b0043983c28be2mr22056123ede.292.1658914671655; Wed, 27 Jul 2022 02:37:51 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:51 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 1/7] mtd: nand: Rename the nand_manufacturers struct Date: Wed, 27 Jul 2022 11:37:42 +0200 Message-Id: <20220727093748.1415135-2-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jmeQOnnq; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream linux commit 8cfb9ab68f9070. Drop the 's' at the end of nand_manufacturers since the struct is actually describing a single manufacturer, not a manufacturer table. Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/nand_base.c | 4 ++-- drivers/mtd/nand/raw/nand_ids.c | 2 +- include/linux/mtd/rawnand.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 4b09a11288..9d8ccfda53 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4261,7 +4261,7 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, * Returns a nand_manufacturer_desc object if the manufacturer is defined * in the NAND manufacturers database, NULL otherwise. */ -static const struct nand_manufacturers *nand_get_manufacturer_desc(u8 id) +static const struct nand_manufacturer *nand_get_manufacturer_desc(u8 id) { int i; @@ -4281,7 +4281,7 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, struct nand_flash_dev *type) { struct mtd_info *mtd = &chip->mtd; - const struct nand_manufacturers *manufacturer_desc; + const struct nand_manufacturer *manufacturer_desc; int busw, ret; u8 *id_data = chip->id.data; diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index 4dece1b206..d0cfacc69b 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -177,7 +177,7 @@ struct nand_flash_dev nand_flash_ids[] = { }; /* Manufacturer IDs */ -struct nand_manufacturers nand_manuf_ids[] = { +struct nand_manufacturer nand_manuf_ids[] = { {NAND_MFR_TOSHIBA, "Toshiba", &toshiba_nand_manuf_ops}, {NAND_MFR_SAMSUNG, "Samsung", &samsung_nand_manuf_ops}, {NAND_MFR_FUJITSU, "Fujitsu"}, diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index aa45558b3d..8dc2d81dba 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -976,7 +976,7 @@ struct nand_chip { void *priv; struct { - const struct nand_manufacturers *desc; + const struct nand_manufacturer *desc; void *priv; } manufacturer; }; @@ -1124,19 +1124,19 @@ struct nand_flash_dev { }; /** - * struct nand_manufacturers - NAND Flash Manufacturer ID Structure + * struct nand_manufacturer - NAND Flash Manufacturer ID Structure * @name: Manufacturer name * @id: manufacturer ID code of device. * @ops: manufacturer operations */ -struct nand_manufacturers { +struct nand_manufacturer { int id; char *name; const struct nand_manufacturer_ops *ops; }; extern struct nand_flash_dev nand_flash_ids[]; -extern struct nand_manufacturers nand_manuf_ids[]; +extern struct nand_manufacturer nand_manuf_ids[]; extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops; extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; From patchwork Wed Jul 27 09:37:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2263 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 282E33F1F7 for ; Wed, 27 Jul 2022 11:37:55 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id sd24-20020a1709076e1800b0072b582293c2sf4895693ejc.0 for ; Wed, 27 Jul 2022 02:37:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914675; cv=pass; d=google.com; s=arc-20160816; b=GxS5/8UJ/fPZw0YYdsDy3oH+ZHmnMEtvYV7zqZuDeY2J0YspbXw6CYRjomk4KxbW1W naq1oXUbwjfl4EltIG4D56VBk2lE92CBbrfXhgfVaGuFHmxi7hsViecmqu51imEfWxJO lZNVDU4cVgvrvRAHKqzwO7u1Mm9daSs5EfFRtm9sDPkDwSysa4+fV7RYbrP0j3gUzwo2 09cjQf40jTUtsJThu+mUsFtfIxV6C6Drd6BTwNL3KFqhquvply47qTqJ8zaof0WNxeIz E6f2aCRlxuzTzXli1hf5XCbZRJRrMpt16fvKOeR7ZXbTkRLb/npcq8VQi+PYbVF98VEo oozQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=q8Bj5Myt299A2GWCFF9Wv1du+GArgwDxAxI8gz5Cr1s=; b=exP4TxS//h4HaRbb5MFp/papGoe/065KjxN1ts/II0D/fuonuBPRzkq1LrJ/INlDXM 9tS4BdXc1iFJ89xgp4DaRxMhOtUpPU4ta38aQufh+Lab6HSr4CUDghmUr/jRUU3RbpHL zS90XPjxg3Jp+WIeYK8nq5wvpI0Qs5OOJyGXUYZQ6nqyh/Yr3DM/7h1FJYnrGnOkcwMt 2o/8Rd0J9J3+tt9ulSbibyJ9U3nqmQx65z7xpgmiFojxv9zF5ypeswGkOdjWCUIu7Nc5 n/2049RGTwLJaWTjXrUU/Tt0lcTgySYLduev7kAfEip6XDzCN+kHgCgpDJNDD/abOV8p 5qJA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=O2y1jS1V; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=q8Bj5Myt299A2GWCFF9Wv1du+GArgwDxAxI8gz5Cr1s=; b=JqWB07uH7112FUaRMy8PdvsnOhfiuXk3rv6Kfqfxr6JOt1ic742YfZ53uszNN/KvsZ cl63ioIzJUXjV8PjD7n8xW7rohsRJBtoaCuMiCxRKKttXot4zfKYJeNXhHVuPcZ2NLB+ Ja6m/vn6OttmsSVIoaG1S5o9cihLPYagT9C9Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=q8Bj5Myt299A2GWCFF9Wv1du+GArgwDxAxI8gz5Cr1s=; b=7f2mH1drEBrEteEYxfS05gZd17lt5YmYDobfRyjfvOItsTSW4GxR69TdAavXuw7aDJ mlN7k3+0Gvot469b+EhLgONPsnYwLbotu974aG83Q5/FpCkW1LA/F0tRQDmBHnpbaNaf UCpgi9UcQm2U91X/+ozJAArCVBzFiSkXdWvMJ2u4laA6Zs/Hby2SSTRIu0mDzHvUg5Hy k6hq07/vp/Ipel6JgSZCfTjZPLJ0a7TseesVATzaVUYqBUuLft3zbBnH8J56H7W1mdRj /KmQxpiVI0LauueiBLVNdeZj1svH6MNMTPlUo12ojgzIuCOfpMt/MyZ2v1Y/7cahxzTk VsTA== X-Gm-Message-State: AJIora8zy645KGqNMN70eTz6ZZLdZ/xdwZ0pwY0NmP2th31ajuFnE2Tq NWWHsazgKskJceJOL5tLlBja3zYk X-Google-Smtp-Source: AGRyM1uU29bisLxOZUZ1AXoZdzV3qJM6UC0GcbGhd4okIMmrdUMMceBiBcD8S8Nz7za4dgmvg8lh/Q== X-Received: by 2002:a17:907:6eac:b0:72b:4c75:28fb with SMTP id sh44-20020a1709076eac00b0072b4c7528fbmr17286372ejc.675.1658914674753; Wed, 27 Jul 2022 02:37:54 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:7256:b0:72f:6ce5:d858 with SMTP id n22-20020a170906725600b0072f6ce5d858ls1897460ejk.4.-pod-prod-gmail; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) X-Received: by 2002:a17:906:7308:b0:72f:3294:8001 with SMTP id di8-20020a170906730800b0072f32948001mr16734616ejc.254.1658914673414; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914673; cv=none; d=google.com; s=arc-20160816; b=JHTfjweDH82ql/TqqHDVRS2+ZBg1eLHFvZqGsRHADLsKf61q/BGH1UK5hhi2GfRdKh cuCSYOfPcnqFwHT7kKWz0hE4KRufJHD7PsvM8SSlaXvC87I0oX0MQgX7M110vHVMYNVa ME5PcUhlPGCMfitGBlwVgRAGChiixAQzwX+cxJDvTBhs+d7pxV29ri3YGwYrNQ0redHX WsHksn11/aw4SvL1OgQzS7hm/+yjNYnCDpA3d2pdWszT72ibOtrUA5ggMGkeCDU8ibg4 xcFpbTZke7z0ea85oSw8ZJjfOzydF+zWvGrpNl2lAJb7M759M55sNl/fTAVjTKEYKCGN mSKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=MNpcuzewDZbHWetPCMtSq+7NxdT3aCHxDyE39RwXta0=; b=XliI9QbZwvcS6RXWBrUSvH4WGQ+dlaTVFiaf8PQtb5Rc1dXSLmyUwTUcCx5GtiP0ZT PPEvDkziWHLfDUF3WmOdRyLgHB8zq/x4HJi6HOF1nPu/7sCmYAwNXX0yKMp8T6J5o4u/ +nGC7wKQOxcQL1J0qTmOTbPck/v+rAEVpmenREN4w1qafE4MBoz9nPwI6nBNicjv5rTV Xpkom/8Oh3DVqdBA0wvitccFgYklGzx0ksSgncABVwnra/Y4YbtjHmZeRxy0Z9OE4Oxn DpLDtUU6G6SN/Sq3yziAZK/hRkoKGd2/FQIQYRqlAsBGDNbwduzCQph7Prx8cQ5Ded2r FBMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=O2y1jS1V; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id z29-20020a50cd1d000000b0043a86563d8esor8141252edi.0.2022.07.27.02.37.53 for (Google Transport Security); Wed, 27 Jul 2022 02:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:aa7:d943:0:b0:43b:9010:9d86 with SMTP id l3-20020aa7d943000000b0043b90109d86mr22270988eds.34.1658914673048; Wed, 27 Jul 2022 02:37:53 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:52 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 2/7] mtd: nand: change return type of nand_get_flash_type() to int Date: Wed, 27 Jul 2022 11:37:43 +0200 Message-Id: <20220727093748.1415135-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=O2y1jS1V; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream linux commit 4722c0e958e636. The returned "type" is never used in nand_scan_ident() and spl code Make nand_get_flash_type() simply return an integer value in order to avoid unnecessary ERR_PTR/PTR_ERR dance. Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mt7621_nand.c | 10 +++++----- drivers/mtd/nand/raw/mxs_nand_spl.c | 8 ++++---- drivers/mtd/nand/raw/nand_base.c | 28 +++++++++++++--------------- include/linux/mtd/rawnand.h | 5 ++--- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/nand/raw/mt7621_nand.c b/drivers/mtd/nand/raw/mt7621_nand.c index 9763ae6dc5..a4a0bce35d 100644 --- a/drivers/mtd/nand/raw/mt7621_nand.c +++ b/drivers/mtd/nand/raw/mt7621_nand.c @@ -1184,13 +1184,13 @@ int mt7621_nfc_spl_post_init(struct mt7621_nfc *nfc) { struct nand_chip *nand = &nfc->nand; int nand_maf_id, nand_dev_id; - struct nand_flash_dev *type; + int ret; - type = nand_get_flash_type(nand, &nand_maf_id, - &nand_dev_id, NULL); + ret = nand_get_flash_type(nand, &nand_maf_id, + &nand_dev_id, NULL); - if (IS_ERR(type)) - return PTR_ERR(type); + if (ret) + return ret; nand->numchips = 1; nand->mtd.size = nand->chipsize; diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 3daacbb330..773d375fc2 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -81,13 +81,13 @@ static int mxs_flash_full_ident(struct mtd_info *mtd) { int nand_maf_id, nand_dev_id; struct nand_chip *chip = mtd_to_nand(mtd); - struct nand_flash_dev *type; + int ret; - type = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); + ret = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); - if (IS_ERR(type)) { + if (ret) { chip->select_chip(mtd, -1); - return PTR_ERR(type); + return ret; } return 0; diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 9d8ccfda53..b4fa618dc4 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4276,9 +4276,8 @@ static const struct nand_manufacturer *nand_get_manufacturer_desc(u8 id) /* * Get the flash and manufacturer id and lookup if the type is supported. */ -struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, - int *dev_id, - struct nand_flash_dev *type) +int nand_get_flash_type(struct nand_chip *chip, int *maf_id, + int *dev_id, struct nand_flash_dev *type) { struct mtd_info *mtd = &chip->mtd; const struct nand_manufacturer *manufacturer_desc; @@ -4291,7 +4290,7 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, */ ret = nand_reset(chip, 0); if (ret) - return ERR_PTR(ret); + return ret; /* Select the device */ chip->select_chip(mtd, 0); @@ -4299,7 +4298,7 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, /* Send the command for reading device ID */ ret = nand_readid_op(chip, 0, id_data, 2); if (ret) - return ERR_PTR(ret); + return ret; /* Read manufacturer and device IDs */ *maf_id = id_data[0]; @@ -4315,12 +4314,12 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, /* Read entire ID string */ ret = nand_readid_op(chip, 0, id_data, 8); if (ret) - return ERR_PTR(ret); + return ret; if (id_data[0] != *maf_id || id_data[1] != *dev_id) { pr_info("second ID read did not match %02x,%02x against %02x,%02x\n", *maf_id, *dev_id, id_data[0], id_data[1]); - return ERR_PTR(-ENODEV); + return -ENODEV; } chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data)); @@ -4368,7 +4367,7 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, } if (!type->name) - return ERR_PTR(-ENODEV); + return -ENODEV; if (!mtd->name) mtd->name = type->name; @@ -4401,7 +4400,7 @@ ident_done: pr_warn("bus width %d instead %d bit\n", (chip->options & NAND_BUSWIDTH_16) ? 16 : 8, busw ? 16 : 8); - return ERR_PTR(-EINVAL); + return -EINVAL; } nand_decode_bbm_options(mtd, chip); @@ -4432,7 +4431,7 @@ ident_done: ret = nand_manufacturer_init(chip); if (ret) - return ERR_PTR(ret); + return ret; pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", *maf_id, *dev_id); @@ -4460,7 +4459,7 @@ ident_done: pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n", (int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC", mtd->erasesize >> 10, mtd->writesize, mtd->oobsize); - return type; + return 0; } EXPORT_SYMBOL(nand_get_flash_type); @@ -4547,7 +4546,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, { int i, nand_maf_id, nand_dev_id; struct nand_chip *chip = mtd_to_nand(mtd); - struct nand_flash_dev *type; int ret; if (ofnode_valid(chip->flash_node)) { @@ -4560,14 +4558,14 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); /* Read the flash type */ - type = nand_get_flash_type(chip, &nand_maf_id, + ret = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, table); - if (IS_ERR(type)) { + if (ret) { if (!(chip->options & NAND_SCAN_SILENT_NODEV)) pr_warn("No NAND device found\n"); chip->select_chip(mtd, -1); - return PTR_ERR(type); + return ret; } /* Initialize the ->data_interface field. */ diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 8dc2d81dba..8178f36b49 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -29,9 +29,8 @@ struct nand_flash_dev; struct device_node; /* Get the flash and manufacturer id and lookup if the type is supported. */ -struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, - int *maf_id, int *dev_id, - struct nand_flash_dev *type); +int nand_get_flash_type(struct nand_chip *chip, int *maf_id, int *dev_id, + struct nand_flash_dev *type); /* Scan and identify a NAND device */ int nand_scan(struct mtd_info *mtd, int max_chips); From patchwork Wed Jul 27 09:37:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2264 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2FE1B3F1F7 for ; Wed, 27 Jul 2022 11:37:57 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id s17-20020a056402521100b0043ade613038sf10456206edd.17 for ; Wed, 27 Jul 2022 02:37:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914677; cv=pass; d=google.com; s=arc-20160816; b=SDt+1h9cfVuJUKWTrwhKHlJYIGzAq7NGiyEVJpK/69wmxrxFtaVqhDRrCzqDMTZJaI /tJXl56mlzA+WxVlGWKZnLZrcpzgTjs43fIdVXTpW74UfF7hH3MGODGkSepwLX7xonsa hKbnmDl9Kv/M8WjQEYw2WBtgczjuFFe6HBjqrZvgaJcZOjB9mGDBgl5yPPuit+2iwctq UIJGc8BLu1i/jcf0RTeO8up1P7Y/tvJhtzeBgI2BoRooA29rujTb+Het2pyKjND3iBTV MPwZUXRPZKI13H/u81u5Fcr7vLxVnz+rI/jdy8+b5VBNZkUSctohu+9Sej/MNw7emjoj nLfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=mlF480/gEEJuLqJ2obV3FdcFjW6Xdvq7tVtXIoysm4Q=; b=opuTTF1ykh5EgLLjWj8Z6/lcNS0u+qUukd9Ec/hetiqq2NAXez4qvYXPbgl0ZkJE4s aFFUpPpJfZ3uJnt9Df8Gwl3d4UX/labqg0IjJ/v/YT8bNmZ9bzqSmbEg5EzTegPz2LtD QGdVW76cIh2TF52HNYZ8714PsY3GHAbEtISI5bxKuL58wT0knoP9tpxCSOTyeWdQwMLu HGJciDaTvVjdcvXDnTftq23FeQUze+UNRoshsc+PFDijWUEZp70ZVviUiyzIcA/whDaU DtFOE2KYQ7LCGObJiWcfUsBlWVfOl4v170py7wOUylBV929+TWHOEiAW6ump62kB3U1x o54A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HXxuLHfB; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=mlF480/gEEJuLqJ2obV3FdcFjW6Xdvq7tVtXIoysm4Q=; b=B4YGqhrOmfcyimLkaZpINhV2RX3ypHfqQCJZgYX89S5qtHra1e8Pl/IhAJb+N+9yyu 2eNgkFSp79bdSMRhVaneLnFwSYujAy0faeY+BsNmDcyHfA3swh9liv2AeP14hdUjIFyg T8KBcVdvzddq2RaWU5S4WOckHb8I0b4Bxe0mI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=mlF480/gEEJuLqJ2obV3FdcFjW6Xdvq7tVtXIoysm4Q=; b=13f5CK61+8KHwkXXjcb87xcCSiWF7LUYMK2K7gwgOnxnUgA1gvUvsvgVrNBgXi8YgW FPK+t7z2pBsC3/CcjDdKEKYn7vlJ6Pbb4a4WLdoH0wAiUGSrcmWKnil6Cu//xLnXyB7m icVWM9xfSEhMcvAcEkj00tITr/2Axdh4n3U2vySUPs4YuuHEiu3qcGsz0ccXOS9RrPwh q8zTMZVqUTpHD/Y7lOOCYyG1yKcCjQaaY7MRr41/NQpjXbwDa7yIDqo0w4TgV338vING 22xqRORpXodOXF5aeIW/zeLFEE3SKlIMW79YURYgUA25EiJIallcWPN9UOyqmhLFHOQ0 +z5A== X-Gm-Message-State: AJIora/vxlMbc9p36FQxlGanggtfNPan3hdz/KtEYs6l5wJ0JMW+PEea EGEC6sQ636ENVc4EmrAoomN7uqLU X-Google-Smtp-Source: AGRyM1srpL7Z93dO14u9f+TKvkWuqdURrpZ3Vzkb2VrSMCtGdD0d5U7dpzld0iPYMzxuC49Ibt5jyg== X-Received: by 2002:a17:907:2c5b:b0:72b:54bd:40f8 with SMTP id hf27-20020a1709072c5b00b0072b54bd40f8mr17007051ejc.137.1658914677076; Wed, 27 Jul 2022 02:37:57 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:40c6:b0:43a:7c1c:8981 with SMTP id z6-20020a05640240c600b0043a7c1c8981ls314158edb.0.-pod-prod-gmail; Wed, 27 Jul 2022 02:37:56 -0700 (PDT) X-Received: by 2002:a05:6402:5ca:b0:43b:6e01:482c with SMTP id n10-20020a05640205ca00b0043b6e01482cmr22411249edx.189.1658914675828; Wed, 27 Jul 2022 02:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914675; cv=none; d=google.com; s=arc-20160816; b=onlUMfez/ROFjZ+YPNvXHRJD5L25DvjYTXgYflHeM9pNIXAOpMU8GSIPcJ+uDuXEaD Chl9T+2cZHNz25YXZ/ApKoFGH4WS9ns0B1CgTiI2AEUklQBmX0cqvvz92nKV3bB3jQye jCWzA5q7+Sa1auY8yAltJ4vwZSxFAK1c+v7it7GSl5gF3DBW18lsrH9EoLR654J8+mEC zh9VjCkT1drZlq9KtxLnz0l934Fxb+z40Ca4KrS+KahsIaPBN6o/Klb17KO/oEQkcU2a Uyaof4QkDbbggtMTTldTi58KTWPDkrSBhXoNCy8WHkuJW94oZ9Z+lnIZigiB5eNc4+jb OMWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=QgWx6uBsHMWGCvY5GK3Oe2abtGSea4FH/c0PGLNzD7o=; b=h/1x4+qGIhbIDxMeF82Ff825OfrhbdbWQmFThLcYElzOFOvEzjh6ZsbGl5itUgxQmF P/kNReJoGrpp1/j2BMMptFqKB+/xjkPdc99NbSDpqN5FcKhLCZL6xOub4lp+Wk2dy2tR SCCQ3HWe5IzgU2U/x3ldPak8sR+uQjFqwE+XYbrltGdzN7D7h+cuErDu3dk/hMuMC1pa DrxHI29z2OZZ8VL1EMyEVFdu26QfPCM+Wzyxeao3AdVBDCz1zks2VvHlhLhLXz9BcRVA EOeOOMz/QF2ZOARTr2HuCsC4TUnb/H/l6i77uPtzZ7S65LxGE3b5iU0VxwsOhOvaA40O BWjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HXxuLHfB; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id q30-20020a50aa9e000000b0043b095325cfsor8185517edc.10.2022.07.27.02.37.55 for (Google Transport Security); Wed, 27 Jul 2022 02:37:55 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:aa7:db9a:0:b0:43a:76bf:5401 with SMTP id u26-20020aa7db9a000000b0043a76bf5401mr22609508edt.244.1658914675542; Wed, 27 Jul 2022 02:37:55 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:53 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 3/7] mtd: nand: Rename nand_get_flash_type() into nand_detect() Date: Wed, 27 Jul 2022 11:37:44 +0200 Message-Id: <20220727093748.1415135-4-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HXxuLHfB; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream linux commit 7bb427990ee364. Rename the function to match this new behavior. Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mt7621_nand.c | 3 +-- drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 11 +++++------ include/linux/mtd/rawnand.h | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/raw/mt7621_nand.c b/drivers/mtd/nand/raw/mt7621_nand.c index a4a0bce35d..f6eddb84a9 100644 --- a/drivers/mtd/nand/raw/mt7621_nand.c +++ b/drivers/mtd/nand/raw/mt7621_nand.c @@ -1186,8 +1186,7 @@ int mt7621_nfc_spl_post_init(struct mt7621_nfc *nfc) int nand_maf_id, nand_dev_id; int ret; - ret = nand_get_flash_type(nand, &nand_maf_id, - &nand_dev_id, NULL); + ret = nand_detect(nand, &nand_maf_id, &nand_dev_id, NULL); if (ret) return ret; diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 773d375fc2..4dffa76eaf 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -83,7 +83,7 @@ static int mxs_flash_full_ident(struct mtd_info *mtd) struct nand_chip *chip = mtd_to_nand(mtd); int ret; - ret = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); + ret = nand_detect(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); if (ret) { chip->select_chip(mtd, -1); diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index b4fa618dc4..1a1a757932 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4276,8 +4276,8 @@ static const struct nand_manufacturer *nand_get_manufacturer_desc(u8 id) /* * Get the flash and manufacturer id and lookup if the type is supported. */ -int nand_get_flash_type(struct nand_chip *chip, int *maf_id, - int *dev_id, struct nand_flash_dev *type) +int nand_detect(struct nand_chip *chip, int *maf_id, + int *dev_id, struct nand_flash_dev *type) { struct mtd_info *mtd = &chip->mtd; const struct nand_manufacturer *manufacturer_desc; @@ -4461,7 +4461,7 @@ ident_done: mtd->erasesize >> 10, mtd->writesize, mtd->oobsize); return 0; } -EXPORT_SYMBOL(nand_get_flash_type); +EXPORT_SYMBOL(nand_detect); #if CONFIG_IS_ENABLED(OF_CONTROL) @@ -4558,8 +4558,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); /* Read the flash type */ - ret = nand_get_flash_type(chip, &nand_maf_id, - &nand_dev_id, table); + ret = nand_detect(chip, &nand_maf_id, &nand_dev_id, table); if (ret) { if (!(chip->options & NAND_SCAN_SILENT_NODEV)) @@ -4591,7 +4590,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, for (i = 1; i < maxchips; i++) { u8 id[2]; - /* See comment in nand_get_flash_type for reset */ + /* See comment in nand_detect for reset */ nand_reset(chip, i); chip->select_chip(mtd, i); diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 8178f36b49..fb002ae641 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -29,8 +29,8 @@ struct nand_flash_dev; struct device_node; /* Get the flash and manufacturer id and lookup if the type is supported. */ -int nand_get_flash_type(struct nand_chip *chip, int *maf_id, int *dev_id, - struct nand_flash_dev *type); +int nand_detect(struct nand_chip *chip, int *maf_id, int *dev_id, + struct nand_flash_dev *type); /* Scan and identify a NAND device */ int nand_scan(struct mtd_info *mtd, int max_chips); From patchwork Wed Jul 27 09:37:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2265 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B19E53F1F7 for ; Wed, 27 Jul 2022 11:37:59 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id v9-20020a056402348900b0043bcd680e50sf8995060edc.18 for ; Wed, 27 Jul 2022 02:37:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914679; cv=pass; d=google.com; s=arc-20160816; b=TxWxd12584tpwxpWQpqn1bXAPzi+DcSAabM71qGu26XIN8k71+ZSmRFtztqH6aU6WL qcH+9xRxBMAHi2LpxRdfM4btahTTR0wc3di4xP7+CpbO5WnCPiHixbq14aI1Eao3i+qn zEgmJ0hx+D5qWeoxYpkepg77vTH6gNG1WyLi15tnNscZur0uUhjGKEtcnL1nCUaJ3yU0 aEut0Jlk3sqMyKh8OJd/m6MUSm7kU0/uMrxnPaiKBXo2yvsx7oq9F5HBj6A4sl70D+Ou y5l+GcVgCVjLZLzYXy+IXQ4jPoVuWqJhF6w9lfFN55Cfyie9ue0+/P8TIdU6+/aB3I1W PrHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=5ddosn4/bJZT7jBt2EfL5ixz/9xuydVCf9J/kAMK6ac=; b=ji06vOS0ECxn8Pe+elq676KCKSHbDgVzbo1Y5N75tNsoT3oJrL2do26EfT4N1OQm9b rOyVtnA2m7j/lJaT4P0+8Fzngl5yQEwgGMkWH3jB1bSf4HZJJtVEMy/Dy0jJJgATKzyk X7B07TuYd3DMVuWkcvNaDmJkrpNBzOXf+74J58meuv1z67oFtVec+V1Y5rTFWDuLIIvh /A6OZpzVZK62AgzxzG9oiP65t2yJ82R/9WaQxmXJGN+gzo4prBWsz9dAcSrx4WD0FGcH C1SI6duFTyAi+SbI+Op83/7ofWMiQBgPatZJgdXlZgEqqX4WUHF25d3OihIpUdhPy0uh DOnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nMrQ2n5R; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=5ddosn4/bJZT7jBt2EfL5ixz/9xuydVCf9J/kAMK6ac=; b=e6g75m9Cpin6IFBvYcLt3seelIlzB/5EA1sba8ZKGp1MZysns2u2PmcTf5kfvDfe41 Cpz9zAbp78YV85uwcEDRJyD+7U+j5wa0zEbmNFe6d6mwDQZeSAGywwD91SdPn98ZUoum 4pNgRUwoHNPIIwVDPdj4ZJQkG4ZQn0Kj6RP4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=5ddosn4/bJZT7jBt2EfL5ixz/9xuydVCf9J/kAMK6ac=; b=pbl0j2Yx0Z0B3dUw7JdJLtICn+Q52Lxn8kMSarXBe2OvRxFlR/T63luHncVHCljzn6 mAcr0RgWZpGtKMbQTxzrEw+bg1D5BTJ4/7tRoMjFeawCR4xlXFOUe431zDWZG/lccFAr jMXqTBi54uN/5gw7NDzL5MNJbKNJJ4okWzfbBxUbiOBEBmLzqD+FvFQ02hIs45nJnMPW FmeGQ6u8Ns1u0rM0Giqxaragf36xXw0NQPsDSSl1+RxP7pEjXOh2jcMdXswJJ94HkYh3 kTZKBhU9Pddz/A2c8OzGWRSVTS18xXQXdCwAZ7GrmG6WGdMcdIgyuFc+xktSF+Fr3/9z lcCQ== X-Gm-Message-State: AJIora+3fWnFdpeHFU6kTUglZ3cGaYXfsudpl1mWUN397gJgeiVAf0yC D+OhSlJBuzNfWcTOb80T2JdrzagP X-Google-Smtp-Source: AGRyM1tcUvWO3vnRCNR5zrSBpLsvTFWuYD1GN7AeRod5E3EWW0Lscr3XZZJ99IaK0VDYSXCVeO3iHg== X-Received: by 2002:a17:907:2848:b0:72b:5ba5:1db5 with SMTP id el8-20020a170907284800b0072b5ba51db5mr17543097ejc.703.1658914679549; Wed, 27 Jul 2022 02:37:59 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:680f:b0:72b:564b:c25b with SMTP id k15-20020a170906680f00b0072b564bc25bls1900897ejr.7.-pod-prod-gmail; Wed, 27 Jul 2022 02:37:58 -0700 (PDT) X-Received: by 2002:a17:907:2d26:b0:72f:d05:f530 with SMTP id gs38-20020a1709072d2600b0072f0d05f530mr16887394ejc.284.1658914678150; Wed, 27 Jul 2022 02:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914678; cv=none; d=google.com; s=arc-20160816; b=wp2hgw6cYNbtpE2gqG+SAoOJUhaT/6yMQ7ZsdPjHYRIkZbuWqlY7SJaL0K0zqQNwt4 GmgKMgY47c6xcnaIXaoLlMqJoNpkDsI4frh2uw24km4LuJQR/Tft+XHg9NE9bdisjq8+ tWM3ibNmUG8XEBCiGB8/NdLbtmlWL/PlIBpsNd8WDa2t4rJHPX12kz2mXhavytCtaNRr ShknzE8EZn4ZdRTfY2E6h4Lk80gfIhiCjx7Jj0Gts2ZA3Ps1NavLsiNsmzb1t+JY5KxB uDQPRi4Ik9pnkXKvDZfRHM1V4BuX/YtzZW4m3BwWfcrFHUNGDUf7TEG5+xjr9hiKyWTH QuRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=+Kmdd9fm+cOxM+5ZJRvmWU6Fbc3fNB7QutxwJjisqyQ=; b=ahrMPJ8TWOuVmBbfVQyMm0mLe0Z0EhBxkGnQWPSHuAkJhxJN1FE+Qx1HT8t4TVZFKD 9TJH3zCRDgFT3MjkRy+XMU6+4g8YiZsavyZwgvdwL7Mc6LrhKQmZ/ju8tXG6mH+Be+P6 FGXjfI8my/IyBA37TN6o24oLFrAaSFcajAiiPCbcMpyrndLRbzValJwW/xxAASQu1dC4 L6qcMUxyu7fUsKhzr6XZW6NQ3yepOigdBjXZXUjTS5kZjDxHkzXTi+AaYo3WxR/MOORQ JvpIKA4sgyuSIvS5FabLfwK8XQSqgkFTiICfRRfjrSew6Im4pYrh2iy7Hw+fYzeg4Sbb zJCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nMrQ2n5R; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id c2-20020a50d642000000b0043cbf85a224sor400559edj.18.2022.07.27.02.37.58 for (Google Transport Security); Wed, 27 Jul 2022 02:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:5516:b0:43a:42f9:24d6 with SMTP id fi22-20020a056402551600b0043a42f924d6mr10505093edb.204.1658914677823; Wed, 27 Jul 2022 02:37:57 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:57 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 4/7] mtd: nand: samsung: Retrieve ECC requirements from extended Date: Wed, 27 Jul 2022 11:37:45 +0200 Message-Id: <20220727093748.1415135-5-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nMrQ2n5R; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream linux commit 8fc82d456e40a0. On some nand controllers with hw-ecc the controller code wants to know the ecc strength and size and having these as 0, 0 is not accepted. Specifying these in devicetree is possible but undesirable as the nand may be different in different production runs of the same board, so it is better to get this info from the nand id where possible. This commit adds code to read the ecc strength and size from the nand for Samsung extended-id nands. This code is based on the info for the 5th id byte in the datasheets for the following Samsung nands: K9GAG08U0E, K9GAG08U0F, K9GAG08X0D, K9GBG08U0A, K9GBG08U0B. These all use these bits in the exact same way. Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/nand_samsung.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_samsung.c b/drivers/mtd/nand/raw/nand_samsung.c index 0ab8062193..36ef48e5ec 100644 --- a/drivers/mtd/nand/raw/nand_samsung.c +++ b/drivers/mtd/nand/raw/nand_samsung.c @@ -64,6 +64,26 @@ static void samsung_nand_decode_id(struct nand_chip *chip) extid >>= 2; mtd->erasesize = (128 * 1024) << (((extid >> 1) & 0x04) | (extid & 0x03)); + + /* Extract ECC requirements from 5th id byte*/ + extid = (chip->id.data[4] >> 4) & 0x07; + if (extid < 5) { + chip->ecc_step_ds = 512; + chip->ecc_strength_ds = 1 << extid; + } else { + chip->ecc_step_ds = 1024; + switch (extid) { + case 5: + chip->ecc_strength_ds = 24; + break; + case 6: + chip->ecc_strength_ds = 40; + break; + case 7: + chip->ecc_strength_ds = 60; + break; + } + } } else { nand_decode_ext_id(chip); } From patchwork Wed Jul 27 09:37:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2267 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4E69F3F1F7 for ; Wed, 27 Jul 2022 11:38:03 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id q16-20020a056402519000b0043bd73ad1basf7768257edd.3 for ; Wed, 27 Jul 2022 02:38:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914683; cv=pass; d=google.com; s=arc-20160816; b=YY0bKiAjB6plh9A6CWvvbVipAdoRbmQEwgpo85HIq8nCQrBzx24kdhjpMk9mc6Zh0Y S64sILGA9w7c0Me8BHizpf6nbGueRy0iwytT2B1M/139a64zAdGWTZlo6JWe+YAYq3JP PoU7v0diFS3mMpbTWhP1Y+cJM7JTCSb4e4GpP2MjCNvxM74lvVzMhZw3K2mjvdb95OF+ AQMuwmasozJtddISkINsO0s0nVNa05sp4pZm3S1CPvS89PLLbICVgEIYIT0zMRySDfnK k+MOgNX8coWlFNAR/AbkqXW/yGNHx7UbvYbPvmWm9mdX7qZIIUNVRHt0SjFGQE9XeiIl X0iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=RjGNs6MxOeqpLZbGd0XkMBKG81qp0kIMZLGuWK2gHX0=; b=u9XPPdswoRROFjF6zWIiQU1QvZULdtwa8lvin7l71N8IR5Wv3kv2yE72JDB64RsCNX DUwcC+e+zS2lEQ6bO3Wj5zH0+++NYu3lzXsxkXFAeI00qTdO5HcDEjlJxjbhBVgr9qoK K5DyjgUBhk2ucHgejd8SdkAvKgi2+zmQ5toKkukW1OyaFO6ZLmguKoqvc1Eb2Pc+ZSMY OLuTA7hwdz10nqDeWBox9uOsEExX4ri/fJGQQgvD0DKSL7XHXVFWTNbVm6+kvq7ZIaDm Xz/ljzASpfawPcarwxmTtjQ27QMVigZ6FeG1VbWIzV6cGYJJpGCu9SM4CmAG2ytqg94X B7YQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHcl8wBk; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=RjGNs6MxOeqpLZbGd0XkMBKG81qp0kIMZLGuWK2gHX0=; b=gppQFCu/rT9Rlw8ybRmMFHTqgIrl7E1u7l9n0XLRWpddscLsoJ1RdwxUyJ5QRwWdNV y5VEtqKQxA+c3Be00ZoPQpBvZ2EWTcZicD7ahrPo2+CaxdVbdon92U5OxmCePLMXB56N 4FMXKwsIh4f7CCYtzxkerxQ/GF2lyZpwGZdEw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=RjGNs6MxOeqpLZbGd0XkMBKG81qp0kIMZLGuWK2gHX0=; b=4Rn+Nu9lPrtyqGrsameT4yqZzYZENZZl8TRI5XrATt7CeL16zJRh4vY4TlPOh48oxt /kvcB8InlfEExqmU5jMv8XkzgEwTPRv78W2cjhr1pvjcZTUFuiSKN1IRsIpk6AYc6gO7 kcQE5MN7Mb7saKEYI/FNxik2X7QfZzPGxDvTaz4JCFXZ/PHdS1Hyb4bNGdO13Az8uzOV 3QfMZ5yVD7nHWmagP6/Zs84PgEc89Z2xX5OWa8+u26SBH8XPxFMlQJbkRobOo6wtQ2+E 0gjdpDOXobViKZfarY7yPZmYXHEgrqmy+ZWLbs1dPdVKCD21RQsL9iFmMrTyeGMsCc6a bwgQ== X-Gm-Message-State: AJIora9jJZ8aDVoFnu6LZHMP1hZVU9eq2q5uOvqzUn0sy1WTvTBRdJl/ ce+QVFPDig7NDYChNqvuVaCiSS2p X-Google-Smtp-Source: AGRyM1vZOyexRKnC9uiO9HjmJvW9FIEo7bK+YJw22bpLySZjga+v6KHj5GllxiSxRScym7ouijuMuA== X-Received: by 2002:a17:907:3e0e:b0:72b:568f:7fa7 with SMTP id hp14-20020a1709073e0e00b0072b568f7fa7mr17702393ejc.119.1658914680672; Wed, 27 Jul 2022 02:38:00 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:680f:b0:72b:564b:c25b with SMTP id k15-20020a170906680f00b0072b564bc25bls1900920ejr.7.-pod-prod-gmail; Wed, 27 Jul 2022 02:37:59 -0700 (PDT) X-Received: by 2002:a17:906:844c:b0:72b:4d77:fd83 with SMTP id e12-20020a170906844c00b0072b4d77fd83mr17541035ejy.151.1658914679478; Wed, 27 Jul 2022 02:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914679; cv=none; d=google.com; s=arc-20160816; b=H3ppfeJdfKLL6wikkln5N38tNP7yNpJoIOCvyhQSo8pOOrJcxF3hzJaMTYKHwwpyBd 5aFM+433e/Knzy/tRV2yenikKoMmwT2KJ1JC/lOumOAcWx7EnaXgonqzQVSKW4/8eTJ7 FGXDUqPxDzlYMxdHvNxb0sHbhwszb04op9Ns2sXrdSp4uq5c7OxDezO79hqqhltOk+M3 N26inbkf1COlLmRatigfZPvKzvz0C9HwF68q5B4R6NubErjGPAFSp1F4VsPE3p7LixsJ z/fodcMWGoXxLxUaXKyQHz+liwrdoWRzZf0cjI9rAQI2+3U3IhVGIsxwhatQLSEXZh4O RlvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=ZlSwORXpfbA7ZP6exhkpLuqHtEFhtBdAE2uTkn1B4uo=; b=TdNSbUcjMuQVrgAPozDYiQL1vYsNLDke0Z79r114QNrl3w4cNcZ4PA56RVwvqrOFYX ktSEz9CXycWCadwIVHU5eHsFBvDHL/4GFQ1H4zktFF3i2rcC6b/wevC/4gB+DpeDmmpH UKbiYDvDIsxUpiENr5dYo2ka2cZo+1eTwvqWpF1eoOlQ0QxPniAhxBCYtOMe5bbKcra4 t/oU+SYplL0Dv4RYpsFqIo9dquK3a3Q0vXvUHJCCoBwOVRsUyPqc/3g1Dgok3a5zixTm 6l9T8zGZh3qFnI9+fAcVkwIpfdzNJbVzR1t1kgn1fF4vPXCEN3YktMwmrKRKbSMqXWn2 fKCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHcl8wBk; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d16-20020a50f690000000b0043ba4f8d2e5sor8286709edn.52.2022.07.27.02.37.59 for (Google Transport Security); Wed, 27 Jul 2022 02:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:aa7:ccc8:0:b0:43b:e3b4:bc0a with SMTP id y8-20020aa7ccc8000000b0043be3b4bc0amr18562103edt.289.1658914679064; Wed, 27 Jul 2022 02:37:59 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:58 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 5/7] mtd: nand: Fix ecc in mxs_nand_spl onfi mode Date: Wed, 27 Jul 2022 11:37:46 +0200 Message-Id: <20220727093748.1415135-6-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHcl8wBk; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We need to calculate the ecc parameters in a way that are the same in uboot and spl. The parameters are connected to the onfi computation. We need to assign all the value of chip in order to have same ecc strength parameters before calling mxs_nand_set_geometry that calculate the ecc layout /* use the legacy bch setting by default */ if ((!nand_info->use_minimum_ecc && mtd->oobsize < 1024) || !(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0)) { dev_dbg(mtd->dev, "use legacy bch geometry\n"); err = mxs_nand_legacy_calc_ecc_layout(geo, mtd); if (!err) return 0; } Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mxs_nand_spl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 4dffa76eaf..6d8ec5b3cb 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -139,6 +139,10 @@ static int mxs_flash_onfi_ident(struct mtd_info *mtd) mtd->writesize = le32_to_cpu(p->byte_per_page); mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize; mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page); + if (p->ecc_bits != 0xff) { + chip->ecc_strength_ds = p->ecc_bits; + chip->ecc_step_ds = 512; + } chip->chipsize = le32_to_cpu(p->blocks_per_lun); chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count; /* Calculate the address shift from the page size */ @@ -152,6 +156,8 @@ static int mxs_flash_onfi_ident(struct mtd_info *mtd) debug("writesize=%d (>>%d)\n", mtd->writesize, chip->page_shift); debug("oobsize=%d\n", mtd->oobsize); debug("chipsize=%lld\n", chip->chipsize); + debug("ecc_strength_ds=%d\n", chip->ecc_strength_ds); + debug("ecc_step_ds = %d\n", chip->ecc_step_ds); return 0; } From patchwork Wed Jul 27 09:37:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2266 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2CB573F1F7 for ; Wed, 27 Jul 2022 11:38:02 +0200 (CEST) Received: by mail-ej1-f71.google.com with SMTP id sc42-20020a1709078a2a00b0072b5f51a9dbsf4917586ejc.1 for ; Wed, 27 Jul 2022 02:38:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914682; cv=pass; d=google.com; s=arc-20160816; b=IC6m9/xCsR1wDcRX/iLbqMfCAKus/XxOYzp7NRn1V8TCiUB16kiUCUFQ3lTHTD1+Zb BP97bxe309FxD3llt3v5XK9UrRL2ieSW5weKWnflunkd3rJF8+AhF3QyiXk3ewsdoVeW mOTz3laBqo2eE13zqu0moggszvIFtjOrAb3V2ucuFp3fAml72QCJ6NZfk3W5jLYJ1y3q IiYF+2XVVv0m6Erpz8v+mmY0+qmk1anNpQVCU0ToNTp+0lrrmUUzaOf7YKpakttT5ibB pm5FX1Biziq0dz2g77pqVCGqAN03TKCir6VmKmRih7xAf1bUqpYNwRp/olXFm/YTiLaz RtWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=br1mcQycVJoLCck3UiyyTozvRH410Qsu7npSSDXy79M=; b=Gb+J+JeFqlEvKJtxLOjiK+wVnL9/JGsV1FiBgWqPmjBz5cmnAHwe7NakfEYSpUIYsG NLD3l7KntWGWk3ZsQgx0q0+GzkwdH1kh0L/4A+EFAgWOh9Inip8ob7EefTwrB/wJ7DcT i5lFlgpT+PH6eL05KSM8OOk1Pxmjz55NCuJxcTQfpEvwg33YRqriBfSEBpl4e97+Q0Qk QZbkLHGh+VGLHUbQLcNj65iTrTb65EoyK6S2YA55urcBpuDjqPawOnRKf2RQ73/okn8y ObVxkiIPrJ+NshY5j8LtzE3ok/zJdsqqRqnHD/8zckS0Br1fCEjHQtjsC2cKVzjYL9ZV dPVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=COBy4SME; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=br1mcQycVJoLCck3UiyyTozvRH410Qsu7npSSDXy79M=; b=UgAfNqoZyhbXEpdvXqN5aigSODZMpXNX3YC7CGNajEIN8awsXlE79GLPlUQ21DChmm 4zJs2Pzjt7JORCmxldLhb5yJg7qPzzgWUu/ZYXzzq3XoduermpWbFpmL4SwRU1WzlYB3 hheABP27yiBkwilMO3QS4MaZW05/fYYL8DM1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=br1mcQycVJoLCck3UiyyTozvRH410Qsu7npSSDXy79M=; b=UouJrsRCwXr6oXdDx35UAhJDFrTbHX1jwDEcg93jdA02XOBTGwoKFwq3X1xkuxie+x AcunGjqc7uVtEeXhB61t+7OW0fwi0uprFC6h4Mxb5O8pujy/+qkhrPmfDqoA1FcWeeaq peWfm7VuE1XUCxkmxeXMilaz0s5IaU11Hd2dIk0CtoUiPwTn+P9feS0eAtzVwGcLoRny 3tqTv4TrjNY4FSp5k6GGlYLOSEavgJUAhOGKPHMmTRZOZ90i1Zb7ftVYYCoTUo9LreRE QpA8ymdV8OMFS1asfTNJJi0bfohB9ZZsfamKwpa+9gO28FgeNK8ODEHugOdm8s0Eof2+ cCcw== X-Gm-Message-State: AJIora8Z1N5narwfQiAGBC1dZuslXekFCVt3qLiXvbU8qa4viUNLvQns z1VgHbiZ5bwc78dTEPovp/q8XV71 X-Google-Smtp-Source: AGRyM1uAKruciYNWn9n8tAIb6oxvEn3xnxkO+hCSwHMHYv2yyVL8emmK2owHKZStfkeJnExhZNLDig== X-Received: by 2002:a05:6402:5415:b0:43b:a888:fefe with SMTP id ev21-20020a056402541500b0043ba888fefemr22088675edb.302.1658914681931; Wed, 27 Jul 2022 02:38:01 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:4248:b0:43a:77a6:b0d with SMTP id g8-20020a056402424800b0043a77a60b0dls313648edb.3.-pod-prod-gmail; Wed, 27 Jul 2022 02:38:00 -0700 (PDT) X-Received: by 2002:a05:6402:2756:b0:43b:fda4:abc6 with SMTP id z22-20020a056402275600b0043bfda4abc6mr13823757edd.274.1658914680485; Wed, 27 Jul 2022 02:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914680; cv=none; d=google.com; s=arc-20160816; b=IJzOTQJThOgw+lostBjy7dmbFi0f4zYiMvIWykSCNZ2uiAJ2DL8c1spI1qM+ApMiPY Jy7GEXshXoesPj98FOfZn4/hColFf4pXf4CnH3GIO8cpMHX10AxC+Asx7kOH6DesZ06d FXN89XDamjfYh7AZOftwifkBgw3hdcLldHsnNFCZeUB5MUa5wjCKq2QdtR8cOcojS358 OI1h8bWOKDal6DlJRAcw3BJkYaVGYKyXUawBX9dMODlhMB4tX0QeT48UOJRCzQ5XfpC2 nVPAZVUWRCn2rUtcSLG3lG8QnGIVrU1hmF5U+nDkmcLDOpVdN4aCI8SzTUvBaefCq44K sgNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=DD7+ShKgaM7CrLp2fVtWX6L/5dfIJ86fIXwLfW6VMfE=; b=Cmmf8jbxfq7QK7StjnstZkw7Q6VM/HwSf1NrPXx6SJC8pMX2a2lBJ67rjdYU8AKjXG MombFebjM8oKRtOXGxdhDlNEHsGLX2yfN+Do37v0KQAK6rJFPcPwrmn81Yr80FfDiR5H zK6E2d9v8+Q9x/J79SNL6FBFfr+n/DCkaTZNZ7fjXd4Nr9AdFYjBVnLRbGvMXZblpb86 v44C1B7v7j7NfPt/6e6DQ16cohK0QZJoDjZ1M0KbyOP3cmZwF6VTTr94DSsYH7cUKZsH EHQVqSf/slncoQTuuut9VGOBw5PyxN5NNdWjELbrb8En6xefUxEstpmkHwkhRWhelckd 6X0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=COBy4SME; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id s10-20020a170906a18a00b00702d89a4050sor6213168ejy.54.2022.07.27.02.38.00 for (Google Transport Security); Wed, 27 Jul 2022 02:38:00 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:84e8:b0:72b:6d91:a0d1 with SMTP id zp8-20020a17090684e800b0072b6d91a0d1mr17606571ejb.60.1658914680211; Wed, 27 Jul 2022 02:38:00 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:59 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 6/7] mtd: nand: mxs_nand_spl Fix loop exit condition Date: Wed, 27 Jul 2022 11:37:47 +0200 Message-Id: <20220727093748.1415135-7-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=COBy4SME; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When size is 0 we need to stop the inner loop or we just waste time to load all the block of the eraseblock Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mxs_nand_spl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 6d8ec5b3cb..c7ea09e2f9 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -260,10 +260,10 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) page_offset = offs % mtd->writesize; nand_page_per_block = mtd->erasesize / mtd->writesize; - while (block <= lastblock && size > 0) { + while (block <= lastblock) { if (!is_badblock(mtd, mtd->erasesize * block, 1)) { /* Skip bad blocks */ - while (page < nand_page_per_block) { + while (page < nand_page_per_block && size > 0) { int curr_page = nand_page_per_block * block + page; if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) { From patchwork Wed Jul 27 09:37:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2268 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A38893F330 for ; Wed, 27 Jul 2022 11:38:03 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id b15-20020a056402278f00b0043acaf76f8dsf10523854ede.21 for ; Wed, 27 Jul 2022 02:38:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914683; cv=pass; d=google.com; s=arc-20160816; b=Yway9joLw+q35PJf4muTGRgg5XEtkCNDuPK7dYzudxl/GAMtZwaM+LycHlF/4s6BK5 AI+qF+Aln+96cYr4u8owh+Lp4af6j1rIeNhuhUBnh881uqUItQggFjoeTN0NM//tTlMt GQJnNM5wNLEeCQ89F7KoEOOIYFDPEfldf5p25hGrfLRFRlueUETbHUS9S5G9g/5/LtWT EywJCP5lJUF+pV9ZhmggMG8cDWHbwJgUaEFYm/rwANsfc54FuZrnIpc4at6GyrGF7hc8 wl2cOHmGD1jAXj7ZRjXV/3EOOtg0LOlMojKRRI7J5wfy9EmpadvpDg3FJJUP5x2jD0i2 7VmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=hGQK7q3kYEStFWJxXj+NZCTCHwxTvLngnioWV2DdpOo=; b=zG655dUrjwXF8UH/O8YT9T0c/ZAjh8DNxpQ9zjfOZJmvrgyoG+3hXaDZT1PLCYI7x5 6gTNMqUNBzWsDL++7ly4NQsh0yqR4FvodVvwUn3WVBJb5Okh6gtalmu8mTDOKc+kwn1d xS0Qpgkz4K1pDVhELMmpMZg6cw1H6tcw9Wzzn/o/xYOfl4X0f66cQAtnVc3zf+6qLViX TwjdbT3Bv0RpSgEXENK4ELfrRK0WROVNUxUjFLp+0lgCaFOMbUWWAAVTAf+1E70e0gU9 uttwwiN8M9UnTKEuwzJWxw/UK3XBvgnGjnVMji+gcuTRSLTJ7pC9CA37o30tfCsu2ZRO dPjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KZ8hSNfI; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=hGQK7q3kYEStFWJxXj+NZCTCHwxTvLngnioWV2DdpOo=; b=I0UHHJ5fK+PZwUW3F5QgIu2vQ0s57+nZc5Yp6kQrpq9W5AUOwGwAlimYuCi8hycQI4 TSgPP6wBwJcMtQshUfJsmNbZ3ICT9M0uTBpotb2/XQj1pmavwpaxwfX6Tb4PDCb0NNcJ lU6K6Yq1AlxZldy3TSVq90iKW47wQhP24PcvE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=hGQK7q3kYEStFWJxXj+NZCTCHwxTvLngnioWV2DdpOo=; b=DxkyvLtWq4SbgUNOfqqaHwaLmIi/C9ZmcgxhBEakhC1Cfvso72w/jH8/OgF61xy2sI 2DNi6cmoKt3jHzw8KhpQjKlyaAjGdEew03q+4Ifzv5eo8C21CL+wzqFmxKDaVgx5Paa+ 9lPB4pHF2AureVqZGBhW0PqD00p99drT+NImynVdPF5WfT3t0zWhYUpQLSHtjUO8dBx8 YvG09pOCRH0lVi93hV0806bN8qWl8qynXy83FmXqU15PJ1m0+tvBuBDpcOifzPLVoxsd qO6JryoAMNUkp++eaekmtr0yyAHPvJGDP1FhD4atfdk7iJgzLq050sZl1tu0V7S7eEch y15Q== X-Gm-Message-State: AJIora9rt2dLwDP9TxwSKnoxGpLOO5xXTKPEdFSCP/i6WoJYOdJfUldO fA361IKNpj4XmL3eU8ytKhCaVOiM X-Google-Smtp-Source: AGRyM1tNprOv8Hi6kXRG0y/OUSt3tllS/qQx8ZiWsvbY9NRv29hRowOx8hzz0gOCh/DgG/gTuiH0ZQ== X-Received: by 2002:a17:907:2722:b0:72b:735a:d3b4 with SMTP id d2-20020a170907272200b0072b735ad3b4mr17032431ejl.363.1658914683266; Wed, 27 Jul 2022 02:38:03 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:9419:b0:72f:5c1f:1852 with SMTP id q25-20020a170906941900b0072f5c1f1852ls1901926ejx.0.-pod-prod-gmail; Wed, 27 Jul 2022 02:38:02 -0700 (PDT) X-Received: by 2002:a17:906:49d4:b0:6d6:e5ec:9a23 with SMTP id w20-20020a17090649d400b006d6e5ec9a23mr17385093ejv.79.1658914681870; Wed, 27 Jul 2022 02:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914681; cv=none; d=google.com; s=arc-20160816; b=wQZZnY9nbfbdoB/PpqqM6yYg5VxXEHhrDzhXkMwezDQ/pytDdYy0dnYeXNmNCJkSdt RIx0jqkFGXKwLJLtGJtVgieJh0Ihdz3ITO91zJGORxmvHyBlLBGbjE0HleOXJi6nUJ2F +Z512a7NmmouNMv0HJ4WVpY6u5VDRxQIQrHPWUWR/21pscV1eVCra/cJcJGb68OxoL3Y abBWO7yV3kKTvAbEoFre3ja65ZFLhvHscbVvxbP9MSTz0mcAjlUHAcoaivjpy8fqJ2PK BWSRFKMbB0/jcdUKs5nnL+OYhx6pj673qGSA14//8pKa4ShcNLC51sHSdoWAFmJvN3+6 TA1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=UZUZXKxTq2eFYFCwdvp9L9eetpmBXu2yxepeYUnvBdw=; b=r6C4HUfdrDkvpv1lmSoWDv2EU8bnwU7oAW7MXoZCkjQVjOdUjtWQLEZOstErFoKj1W 9xWtmfsNzv7lEkFbtuiP+2H3wX3erGk6sEHLdA7XExJazS0bhBNq1aS5UnVAwkq+yIIT f2500pbmOmTN8wLrY8D3cizc3BEt43CWwYZcPF65ZffYpbC4ZFLLAkWOJVYMA35hvnnC 3Y0ohkSXhczhahaF27pKE3bfLM2TnQEufOyeH9QNmCMnEaiuENTmcWHkJR9KPwxLHSkX OzETbe6HDKDeX1kw6so6l6GxL+xSXu51wirozltFEt+C9w0zZOAge2UwTnV1deX6edIi oWtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KZ8hSNfI; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d16-20020a50f690000000b0043ba4f8d2e5sor8286748edn.52.2022.07.27.02.38.01 for (Google Transport Security); Wed, 27 Jul 2022 02:38:01 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:5193:b0:43b:e957:cdef with SMTP id q19-20020a056402519300b0043be957cdefmr17067650edd.345.1658914681537; Wed, 27 Jul 2022 02:38:01 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:38:01 -0700 (PDT) From: Michael Trimarchi To: dario.binacchi@amarulasolutions.com, Tommaso Merciai , linux-amarula@amarulasolutions.com Subject: [PATCH 7/7] mtd: nand: Add a common spl layer for nand subsystem Date: Wed, 27 Jul 2022 11:37:48 +0200 Message-Id: <20220727093748.1415135-8-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KZ8hSNfI; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Avoid code duplication accross drivers but make them use the same implementation. Create nand_common_spl to implement the part that does not depend on nand chipset. Apply to - mxs nand spl driver - mt7621 spl driver The mt7621 now as side effect implement nand_spl_adjust_offset, that implements bad block handle for complex image like fitImage Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/Makefile | 4 +- drivers/mtd/nand/raw/mt7621_nand_spl.c | 188 +------------------ drivers/mtd/nand/raw/mxs_nand_spl.c | 176 +----------------- drivers/mtd/nand/raw/nand_common_spl.c | 245 +++++++++++++++++++++++++ drivers/mtd/nand/raw/nand_common_spl.h | 15 ++ 5 files changed, 269 insertions(+), 359 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_common_spl.c create mode 100644 drivers/mtd/nand/raw/nand_common_spl.h diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index a398aa9d88..82ddb2b5d8 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -87,8 +87,8 @@ else # minimal SPL drivers obj-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_spl.o obj-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_spl.o obj-$(CONFIG_NAND_MXC) += mxc_nand_spl.o -obj-$(CONFIG_NAND_MXS) += mxs_nand_spl.o mxs_nand.o +obj-$(CONFIG_NAND_MXS) += mxs_nand_spl.o mxs_nand.o nand_common_spl.o obj-$(CONFIG_NAND_SUNXI) += sunxi_nand_spl.o -obj-$(CONFIG_NAND_MT7621) += mt7621_nand_spl.o mt7621_nand.o +obj-$(CONFIG_NAND_MT7621) += mt7621_nand_spl.o mt7621_nand.o nand_common_spl.o endif # drivers diff --git a/drivers/mtd/nand/raw/mt7621_nand_spl.c b/drivers/mtd/nand/raw/mt7621_nand_spl.c index 114fc8b7ce..254e14a553 100644 --- a/drivers/mtd/nand/raw/mt7621_nand_spl.c +++ b/drivers/mtd/nand/raw/mt7621_nand_spl.c @@ -10,187 +10,13 @@ #include #include #include +#include "nand_common_spl.h" #include "mt7621_nand.h" +#include "nand_common_spl.h" static struct mt7621_nfc nfc_dev; -static u8 *buffer; static int nand_valid; -static void nand_command_lp(struct mtd_info *mtd, unsigned int command, - int column, int page_addr) -{ - register struct nand_chip *chip = mtd_to_nand(mtd); - - /* Command latch cycle */ - chip->cmd_ctrl(mtd, command, NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - - if (column != -1 || page_addr != -1) { - int ctrl = NAND_CTRL_CHANGE | NAND_NCE | NAND_ALE; - - /* Serially input address */ - if (column != -1) { - chip->cmd_ctrl(mtd, column, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; - if (command != NAND_CMD_READID) - chip->cmd_ctrl(mtd, column >> 8, ctrl); - } - if (page_addr != -1) { - chip->cmd_ctrl(mtd, page_addr, ctrl); - chip->cmd_ctrl(mtd, page_addr >> 8, - NAND_NCE | NAND_ALE); - if (chip->options & NAND_ROW_ADDR_3) - chip->cmd_ctrl(mtd, page_addr >> 16, - NAND_NCE | NAND_ALE); - } - } - chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); - - /* - * Program and erase have their own busy handlers status, sequential - * in and status need no delay. - */ - switch (command) { - case NAND_CMD_STATUS: - case NAND_CMD_READID: - case NAND_CMD_SET_FEATURES: - return; - - case NAND_CMD_READ0: - chip->cmd_ctrl(mtd, NAND_CMD_READSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); - } - - /* - * Apply this short delay always to ensure that we do wait tWB in - * any case on any machine. - */ - ndelay(100); - - nand_wait_ready(mtd); -} - -static int nfc_read_page_hwecc(struct mtd_info *mtd, void *buf, - unsigned int page) -{ - struct nand_chip *chip = mtd_to_nand(mtd); - int ret; - - chip->cmdfunc(mtd, NAND_CMD_READ0, 0x0, page); - - ret = chip->ecc.read_page(mtd, chip, buf, 1, page); - if (ret < 0 || ret > chip->ecc.strength) - return -1; - - return 0; -} - -static int nfc_read_oob_hwecc(struct mtd_info *mtd, void *buf, u32 len, - unsigned int page) -{ - struct nand_chip *chip = mtd_to_nand(mtd); - int ret; - - chip->cmdfunc(mtd, NAND_CMD_READ0, 0x0, page); - - ret = chip->ecc.read_page(mtd, chip, NULL, 1, page); - if (ret < 0) - return -1; - - if (len > mtd->oobsize) - len = mtd->oobsize; - - memcpy(buf, chip->oob_poi, len); - - return 0; -} - -static int nfc_check_bad_block(struct mtd_info *mtd, unsigned int page) -{ - struct nand_chip *chip = mtd_to_nand(mtd); - u32 pages_per_block, i = 0; - int ret; - u8 bad; - - pages_per_block = 1 << (mtd->erasesize_shift - mtd->writesize_shift); - - /* Read from first/last page(s) if necessary */ - if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) { - page += pages_per_block - 1; - if (chip->bbt_options & NAND_BBT_SCAN2NDPAGE) - page--; - } - - do { - ret = nfc_read_oob_hwecc(mtd, &bad, 1, page); - if (ret) - return ret; - - ret = bad != 0xFF; - - i++; - page++; - } while (!ret && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE) && i < 2); - - return ret; -} - -int nand_spl_load_image(uint32_t offs, unsigned int size, void *dest) -{ - struct mt7621_nfc *nfc = &nfc_dev; - struct nand_chip *chip = &nfc->nand; - struct mtd_info *mtd = &chip->mtd; - u32 addr, col, page, chksz; - bool check_bad = true; - - if (!nand_valid) - return -ENODEV; - - while (size) { - if (check_bad || !(offs & mtd->erasesize_mask)) { - addr = offs & (~mtd->erasesize_mask); - page = addr >> mtd->writesize_shift; - if (nfc_check_bad_block(mtd, page)) { - /* Skip bad block */ - if (addr >= mtd->size - mtd->erasesize) - return -1; - - offs += mtd->erasesize; - continue; - } - - check_bad = false; - } - - col = offs & mtd->writesize_mask; - page = offs >> mtd->writesize_shift; - chksz = min(mtd->writesize - col, (uint32_t)size); - - if (unlikely(chksz < mtd->writesize)) { - /* Not reading a full page */ - if (nfc_read_page_hwecc(mtd, buffer, page)) - return -1; - - memcpy(dest, buffer + col, chksz); - } else { - if (nfc_read_page_hwecc(mtd, dest, page)) - return -1; - } - - dest += chksz; - offs += chksz; - size -= chksz; - } - - return 0; -} - -int nand_default_bbt(struct mtd_info *mtd) -{ - return 0; -} - unsigned long nand_size(void) { if (!nand_valid) @@ -203,10 +29,6 @@ unsigned long nand_size(void) return SZ_2G; } -void nand_deselect(void) -{ -} - void nand_init(void) { struct mtd_info *mtd; @@ -219,7 +41,7 @@ void nand_init(void) chip = &nfc_dev.nand; mtd = &chip->mtd; - chip->cmdfunc = nand_command_lp; + chip->cmdfunc = nand_spl_command_lp; if (mt7621_nfc_spl_post_init(&nfc_dev)) return; @@ -229,9 +51,7 @@ void nand_init(void) mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1; mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; - buffer = malloc(mtd->writesize); - if (!buffer) - return; + nand_spl_init(chip); nand_valid = 1; } diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index c7ea09e2f9..5cff6020c4 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -14,66 +14,11 @@ #include #include #include +#include "nand_common_spl.h" static struct mtd_info *mtd; static struct nand_chip nand_chip; -static void mxs_nand_command(struct mtd_info *mtd, unsigned int command, - int column, int page_addr) -{ - register struct nand_chip *chip = mtd_to_nand(mtd); - u32 timeo, time_start; - - /* write out the command to the device */ - chip->cmd_ctrl(mtd, command, NAND_CLE); - - /* Serially input address */ - if (column != -1) { - /* Adjust columns for 16 bit buswidth */ - if (chip->options & NAND_BUSWIDTH_16 && - !nand_opcode_8bits(command)) - column >>= 1; - chip->cmd_ctrl(mtd, column, NAND_ALE); - - /* - * Assume LP NAND here, so use two bytes column address - * but not for CMD_READID and CMD_PARAM, which require - * only one byte column address - */ - if (command != NAND_CMD_READID && - command != NAND_CMD_PARAM) - chip->cmd_ctrl(mtd, column >> 8, NAND_ALE); - } - if (page_addr != -1) { - chip->cmd_ctrl(mtd, page_addr, NAND_ALE); - chip->cmd_ctrl(mtd, page_addr >> 8, NAND_ALE); - /* One more address cycle for devices > 128MiB */ - if (chip->chipsize > (128 << 20)) - chip->cmd_ctrl(mtd, page_addr >> 16, NAND_ALE); - } - chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0); - - if (command == NAND_CMD_READ0) { - chip->cmd_ctrl(mtd, NAND_CMD_READSTART, NAND_CLE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0); - } else if (command == NAND_CMD_RNDOUT) { - /* No ready / busy check necessary */ - chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, - NAND_NCE | NAND_CLE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE); - } - - /* wait for nand ready */ - ndelay(100); - timeo = (CONFIG_SYS_HZ * 20) / 1000; - time_start = get_timer(0); - while (get_timer(time_start) < timeo) { - if (chip->dev_ready(mtd)) - break; - } -} - #if defined (CONFIG_SPL_NAND_IDENT) /* Trying to detect the NAND flash using ONFi, JEDEC, and (extended) IDs */ @@ -175,35 +120,6 @@ static int mxs_flash_ident(struct mtd_info *mtd) return ret; } -static int mxs_read_page_ecc(struct mtd_info *mtd, void *buf, unsigned int page) -{ - register struct nand_chip *chip = mtd_to_nand(mtd); - int ret; - - chip->cmdfunc(mtd, NAND_CMD_READ0, 0x0, page); - ret = nand_chip.ecc.read_page(mtd, chip, buf, 1, page); - if (ret < 0) { - printf("read_page failed %d\n", ret); - return -1; - } - return 0; -} - -static int is_badblock(struct mtd_info *mtd, loff_t offs, int allowbbt) -{ - register struct nand_chip *chip = mtd_to_nand(mtd); - unsigned int block = offs >> chip->phys_erase_shift; - unsigned int page = offs >> chip->page_shift; - - debug("%s offs=0x%08x block:%d page:%d\n", __func__, (int)offs, block, - page); - chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page); - memset(chip->oob_poi, 0, mtd->oobsize); - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); - - return chip->oob_poi[0] != 0xff; -} - /* setup mtd and nand structs and init mxs_nand driver */ void nand_init(void) { @@ -215,7 +131,7 @@ void nand_init(void) mxs_nand_init_spl(&nand_chip); mtd = nand_to_mtd(&nand_chip); /* set mtd functions */ - nand_chip.cmdfunc = mxs_nand_command; + nand_chip.cmdfunc = nand_spl_command_lp; nand_chip.scan_bbt = nand_default_bbt; nand_chip.numchips = 1; @@ -234,92 +150,6 @@ void nand_init(void) mtd->size = nand_chip.chipsize; nand_chip.scan_bbt(mtd); mxs_nand_setup_ecc(mtd); -} - -int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) -{ - unsigned int sz; - unsigned int block, lastblock; - unsigned int page, page_offset; - unsigned int nand_page_per_block; - struct nand_chip *chip; - u8 *page_buf = NULL; - - chip = mtd_to_nand(mtd); - if (!chip->numchips) - return -ENODEV; - - page_buf = malloc(mtd->writesize); - if (!page_buf) - return -ENOMEM; - - /* offs has to be aligned to a page address! */ - block = offs / mtd->erasesize; - lastblock = (offs + size - 1) / mtd->erasesize; - page = (offs % mtd->erasesize) / mtd->writesize; - page_offset = offs % mtd->writesize; - nand_page_per_block = mtd->erasesize / mtd->writesize; - - while (block <= lastblock) { - if (!is_badblock(mtd, mtd->erasesize * block, 1)) { - /* Skip bad blocks */ - while (page < nand_page_per_block && size > 0) { - int curr_page = nand_page_per_block * block + page; - - if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) { - free(page_buf); - return -EIO; - } - - if (size > (mtd->writesize - page_offset)) - sz = (mtd->writesize - page_offset); - else - sz = size; - - memcpy(dst, page_buf + page_offset, sz); - dst += sz; - size -= sz; - page_offset = 0; - page++; - } - - page = 0; - } else { - lastblock++; - } - - block++; - } - - free(page_buf); - - return 0; -} - -int nand_default_bbt(struct mtd_info *mtd) -{ - return 0; -} - -void nand_deselect(void) -{ -} - -u32 nand_spl_adjust_offset(u32 sector, u32 offs) -{ - unsigned int block, lastblock; - - block = sector / mtd->erasesize; - lastblock = (sector + offs) / mtd->erasesize; - - while (block <= lastblock) { - if (is_badblock(mtd, block * mtd->erasesize, 1)) { - offs += mtd->erasesize; - lastblock++; - } - - block++; - } - return offs; + nand_spl_init(&nand_chip); } diff --git a/drivers/mtd/nand/raw/nand_common_spl.c b/drivers/mtd/nand/raw/nand_common_spl.c new file mode 100644 index 0000000000..0595fcbc26 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_common_spl.c @@ -0,0 +1,245 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Amarula Solutions B.V. All rights reserved. + * + * Author: Michael Trimarchi + * Author: Weijie Gao + */ + +#include +#include +#include +#include +#include +#include + +static struct nand_chip *nand; +static u8 *buffer; +static int nand_valid; + +int nand_spl_init(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + + if (!mtd) + return -EINVAL; + + buffer = malloc(mtd->writesize); + if (!buffer) + return -ENOMEM; + + nand = chip; + nand_valid = 1; + + return 0; +} + +static struct nand_chip *nand_spl_get_chip(void) +{ + return nand; +} + +void nand_spl_command_lp(struct mtd_info *mtd, unsigned int command, + int column, int page_addr) +{ + register struct nand_chip *chip = mtd_to_nand(mtd); + u32 timeo, time_start; + + /* Command latch cycle */ + chip->cmd_ctrl(mtd, command, NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + + if (column != -1 || page_addr != -1) { + int ctrl = NAND_CTRL_CHANGE | NAND_NCE | NAND_ALE; + + /* Serially input address */ + if (column != -1) { + chip->cmd_ctrl(mtd, column, ctrl); + ctrl &= ~NAND_CTRL_CHANGE; + if (command != NAND_CMD_READID) + chip->cmd_ctrl(mtd, column >> 8, ctrl); + } + if (page_addr != -1) { + chip->cmd_ctrl(mtd, page_addr, ctrl); + chip->cmd_ctrl(mtd, page_addr >> 8, + NAND_NCE | NAND_ALE); + if (chip->options & NAND_ROW_ADDR_3) + chip->cmd_ctrl(mtd, page_addr >> 16, + NAND_NCE | NAND_ALE); + } + } + chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + + /* + * Program and erase have their own busy handlers status, sequential + * in and status need no delay. + */ + switch (command) { + case NAND_CMD_STATUS: + case NAND_CMD_READID: + case NAND_CMD_SET_FEATURES: + return; + + case NAND_CMD_READ0: + chip->cmd_ctrl(mtd, NAND_CMD_READSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); + } + + /* + * Apply this short delay always to ensure that we do wait tWB in + * any case on any machine. + */ + ndelay(100); + + timeo = (CONFIG_SYS_HZ * 20) / 1000; + time_start = get_timer(0); + while (get_timer(time_start) < timeo) { + if (chip->dev_ready(mtd)) + break; + } +} + +static int nand_spl_read_page_hwecc(struct mtd_info *mtd, void *buf, + unsigned int page) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + int ret; + + chip->cmdfunc(mtd, NAND_CMD_READ0, 0x0, page); + + ret = chip->ecc.read_page(mtd, chip, buf, 1, page); + if (ret < 0 || ret > chip->ecc.strength) + return -1; + + return 0; +} + +static int nand_spl_read_oob_hwecc(struct mtd_info *mtd, void *buf, u32 len, + unsigned int page) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + int ret; + + chip->cmdfunc(mtd, NAND_CMD_READ0, 0x0, page); + + ret = chip->ecc.read_page(mtd, chip, NULL, 1, page); + if (ret < 0) + return -1; + + if (len > mtd->oobsize) + len = mtd->oobsize; + + memcpy(buf, chip->oob_poi, len); + + return 0; +} + +static int nand_spl_check_bad_block(struct mtd_info *mtd, unsigned int page) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + u32 pages_per_block, i = 0; + int ret; + u8 bad; + + pages_per_block = 1 << (mtd->erasesize_shift - mtd->writesize_shift); + + /* Read from first/last page(s) if necessary */ + if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) { + page += pages_per_block - 1; + if (chip->bbt_options & NAND_BBT_SCAN2NDPAGE) + page--; + } + + do { + ret = nand_spl_read_oob_hwecc(mtd, &bad, 1, page); + if (ret) + return ret; + + ret = bad != 0xFF; + + i++; + page++; + } while (!ret && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE) && i < 2); + + return ret; +} + +int nand_spl_load_image(uint32_t offs, unsigned int size, void *dest) +{ + struct nand_chip *chip = nand_spl_get_chip(); + struct mtd_info *mtd = &chip->mtd; + u32 addr, col, page, chksz; + bool check_bad = true; + + if (!nand_valid) + return -ENODEV; + + while (size) { + if (check_bad || !(offs & mtd->erasesize_mask)) { + addr = offs & (~mtd->erasesize_mask); + page = addr >> mtd->writesize_shift; + if (nand_spl_check_bad_block(mtd, page)) { + /* Skip bad block */ + if (addr >= mtd->size - mtd->erasesize) + return -ENXIO; + + offs += mtd->erasesize; + continue; + } + + check_bad = false; + } + + col = offs & mtd->writesize_mask; + page = offs >> mtd->writesize_shift; + chksz = min(mtd->writesize - col, (uint32_t)size); + + if (unlikely(chksz < mtd->writesize)) { + /* Not reading a full page */ + if (nand_spl_read_page_hwecc(mtd, buffer, page)) + return -EIO; + + memcpy(dest, buffer + col, chksz); + } else { + if (nand_spl_read_page_hwecc(mtd, dest, page)) + return -EIO; + } + + dest += chksz; + offs += chksz; + size -= chksz; + } + + return 0; +} + +int nand_default_bbt(struct mtd_info *mtd) +{ + return 0; +} + +void nand_deselect(void) +{ +} + +u32 nand_spl_adjust_offset(u32 sector, u32 offs) +{ + struct nand_chip *chip = nand_spl_get_chip(); + struct mtd_info *mtd = nand_to_mtd(chip); + unsigned int block, lastblock; + + block = sector / mtd->erasesize; + lastblock = (sector + offs) / mtd->erasesize; + + while (block <= lastblock) { + if (nand_spl_check_bad_block(mtd, block * mtd->erasesize)) { + offs += mtd->erasesize; + lastblock++; + } + + block++; + } + + return offs; +} diff --git a/drivers/mtd/nand/raw/nand_common_spl.h b/drivers/mtd/nand/raw/nand_common_spl.h new file mode 100644 index 0000000000..36bf63b230 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_common_spl.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Amarula Solution B.V. All rights reserved. + * + * Author: Michael Trimarchi + */ + +#ifndef _NAND_COMMON_SPL_H +#define _NAND_COMMON_SPL_H + +void nand_spl_command_lp(struct mtd_info *mtd, unsigned int command, + int column, int page_addr); +int nand_spl_init(struct nand_chip *chip); + +#endif /* _NAND_COMMON_SPL_H_ */