From patchwork Thu Jul 21 06:44:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2216 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C406344190 for ; Thu, 21 Jul 2022 08:44:52 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id s16-20020adf9790000000b0021e36810385sf68721wrb.15 for ; Wed, 20 Jul 2022 23:44:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385892; cv=pass; d=google.com; s=arc-20160816; b=FRWyYo647A2EexsmK91XT+gwBow4ytdbCXAeaVUypwtIonpIU77b0wJKXr9485g0n7 3NgTJThehws4hsxYJVKFKUxNnbgIbiHGfBwhvPKHc1xuhscVg7/0bB6m+5HMzIV4U2iK ZhwCLKM44+nv88EHNTMVVludW6F7F/CHD0VRBCKfYkel39vE2AwJYQAVQfTVibPuh0sS V85b96aDr0JyOC4Nm1HXJwuucAzvEhv2sD1YLcZeZbm3zmasXy6/EHhHm02E682RmouZ 2yTz1Ovarurql2FvIF45H4rpnX5iq+Wbs9TP9JBX4TOfgGXuTrtvRgoPbSpa2nZvL0SB 71sQ== 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:cc:to:from:dkim-signature; bh=ouBh2Q3M3uq8SGXgzpjsuL+uKHbP9udtl7iMsA//JLA=; b=Uvbj12WxiYFGXzHmNEWs7qMlpwIDMuIdg8Wk996H177nQusRlEfkwodRu1Moi6o9Zs RdK5x8ajeasxbHG0EeIYvKWE/NFRkIkAV4VpwVVZi61AT/pGhQUi+eCo1pOpOp7lXN1+ NBfKsuFFpe1rXimEn3HTpHtVM/uieA1jImb2E+kZ7Ij+oNMWK4PKuMBFxSawy27XUZHr xmBasShRS5dDXuUp+axmy/4v9onlI9SFteQuZ/jluKt5l+oM9KTGDQ5rkkf56Qq3iZ3/ L338M5aGSYU9seik7i4Ysbv8OC8F1HjFZKVXJNjZWgF51RZWkCx88Kcog6T8ztUwplEx XtYA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bYuDstZ3; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=ouBh2Q3M3uq8SGXgzpjsuL+uKHbP9udtl7iMsA//JLA=; b=I2xIJNND9w/iPWw046XHAdcMMpMJj4ExAwusIIdMQ7WNiLkrJpv8PfGadeEyjZ0GlI OqXVpKt+wEr3mNRgOZ3TXjhNO2j/X2PSJ+QNPSuIlUXpCz7k5MGFbt/PzHGWc96fP186 46EmeVNO8haVsr0OxGVk/ZO2llZ1Ic6h+syMU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=ouBh2Q3M3uq8SGXgzpjsuL+uKHbP9udtl7iMsA//JLA=; b=A/m537AWB8J79dcd612/4uyLmRM1G/QXJ6yOwgj2knDdzJBab61xfGrkR4JYDBFehP BGoqi4L2lXNmJrImTKU81VSFdAZfkGy3CISV6WXxFqagy1aXdiarACwCY8YyAb9Is9C4 uHumG1QWcnVaM5IFBojKy1pdNhyMsDbQoZ0ed7zIQ9qQbWDYoBTpMNe8LzRGZ2rP2lvY 1j0vnAx15z96qzPcOg89uiRzDqQKD65wYvGLLWMWdd6sa/NrQYq2f9LTj9oaRY6zH430 PYtSRmNadATkv4HyaPg7H/eRauRTOKd3uFWWaPDDdCdQ/JF4SU9IL7MBWYmz7Dj6DwuJ o4VA== X-Gm-Message-State: AJIora8yDr7AOY9jaECEihXy87Q/ftx5IbDMdkfAT5fJ9endl1wWkC8i oHCid+qO91Nskk/tlnt+V1uOd11W X-Google-Smtp-Source: AGRyM1vjwsDL72GvTGXoLDoz/pUQZsBEkSlf0VnQPMJ/SweFJaVxfNUkNDQMjFop3SwxgM/0dRPmcQ== X-Received: by 2002:adf:e98b:0:b0:21e:3367:cb43 with SMTP id h11-20020adfe98b000000b0021e3367cb43mr9592388wrm.25.1658385892388; Wed, 20 Jul 2022 23:44:52 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:6f03:0:b0:21d:9636:a730 with SMTP id ay3-20020a5d6f03000000b0021d9636a730ls243348wrb.0.-pod-prod-gmail; Wed, 20 Jul 2022 23:44:51 -0700 (PDT) X-Received: by 2002:adf:e192:0:b0:21d:62ee:ef10 with SMTP id az18-20020adfe192000000b0021d62eeef10mr34329611wrb.693.1658385891324; Wed, 20 Jul 2022 23:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385891; cv=none; d=google.com; s=arc-20160816; b=bWxqdwzBlwpuR9Wmae7nmfm9bcG0MT8JxHm8nU+S7knOcyU695BAPAN0jhX52r88pB 8gTAepyoZKoar+lXnmwKkqz+WNIjuWyJ8XQN5QwPiqWDtYCRPC9/Qr8tBR/vMxgyQVnC Y4qluv6rLdMo405h/WK/ZbGtV5N12ARjgWSroPnsPXR6VoIRTYS8P5raZ6BlryVeF82n ER+uHfhfgOyCr0d2DBEMnLfO+T2WDsizv0aS+qjiXCo/iYAyagOp/AzNHtXmzTr5ofbz GgUtOctDibHAg9emZmLk+Y4yFqujEegrdZnR+lK6ujMLEpMkEG34FPrINQ9f0LtMkQCx SRFA== 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:cc:to:from:dkim-signature; bh=Pjc68EH3MfbHU+IghcH+O86js6/5fZzjKV5AuE4OsIU=; b=VDrK2v0/PttGevLw+dnezwxdo1dQwrNao1QibD0oNUr5XEVALaan3SkGWORGsFPO7w /bUMKUiqXIvHzHK/k+XEZ6FqLm02blhjL3Pm6ILWhNq4DfremTBUtQ+decLcGIZLWjos LyrFdfp8eae+sge4DegKnE6AChEUYReiSTETm2mJBdCsqJnk5awE29BAB/nmqIfPBN3F Jwm4SqZqU4j8jnRgYukKfGHOY5yz1NFDCBq7I6S3pB7SJ4UcC8eQU58NosBx80tKUAB/ EYWtMXd/n6y+OmBZLrOSX7GqwqERAXMuNb+qWsj9XkiIN/pT8AEsPz1f9D/SN7PKGAz+ yh9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bYuDstZ3; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 o8-20020a05600002c800b0021e4b033178sor434440wry.29.2022.07.20.23.44.51 for (Google Transport Security); Wed, 20 Jul 2022 23:44:51 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a5d:64c2:0:b0:21e:2e1b:d031 with SMTP id f2-20020a5d64c2000000b0021e2e1bd031mr9637397wri.8.1658385890948; Wed, 20 Jul 2022 23:44:50 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:50 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi Subject: [PATCH v3 01/13] mtd: nand: Get rid of busw parameter Date: Thu, 21 Jul 2022 08:44:23 +0200 Message-Id: <20220721064435.2456601-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bYuDstZ3; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit 29a198a1592d83. Auto-detection functions are passed a busw parameter to retrieve the actual NAND bus width and eventually set the correct value in chip->options. Rework the nand_get_flash_type() function to get rid of this extra parameter and let detection code directly set the NAND_BUSWIDTH_16 flag in chip->options if needed. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. Changes in v2: - Use short-commit form. - Remove linux info. Uboot seems that backport without add this extra information. drivers/mtd/nand/raw/nand_base.c | 59 +++++++++++++++++--------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index e8ece0a4a0dd..9a2194ebd3f8 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3898,8 +3898,7 @@ static void nand_onfi_detect_micron(struct nand_chip *chip, /* * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise. */ -static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, - int *busw) +static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip) { struct nand_onfi_params *p = &chip->onfi_params; char id[4]; @@ -3971,9 +3970,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, chip->bits_per_cell = p->bits_per_cell; if (onfi_feature(chip) & ONFI_FEATURE_16_BIT_BUS) - *busw = NAND_BUSWIDTH_16; - else - *busw = 0; + chip->options |= NAND_BUSWIDTH_16; if (p->ecc_bits != 0xff) { chip->ecc_strength_ds = p->ecc_bits; @@ -4003,8 +4000,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, return 1; } #else -static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, - int *busw) +static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip) { return 0; } @@ -4013,8 +4009,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, /* * Check if the NAND chip is JEDEC compliant, returns 1 if it is, 0 otherwise. */ -static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip, - int *busw) +static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip) { struct nand_jedec_params *p = &chip->jedec_params; struct jedec_ecc_info *ecc; @@ -4076,9 +4071,7 @@ static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip, chip->bits_per_cell = p->bits_per_cell; if (jedec_feature(chip) & JEDEC_FEATURE_16_BIT_BUS) - *busw = NAND_BUSWIDTH_16; - else - *busw = 0; + chip->options |= NAND_BUSWIDTH_16; /* ECC info */ ecc = &p->ecc_info[0]; @@ -4168,7 +4161,7 @@ static int nand_get_bits_per_cell(u8 cellinfo) * manufacturer-specific "extended ID" decoding patterns. */ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, - u8 id_data[8], int *busw) + u8 id_data[8]) { int extid, id_len; /* The 3rd id byte holds MLC / multichip data */ @@ -4221,7 +4214,6 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, /* Calc blocksize */ mtd->erasesize = (128 * 1024) << (((extid >> 1) & 0x04) | (extid & 0x03)); - *busw = 0; } else if (id_len == 6 && id_data[0] == NAND_MFR_HYNIX && !nand_is_slc(chip)) { unsigned int tmp; @@ -4262,7 +4254,6 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, mtd->erasesize = 768 * 1024; else mtd->erasesize = (64 * 1024) << tmp; - *busw = 0; } else { /* Calc pagesize */ mtd->writesize = 1024 << (extid & 0x03); @@ -4275,7 +4266,9 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, mtd->erasesize = (64 * 1024) << (extid & 0x03); extid >>= 2; /* Get buswidth information */ - *busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; + /* Get buswidth information */ + if (extid & 0x1) + chip->options |= NAND_BUSWIDTH_16; /* * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per @@ -4301,15 +4294,13 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, * the chip. */ static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, - struct nand_flash_dev *type, u8 id_data[8], - int *busw) + struct nand_flash_dev *type, u8 id_data[8]) { int maf_id = id_data[0]; mtd->erasesize = type->erasesize; mtd->writesize = type->pagesize; mtd->oobsize = mtd->writesize / 32; - *busw = type->options & NAND_BUSWIDTH_16; /* All legacy ID NAND are small-page, SLC */ chip->bits_per_cell = 1; @@ -4371,7 +4362,7 @@ static inline bool is_full_id_nand(struct nand_flash_dev *type) } static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, - struct nand_flash_dev *type, u8 *id_data, int *busw) + struct nand_flash_dev *type, u8 *id_data) { if (!strncmp((char *)type->id, (char *)id_data, type->id_len)) { mtd->writesize = type->pagesize; @@ -4386,8 +4377,6 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, chip->onfi_timing_mode_default = type->onfi_timing_mode_default; - *busw = type->options & NAND_BUSWIDTH_16; - if (!mtd->name) mtd->name = type->name; @@ -4449,9 +4438,24 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, if (!type) type = nand_flash_ids; + /* + * Save the NAND_BUSWIDTH_16 flag before letting auto-detection logic + * override it. + * This is required to make sure initial NAND bus width set by the + * NAND controller driver is coherent with the real NAND bus width + * (extracted by auto-detection code). + */ + busw = chip->options & NAND_BUSWIDTH_16; + + /* + * The flag is only set (never cleared), reset it to its default value + * before starting auto-detection. + */ + chip->options &= ~NAND_BUSWIDTH_16; + for (; type->name != NULL; type++) { if (is_full_id_nand(type)) { - if (find_full_id_nand(mtd, chip, type, id_data, &busw)) + if (find_full_id_nand(mtd, chip, type, id_data)) goto ident_done; } else if (*dev_id == type->dev_id) { break; @@ -4461,11 +4465,11 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, chip->onfi_version = 0; if (!type->name || !type->pagesize) { /* Check if the chip is ONFI compliant */ - if (nand_flash_detect_onfi(mtd, chip, &busw)) + if (nand_flash_detect_onfi(mtd, chip)) goto ident_done; /* Check if the chip is JEDEC compliant */ - if (nand_flash_detect_jedec(mtd, chip, &busw)) + if (nand_flash_detect_jedec(mtd, chip)) goto ident_done; } @@ -4479,10 +4483,11 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, if (!type->pagesize) { /* Decode parameters from extended ID */ - nand_decode_ext_id(mtd, chip, id_data, &busw); + nand_decode_ext_id(mtd, chip, id_data); } else { - nand_decode_id(mtd, chip, type, id_data, &busw); + nand_decode_id(mtd, chip, type, id_data); } + /* Get chip options */ chip->options |= type->options; From patchwork Thu Jul 21 06:44:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2217 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AF90844190 for ; Thu, 21 Jul 2022 08:44:53 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id h189-20020a1c21c6000000b003a2fdf9bd2asf566822wmh.8 for ; Wed, 20 Jul 2022 23:44:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385893; cv=pass; d=google.com; s=arc-20160816; b=mPaFzsYXJYyKPCo96g2Il17pPvDQy6mqFXkAC/94R7keZnW9A6a3KAz43LsmKXltw8 DhzTFJV4extgwptHBTJQ2lX03b3leCvRQtlSbJS7ELaGVaoilTKkDOw53Eyslws3IIgM kNqYSudi1aabKk0sASjqAhuKGZ/X0OCzsEH3YyZkZcY2HfdXs+ylRRrmZodC8wv5VjiT oFmwmHjk4Rd2UKAcP4ZKDfNGLF9eMQUV1cbftB2PUJLXFZI4E3WOZGaX6oWpDq/ozXHc VlNbWal2gshtcqmDFm6X1K9LB6eQtFOvodKmMpP4b8t504mXas0gJqqpDs67cRb0gvud atdA== 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:cc:to:from:dkim-signature; bh=2WNAcEUUoJze4mzfnXy11tgihs+EpuTieRVh5uKngWk=; b=Y6hMqD3qmOs+NjIUxorujPsDnBbdcT7hc/z+kP3MslbxR+u8aGgfokyys/el/Wc9Xf +jT2afH4vuK6DaUi3qSjiCvTWtsnohJFXykKnbRFPVwQHo3k3xsP0Zbd2pNHySbnctcM 3S2+K9DBTbPZEHHjIArC9munYpbals2hJvzh8W4SldIbAwatX2tR6t2JfHDZtDjWmXze c2RplQcJhl+p/bqIzPQYhmSZ/WWY74tYjap6UwCZIGRw6iLSs6nsciN93dpoE08z54k0 e6snrKuz34NK/sx/Lmikh2ZyroLB8e5RX963YlMqLBkPo+PvVVXgIPpCuUwAtqlfiG8D RlBg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XB4GObuw; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=2WNAcEUUoJze4mzfnXy11tgihs+EpuTieRVh5uKngWk=; b=n5Gx8MNscM3nEG7tUBbmSY3yVrfAEx4LvQLX+CR/WnG0wFie5Vs9bE1vYzbSyrymhW d6u3xasD3Kk72cMXYazisQOcQOzcYe6tx21VveQfP4NqBFM5hGfuIu/hWeKoLQhbx7h8 soVrpCkFl2q2QzS61PtkbxnubYTe5wypRC5Yw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=2WNAcEUUoJze4mzfnXy11tgihs+EpuTieRVh5uKngWk=; b=kLLyWXs8pR2ebcq10chcorD7MmeqvAt5I6rS2eVDL0T3w/PgbBgG4bMsrbRwR1Th9N dznYvecbRxCH1mku/YFt7vnlHYCj7lO68aAngJB5MnmTOX6ye9THpZ2pMA7lxhZjAGCs 7I4XG+j5iA9AhB/EpEZcWPfmpvf72nqJ7okNewTduFjqU1Mc+lKaPvL6qreJ4Qv0JbHq JFHwl6Cs4gZlJiVq/U0QzQUpwYgI/vDSNsShDC2g+R8VApSSEpG5A8eU7bN76Qa0Wdn/ S5Ez4SeCpNu6z0bd4ym+Sbkc1S8mTDxZplFX4201uLvT2qufvgFdb8OlERZz3Izzidpe iRZw== X-Gm-Message-State: AJIora8XkNDb/EjduYB4Ecv9aauf3FGm8dY0d49xacny5d5FYRuC7sV1 G/AqIzEfk0HkI9aw+3znv/E0zMA2 X-Google-Smtp-Source: AGRyM1uhkF+Cvw9DAoexQWJdadZlRLyvNXZNZPI+RpmU6AV/4zcPqiiI1BufBMeRL6RIFBgGbEOMTQ== X-Received: by 2002:adf:e98b:0:b0:21e:3367:cb43 with SMTP id h11-20020adfe98b000000b0021e3367cb43mr9592441wrm.25.1658385893516; Wed, 20 Jul 2022 23:44:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:6f03:0:b0:21d:9636:a730 with SMTP id ay3-20020a5d6f03000000b0021d9636a730ls243420wrb.0.-pod-prod-gmail; Wed, 20 Jul 2022 23:44:52 -0700 (PDT) X-Received: by 2002:adf:bc07:0:b0:21e:47fc:4b01 with SMTP id s7-20020adfbc07000000b0021e47fc4b01mr5797516wrg.293.1658385892579; Wed, 20 Jul 2022 23:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385892; cv=none; d=google.com; s=arc-20160816; b=Gz9p6ufoJjWJ5farFtTyo1s+DjhIwqNyEFgZPV0wXctYKYL4kFJpbEKUIJ+LraE83c j5RTKTZqJj3F0AoJ1i5Z3m8NyjwsRDhEFkj9WJFWPMaBdVi8SowmIboTMwgGvpdzTyDy 3/Pj16BX7EMMnUe/LnZV1sig/SIHzLWY6iCXh6QwvCButf/uYOZfSth5vap95B3vtB39 7QMX45ng0xynwBNQ9JpzG3qbcH+fW0CGljxvoKEnkQG6fQoPvTtC/TMRVtZTXgbObmoP ECFbtTiJc8xqn7ct9eb+ZajXZ2k61JHJzBRfCgXaHDAfrJqzEjdCI5IwqPamddHOV6vI EzTQ== 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:cc:to:from:dkim-signature; bh=xd8eUKK9iYAZXNsfE7I8BnNoJPlhH4IJYqhYXjF2Fiw=; b=foLnwF5dQS33I5Bb5utr2113kqzmJjo9fvp99BDyiM0QzP9NPn0yqW/I9t0K/lDZnu 4OzSEOXHuRxuMHo9vomjlNftbYAoEtrBlnWeidSybP8S5/p84ZEzSE2bsoPdCyNaqzw4 zGuei74fnDCQrAZ9iDOPpyJWz4l6lN0m7XG5WHgZgpe9haP124/6Q52zLlTR/TQyQdm9 q9kde0kAwlGHO9DkJlDI5QwC896joPr7LT6FjVK4L7vDnVAaTT+9lxvAhP5f84141buZ d2OMRO0vJDJ9tl/ZMXCpJJdPUCZnC9I/cHqr5kpHHQCPmH/Sc6gyN33aMVg7DGIdoyxR n+QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XB4GObuw; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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-20020adfca0c000000b0021b902e572esor465288wrh.14.2022.07.20.23.44.52 for (Google Transport Security); Wed, 20 Jul 2022 23:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6000:992:b0:21d:9240:4337 with SMTP id by18-20020a056000099200b0021d92404337mr33606093wrb.323.1658385892310; Wed, 20 Jul 2022 23:44:52 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:51 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 02/13] mtd: nand: Store nand ID in struct nand_chip Date: Thu, 21 Jul 2022 08:44:24 +0200 Message-Id: <20220721064435.2456601-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XB4GObuw; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit 7f501f0a72036d. Store the NAND ID in struct nand_chip to avoid passing id_data and id_len as function parameters. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form. - Remove linux info. Uboot seems that backport without add this extra information. drivers/mtd/nand/raw/nand_base.c | 58 ++++++++++++++++---------------- include/linux/mtd/rawnand.h | 15 +++++++++ 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 9a2194ebd3f8..220804c75c87 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4160,16 +4160,14 @@ static int nand_get_bits_per_cell(u8 cellinfo) * chip. The rest of the parameters must be decoded according to generic or * manufacturer-specific "extended ID" decoding patterns. */ -static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, - u8 id_data[8]) +static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) { int extid, id_len; /* The 3rd id byte holds MLC / multichip data */ - chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); + chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); /* The 4th id byte is the important one */ - extid = id_data[3]; - - id_len = nand_id_len(id_data, 8); + extid = chip->id.data[3]; + id_len = chip->id.len; /* * Field definitions are in the following datasheets: @@ -4180,8 +4178,8 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, * Check for ID length, non-zero 6th byte, cell type, and Hynix/Samsung * ID to decide what to do. */ - if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG && - !nand_is_slc(chip) && id_data[5] != 0x00) { + if (id_len == 6 && chip->id.data[0] == NAND_MFR_SAMSUNG && + !nand_is_slc(chip) && chip->id.data[5] != 0x00) { /* Calc pagesize */ mtd->writesize = 2048 << (extid & 0x03); extid >>= 2; @@ -4214,7 +4212,7 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, /* Calc blocksize */ mtd->erasesize = (128 * 1024) << (((extid >> 1) & 0x04) | (extid & 0x03)); - } else if (id_len == 6 && id_data[0] == NAND_MFR_HYNIX && + } else if (id_len == 6 && chip->id.data[0] == NAND_MFR_HYNIX && !nand_is_slc(chip)) { unsigned int tmp; @@ -4278,10 +4276,10 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, * 110b -> 24nm * - ID byte 5, bit[7]: 1 -> BENAND, 0 -> raw SLC */ - if (id_len >= 6 && id_data[0] == NAND_MFR_TOSHIBA && - nand_is_slc(chip) && - (id_data[5] & 0x7) == 0x6 /* 24nm */ && - !(id_data[4] & 0x80) /* !BENAND */) { + if (id_len >= 6 && chip->id.data[0] == NAND_MFR_TOSHIBA && + nand_is_slc(chip) && + (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && + !(chip->id.data[4] & 0x80) /* !BENAND */) { mtd->oobsize = 32 * mtd->writesize >> 9; } @@ -4294,9 +4292,9 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, * the chip. */ static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, - struct nand_flash_dev *type, u8 id_data[8]) + struct nand_flash_dev *type) { - int maf_id = id_data[0]; + int maf_id = chip->id.data[0]; mtd->erasesize = type->erasesize; mtd->writesize = type->pagesize; @@ -4311,11 +4309,11 @@ static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, * listed in nand_ids table. * Data sheet (5 byte ID): Spansion S30ML-P ORNAND (p.39) */ - if (maf_id == NAND_MFR_AMD && id_data[4] != 0x00 && id_data[5] == 0x00 - && id_data[6] == 0x00 && id_data[7] == 0x00 - && mtd->writesize == 512) { + if (maf_id == NAND_MFR_AMD && chip->id.data[4] != 0x00 && + chip->id.data[5] == 0x00 && chip->id.data[6] == 0x00 && + chip->id.data[7] == 0x00 && mtd->writesize == 512) { mtd->erasesize = 128 * 1024; - mtd->erasesize <<= ((id_data[3] & 0x03) << 1); + mtd->erasesize <<= ((chip->id.data[3] & 0x03) << 1); } } @@ -4325,9 +4323,9 @@ static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, * page size, cell-type information). */ static void nand_decode_bbm_options(struct mtd_info *mtd, - struct nand_chip *chip, u8 id_data[8]) + struct nand_chip *chip) { - int maf_id = id_data[0]; + int maf_id = chip->id.data[0]; /* Set the bad block position */ if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16)) @@ -4362,14 +4360,14 @@ static inline bool is_full_id_nand(struct nand_flash_dev *type) } static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, - struct nand_flash_dev *type, u8 *id_data) + struct nand_flash_dev *type) { - if (!strncmp((char *)type->id, (char *)id_data, type->id_len)) { + if (!strncmp((char *)type->id, (char *)chip->id.data, type->id_len)) { mtd->writesize = type->pagesize; mtd->erasesize = type->erasesize; mtd->oobsize = type->oobsize; - chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); + chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); chip->chipsize = (uint64_t)type->chipsize << 20; chip->options |= type->options; chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); @@ -4395,7 +4393,7 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, { int busw, ret; int maf_idx; - u8 id_data[8]; + u8 *id_data = chip->id.data; /* * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx) @@ -4453,9 +4451,11 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, */ chip->options &= ~NAND_BUSWIDTH_16; + chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data)); + for (; type->name != NULL; type++) { if (is_full_id_nand(type)) { - if (find_full_id_nand(mtd, chip, type, id_data)) + if (find_full_id_nand(mtd, chip, type)) goto ident_done; } else if (*dev_id == type->dev_id) { break; @@ -4483,9 +4483,9 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, if (!type->pagesize) { /* Decode parameters from extended ID */ - nand_decode_ext_id(mtd, chip, id_data); + nand_decode_ext_id(mtd, chip); } else { - nand_decode_id(mtd, chip, type, id_data); + nand_decode_id(mtd, chip, type); } /* Get chip options */ @@ -4523,7 +4523,7 @@ ident_done: return ERR_PTR(-EINVAL); } - nand_decode_bbm_options(mtd, chip, id_data); + nand_decode_bbm_options(mtd, chip); /* Calculate the address shift from the page size */ chip->page_shift = ffs(mtd->writesize) - 1; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 3417ca2a0d2e..f2c6a978cbf8 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -507,6 +507,19 @@ static inline void nand_hw_control_init(struct nand_hw_control *nfc) init_waitqueue_head(&nfc->wq); } +/* The maximum expected count of bytes in the NAND ID sequence */ +#define NAND_MAX_ID_LEN 8 + +/** + * struct nand_id - NAND id structure + * @data: buffer containing the id bytes. + * @len: ID length. + */ +struct nand_id { + u8 data[NAND_MAX_ID_LEN]; + int len; +}; + /** * struct nand_ecc_step_info - ECC step information of ECC engine * @stepsize: data bytes per ECC step @@ -888,6 +901,8 @@ nand_get_sdr_timings(const struct nand_data_interface *conf) struct nand_chip { struct mtd_info mtd; + struct nand_id id; + void __iomem *IO_ADDR_R; void __iomem *IO_ADDR_W; From patchwork Thu Jul 21 06:44:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2218 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5480944190 for ; Thu, 21 Jul 2022 08:44:55 +0200 (CEST) Received: by mail-wm1-f70.google.com with SMTP id v67-20020a1cac46000000b003a2be9fa09csf584812wme.3 for ; Wed, 20 Jul 2022 23:44:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385895; cv=pass; d=google.com; s=arc-20160816; b=hHHqO++m8YUPufRg4yxhbyxIRA2I7cwMbspG7JItFn9sPdlTJ8aQjoxq0Ejz8A4Deb PxZ6ZEG435K3utNEVzhkSqXd7tE35USuwR4KZutinAgA+eI+FtVacKDZoDMevalRaNrG WogUb+JSfOCnaxN1G+4scwN+FNCpNcY2XoAMyyNIyfsluJvairZoFuXlQGS0coKI7EGo pbSjcFia5X9VQ865L51m7hue3YumUObXI6penTCx16CRX2bk+wxDAJX8Duq5v1RXrKFu x39+7abymSbP4LKlqMZCVME7VsSoY18k1xiwkO6XqmAQbCBQ7exS4NjIxh0rJYPJJ20z w2mw== 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:cc:to:from:dkim-signature; bh=uXjrM6x3VLuZWW+6dwlmiwT/M5BegrrLiW4c1UeKEgc=; b=Jv9wUhY1Kkob0FB46vciQJoNhMvFlLjjltOW3o3oFEwbKmHWSX48WTnmMWAGckISh0 NkI5PuImXqbSfZRD61F6JRG9UNT6oUwQ6/jbW+nYtTYRfqmK5LLCWpEP/XRkxr476z6r rTf3WM3o4tfzdQ0R9n0jtZIqSa++xEo6qn0F+PSkNUodKpiygCQBEOh8ydWrjplkXwa7 6BuveqRtyinUOVuJec6bsNfNRkdM51WuoUpZdgNzY6K0bu5I5/rRnaY83PhRYDI30L7k HQ9W/S6MmAQUJjffsn1IJgttZfvmNFm1Px2cLVV9DWpdlLoUErf+QlsU5FmrQEg68ru8 PSaw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cuwYcSY+; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=uXjrM6x3VLuZWW+6dwlmiwT/M5BegrrLiW4c1UeKEgc=; b=jv+OBUtkNshgDZY6H9zHumng5Qsmg8AtU8pXrx8Z+evk8Ou0ZmdPEO0UxOVuqm2lIa ywa2GGxX40tH0HD3u3z2umYv2T+lg4igWkR1vceIApW07UFwxCP0hfvPqterqCsKlnR2 QgGVqNirbKaFaC0I5tJDkk/IAfF6e0v8i8Z4Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=uXjrM6x3VLuZWW+6dwlmiwT/M5BegrrLiW4c1UeKEgc=; b=7qbOBBcCt2lLH3XLpT2RDOxdPy5WkdFkJwmqngFYDI86N5s1dynb9t6HjVPKfGnrwa O5M/Wh+OGnaygDKFN1A/XA35ait/K+ccfta7Oe3Z2p9HF9QsEYltnq5cnX82vtEqlA7q HjWnEe0yAQpsUkj4Hy1Gd8QPZ2MT8rmPIkxmQhgpMzCwrI6RGyXurqt7m3uFPAlsA2sI tC4096WMDXsc1MwCnsY6oY4e0YVvzyIvT/qNi9N6FeLkdvjBw5PLl7MxeA/Qgl4Uruih 9cCr9I4jiHLDnyzbDimVHRDhA7C1yjq5pCPc0W6mLhxCr611H8hjvz9X6NyXyxRM+ltf 5VZA== X-Gm-Message-State: AJIora/2SGz1EXPv/VNYHXV8LOUggZI3vrq3ydB6GxB11uSuULlLxfs+ a+bU21inpayXj1FPDatGEIzvI2IG X-Google-Smtp-Source: AGRyM1vDXdZtrCrg0uRZac9Izs0clYHAiEUVRUl7TVPtY+j5TM7gC5XFekc5tY5WbLEyEEGEbvAnSQ== X-Received: by 2002:adf:ecc8:0:b0:21d:e148:64a9 with SMTP id s8-20020adfecc8000000b0021de14864a9mr22374955wro.518.1658385895095; Wed, 20 Jul 2022 23:44:55 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:d209:0:b0:21e:53a1:af5d with SMTP id j9-20020adfd209000000b0021e53a1af5dls243643wrh.3.-pod-prod-gmail; Wed, 20 Jul 2022 23:44:54 -0700 (PDT) X-Received: by 2002:adf:d1c6:0:b0:21e:4f40:9029 with SMTP id b6-20020adfd1c6000000b0021e4f409029mr3621619wrd.719.1658385894061; Wed, 20 Jul 2022 23:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385894; cv=none; d=google.com; s=arc-20160816; b=F9QF/n6UAwCycIeo2F1zq+D/gFRshkgPL+9X4hSitqspg39elW9DW3N2wEPxXra6GK p20l0/i0wlSF8bGddKO/bPlqmCguF4INtHVYbXId/3DydUwg8aQDKiihx4YcdVKAWUo3 BYVSnFyslznFNQNDdz/IZKU/ZAuSyQqeWlUhNwp/E9TRJ2UVnFNsKWAMZWinKHGE2PCq H4riU2qN+RoeGD87yDyzbH8mg6yVPcwa+qO6QSXq5/WrVESeD/h2WyM8SLRdsirk0tuH 2XZWAAfK4WkMrAmTOkeq6pY9Y48Mbr5GUpNrHp8KgnuePdsXV9rn+2jmYGs6W5DVP4b1 3kbw== 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:cc:to:from:dkim-signature; bh=qaBOrJiZDoLWMMI8Ww/DBu1HH0fVqO05oj5JUuFlTh8=; b=YxhGgs/4h82FIBhyghQcxpywVgoIWIqiQHnV0YlXoZPjuEdSr+033uTxItZry/ntIu 4qtowXX6CS3JRUtbVWIift5qCPra+4qvfZ8liAkFxzW0cvR7SXN+vxbdrJ5VNK4OSTY6 q85O1wSm6SLMlto9Lk5XieJZLiwLPVTM0XvRQI9M59uem/tkTe/XI5aNRmsOYbumSwOi xoYDGYXPR5lvdSYVKZwtjMFUgtkpLtawo46zjjobXOZy9gmimsc24RM+1IJXXU5AsbMR +cdjCwMrYX1++a7N8YTkffffIh25HDDXpkdP976s1Qhc9p2wTjaQuzEAJfKErENT8BDH x2oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cuwYcSY+; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 l11-20020adfc78b000000b0021dc1558c51sor454016wrg.17.2022.07.20.23.44.54 for (Google Transport Security); Wed, 20 Jul 2022 23:44:54 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a5d:64a3:0:b0:21d:adaa:ce4c with SMTP id m3-20020a5d64a3000000b0021dadaace4cmr33211898wrp.161.1658385893703; Wed, 20 Jul 2022 23:44:53 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:53 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 03/13] mtd: nand: Add manufacturer specific initialization/detection steps Date: Thu, 21 Jul 2022 08:44:25 +0200 Message-Id: <20220721064435.2456601-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cuwYcSY+; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit abbe26d144ec22. A lot of NANDs are implementing generic features in a non-generic way, or are providing advanced auto-detection logic where the NAND ID bytes meaning changes with the NAND generation. Providing this vendor specific initialization step will allow us to get rid of full-id entries in the nand_ids table or all the vendor specific cases added over the time in the generic NAND ID decoding logic. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form. - Remove linux info. Uboot seems that backport without add this extra information. drivers/mtd/nand/raw/nand_base.c | 98 ++++++++++++++++++++++++-------- include/linux/mtd/rawnand.h | 30 ++++++++++ 2 files changed, 105 insertions(+), 23 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 220804c75c87..0900e6dbf9a6 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4286,6 +4286,39 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) } } +/* + * Manufacturer detection. Only used when the NAND is not ONFI or JEDEC + * compliant and does not have a full-id or legacy-id entry in the nand_ids + * table. + */ +static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chip) +{ + /* + * Try manufacturer detection if available and use + * nand_decode_ext_id() otherwise. + */ + if (chip->manufacturer.desc && chip->manufacturer.desc->ops && + chip->manufacturer.desc->ops->detect) + chip->manufacturer.desc->ops->detect(chip); + else + nand_decode_ext_id(mtd, chip); +} + +/* + * Manufacturer initialization. This function is called for all NANDs including + * ONFI and JEDEC compliant ones. + * Manufacturer drivers should put all their specific initialization code in + * their ->init() hook. + */ +static int nand_manufacturer_init(struct nand_chip *chip) +{ + if (!chip->manufacturer.desc || !chip->manufacturer.desc->ops || + !chip->manufacturer.desc->ops->init) + return 0; + + return chip->manufacturer.desc->ops->init(chip); +} + /* * Old devices have chip data hardcoded in the device ID table. nand_decode_id * decodes a matching ID table entry and assigns the MTD size parameters for @@ -4383,6 +4416,26 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, return false; } +/** + * nand_get_manufacturer_desc - Get manufacturer information from the + * manufacturer ID + * @id: manufacturer ID + * + * 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) +{ + int i; + + for (i = 0; nand_manuf_ids[i].id != 0x0; i++) { + if (nand_manuf_ids[i].id == id) + return &nand_manuf_ids[i]; + } + + return NULL; +} + /* * Get the flash and manufacturer id and lookup if the type is supported. */ @@ -4391,8 +4444,8 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, int *maf_id, int *dev_id, struct nand_flash_dev *type) { + const struct nand_manufacturers *manufacturer_desc; int busw, ret; - int maf_idx; u8 *id_data = chip->id.data; /* @@ -4433,6 +4486,12 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, return ERR_PTR(-ENODEV); } + chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data)); + + /* Try to identify manufacturer */ + manufacturer_desc = nand_get_manufacturer_desc(*maf_id); + chip->manufacturer.desc = manufacturer_desc; + if (!type) type = nand_flash_ids; @@ -4451,8 +4510,6 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, */ chip->options &= ~NAND_BUSWIDTH_16; - chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data)); - for (; type->name != NULL; type++) { if (is_full_id_nand(type)) { if (find_full_id_nand(mtd, chip, type)) @@ -4482,8 +4539,7 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, chip->chipsize = (uint64_t)type->chipsize << 20; if (!type->pagesize) { - /* Decode parameters from extended ID */ - nand_decode_ext_id(mtd, chip); + nand_manufacturer_detect(mtd, chip); } else { nand_decode_id(mtd, chip, type); } @@ -4499,12 +4555,6 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, chip->options &= ~NAND_SAMSUNG_LP_OPTIONS; ident_done: - /* Try to identify manufacturer */ - for (maf_idx = 0; nand_manuf_ids[maf_idx].id != 0x0; maf_idx++) { - if (nand_manuf_ids[maf_idx].id == *maf_id) - break; - } - if (chip->options & NAND_BUSWIDTH_AUTO) { WARN_ON(chip->options & NAND_BUSWIDTH_16); chip->options |= busw; @@ -4516,7 +4566,7 @@ ident_done: */ pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", *maf_id, *dev_id); - pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, mtd->name); + pr_info("%s %s\n", manufacturer_desc->name, mtd->name); pr_warn("bus width %d instead %d bit\n", (chip->options & NAND_BUSWIDTH_16) ? 16 : 8, busw ? 16 : 8); @@ -4549,28 +4599,30 @@ ident_done: if (mtd->writesize > 512 && chip->cmdfunc == nand_command) chip->cmdfunc = nand_command_lp; + ret = nand_manufacturer_init(chip); + if (ret) + return ERR_PTR(ret); + pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", *maf_id, *dev_id); #ifdef CONFIG_SYS_NAND_ONFI_DETECTION if (chip->onfi_version) - pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, - chip->onfi_params.model); + pr_info("%s %s\n", manufacturer_desc->name, + chip->onfi_params.model); else if (chip->jedec_version) - pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, - chip->jedec_params.model); + pr_info("%s %s\n", manufacturer_desc->name, + chip->jedec_params.model); else - pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, - type->name); + pr_info("%s %s\n", manufacturer_desc->name, type->name); #else if (chip->jedec_version) - pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, - chip->jedec_params.model); + pr_info("%s %s\n", manufacturer_desc->name, + chip->jedec_params.model); else - pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, - type->name); + pr_info("%s %s\n", manufacturer_desc->name, type->name); - pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, + pr_info("%s %s\n", manufacturer_desc->name, type->name); #endif diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index f2c6a978cbf8..57fe7fb47bd8 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -796,6 +796,17 @@ nand_get_sdr_timings(const struct nand_data_interface *conf) return &conf->timings.sdr; } +/** + * struct nand_manufacturer_ops - NAND Manufacturer operations + * @detect: detect the NAND memory organization and capabilities + * @init: initialize all vendor specific fields (like the ->read_retry() + * implementation) if any. + */ +struct nand_manufacturer_ops { + void (*detect)(struct nand_chip *chip); + int (*init)(struct nand_chip *chip); +}; + /** * struct nand_chip - NAND Private Flash Chip Data * @mtd: MTD device registered to the MTD framework @@ -897,6 +908,7 @@ nand_get_sdr_timings(const struct nand_data_interface *conf) * devices. * @priv: [OPTIONAL] pointer to private chip data * @write_page: [REPLACEABLE] High-level page write function + * @manufacturer: [INTERN] Contains manufacturer information */ struct nand_chip { @@ -983,6 +995,11 @@ struct nand_chip { struct nand_bbt_descr *badblock_pattern; void *priv; + + struct { + const struct nand_manufacturers *desc; + void *priv; + } manufacturer; }; static inline void nand_set_flash_node(struct nand_chip *chip, @@ -1016,6 +1033,17 @@ static inline void nand_set_controller_data(struct nand_chip *chip, void *priv) chip->priv = priv; } +static inline void nand_set_manufacturer_data(struct nand_chip *chip, + void *priv) +{ + chip->manufacturer.priv = priv; +} + +static inline void *nand_get_manufacturer_data(struct nand_chip *chip) +{ + return chip->manufacturer.priv; +} + /* * NAND Flash Manufacturer ID Codes */ @@ -1120,10 +1148,12 @@ struct nand_flash_dev { * struct nand_manufacturers - NAND Flash Manufacturer ID Structure * @name: Manufacturer name * @id: manufacturer ID code of device. + * @ops: manufacturer operations */ struct nand_manufacturers { int id; char *name; + const struct nand_manufacturer_ops *ops; }; extern struct nand_flash_dev nand_flash_ids[]; From patchwork Thu Jul 21 06:44:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2219 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6FA5744190 for ; Thu, 21 Jul 2022 08:44:56 +0200 (CEST) Received: by mail-wr1-f70.google.com with SMTP id t12-20020adfa2cc000000b0021e564cde06sf50797wra.17 for ; Wed, 20 Jul 2022 23:44:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385896; cv=pass; d=google.com; s=arc-20160816; b=Rn9IgcW7Ap2XAWStOmCpD7WqvD49a5tmV28P2O+pOW6mfwbQqqzBvpvOyvCKBUxW28 EAsfOPULxWs+NViqkzEek3iftYO4Fb4zyegKaWwfruyVQ5u2lUsYlDgAvqPsGaxA7Ftg RhuR/R4+qY7XKxjUMZNpK+sqjOLr1sTAu+b/4Vt+9PauB9Kz5Nc2Uu9LOmLfz9M23h2J ai8LT0YvX5ZXOpwl/nj0/U0NIgJuZJGwJJZqz0QK66XBNUiE1qETLNU74w8BO8w6MNA5 RrAIC1+eXoPVAJgSrVuB3cMB8QeXWFwoiu38mz7tntwF5d9V9iHph3mIgJGJJ+ahiYWd QfpQ== 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:cc:to:from:dkim-signature; bh=PNnAaAD0MVmU1Dt77oP+IW2haOw8iUHhG6sZ4ltHmqQ=; b=P5fVtdxAjUq6p/x0CfGxnDpS21TsRxiED3PAC7zDFZoQEwil+wksm5fU1cCSQBgoTs cb45BDEa9OpfaZcJ02iErV6m1p+tVr9MSKtNW/PJOsgOKpXMDBCDDKEn/C+5beRKlTeQ Yn4pMt6bZwO4+TX11iZ1nfMrXyiMYwy9vbHsfgaHvnv5CIAURHpl3lN7kP70jHhhDeu4 V6yBPsoUxDKum+hyGouaAzBcIf2l4z1DmaWKlNz95FXu01Mnrjvuf2IN9L8jquLCKgDP 96FVgHyAFfQe8z8Bb6ElbrL96GFw62en12OAPBTYnpW9XrxHkIyQavZmYiPo3Mhd+B5b bqfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="q/C3C0Y4"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=PNnAaAD0MVmU1Dt77oP+IW2haOw8iUHhG6sZ4ltHmqQ=; b=Xrihgwisa/uDxHxG991tmgkyu9iVpmMBkZr68jhUC/z1BswQvW42Q5c8FIATmXR9rY T09p1+sfN1ZS/FdBzK+4J5sgOQckWIyJduRggCF98+qMATB/sgmlydpWXvtHZss5pFZH 2XTEbLclX64acicaivOVsTfa8KN89j6jgis+A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=PNnAaAD0MVmU1Dt77oP+IW2haOw8iUHhG6sZ4ltHmqQ=; b=18ZZw4y2BKRG+jgg53AfRFzyK0T6S3gdoxDgkWZYYvn5KEvAb4RCvpDWJu51ZLw2eg ANlGZ9y43MQiXqcDxX6oz6TiiduhFUEX3cKhwXfXSG7+hOPo0t2c2Tzv9Gq1rbp70vX0 KUOBpZwwnlbjGeJfNcAVDVVq9e3sp0qyvCVv/fJSDxtuuZbw9zjBLUlZPP12rAh7yMaJ PAh1VStItb5No2uQrswQML6ReSX7xz9+r+wi4YC9OHy7ZhqFKrXMWYX547fRtmcs4Zy4 uBvrYkkKrOWXnymOL58cK7bL+zsuUXrJaQiBnJy3FbsQKGoFx9x+zlxWoYPR9hfMQzxA LB4w== X-Gm-Message-State: AJIora/rfMyYD5Y4wwCR8eIfyte/Jq0FyhNK/ylniBLUO6CK5zbfhUll OQwgQ6AY2VhhPm6aGx3z/dUJmfZm X-Google-Smtp-Source: AGRyM1sAZmttBzBZ+5CK4kmuL2vbHUtcp2c9gKL9CbpPyaV0nv/49OZVakuuU5fBPJ0BIGW2cO9QEw== X-Received: by 2002:adf:f5cf:0:b0:21e:2ebc:4126 with SMTP id k15-20020adff5cf000000b0021e2ebc4126mr9919710wrp.195.1658385896178; Wed, 20 Jul 2022 23:44:56 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:d209:0:b0:21e:53a1:af5d with SMTP id j9-20020adfd209000000b0021e53a1af5dls243689wrh.3.-pod-prod-gmail; Wed, 20 Jul 2022 23:44:55 -0700 (PDT) X-Received: by 2002:a05:6000:60a:b0:21d:9451:e91 with SMTP id bn10-20020a056000060a00b0021d94510e91mr34278444wrb.73.1658385895212; Wed, 20 Jul 2022 23:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385895; cv=none; d=google.com; s=arc-20160816; b=eH4gsLoS+1m1sWpfU6ZyfP0bSlCOrmL6xX7CmdzhwSEn5tSlbbn/YIQpajHToA2JbV cEHRAICrWjtgPrHFIUlg7WcsBaY8Zg0z2kBxetcy7RuhUBkJePGC8UM2dSFjGEazdL8V Zu2Nv04QSi4JVe50zAHy3VFiI5Kmx8FjkVPviNym0QHyiTmPp0slM2yHLOFOy2b2qgyK E70+jpHwiaycKwF9vOcqJm5Bb1sQCWJGpxr1HDXfcRueA1p/k14dcHBfVV5bnOCHoOM/ ZKoYHNTsw3wPc+FhsUb9AfqY86SDnjUWQkjI29rtyALBuHE57xiXvMtP9SudiGHytPIn CIhg== 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:cc:to:from:dkim-signature; bh=/Qrxi4xtJKkwAMXpR1/qDY76Jr73md3YvbKXiEzew8g=; b=gM9C81R9K85EWoXFykdPcl90oh1IOkmiUfFhDWRI8TYEZN7NVSl0MpHYSGH45X7By3 1BSQnvZ99tDd/xyKA8STgMPn8Gm5569IG7Z1MCavKCdI3uM3aK4U6fxCJvp7c5Dpn7Tt GZ9KUkCFnVU9dYqozSINmXs6+OT1Q1JFpg8KVXdq+MyuiMcdMKWWBUNOutlUWrjEL/z2 pxgPwzEOJJd3CXeDmbRE2rAwHPwFJOUy+47i4fF6uEX3PBfrQcw6mnZ7ykooeK327tNN t9UqzWxnrQztLN90gwgEatBTAEcTMQHCWmG1rDiG106uiuCms+mP51EaWa8j1LpFCB8U ZqTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="q/C3C0Y4"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 o7-20020a5d6487000000b0021e138d93a1sor409113wri.74.2022.07.20.23.44.55 for (Google Transport Security); Wed, 20 Jul 2022 23:44:55 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:adf:e44f:0:b0:21e:4ee5:eac4 with SMTP id t15-20020adfe44f000000b0021e4ee5eac4mr3604892wrm.485.1658385895000; Wed, 20 Jul 2022 23:44:55 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:54 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 04/13] mtd: nand: Get rid of mtd variable in function calls Date: Thu, 21 Jul 2022 08:44:26 +0200 Message-Id: <20220721064435.2456601-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="q/C3C0Y4"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi chip points to mtd. Passing chip is enough to have a reference to mtd when is necessary Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Fix code style warnings raised by patman. drivers/mtd/nand/raw/nand_base.c | 25 +++++++++++++------------ include/linux/mtd/rawnand.h | 3 +-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 0900e6dbf9a6..145de22be852 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4160,8 +4160,9 @@ static int nand_get_bits_per_cell(u8 cellinfo) * chip. The rest of the parameters must be decoded according to generic or * manufacturer-specific "extended ID" decoding patterns. */ -static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) +static void nand_decode_ext_id(struct nand_chip *chip) { + struct mtd_info *mtd = &chip->mtd; int extid, id_len; /* The 3rd id byte holds MLC / multichip data */ chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); @@ -4291,7 +4292,7 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) * compliant and does not have a full-id or legacy-id entry in the nand_ids * table. */ -static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chip) +static void nand_manufacturer_detect(struct nand_chip *chip) { /* * Try manufacturer detection if available and use @@ -4301,7 +4302,7 @@ static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chi chip->manufacturer.desc->ops->detect) chip->manufacturer.desc->ops->detect(chip); else - nand_decode_ext_id(mtd, chip); + nand_decode_ext_id(chip); } /* @@ -4324,9 +4325,9 @@ static int nand_manufacturer_init(struct nand_chip *chip) * decodes a matching ID table entry and assigns the MTD size parameters for * the chip. */ -static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, - struct nand_flash_dev *type) +static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type) { + struct mtd_info *mtd = &chip->mtd; int maf_id = chip->id.data[0]; mtd->erasesize = type->erasesize; @@ -4439,11 +4440,11 @@ static const struct nand_manufacturers *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 mtd_info *mtd, - struct nand_chip *chip, - int *maf_id, int *dev_id, - struct nand_flash_dev *type) +struct nand_flash_dev *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_manufacturers *manufacturer_desc; int busw, ret; u8 *id_data = chip->id.data; @@ -4539,9 +4540,9 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, chip->chipsize = (uint64_t)type->chipsize << 20; if (!type->pagesize) { - nand_manufacturer_detect(mtd, chip); + nand_manufacturer_detect(chip); } else { - nand_decode_id(mtd, chip, type); + nand_decode_id(chip, type); } /* Get chip options */ @@ -4729,7 +4730,7 @@ 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(mtd, chip, &nand_maf_id, + type = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, table); if (IS_ERR(type)) { diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 57fe7fb47bd8..d8141cb4d114 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -29,8 +29,7 @@ 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 mtd_info *mtd, - struct nand_chip *chip, +struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, int *dev_id, struct nand_flash_dev *type); From patchwork Thu Jul 21 06:44:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2220 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id EE1C344190 for ; Thu, 21 Jul 2022 08:44:57 +0200 (CEST) Received: by mail-wm1-f71.google.com with SMTP id p2-20020a05600c1d8200b003a3262d9c51sf2378090wms.6 for ; Wed, 20 Jul 2022 23:44:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385897; cv=pass; d=google.com; s=arc-20160816; b=m1XZ2prNp6PBLmZNv4mVzj1ubFdrZWOcUqcYwOISGpNk7DgJ7t6Js69QLI2r6duyPJ whp7XA+dMsxgAQUrx0LyfxKs4K0ipn7q7wQI6+utB7gn3q72SUMtndWChQs4TZaCxvNc PlqLXopPdBjA9Nqu7skUBZHMSflklk/vFeVFtSp1soJp1dMTVKkrSsbJjP4/aOySR7Va GfFS4V04wiqxwFUzGRvghFNzldVc8KXs7Lm3nE/d615YxeullGeixyD1n8i3mTeYcW5P CEVsfmztzm1Y+uNoUYQheX1a3+0uwhJNJvYH8KUCR+cFIrJm9+zLh6AbdGdWXilynKli KdPQ== 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:cc:to:from:dkim-signature; bh=Mx4WhDoVE9eDaatrUeXtmIleNQy27p8J6+NyWVgG2ZE=; b=iVjCXcGXAemuf6I3ND6pt2E5dpk7QcwaQ91ZupKXlcd+xpbyFzBKNB4Jh8lkiiN841 VyZxnugXbFdDwheKfZ05Qhp6xERz7Owk5Rzv67Gym/JI0L+8jbH5++YbgdOn53dvPrbv 4MosKlZUL9/rfn5vb/Z6CLBMFA+BGOdoMDynSvIEkPZXYAteFV0PzwgO1H22syN3584m ExmXxW078Tjjjs0RLisZBkbLkmNA7w42Qab/f9XO2mt3xWdluWCOIPXz1pTlw4LgjipS YOBkgCn6qkRRDW8OTgVk5hZOQOA2WNzhatVMCQ9LrY0QLpGZ97JKQtJChloCgBlq3QWz fz+A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T92lpCrA; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=Mx4WhDoVE9eDaatrUeXtmIleNQy27p8J6+NyWVgG2ZE=; b=QfK9bwCgyNa2EXGv4O38Nk6RG+LLd60tkWUDkWiRxtm62LUBxOCDa2oKsChCe+Uws9 XO5GlQp9ycQngZOpLnDwoT9knjU5EgzPEpiWWds/MM6WxSk1765X3NIk7+2wVcDoIqP3 oWCnE5FZYbmYKh3CqfjztIFlEW3TKekqlJjqo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=Mx4WhDoVE9eDaatrUeXtmIleNQy27p8J6+NyWVgG2ZE=; b=17UoAS2rv4JaXh9j9Vy1hrtBWYRQfQCYozEYQBBXZUlGsXU0jeF2SfHkIvXRocYv3K 5l9o9T8E3yS+YDUcxtMfJbH4N/T7ar8i//PJFRe/+XcSPUz6O++LlUo3L48v6AuH8DD9 qyKD7ms0WLKZlR8jqF17F+HYvEgNkWKB93PeppphvIGgvUXjBhvdntHtf/apwk23YBHX yR7crptv1X8O7WHix77btq1bEuBzvHCoTbDzPHO2wisnvY5lWdmZVls2UtDy1XvsHj4t 8ZmrCmEgVAklK0DDRjJiQhbj7CXSwD6egOB2z+joUHfoDpzMVLaqlEb5BCccP3yqQHGh knLw== X-Gm-Message-State: AJIora8Ak2aFa77FEaPIbI4P8RdAaf7GwfRGu+Pp41UMeXzAEWDsno0Z jPCb6MCmz36GyIXH+nmnPXhisPp7 X-Google-Smtp-Source: AGRyM1tFbRaAvcb8xAI6Ff6pOUaCRmKvtCRsOGsEpsXmxRUFtp6JO8SdLnvUrw0HLo1JSnHDID/77Q== X-Received: by 2002:a5d:6d08:0:b0:21d:adba:1a65 with SMTP id e8-20020a5d6d08000000b0021dadba1a65mr33420496wrq.229.1658385897764; Wed, 20 Jul 2022 23:44:57 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:6547:0:b0:21d:668b:3503 with SMTP id z7-20020a5d6547000000b0021d668b3503ls243207wrv.2.-pod-prod-gmail; Wed, 20 Jul 2022 23:44:56 -0700 (PDT) X-Received: by 2002:a05:6000:144a:b0:21d:c50a:89dd with SMTP id v10-20020a056000144a00b0021dc50a89ddmr27621371wrx.608.1658385896657; Wed, 20 Jul 2022 23:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385896; cv=none; d=google.com; s=arc-20160816; b=yQjgjhy7J98EhA4f0Jj2Rgf9snZRyY/EtmtHQOr1CihEK9Jq/lyX+6uAyIru6nvBmO drGXQBZndqxIMDwiSq1IufyHwsobt+jDjGlHRi2NlAXnZjUX9bJ7/kYeaPkrwD9EsV4G a4WB1UsCW+68Ri5+9dK0Gdt+ucXeWmOeO7z+2Rjo8fmFSzQDRLeYEq65nZqegMm+WlSS BuiQexx2R/ZzSqSXAYH+lvTCO6ciFHau+ewqP5D793hACaZ4dOtvk2+tBKWTs1XuPR7d cS6vwLsFmGsaYZLINAsBZEkGP1KU2jq6Js0DRLvH/7nmdPG5iHeW6AK/IMEHuDVUF9Qe vZHg== 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:cc:to:from:dkim-signature; bh=PqkGaZHSNiv+wfu/yU2ktE6N+nN1VwOJ0uXBw8IizDw=; b=OxoVh2D2812MKzAE3PrvE+UHLLpYaVwJQytiDDTWbaHGQVrvylUXghKr5Wtp96p47H lcga9jjnuUOYUkGJr++fQRq1KalHCnaawqesZ/uMc0R74Ikv5RdmE/KHo1xkmaIEPrE4 u2ECI+J/6vgJkslxjMi7clgXXOY2VBGQge8NiI/jlHEFPGUD4pldLwuzr1il4nE8wOXP PZd3xgLRLXILtPpsKhMS/EDv9EkNCUiLlkqcDWols237QjC8+OrMVVo9RUuhu/wQZ6+o mbc4OmN9rnrN7CXxBbuDBYu0iQCkEJo9ziRBrlo94q2A1JWwROsKmLQ7F0Dnvghlrpwp y3FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T92lpCrA; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 x3-20020adfcc03000000b0021bbc8a65d1sor413872wrh.41.2022.07.20.23.44.56 for (Google Transport Security); Wed, 20 Jul 2022 23:44:56 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a5d:595f:0:b0:21d:78fd:70d6 with SMTP id e31-20020a5d595f000000b0021d78fd70d6mr33123640wri.402.1658385896371; Wed, 20 Jul 2022 23:44:56 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:55 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 05/13] mtd: nand: Export symbol nand_decode_ext_id Date: Thu, 21 Jul 2022 08:44:27 +0200 Message-Id: <20220721064435.2456601-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T92lpCrA; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi In preparation of moving specific nand support that are not jedec or onfi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/mtd/nand/raw/nand_base.c | 3 ++- include/linux/mtd/rawnand.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 145de22be852..174c760f3416 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4160,7 +4160,7 @@ static int nand_get_bits_per_cell(u8 cellinfo) * chip. The rest of the parameters must be decoded according to generic or * manufacturer-specific "extended ID" decoding patterns. */ -static void nand_decode_ext_id(struct nand_chip *chip) +void nand_decode_ext_id(struct nand_chip *chip) { struct mtd_info *mtd = &chip->mtd; int extid, id_len; @@ -4286,6 +4286,7 @@ static void nand_decode_ext_id(struct nand_chip *chip) } } +EXPORT_SYMBOL_GPL(nand_decode_ext_id); /* * Manufacturer detection. Only used when the NAND is not ONFI or JEDEC diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index d8141cb4d114..8fb2a43296f5 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1374,4 +1374,7 @@ int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len, int nand_write_data_op(struct nand_chip *chip, const void *buf, unsigned int len, bool force_8bit); +/* Default extended ID decoding function */ +void nand_decode_ext_id(struct nand_chip *chip); + #endif /* __LINUX_MTD_RAWNAND_H */ From patchwork Thu Jul 21 06:44:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2221 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BECC444190 for ; Thu, 21 Jul 2022 08:44:59 +0200 (CEST) Received: by mail-wm1-f71.google.com with SMTP id c62-20020a1c3541000000b003a30d86cb2dsf2374941wma.5 for ; Wed, 20 Jul 2022 23:44:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385899; cv=pass; d=google.com; s=arc-20160816; b=SxJgzafmtCa8X3+328W4+N11YGQzSpikBlakO7RDc/yj/HSSJg5wMER9X+tRQxxxcQ iANTRmTWHQLfXMqwu8c/D5c9jmoMmJjOSPlX15005OVut/c79unzjYAhs9CORB5Mrw8J vNjRs09i++GKO5BEBVHI/juImkRl4tc001/ODV3P+Oc3hJMLVCu8kNy3L0IBditgcJ8k YoOUN+6M3uKz8sernCb71hHOtM8INb3dfSAPUpKGe77X8uOVHhdh09a2FLu71jBeOy49 hHIYg8oPdAfx0AY7U2OAipm2BJ0h6TwSlMErvZ3kVmXB3hLUW37hPIf0q+tUy8+xTfJ0 UzCQ== 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:cc:to:from:dkim-signature; bh=bqzaH7mo1dXBMUA6ZLakIOijnDz2CJQqz5oMmXQinO8=; b=hAGBJfGkFiv4vwi3kE0/2/TVoZBU0i9/OxJEuzlYW/u3kDWeFFvgeBM8NV5wWfNLQ5 zObZoSy+vLT68uCTelD+B67R2vCU859V026/F5x9MmfbrF9vGWfyd2E+I0+J9H+62Hff ROzf8NlKMsEG47UH6gmtV69tgM3sAm6DSE2jXUud7TZRcsq76jWQp5qO88YW/C7P9pUU pFRQlYTeIHikeML/VcxolHf3C8ZOYkG07iVE4ZcAYapQ7w2Zb+/ZDShdmcEIMSKG5SKj nysNT4P09RWwybv8LkRXUaPPf4AmOzh6znXSa0745Lyb3WXX/uaMPWQZsHdBref0aiUp hFpw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TbsNpCBL; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=bqzaH7mo1dXBMUA6ZLakIOijnDz2CJQqz5oMmXQinO8=; b=Uae9VNUGamIJQy80L1akiZVRH+QBvphMDG2ocw7PAIaMmp8XD/+D/FahfBhV7K5M/W KrsYyKd97MndRgrrikvtbCHSQfA8kDLenjoq4WOlFldKO0XrjSUJ1CBrm1J8ppRwaokk kUwufNLGfeHW9Hv9aHiVmUGPyLz8C2TW/ELJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=bqzaH7mo1dXBMUA6ZLakIOijnDz2CJQqz5oMmXQinO8=; b=pWZuX0Fm27jxEYaR+7lCvyDvVGz3l2xeTEOkjhgM1joHPLhRqjWCV/19ffpY4wIce5 g/9ybqNfbv04ioBrWEL/3qOatnYWFSHMFyiYaUX2iC+pDEMcKZKn4WNWJ3i4UmBjgQpA zv2dX/ZGd6gcq8MMFQyb2QIYkOdtEvAU+shgATW53d/lyRrUQQA1TLOeKH/r95lrH8jt 2GS9BdWNbSLQT2T8bQthk/n0wVuWFQTIem519SSfyknG6dehxpEsBNzhkQsENI4nI9m1 pmXoYf5DoxA+7DtOzJq10ZT6M4QPHFo1+vJLnApn5Hau6J4Fnledxv+qFofNE/eHKiUw Xo0Q== X-Gm-Message-State: AJIora/scVfaD6eWH7WDgo/5BReClkntW+SKWzXu1hh9E0s/AdPzFocg LGb7wpcn663JG+dmtm38mnXC7MLr X-Google-Smtp-Source: AGRyM1vTGpRbSRxfx4B7woZh0OQeV9cu+cCNCb/xp+nkjf2EfAqV9If4Kg/424vgHPZcxtL5FLD27Q== X-Received: by 2002:a05:600c:ad2:b0:3a3:181e:e228 with SMTP id c18-20020a05600c0ad200b003a3181ee228mr6992440wmr.139.1658385899448; Wed, 20 Jul 2022 23:44:59 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:6f03:0:b0:21d:9636:a730 with SMTP id ay3-20020a5d6f03000000b0021d9636a730ls243674wrb.0.-pod-prod-gmail; Wed, 20 Jul 2022 23:44:58 -0700 (PDT) X-Received: by 2002:a5d:4301:0:b0:21b:8af6:4a21 with SMTP id h1-20020a5d4301000000b0021b8af64a21mr34271246wrq.296.1658385898281; Wed, 20 Jul 2022 23:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385898; cv=none; d=google.com; s=arc-20160816; b=efRGWz+l/zcdUD7GcGzvARmhJWArglA7s5VU2eg+L0fwtFoEA30K0/Pt+hvf5hovW8 yi5E1Gzk6443vQKl0ar+PdNmw3YpGADPfqSW/YobuN4UffZ32FqKKzK/k9Q4qAreJKBU blNfTBdNOzNQ0XWlIO26Fn5XzmVM0TsuTjeafweM6druCZehwbRMHWUr8o6atshVuSGL KHGpuL3UvE/DcdZeKRQpHbieNxT3iWHAhMk3qcEIyJT4UO4HYMYLj0kE1gWRPiRCa3GF w311mKastLLNsKNAWj4JMGh3p/eAHmLdxxKUd83zVsJRQqlTTUPeKPeL9Lt/i5PXuY2S HjIg== 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:cc:to:from:dkim-signature; bh=i8A8CzFILS7ro6NcMA+hZ9Vq5gjU4ZOypegayHdfqAs=; b=CQ+84ygpfD4QoAoskR42r4WmmUkw9fgPzTFJllFOfaNR0ZcTye4g8jyz17086Cze4c GO93Io34LQ+3KJqW+wl9uz7BEO34No8Bb6nOo54e9a8+fPC2MAMkJbVL1SsSF9bRfgSl 3m0fGQxtIyIOfBRxyf60DFiqjUStIjDP8FSqv9yMLCxQl/32FK20STcTP7Ns4+paztqb Cmb9LOal7t/ZFvZRRlLFrMF8+m2JWKToWn26H4x1rAv1Hp1sAHGyh2xRO0I0+kksRTE/ mYn1fb2CnYRhopufBCuadVGJQI6/O8WiAvj7mP0UGGNiIM/QO5QguBPX80pZrmqU5wLd Kcpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TbsNpCBL; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 g4-20020a5d64e4000000b0021d669fc740sor453099wri.21.2022.07.20.23.44.58 for (Google Transport Security); Wed, 20 Jul 2022 23:44:58 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a5d:4d8e:0:b0:21d:68d4:56eb with SMTP id b14-20020a5d4d8e000000b0021d68d456ebmr32243625wru.40.1658385897762; Wed, 20 Jul 2022 23:44:57 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:57 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 06/13] mtd: nand: Move Samsung specific init/detection logic in nand_samsung.c Date: Thu, 21 Jul 2022 08:44:28 +0200 Message-Id: <20220721064435.2456601-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TbsNpCBL; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit c51d0ac59f2420. Move Samsung specific initialization and detection logic into nand_samsung.c. This is part of the "separate vendor specific code from core" cleanup process. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Fix code style warnings raised by patman. - Add the SPDX-License-Identifier tag. Changes in v2: - Use short-commit form. - Remove linux info. Uboot seems that backport without add this extra information. - Adjust the include file in nand_samsung. drivers/mtd/nand/raw/Makefile | 3 +- drivers/mtd/nand/raw/nand_base.c | 52 ++--------------- drivers/mtd/nand/raw/nand_ids.c | 4 +- drivers/mtd/nand/raw/nand_samsung.c | 90 +++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 2 + 5 files changed, 100 insertions(+), 51 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_samsung.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index f278f31f5cd5..440290bed0fe 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -14,7 +14,7 @@ obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o -obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o +obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_samsung.o obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o obj-$(CONFIG_TPL_NAND_INIT) += nand.o ifeq ($(CONFIG_SPL_ENV_SUPPORT),y) @@ -31,6 +31,7 @@ obj-y += nand_ids.o obj-y += nand_util.o obj-y += nand_ecc.o obj-y += nand_base.o +obj-y += nand_samsung.o obj-y += nand_timings.o endif # not spl diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 174c760f3416..fe59157bc3c4 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4173,48 +4173,13 @@ void nand_decode_ext_id(struct nand_chip *chip) /* * Field definitions are in the following datasheets: * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32) - * New Samsung (6 byte ID): Samsung K9GAG08U0F (p.44) * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) * * Check for ID length, non-zero 6th byte, cell type, and Hynix/Samsung * ID to decide what to do. */ - if (id_len == 6 && chip->id.data[0] == NAND_MFR_SAMSUNG && - !nand_is_slc(chip) && chip->id.data[5] != 0x00) { - /* Calc pagesize */ - mtd->writesize = 2048 << (extid & 0x03); - extid >>= 2; - /* Calc oobsize */ - switch (((extid >> 2) & 0x04) | (extid & 0x03)) { - case 1: - mtd->oobsize = 128; - break; - case 2: - mtd->oobsize = 218; - break; - case 3: - mtd->oobsize = 400; - break; - case 4: - mtd->oobsize = 436; - break; - case 5: - mtd->oobsize = 512; - break; - case 6: - mtd->oobsize = 640; - break; - case 7: - default: /* Other cases are "reserved" (unknown) */ - mtd->oobsize = 1024; - break; - } - extid >>= 2; - /* Calc blocksize */ - mtd->erasesize = (128 * 1024) << - (((extid >> 1) & 0x04) | (extid & 0x03)); - } else if (id_len == 6 && chip->id.data[0] == NAND_MFR_HYNIX && - !nand_is_slc(chip)) { + if (id_len == 6 && chip->id.data[0] == NAND_MFR_HYNIX && + !nand_is_slc(chip)) { unsigned int tmp; /* Calc pagesize */ @@ -4374,13 +4339,10 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, * Micron devices with 2KiB pages and on SLC Samsung, Hynix, Toshiba, * AMD/Spansion, and Macronix. All others scan only the first page. */ - if (!nand_is_slc(chip) && - (maf_id == NAND_MFR_SAMSUNG || - maf_id == NAND_MFR_HYNIX)) + if (!nand_is_slc(chip) && maf_id == NAND_MFR_HYNIX) chip->bbt_options |= NAND_BBT_SCANLASTPAGE; else if ((nand_is_slc(chip) && - (maf_id == NAND_MFR_SAMSUNG || - maf_id == NAND_MFR_HYNIX || + (maf_id == NAND_MFR_HYNIX || maf_id == NAND_MFR_TOSHIBA || maf_id == NAND_MFR_AMD || maf_id == NAND_MFR_MACRONIX)) || @@ -4549,12 +4511,6 @@ struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, /* Get chip options */ chip->options |= type->options; - /* - * Check if chip is not a Samsung device. Do not clear the - * options for chips which do not have an extended id. - */ - if (*maf_id != NAND_MFR_SAMSUNG && !type->pagesize) - chip->options &= ~NAND_SAMSUNG_LP_OPTIONS; ident_done: if (chip->options & NAND_BUSWIDTH_AUTO) { diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index 2a50f0b2144c..f4126c3a5a13 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -10,7 +10,7 @@ #include #include -#define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS +#define LP_OPTIONS 0 #define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16) #define SP_OPTIONS NAND_NEED_READRDY @@ -189,7 +189,7 @@ struct nand_flash_dev nand_flash_ids[] = { /* Manufacturer IDs */ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_TOSHIBA, "Toshiba"}, - {NAND_MFR_SAMSUNG, "Samsung"}, + {NAND_MFR_SAMSUNG, "Samsung", &samsung_nand_manuf_ops}, {NAND_MFR_FUJITSU, "Fujitsu"}, {NAND_MFR_NATIONAL, "National"}, {NAND_MFR_RENESAS, "Renesas"}, diff --git a/drivers/mtd/nand/raw/nand_samsung.c b/drivers/mtd/nand/raw/nand_samsung.c new file mode 100644 index 000000000000..0ab80621936f --- /dev/null +++ b/drivers/mtd/nand/raw/nand_samsung.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2017 Free Electrons + * Copyright (C) 2017 NextThing Co + * + * Author: Boris Brezillon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +static void samsung_nand_decode_id(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + + /* New Samsung (6 byte ID): Samsung K9GAG08U0F (p.44) */ + if (chip->id.len == 6 && !nand_is_slc(chip) && + chip->id.data[5] != 0x00) { + u8 extid = chip->id.data[3]; + + /* Get pagesize */ + mtd->writesize = 2048 << (extid & 0x03); + + extid >>= 2; + + /* Get oobsize */ + switch (((extid >> 2) & 0x4) | (extid & 0x3)) { + case 1: + mtd->oobsize = 128; + break; + case 2: + mtd->oobsize = 218; + break; + case 3: + mtd->oobsize = 400; + break; + case 4: + mtd->oobsize = 436; + break; + case 5: + mtd->oobsize = 512; + break; + case 6: + mtd->oobsize = 640; + break; + case 7: + default: /* Other cases are "reserved" (unknown) */ + WARN(1, "Invalid OOB size value"); + mtd->oobsize = 1024; + break; + } + + /* Get blocksize */ + extid >>= 2; + mtd->erasesize = (128 * 1024) << + (((extid >> 1) & 0x04) | (extid & 0x03)); + } else { + nand_decode_ext_id(chip); + } +} + +static int samsung_nand_init(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + + if (mtd->writesize > 512) + chip->options |= NAND_SAMSUNG_LP_OPTIONS; + + if (!nand_is_slc(chip)) + chip->bbt_options |= NAND_BBT_SCANLASTPAGE; + else + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; + + return 0; +} + +const struct nand_manufacturer_ops samsung_nand_manuf_ops = { + .detect = samsung_nand_decode_id, + .init = samsung_nand_init, +}; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 8fb2a43296f5..d0312e924b4d 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1158,6 +1158,8 @@ struct nand_manufacturers { extern struct nand_flash_dev nand_flash_ids[]; extern struct nand_manufacturers nand_manuf_ids[]; +extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; + int nand_default_bbt(struct mtd_info *mtd); int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs); From patchwork Thu Jul 21 06:44:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2222 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id ABFC644190 for ; Thu, 21 Jul 2022 08:45:00 +0200 (CEST) Received: by mail-wr1-f72.google.com with SMTP id k26-20020adfb35a000000b0021d6c3b9363sf71261wrd.1 for ; Wed, 20 Jul 2022 23:45:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385900; cv=pass; d=google.com; s=arc-20160816; b=NcZnXCwUwnIcWIniqimfNRJM5HCkdbkWLXVIMHLC/TOOQkj7OrvmHpyr33XCd4UeEs GZmTNlWLui6QHG8WwdY1y4G8fQbDo4ZGPoUv1makw6VXzTUNrIcQO1WdbW/EFWtyBEox 71Ro7qL0ki+My2bp2wW2TZSGqNgT3dtqiODMJznrM7hRZdsiV3phHdqLum7nJBTmfPCv UMYZsluaxJTgFn8SLS0M72mmYo0RM5TRRLUxhAAQUY3uxBpsw0d5IIuAgOUCb9n+kWvs +sHcVRMNZEDB/Ju3wdwwNhr1JCtR253G5yUeYNpxwz9kliVzsc+367brNTyTZv/LUkiV auvA== 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:cc:to:from:dkim-signature; bh=czcbD/yQLceeBuw4OrKgqIT52ezQgIvSxL/gW46tqQ4=; b=kcQTYRl8fXTBARY33odombG9hUmQAVVAc7/hD9UY9txhRiMsF6/aXlro7hRne0Phx8 SRMm2zBjaBLXEpQ1gi2MQl9MNOxZ/slyMLCLIVS7iBIR9lJieGOFdo4pyw30bV5YqDtM qgXAWPV+FBCQir5a4GjMFXwv/CSUCgSmkrYR0IB53wmCpCTyQH+/gVHm4XHFF/FA8BRb Btl0gBHNBwjssRu4VwsJKcEPV6/UHXY5JenLTDBvKmSxrftolS9XPF2zZG2/5DnwwDIZ cdalBowv+Obapi79CNFa0UYFeR37BTH7umaJgugwp1gXQOSpnmJbeC9AIqGhBn7YTsZK w3dQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PmSrI6hK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=czcbD/yQLceeBuw4OrKgqIT52ezQgIvSxL/gW46tqQ4=; b=eimfNli3+nSQPv2qDKkaSJL1QQr3HjERlpmJAkprKQG9Hhp0CEoAMbrd3w3oFpx8/0 3DWWYR5HUTaCwIuFKVV6FcA35C7u0ddL58AN5e42yAWCElaKfVT5KPLb9kUNwmfOZqiK zb8tCTwxRmlBPa1TLSVBMxe/+fAS1LPQiRAGs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=czcbD/yQLceeBuw4OrKgqIT52ezQgIvSxL/gW46tqQ4=; b=bvtyi5Zkw/Rd4qz1WSAfyFfoDvE8RBQOwl6d+H2ClCOB6JQYH+Pn/ughm9ag7pmQC6 QlaPokNLafpcg6p4IIL2oYENU+QXa4Ixqla/JozI2IpkmEJZfwGXlQVnt7HqRG+h2E7S YFHYdkgXttoK0S40IqyWOQBMIEc8Ovi6Ez1hzLrByPaSTNNCARqwF7+8A7Dk2nw+4aS9 UNBrpknjq1iCmEABvCVh+nFlk0cq0l3/pJIgroXad8wriZeMUG55/DJikpPktp/RvcoN p7f993ml0i8XUiRcoD0i8BfSWECNpzmqUBM4shH2dZxXT+QIAtd3cvz7pqu+l6oZxOZP Jtnw== X-Gm-Message-State: AJIora+G5FtJvYUVEpRKwinzZBrOVczkzPfxRu2yOG4gaz45j0xirQ/4 ivr7vCf6cDHZUJ58pxkAY6mwNC8L X-Google-Smtp-Source: AGRyM1t3Sg/SeQQsTdM+12Fc8+e5fBqqbA+WY6ELZyz6vXEV4YsV7VfL+O+oN3qctkrZeUfnD2Gisg== X-Received: by 2002:a05:600c:a188:b0:3a3:1802:e327 with SMTP id id8-20020a05600ca18800b003a31802e327mr6916787wmb.41.1658385900434; Wed, 20 Jul 2022 23:45:00 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:d209:0:b0:21e:53a1:af5d with SMTP id j9-20020adfd209000000b0021e53a1af5dls243871wrh.3.-pod-prod-gmail; Wed, 20 Jul 2022 23:44:59 -0700 (PDT) X-Received: by 2002:adf:f0cf:0:b0:21e:4915:2224 with SMTP id x15-20020adff0cf000000b0021e49152224mr5047772wro.418.1658385899473; Wed, 20 Jul 2022 23:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385899; cv=none; d=google.com; s=arc-20160816; b=YoukStFcyL7g/5wKx89TP/FyuaOlVatCSdpfHRz1Rq1wOKHF6Zbsum5XEM6A4jF4ad iA47+9CO8bwaeMwfpvLK8o3y++zB2m7undOuFtEXLTAj/u6pXUuTvpx8+0Bjn+1gx1qp wzdP59dgWkJqj8L3ZfidTgTq9MPpLHtmUXWPZ2fjhK/aBeaKMW51ZhD3UcCWzNH0Hr4a A/2lwvfIqghga0b/lbJFVa4RFm36wN72L1VX3P9kHlPi8RU008WLfIxT1s4bH7hXUwcp ndpfNRetnb84PZg1F8wz0bFhr23hO13YnvlmRJwhYjRBn+Xzml4ulePKOQoH3l8YKKOw Oblw== 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:cc:to:from:dkim-signature; bh=8OpcHreBUVChk8kHrZJ/Qqi1ZoIveTy4LkKfvCBsChw=; b=i5iX2Ry2X7S06woIdfgFdCv6NXpBLbYK/qZYOxn5ayLSzQTg5G24bESx/z0SDCydxi 9HDcFCIbwGtlThevpvWSA1HPhmKi6ncL8Cqqy5ZPyEFh3f0yXf9DKFrwpM/vKoQYyjRH Zukyun0jnkAxGNP34nPfHh20v9QPO4XuNcxn65uCdI1kMjs70MRJ0/mkNfDSByWfoINJ ywacMF5jSn0+IhiFgbt5sYLYlkNYtlkDzgYSiH6utH8OwrKw62f5Q8yDqG/GzSV+C6Bx J+PqDTuBdwYTQJdxl6kN+oNvhCi9FlDcNplyo37oC/mKyh48kMel+bMfpb4wDcjMOxSi CnkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PmSrI6hK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 o13-20020adfba0d000000b0021d8011fa5esor406299wrg.57.2022.07.20.23.44.59 for (Google Transport Security); Wed, 20 Jul 2022 23:44:59 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6000:49:b0:21d:78fe:34b2 with SMTP id k9-20020a056000004900b0021d78fe34b2mr32411473wrx.200.1658385899106; Wed, 20 Jul 2022 23:44:59 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:58 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 07/13] mtd: nand: Move Hynix specific init/detection logic in nand_hynix.c Date: Thu, 21 Jul 2022 08:44:29 +0200 Message-Id: <20220721064435.2456601-8-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PmSrI6hK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit 01389b6bd2f4f7. Move Hynix specific initialization and detection logic into nand_hynix.c. This is part of the "separate vendor specific code from core" cleanup process. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Add the SPDX-License-Identifier tag. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. - Adjust the include file in nand_hynix. drivers/mtd/nand/raw/Makefile | 3 +- drivers/mtd/nand/raw/nand_base.c | 117 ++++++++---------------------- drivers/mtd/nand/raw/nand_hynix.c | 85 ++++++++++++++++++++++ drivers/mtd/nand/raw/nand_ids.c | 2 +- include/linux/mtd/rawnand.h | 1 + 5 files changed, 120 insertions(+), 88 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_hynix.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index 440290bed0fe..86d9b8e8beb8 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -14,7 +14,7 @@ obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o -obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_samsung.o +obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_samsung.o obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o obj-$(CONFIG_TPL_NAND_INIT) += nand.o ifeq ($(CONFIG_SPL_ENV_SUPPORT),y) @@ -31,6 +31,7 @@ obj-y += nand_ids.o obj-y += nand_util.o obj-y += nand_ecc.o obj-y += nand_base.o +obj-y += nand_hynix.o obj-y += nand_samsung.o obj-y += nand_timings.o diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index fe59157bc3c4..5698c1e6a229 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4170,85 +4170,34 @@ void nand_decode_ext_id(struct nand_chip *chip) extid = chip->id.data[3]; id_len = chip->id.len; + /* Calc pagesize */ + mtd->writesize = 1024 << (extid & 0x03); + extid >>= 2; + /* Calc oobsize */ + mtd->oobsize = (8 << (extid & 0x01)) * + (mtd->writesize >> 9); + extid >>= 2; + /* Calc blocksize. Blocksize is multiples of 64KiB */ + mtd->erasesize = (64 * 1024) << (extid & 0x03); + extid >>= 2; + /* Get buswidth information */ + /* Get buswidth information */ + if (extid & 0x1) + chip->options |= NAND_BUSWIDTH_16; + /* - * Field definitions are in the following datasheets: - * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32) - * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) - * - * Check for ID length, non-zero 6th byte, cell type, and Hynix/Samsung - * ID to decide what to do. + * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per + * 512B page. For Toshiba SLC, we decode the 5th/6th byte as + * follows: + * - ID byte 6, bits[2:0]: 100b -> 43nm, 101b -> 32nm, + * 110b -> 24nm + * - ID byte 5, bit[7]: 1 -> BENAND, 0 -> raw SLC */ - if (id_len == 6 && chip->id.data[0] == NAND_MFR_HYNIX && - !nand_is_slc(chip)) { - unsigned int tmp; - - /* Calc pagesize */ - mtd->writesize = 2048 << (extid & 0x03); - extid >>= 2; - /* Calc oobsize */ - switch (((extid >> 2) & 0x04) | (extid & 0x03)) { - case 0: - mtd->oobsize = 128; - break; - case 1: - mtd->oobsize = 224; - break; - case 2: - mtd->oobsize = 448; - break; - case 3: - mtd->oobsize = 64; - break; - case 4: - mtd->oobsize = 32; - break; - case 5: - mtd->oobsize = 16; - break; - default: - mtd->oobsize = 640; - break; - } - extid >>= 2; - /* Calc blocksize */ - tmp = ((extid >> 1) & 0x04) | (extid & 0x03); - if (tmp < 0x03) - mtd->erasesize = (128 * 1024) << tmp; - else if (tmp == 0x03) - mtd->erasesize = 768 * 1024; - else - mtd->erasesize = (64 * 1024) << tmp; - } else { - /* Calc pagesize */ - mtd->writesize = 1024 << (extid & 0x03); - extid >>= 2; - /* Calc oobsize */ - mtd->oobsize = (8 << (extid & 0x01)) * - (mtd->writesize >> 9); - extid >>= 2; - /* Calc blocksize. Blocksize is multiples of 64KiB */ - mtd->erasesize = (64 * 1024) << (extid & 0x03); - extid >>= 2; - /* Get buswidth information */ - /* Get buswidth information */ - if (extid & 0x1) - chip->options |= NAND_BUSWIDTH_16; - - /* - * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per - * 512B page. For Toshiba SLC, we decode the 5th/6th byte as - * follows: - * - ID byte 6, bits[2:0]: 100b -> 43nm, 101b -> 32nm, - * 110b -> 24nm - * - ID byte 5, bit[7]: 1 -> BENAND, 0 -> raw SLC - */ - if (id_len >= 6 && chip->id.data[0] == NAND_MFR_TOSHIBA && - nand_is_slc(chip) && - (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && - !(chip->id.data[4] & 0x80) /* !BENAND */) { - mtd->oobsize = 32 * mtd->writesize >> 9; - } - + if (id_len >= 6 && chip->id.data[0] == NAND_MFR_TOSHIBA && + nand_is_slc(chip) && + (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && + !(chip->id.data[4] & 0x80) /* !BENAND */) { + mtd->oobsize = 32 * mtd->writesize >> 9; } } EXPORT_SYMBOL_GPL(nand_decode_ext_id); @@ -4339,15 +4288,11 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, * Micron devices with 2KiB pages and on SLC Samsung, Hynix, Toshiba, * AMD/Spansion, and Macronix. All others scan only the first page. */ - if (!nand_is_slc(chip) && maf_id == NAND_MFR_HYNIX) - chip->bbt_options |= NAND_BBT_SCANLASTPAGE; - else if ((nand_is_slc(chip) && - (maf_id == NAND_MFR_HYNIX || - maf_id == NAND_MFR_TOSHIBA || - maf_id == NAND_MFR_AMD || - maf_id == NAND_MFR_MACRONIX)) || - (mtd->writesize == 2048 && - maf_id == NAND_MFR_MICRON)) + if ((nand_is_slc(chip) && + (maf_id == NAND_MFR_TOSHIBA || + maf_id == NAND_MFR_AMD || + maf_id == NAND_MFR_MACRONIX)) || + (mtd->writesize == 2048 && maf_id == NAND_MFR_MICRON)) chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; } diff --git a/drivers/mtd/nand/raw/nand_hynix.c b/drivers/mtd/nand/raw/nand_hynix.c new file mode 100644 index 000000000000..547ce7c92031 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_hynix.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2017 Free Electrons + * Copyright (C) 2017 NextThing Co + * + * Author: Boris Brezillon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +static void hynix_nand_decode_id(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + + /* Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) */ + if (chip->id.len == 6 && !nand_is_slc(chip)) { + u8 tmp, extid = chip->id.data[3]; + + /* Extract pagesize */ + mtd->writesize = 2048 << (extid & 0x03); + extid >>= 2; + + /* Extract oobsize */ + switch (((extid >> 2) & 0x4) | (extid & 0x3)) { + case 0: + mtd->oobsize = 128; + break; + case 1: + mtd->oobsize = 224; + break; + case 2: + mtd->oobsize = 448; + break; + case 3: + mtd->oobsize = 64; + break; + case 4: + mtd->oobsize = 32; + break; + case 5: + mtd->oobsize = 16; + break; + default: + mtd->oobsize = 640; + break; + } + + /* Extract blocksize */ + extid >>= 2; + tmp = ((extid >> 1) & 0x04) | (extid & 0x03); + if (tmp < 0x03) + mtd->erasesize = (128 * 1024) << tmp; + else if (tmp == 0x03) + mtd->erasesize = 768 * 1024; + else + mtd->erasesize = (64 * 1024) << tmp; + } else { + nand_decode_ext_id(chip); + } +} + +static int hynix_nand_init(struct nand_chip *chip) +{ + if (!nand_is_slc(chip)) + chip->bbt_options |= NAND_BBT_SCANLASTPAGE; + else + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; + + return 0; +} + +const struct nand_manufacturer_ops hynix_nand_manuf_ops = { + .detect = hynix_nand_decode_id, + .init = hynix_nand_init, +}; diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index f4126c3a5a13..ec263a43279a 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -194,7 +194,7 @@ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_NATIONAL, "National"}, {NAND_MFR_RENESAS, "Renesas"}, {NAND_MFR_STMICRO, "ST Micro"}, - {NAND_MFR_HYNIX, "Hynix"}, + {NAND_MFR_HYNIX, "Hynix", &hynix_nand_manuf_ops}, {NAND_MFR_MICRON, "Micron"}, {NAND_MFR_AMD, "AMD/Spansion"}, {NAND_MFR_MACRONIX, "Macronix"}, diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index d0312e924b4d..d35277d18799 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1159,6 +1159,7 @@ extern struct nand_flash_dev nand_flash_ids[]; extern struct nand_manufacturers nand_manuf_ids[]; extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; +extern const struct nand_manufacturer_ops hynix_nand_manuf_ops; int nand_default_bbt(struct mtd_info *mtd); int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); From patchwork Thu Jul 21 06:44:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2223 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C50CF44190 for ; Thu, 21 Jul 2022 08:45:01 +0200 (CEST) Received: by mail-wm1-f72.google.com with SMTP id n21-20020a7bc5d5000000b003a2ff4d7a9bsf293082wmk.9 for ; Wed, 20 Jul 2022 23:45:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385901; cv=pass; d=google.com; s=arc-20160816; b=mIMawjiqCAymURa74149JMpmwcMW0dam7Akzr2kiBRHAKZbgfdqnkhdU5ho9rAg85m tPXnOLtAZax6cTUqT6GYu03IT9lL5dbrLT4AAdXNdrDTEssYwN5EPz5/V4vN/JjS4Q1/ PGA2xWahW8RIzN+OzKb323MXS9aOiMPwt/lOoawSvyAsC7iLYovTO1hyIN35xkSfL56Q 9X1ZVj6mdwFLhDyvfhfWguzmGqpQ6qwefufiVOpHlHhy9Jnc5IzhfN9UGa8aB9l6DRZ7 DZXD1LFHesnHwXlVgc8LVscuE7un0uUomcGGHbESCBhIfHP1aFAqcavp00xI61Niqlv7 lwsA== 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:cc:to:from:dkim-signature; bh=Sd80JK/xrZ+p+7m3s3H4QZkYf6lDI9j4A97Oo3iY7sQ=; b=hpy9toK1eCyQ2LXB3DAgErg1WSOr9YCboQLwnLEdbhfKWSxU7j3Do8O/EFekmSjVFG IJ5f6lD/CIGCbsGqweg+ZAuM2ukYB+nG9CEryI6GVGNWzMDqe7nHw8vjWpDM7ZMWjnka KGe+5NP1aOnPPEHO4LcQ6HdL1B/UrBEBREVohGJMYD3SLI0y1Abxr2DbFBQpbka0jT2r fxJZCTv6u73bosIxdywhujam2dWYq1CmjO9IO1JP76sKp+XJXl8d69r76a6l9fMb1fTB cW+B+7gV9FzbSZBjIxVUgBhj/ec4Ghm92bxn8OwaX5AJHPGUxwROd2AA2dQZrBnOlITG utrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Wb7nSFqP; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=Sd80JK/xrZ+p+7m3s3H4QZkYf6lDI9j4A97Oo3iY7sQ=; b=mNYiFieZ6a7rJmAYcL+9J/wNH6ZBY+b1wn68z8BKpLXyHSSovm+Ok0dtWb2K5Rkkxq PHzQVJ7EmqMiHeNuO/hhDc+hGzFzfKroFEauDRSXwYY19ZHjHd1iC3Oh4aKEugNNIvi7 9XpVjj/qlYjWdJlw7aUNfC+Px8WOEZH7XuFGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=Sd80JK/xrZ+p+7m3s3H4QZkYf6lDI9j4A97Oo3iY7sQ=; b=G3d/wYu18NmiBxdqs2XLRlpCW9nOQcWv0S2WszjeJaoHj0+Kt/7ceKMR8uJgNzK6SN JmZWpV0b+eLhiK92IB6G3twxij2yBGppxviyVXs8afIAYVP4vBiBXmytuC5AZdeGc4dr tekkE8QXuYNHBR7ta6SNWhWvTBuzovrtMU+K0fxIs/aaLFzM9ACV/EV1E58lANSx5cF8 QE2QjO4iHtCcms551AopvE0euHJfEY7Wmx6pvpR9YKeVCgG4bEqTU/KcxD8Gkx3NVbg+ MoJyJlmunmsNwev/kw8HJ87fG83EoLWaXBT9BADLL5i/W1eeYRbxYwH6Gr+i20QWxInt Xc/g== X-Gm-Message-State: AJIora/pH04WqOiQQ7UdNdWDTS8zd12sE2CjXlSqsPs2FodFw0x7x/Iy 6/OF+4xzWI8nJXkA61bT+c8asdxk X-Google-Smtp-Source: AGRyM1tAsfxoep3qW2v/Bhkfr7vfGterTmqFy9sENNfkJcx2hC60GSfJlGWRaSYv9fCDyY2rObZdxg== X-Received: by 2002:adf:e30c:0:b0:21e:51b9:113c with SMTP id b12-20020adfe30c000000b0021e51b9113cmr2269558wrj.247.1658385901572; Wed, 20 Jul 2022 23:45:01 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:d209:0:b0:21e:53a1:af5d with SMTP id j9-20020adfd209000000b0021e53a1af5dls243925wrh.3.-pod-prod-gmail; Wed, 20 Jul 2022 23:45:00 -0700 (PDT) X-Received: by 2002:adf:e483:0:b0:21d:a52e:261d with SMTP id i3-20020adfe483000000b0021da52e261dmr31926627wrm.228.1658385900620; Wed, 20 Jul 2022 23:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385900; cv=none; d=google.com; s=arc-20160816; b=B9OKX71aDLE67pyA/rwFZrIQ5tHRNnyqVSN10tRNFbU7hCxsWaupBwEUB0JEUnHXcB 0SZLNRCesNS3O+IsqdyPcztHRLIl+yIbfQl2LZ0pHIsljBw6jOYN6OgUbCxSEbAAHXfV H/XqzfC8EXibSs+w7yB4OAxx6SfYynZaCukZ9+XWgaCUYQkse5p9OYxQ8qFBlc/n40Yy VXM4b8igstHeBHHPERbCrbu0feBzhbwInkm7Hg1vIoX2RDG47A8zcXj2COZpzx8Zz5vR HO1SinTC6UR2XDG0ASv0szKmShubttMlBoXBYPrBjSwWZZGgknNaEXS+Zagxu/lWCimh pUxQ== 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:cc:to:from:dkim-signature; bh=hv/HGYTpc1fWngwwSwxD9sfu6nEKm/f/x20cm+QuxFA=; b=Ywr63TCIp9E0SvfD8KrUupv49Sz4UwK6krliIvHR4ouBD5O99uD6BF7138NomHkNOy GAHGHMD5ZFHI5obNnAC4NSWPSyrLQ4hwPMoupFq9ONNmxGG1WeX7GwIaG7zzMZteluO0 XS0DGUl7LByse8IjrdheQr9zEobuo/Vn1qr3wSfnqDJ9WzEIymjgCtpvdiOF83RChFkB 3mwti4kB/4CQI5b0g9+ZWw7mvHx5RMelfl4vNVxRTwbI1ei+ko1wqWgVIghEAi8zIUP3 NYC+uPp/n4xOZccj46ZzBvb9uP7mH0qRYcipF/Ouf3bkKbGKUwrtmOCRiTOIGXQ6aSXd TgmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Wb7nSFqP; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 u13-20020adfc64d000000b0021db3d2e1acsor466057wrg.6.2022.07.20.23.45.00 for (Google Transport Security); Wed, 20 Jul 2022 23:45:00 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:adf:d1c2:0:b0:21d:b3a7:ffcf with SMTP id b2-20020adfd1c2000000b0021db3a7ffcfmr31952191wrd.523.1658385900357; Wed, 20 Jul 2022 23:45:00 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:44:59 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 08/13] mtd: nand: Move Toshiba specific init/detection logic in nand_toshiba.c Date: Thu, 21 Jul 2022 08:44:30 +0200 Message-Id: <20220721064435.2456601-9-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Wb7nSFqP; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit 9b2d61f80b060c. Move Toshiba specific initialization and detection logic into nand_toshiba.c. This is part of the "separate vendor specific code from core" cleanup process. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Add the SPDX-License-Identifier tag. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. - Adjust the include file in nand_toshiba. drivers/mtd/nand/raw/Makefile | 3 +- drivers/mtd/nand/raw/nand_base.c | 21 ++---------- drivers/mtd/nand/raw/nand_ids.c | 2 +- drivers/mtd/nand/raw/nand_toshiba.c | 53 +++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 1 + 5 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_toshiba.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index 86d9b8e8beb8..16e0775395a2 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -14,7 +14,7 @@ obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o -obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_samsung.o +obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_samsung.o nand_toshiba.o obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o obj-$(CONFIG_TPL_NAND_INIT) += nand.o ifeq ($(CONFIG_SPL_ENV_SUPPORT),y) @@ -33,6 +33,7 @@ obj-y += nand_ecc.o obj-y += nand_base.o obj-y += nand_hynix.o obj-y += nand_samsung.o +obj-y += nand_toshiba.o obj-y += nand_timings.o endif # not spl diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 5698c1e6a229..4ea7f10a06fc 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4163,12 +4163,11 @@ static int nand_get_bits_per_cell(u8 cellinfo) void nand_decode_ext_id(struct nand_chip *chip) { struct mtd_info *mtd = &chip->mtd; - int extid, id_len; + int extid; /* The 3rd id byte holds MLC / multichip data */ chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); /* The 4th id byte is the important one */ extid = chip->id.data[3]; - id_len = chip->id.len; /* Calc pagesize */ mtd->writesize = 1024 << (extid & 0x03); @@ -4184,21 +4183,6 @@ void nand_decode_ext_id(struct nand_chip *chip) /* Get buswidth information */ if (extid & 0x1) chip->options |= NAND_BUSWIDTH_16; - - /* - * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per - * 512B page. For Toshiba SLC, we decode the 5th/6th byte as - * follows: - * - ID byte 6, bits[2:0]: 100b -> 43nm, 101b -> 32nm, - * 110b -> 24nm - * - ID byte 5, bit[7]: 1 -> BENAND, 0 -> raw SLC - */ - if (id_len >= 6 && chip->id.data[0] == NAND_MFR_TOSHIBA && - nand_is_slc(chip) && - (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && - !(chip->id.data[4] & 0x80) /* !BENAND */) { - mtd->oobsize = 32 * mtd->writesize >> 9; - } } EXPORT_SYMBOL_GPL(nand_decode_ext_id); @@ -4289,8 +4273,7 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, * AMD/Spansion, and Macronix. All others scan only the first page. */ if ((nand_is_slc(chip) && - (maf_id == NAND_MFR_TOSHIBA || - maf_id == NAND_MFR_AMD || + (maf_id == NAND_MFR_AMD || maf_id == NAND_MFR_MACRONIX)) || (mtd->writesize == 2048 && maf_id == NAND_MFR_MICRON)) chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index ec263a43279a..509652c8e26c 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -188,7 +188,7 @@ struct nand_flash_dev nand_flash_ids[] = { /* Manufacturer IDs */ struct nand_manufacturers nand_manuf_ids[] = { - {NAND_MFR_TOSHIBA, "Toshiba"}, + {NAND_MFR_TOSHIBA, "Toshiba", &toshiba_nand_manuf_ops}, {NAND_MFR_SAMSUNG, "Samsung", &samsung_nand_manuf_ops}, {NAND_MFR_FUJITSU, "Fujitsu"}, {NAND_MFR_NATIONAL, "National"}, diff --git a/drivers/mtd/nand/raw/nand_toshiba.c b/drivers/mtd/nand/raw/nand_toshiba.c new file mode 100644 index 000000000000..f7426fa59f51 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_toshiba.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2017 Free Electrons + * Copyright (C) 2017 NextThing Co + * + * Author: Boris Brezillon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +static void toshiba_nand_decode_id(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + + nand_decode_ext_id(chip); + + /* + * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per + * 512B page. For Toshiba SLC, we decode the 5th/6th byte as + * follows: + * - ID byte 6, bits[2:0]: 100b -> 43nm, 101b -> 32nm, + * 110b -> 24nm + * - ID byte 5, bit[7]: 1 -> BENAND, 0 -> raw SLC + */ + if (chip->id.len >= 6 && nand_is_slc(chip) && + (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && + !(chip->id.data[4] & 0x80) /* !BENAND */) + mtd->oobsize = 32 * mtd->writesize >> 9; +} + +static int toshiba_nand_init(struct nand_chip *chip) +{ + if (nand_is_slc(chip)) + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; + + return 0; +} + +const struct nand_manufacturer_ops toshiba_nand_manuf_ops = { + .detect = toshiba_nand_decode_id, + .init = toshiba_nand_init, +}; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index d35277d18799..73abb3401649 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1158,6 +1158,7 @@ struct nand_manufacturers { extern struct nand_flash_dev nand_flash_ids[]; extern struct nand_manufacturers nand_manuf_ids[]; +extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops; extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; extern const struct nand_manufacturer_ops hynix_nand_manuf_ops; From patchwork Thu Jul 21 06:44:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2224 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 7CAA344190 for ; Thu, 21 Jul 2022 08:45:03 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id a18-20020a05600c225200b003a30355c0fesf296501wmm.6 for ; Wed, 20 Jul 2022 23:45:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385903; cv=pass; d=google.com; s=arc-20160816; b=N1Y4mYc8NU9HGtsrFOWm8F6I5T+idmAUhHIGLZEnezvmMjHGldlCygxk+M41HFlIJk I+5Mfvijz9zUFj5joDyAO/m9drv45m6HhF27GQxgDV5JLpfzp7+KNxeQ0HostNxIp8OY jM1OopJddk9F7qrsFzORec95XgEkB17NU45eS1RJX6cStg4pk95o0HPqcBWzIIps+beo SHs9rARePJMzOIO+MecZCOjkrWu0cUskTVT9d9bBTGhJy442tZ44TQ45J9MJ5H2aD4Id mGEcQBXeHWS5VeORcSuZickoKPS3XYtKU02/0Pzln0nfRqV2ZJufR2Dysh46bO/4X3uR 9ymw== 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:cc:to:from:dkim-signature; bh=gf8yi+A3ByNhda9glCBbh9803s0KyqAl2fy635viMnk=; b=B4U4dm7jiPbhO9/uZvrqljashkLwPgNwfd03eLPm9JWSNb8Bw7CdRSlYYnckXD93j+ 4Woq3NMIyHHj+rx59FTPaMWI9q+VihSMsRb+g+57pRZ/f5ZAABPxVgFenruk0AM1c3xP FGBxmxZExt/Ma4hZ3F2dzs6i/reerL1pO0vbo0RwIxUrhxolLPx50M3XXLtkIxscBtne WpL4zgAKil1VaZbls0mOea/NagUOr4mbJSGJPM+vJf+ucmtgsOFukXYGeW77ZjvZZm9h q1oaOJqTp2RWAjbgRtohQ/Ag25PR0/v09iaDaJG7uK1WKklEAalcqCYncd5nQ7f7w104 hPrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SE4nKpY2; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=gf8yi+A3ByNhda9glCBbh9803s0KyqAl2fy635viMnk=; b=eoJYsDBc1lZ609tBjuiJI9NtYkb85TS0Hmay62u2jrlcojKsSbyqVtl6Qj12JMPsN5 2vIANvNIFkx1Lo/FmmtUQcWBR+fnKUUqq0mTSCMnroZREf32WwBt+1kfrYfjQyFQ6RWo J3OmLSy+1xY0pY1yb9ZvfZ/edKCLBRCgf+Yg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=gf8yi+A3ByNhda9glCBbh9803s0KyqAl2fy635viMnk=; b=zIx6j7TCnxX5u2MoAxP9rgHnJl3kOAsLXGv44ukLbTaJHj9x1F5tVYrGXs9g8PXnS7 S5ldgN2Yjw2/UrcoeGveQPvYGy3Wg7lCo3ngx1sHYHoxXvU+fwe+CnbNwBDXfZAuecdl 4TD6OuPR/UWVFtKZKKJKJ5712+84/ZHw4ZctFA/O7ATQZnMUau0A27XMGfvWkTm1uaWc aGXs07LiKydQeCdoNS9jagBUPWe+PYWcGgNaHk8f30FRGYq1EconqKtmLDi/zrZE1e9a CyUwG3KcLPM4VXlTHyAMrzygbkw1tzFnrrDS7mbl6ssZWS6Zl6mQ998e4w5+pMj4KMne Qv6Q== X-Gm-Message-State: AJIora/J5oSzyM6wQpw36aJUus9+eTkYLVlAH+ABHbaVAdxpKjX8VEdO iuTVZcTT+r9kcj4P+R8sicl4Ey7M X-Google-Smtp-Source: AGRyM1vEg9zWelDC/ttJfdzh7hmOxactxGYuA/QX90arNYIwF/Cdu+w0N/OQUEW3E95uxP92JnhCEA== X-Received: by 2002:adf:d1c8:0:b0:21d:a082:9290 with SMTP id b8-20020adfd1c8000000b0021da0829290mr34357025wrd.246.1658385903241; Wed, 20 Jul 2022 23:45:03 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:2195:b0:3a3:1b8f:2e1 with SMTP id e21-20020a05600c219500b003a31b8f02e1ls1448220wme.1.-pod-prod-gmail; Wed, 20 Jul 2022 23:45:02 -0700 (PDT) X-Received: by 2002:a7b:c417:0:b0:3a3:236f:9f98 with SMTP id k23-20020a7bc417000000b003a3236f9f98mr6764365wmi.48.1658385902103; Wed, 20 Jul 2022 23:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385902; cv=none; d=google.com; s=arc-20160816; b=DFbqBxC1WQXe9qyNULl6kMSB1Ej1g/tws0f0kGovAadrNv4X8b0NXLWVdOYNI9aYmK q2QnqVSjZF6CG0kc6ZE42LaGEUBV+jBlrF4ztnOjfoLIHTyQBp2/bAyOOj5M8i1JRwuy j31zNtgcAhBVDPNMa/+ClQSWp3ZYaexdfumM2aGd+nGGq3g2JFU6eb2N2UNtUDs7HbEo hojp9jYwxtWtD/6ujL47LB/USjtbadv9J4HlTymPFdj63ZSgeormQ0HKkCgemC+scKc2 ewbqKBMT5I8iZ0FS2R6mg27r9mypukD1QzNIQn4qgXBCQ/WzrydB1r2IHDYOuGXaxW90 0woQ== 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:cc:to:from:dkim-signature; bh=60G2gAXdyvXVp1G8eokKbB/NS8ffGuQU42nXwBlFMIs=; b=mBpgZ8pjSToDQuIh1wCiAoSYBr90SxgxW4SxHV5GMZrx4pN3cxmhtTqWDiHIi55TRD FScwYrRYmCZSCJeW25lXU6vyTBy0QIZLdNMbzuW/8UrYpFYMRy4ljgwBD8KaQH+KzHcW au0KnueuWE8l9ULp9fvUPjtNpTY+OirT7pyumkpK7rwjS2lvlW2+z1KioMRRTVID+dO9 vmNXfI7TGibeSFa74D9LNNvKaqVkbo2/W+NQd5k+QyEHMblttKJQeG5Tv27chNSrZLnD bhdwEK2JymLES3J2/0P6+AWZuWIcZ8JSLLeGo2wGqW5Dmho2TxmvmVr5Sh5czN6XsSQj qXEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SE4nKpY2; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 n6-20020a5d5886000000b0021b89b50004sor441726wrf.44.2022.07.20.23.45.02 for (Google Transport Security); Wed, 20 Jul 2022 23:45:02 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6000:144f:b0:21d:a3cc:a6fa with SMTP id v15-20020a056000144f00b0021da3cca6famr33234701wrx.191.1658385901797; Wed, 20 Jul 2022 23:45:01 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:45:01 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 09/13] mtd: nand: Move Micron specific init logic in nand_micron.c Date: Thu, 21 Jul 2022 08:44:31 +0200 Message-Id: <20220721064435.2456601-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SE4nKpY2; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit 10d4e75c36f6c1. Move Micron specific initialization logic into nand_micron.c. This is part of the "separate vendor specific code from core" cleanup process. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Add the SPDX-License-Identifier tag. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. - Adjust the include file in nand_micron. drivers/mtd/nand/raw/Makefile | 3 +- drivers/mtd/nand/raw/nand_base.c | 33 +----------- drivers/mtd/nand/raw/nand_ids.c | 2 +- drivers/mtd/nand/raw/nand_micron.c | 87 ++++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 21 +------- 5 files changed, 93 insertions(+), 53 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_micron.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index 16e0775395a2..8ef30b45fd2d 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -14,7 +14,7 @@ obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o -obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_samsung.o nand_toshiba.o +obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_micron.o nand_samsung.o nand_toshiba.o obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o obj-$(CONFIG_TPL_NAND_INIT) += nand.o ifeq ($(CONFIG_SPL_ENV_SUPPORT),y) @@ -32,6 +32,7 @@ obj-y += nand_util.o obj-y += nand_ecc.o obj-y += nand_base.o obj-y += nand_hynix.o +obj-y += nand_micron.o obj-y += nand_samsung.o obj-y += nand_toshiba.o obj-y += nand_timings.o diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 4ea7f10a06fc..fe7e049d4064 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3871,30 +3871,6 @@ ext_out: return ret; } -static int nand_setup_read_retry_micron(struct mtd_info *mtd, int retry_mode) -{ - struct nand_chip *chip = mtd_to_nand(mtd); - uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode}; - - return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY, - feature); -} - -/* - * Configure chip properties from Micron vendor-specific ONFI table - */ -static void nand_onfi_detect_micron(struct nand_chip *chip, - struct nand_onfi_params *p) -{ - struct nand_onfi_vendor_micron *micron = (void *)p->vendor; - - if (le16_to_cpu(p->vendor_revision) < 1) - return; - - chip->read_retries = micron->read_retry_options; - chip->setup_read_retry = nand_setup_read_retry_micron; -} - /* * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise. */ @@ -3994,9 +3970,6 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip) pr_warn("Could not retrieve ONFI ECC requirements\n"); } - if (p->jedec_id == NAND_MFR_MICRON) - nand_onfi_detect_micron(chip, p); - return 1; } #else @@ -4272,10 +4245,8 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, * Micron devices with 2KiB pages and on SLC Samsung, Hynix, Toshiba, * AMD/Spansion, and Macronix. All others scan only the first page. */ - if ((nand_is_slc(chip) && - (maf_id == NAND_MFR_AMD || - maf_id == NAND_MFR_MACRONIX)) || - (mtd->writesize == 2048 && maf_id == NAND_MFR_MICRON)) + if (nand_is_slc(chip) && + (maf_id == NAND_MFR_AMD || maf_id == NAND_MFR_MACRONIX)) chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; } diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index 509652c8e26c..bb5ac8337fde 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -195,7 +195,7 @@ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_RENESAS, "Renesas"}, {NAND_MFR_STMICRO, "ST Micro"}, {NAND_MFR_HYNIX, "Hynix", &hynix_nand_manuf_ops}, - {NAND_MFR_MICRON, "Micron"}, + {NAND_MFR_MICRON, "Micron", µn_nand_manuf_ops}, {NAND_MFR_AMD, "AMD/Spansion"}, {NAND_MFR_MACRONIX, "Macronix"}, {NAND_MFR_EON, "Eon"}, diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c new file mode 100644 index 000000000000..8b31c6198134 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2017 Free Electrons + * Copyright (C) 2017 NextThing Co + * + * Author: Boris Brezillon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +struct nand_onfi_vendor_micron { + u8 two_plane_read; + u8 read_cache; + u8 read_unique_id; + u8 dq_imped; + u8 dq_imped_num_settings; + u8 dq_imped_feat_addr; + u8 rb_pulldown_strength; + u8 rb_pulldown_strength_feat_addr; + u8 rb_pulldown_strength_num_settings; + u8 otp_mode; + u8 otp_page_start; + u8 otp_data_prot_addr; + u8 otp_num_pages; + u8 otp_feat_addr; + u8 read_retry_options; + u8 reserved[72]; + u8 param_revision; +} __packed; + +static int micron_nand_setup_read_retry(struct mtd_info *mtd, int retry_mode) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + u8 feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode}; + + return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY, + feature); +} + +/* + * Configure chip properties from Micron vendor-specific ONFI table + */ +static int micron_nand_onfi_init(struct nand_chip *chip) +{ + struct nand_onfi_params *p = &chip->onfi_params; + struct nand_onfi_vendor_micron *micron = (void *)p->vendor; + + if (!chip->onfi_version) + return 0; + + if (le16_to_cpu(p->vendor_revision) < 1) + return 0; + + chip->read_retries = micron->read_retry_options; + chip->setup_read_retry = micron_nand_setup_read_retry; + + return 0; +} + +static int micron_nand_init(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + int ret; + + ret = micron_nand_onfi_init(chip); + if (ret) + return ret; + + if (mtd->writesize == 2048) + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; + + return 0; +} + +const struct nand_manufacturer_ops micron_nand_manuf_ops = { + .init = micron_nand_init, +}; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 73abb3401649..ec0f77b24bd6 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -388,26 +388,6 @@ struct onfi_ext_param_page { */ } __packed; -struct nand_onfi_vendor_micron { - u8 two_plane_read; - u8 read_cache; - u8 read_unique_id; - u8 dq_imped; - u8 dq_imped_num_settings; - u8 dq_imped_feat_addr; - u8 rb_pulldown_strength; - u8 rb_pulldown_strength_feat_addr; - u8 rb_pulldown_strength_num_settings; - u8 otp_mode; - u8 otp_page_start; - u8 otp_data_prot_addr; - u8 otp_num_pages; - u8 otp_feat_addr; - u8 read_retry_options; - u8 reserved[72]; - u8 param_revision; -} __packed; - struct jedec_ecc_info { u8 ecc_bits; u8 codeword_size; @@ -1161,6 +1141,7 @@ extern struct nand_manufacturers nand_manuf_ids[]; extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops; extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; extern const struct nand_manufacturer_ops hynix_nand_manuf_ops; +extern const struct nand_manufacturer_ops micron_nand_manuf_ops; int nand_default_bbt(struct mtd_info *mtd); int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); From patchwork Thu Jul 21 06:44:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2225 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 920A944190 for ; Thu, 21 Jul 2022 08:45:04 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id a18-20020a05600c225200b003a30355c0fesf296524wmm.6 for ; Wed, 20 Jul 2022 23:45:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385904; cv=pass; d=google.com; s=arc-20160816; b=UIEGXlR3UhuMycRbmvs0QWaWXfb/hdL2HinleMaaEmPVMLET2oBRutShLKhi+Q0Zfn C/ZC/5jhLf+3wp9dG8JngBoi+u3FBjPe4+LUdmKjjXHpiCEBGRWmQnWRcdZFlTQSpony YcCDJnLKObD9V107zE7k+jA+Av5j6z8KQF5szljGz7m0W3dpz4QV9CiD87O7VZnmBCGR ZYTHuhYljy1OfindvtHoOXgJ0DgB8ecD4OrmDpLDLWozpTvossvvgZKmBK9Jm1I9PN+D 54/X60s9G10oVCToZ5RJJ4qlr51VSQ4IaidNV715zDh3CXdf6E9agzQjixjFVKhvyxr6 kHbw== 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:cc:to:from:dkim-signature; bh=aC9Od0hQPKauauCqSC3c5uqP4FcFRlH8O/UZ0hBxE54=; b=yv68tO7pWeUtnXBfmbsR7kBNLWn1fWbleuagONFMhdPzkWoBxKb+5fVLaeRGFXzjXx jqE61OlHhgUdsmBWFmeeKaW8NqbZQW23DmGfVH+XxB6pnpS6gcu6Shd2Y2dlfaduqEVA nXW4TfognRm1TJHHvAi+m5N4vrzVCDu62CxD6D0IIM+OBei4DKDimRx7fxHIcOiohALU YiIkQ7UqBWy1SQpQYnJS9j+zJSB7Aa0GprDPzDrGkwrTotMLKIK0m1rAE1BjTjWxzxeE CN7CaxkLIoT5VKxMe7qsml5v/wEbjbMTliJCAh5wSRT2DdeOgsYcityVPyFLFRARLTo2 2hNw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=m0B84bIn; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=aC9Od0hQPKauauCqSC3c5uqP4FcFRlH8O/UZ0hBxE54=; b=MqtcDnKzHVOK+gWKEchD5RxH0nxfjXZcvHBpBs8MVWkyJ7gtllLrsgSLYwEbN+/1aV hjnH4If98hvvrGpvNu5jUl+B/8JYX8EoHM+bpmJI/QSRQYXiYi58q5RYzNdP+b5645hY T0Ph4Y0e2RcUISvlcrHy6D/4lm5QeIn0K/8bE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=aC9Od0hQPKauauCqSC3c5uqP4FcFRlH8O/UZ0hBxE54=; b=uk1az5t1rwoMUbw9MhlvzTmqSTcKU9D66s7zxcOJmCNb7S7kfaBcfmiIdg4Z1J4rjD wjNoAivVjJTMNbkXTeg7ou8YFEPb3J5pEaULqoLVhDBN7TWpQq8S32Vskh7q9FJPE0S2 Acn4b04ECl2R/d2c/E01kvQzgXCX6lEQC1CYuIqByvSm7uorM2w3ivKqLK56BwpuAgJe coFD7JkJUyfkWUry+XJ/scIhsj1lGvWMKOjfqBp8wUZQ3/iYKmT7YUeGx/Jw6mfmpcA6 PSRnsU0S5indTVMgndDqnb2ja+z7GtvQ93sajut4Bu9cPuenozPuF0VCtnmKfh6JKCvE m7aQ== X-Gm-Message-State: AJIora+h75Opfjnzyk8Q920zddmWahW98OFCZcD6I1qhrMn2DVdY00LZ p2/Ha6ocOJz6TeTgNt81XXKrrD8B X-Google-Smtp-Source: AGRyM1vk/HKyIl2C0OL8hktC/3SmYZ0R3pqcjrK4OLtTgNn9UcPHdtYzRlBDfQ9lgZt1OpXq992QcQ== X-Received: by 2002:a05:600c:1da2:b0:3a3:10ed:43ce with SMTP id p34-20020a05600c1da200b003a310ed43cemr6857245wms.136.1658385904467; Wed, 20 Jul 2022 23:45:04 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:d209:0:b0:21e:53a1:af5d with SMTP id j9-20020adfd209000000b0021e53a1af5dls244229wrh.3.-pod-prod-gmail; Wed, 20 Jul 2022 23:45:03 -0700 (PDT) X-Received: by 2002:adf:e786:0:b0:21d:6ec1:ee5c with SMTP id n6-20020adfe786000000b0021d6ec1ee5cmr32615149wrm.285.1658385903489; Wed, 20 Jul 2022 23:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385903; cv=none; d=google.com; s=arc-20160816; b=BRC7p4IDnpyoyhLZcsfJxI0WGCfInVXiKZ5SZel2Ix2Cjo9X96p92UuXoLXTY5a1pc Jd8h0uWDVjFfH5CR08QMAIFzSo/LX0joRNq7XLLIFEJfwFAJpB77NiDNDf1/Ub4YsC4G o3W0CPtn+O8157VwhXrKMpxQ7zGUSQixibUh0EXCxNVs7owAhES3EgOAyuTmfGsJDESr Cei1fyttihLKkA/785h/FPIgEv92GQS+qhpdTRnCHytbmGwNHUmO9yVv11sZaLrhrZxs JxclmhQcP0CWQGedARwyfAUp05jTb7aaVidNAVw2iELpkbNhEDBEkCz/WofUm2P3qfAC c0hA== 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:cc:to:from:dkim-signature; bh=akcoLfp54cRGzdnwH5I05Wq5uAksGtC+cqjjY5zmIMY=; b=XQMFvsFSXgAvoC3p/mZmu4ERDPLKgokVconSdtNJDkqzrvq1st7hapxbRzv+DB43IE YWlgFo9LxVO+2JpHuXbLoehYhAa39RPuVNSnHEBwQtEwkh76znswrWyaheokEy15JwMZ m5pENcg1YiPXfWFpW1DenDdh77+l/8XwffZzvhAfmrHpdzOSgijAzodLn44rjV06+TNT j7J10NxmtSZDKgmomf6qsygdRBYb+kqDQjBN2uLj8PBxHhQz6pEO/K77wX2sEqKaE30V 0dSs2fuDUiUWuoQ6oO0P9Re/FSRtVs03tW9xahFpG9wAwer+Gy4XVjnNlugRLIFk6mz/ tw3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=m0B84bIn; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 u3-20020a7bcb03000000b003a32df89156sor180915wmj.45.2022.07.20.23.45.03 for (Google Transport Security); Wed, 20 Jul 2022 23:45:03 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:600c:6014:b0:3a3:14c9:bef1 with SMTP id az20-20020a05600c601400b003a314c9bef1mr6923897wmb.112.1658385903188; Wed, 20 Jul 2022 23:45:03 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:45:02 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 10/13] mtd: nand: Move AMD/Spansion specific init/detection logic in nand_amd.c Date: Thu, 21 Jul 2022 08:44:32 +0200 Message-Id: <20220721064435.2456601-11-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=m0B84bIn; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit 229204da53b31d. Move AMD/Spansion specific initialization/detection logic into nand_amd.c. This is part of the "separate vendor specific code from core" cleanup process. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Add the SPDX-License-Identifier tag. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. - Adjust the include file in nand_amd. drivers/mtd/nand/raw/Makefile | 4 ++- drivers/mtd/nand/raw/nand_amd.c | 52 ++++++++++++++++++++++++++++++++ drivers/mtd/nand/raw/nand_base.c | 17 +---------- drivers/mtd/nand/raw/nand_ids.c | 2 +- include/linux/mtd/rawnand.h | 1 + 5 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_amd.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index 8ef30b45fd2d..9c2ced9925d8 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -14,7 +14,8 @@ obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o -obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_hynix.o nand_micron.o nand_samsung.o nand_toshiba.o +obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_amd.o nand_hynix.o nand_micron.o \ + nand_samsung.o nand_toshiba.o obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o obj-$(CONFIG_TPL_NAND_INIT) += nand.o ifeq ($(CONFIG_SPL_ENV_SUPPORT),y) @@ -31,6 +32,7 @@ obj-y += nand_ids.o obj-y += nand_util.o obj-y += nand_ecc.o obj-y += nand_base.o +obj-y += nand_amd.o obj-y += nand_hynix.o obj-y += nand_micron.o obj-y += nand_samsung.o diff --git a/drivers/mtd/nand/raw/nand_amd.c b/drivers/mtd/nand/raw/nand_amd.c new file mode 100644 index 000000000000..e02b8c79dba2 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_amd.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2017 Free Electrons + * Copyright (C) 2017 NextThing Co + * + * Author: Boris Brezillon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +static void amd_nand_decode_id(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + + nand_decode_ext_id(chip); + + /* + * Check for Spansion/AMD ID + repeating 5th, 6th byte since + * some Spansion chips have erasesize that conflicts with size + * listed in nand_ids table. + * Data sheet (5 byte ID): Spansion S30ML-P ORNAND (p.39) + */ + if (chip->id.data[4] != 0x00 && chip->id.data[5] == 0x00 && + chip->id.data[6] == 0x00 && chip->id.data[7] == 0x00 && + mtd->writesize == 512) { + mtd->erasesize = 128 * 1024; + mtd->erasesize <<= ((chip->id.data[3] & 0x03) << 1); + } +} + +static int amd_nand_init(struct nand_chip *chip) +{ + if (nand_is_slc(chip)) + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; + + return 0; +} + +const struct nand_manufacturer_ops amd_nand_manuf_ops = { + .detect = amd_nand_decode_id, + .init = amd_nand_init, +}; diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index fe7e049d4064..68e6f4f14347 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4200,7 +4200,6 @@ static int nand_manufacturer_init(struct nand_chip *chip) static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type) { struct mtd_info *mtd = &chip->mtd; - int maf_id = chip->id.data[0]; mtd->erasesize = type->erasesize; mtd->writesize = type->pagesize; @@ -4208,19 +4207,6 @@ static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type) /* All legacy ID NAND are small-page, SLC */ chip->bits_per_cell = 1; - - /* - * Check for Spansion/AMD ID + repeating 5th, 6th byte since - * some Spansion chips have erasesize that conflicts with size - * listed in nand_ids table. - * Data sheet (5 byte ID): Spansion S30ML-P ORNAND (p.39) - */ - if (maf_id == NAND_MFR_AMD && chip->id.data[4] != 0x00 && - chip->id.data[5] == 0x00 && chip->id.data[6] == 0x00 && - chip->id.data[7] == 0x00 && mtd->writesize == 512) { - mtd->erasesize = 128 * 1024; - mtd->erasesize <<= ((chip->id.data[3] & 0x03) << 1); - } } /* @@ -4245,8 +4231,7 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, * Micron devices with 2KiB pages and on SLC Samsung, Hynix, Toshiba, * AMD/Spansion, and Macronix. All others scan only the first page. */ - if (nand_is_slc(chip) && - (maf_id == NAND_MFR_AMD || maf_id == NAND_MFR_MACRONIX)) + if (nand_is_slc(chip) && maf_id == NAND_MFR_MACRONIX) chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; } diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index bb5ac8337fde..c78f2e088040 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -196,7 +196,7 @@ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_STMICRO, "ST Micro"}, {NAND_MFR_HYNIX, "Hynix", &hynix_nand_manuf_ops}, {NAND_MFR_MICRON, "Micron", µn_nand_manuf_ops}, - {NAND_MFR_AMD, "AMD/Spansion"}, + {NAND_MFR_AMD, "AMD/Spansion", &amd_nand_manuf_ops}, {NAND_MFR_MACRONIX, "Macronix"}, {NAND_MFR_EON, "Eon"}, {NAND_MFR_SANDISK, "SanDisk"}, diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index ec0f77b24bd6..bb1a359a9c14 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1142,6 +1142,7 @@ extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops; extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; extern const struct nand_manufacturer_ops hynix_nand_manuf_ops; extern const struct nand_manufacturer_ops micron_nand_manuf_ops; +extern const struct nand_manufacturer_ops amd_nand_manuf_ops; int nand_default_bbt(struct mtd_info *mtd); int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); From patchwork Thu Jul 21 06:44:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2226 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 19A7C44190 for ; Thu, 21 Jul 2022 08:45:06 +0200 (CEST) Received: by mail-wr1-f72.google.com with SMTP id n7-20020adfc607000000b0021a37d8f93asf68351wrg.21 for ; Wed, 20 Jul 2022 23:45:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385905; cv=pass; d=google.com; s=arc-20160816; b=RAG5femvo2PtyPjc4LGJEHhC/wQJNH+9JioJiQWEEJ27r0OatT0ykJelZR93RiJgF8 SVJhu0srPlrStZxlVXKv2v3G56B2PVagBKqJRkQub1GjlTw8CQb0CuWNyk2PIXdOyUJ/ ucH8LfLKTV1XYh6yYsM0HKyxuUM+obTiU+QvScQSc6cFCYGA7LSPNb6WB6etbHqJ15oW /eWs/xLtECp6rhkuSaglgnTKqV1XAwd7puPkFjhEQnsaWma/uLi0stLZAZgKUbXc8Qbd MI2qhvtxGE7x6aro0Btbq2b/DlHH6layjnKyaYDaGBu/WJSgk//KOUTc0j5zOWoYDbI8 QFag== 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:cc:to:from:dkim-signature; bh=VUpUJjefdYqwIDL/s/KW2j6Mgjydarb1A7kXrCG78U4=; b=sQR4MkEXMHRU3Vt+GcaWWw1wTSr0CZfjq8d9lbcMMgfO8ilWpJ1k67iWMmYbcikh2x Zyq5M7fsiazfx+uWQ7xAxxQZJIaw3QkE237QkiPUF1/Z5BqHmxIeDjrXs8RCgV9lngZA AuR9EsnMJrGj1PKX54ddTwq93rjsckqJEyDhC6Su++HifTvQqDfCmAYX1w4A8MRYYPr1 /tbrXihZnvwrivQOSB/do3dt/3jfT6Nkw5oiMDj/Ro5quXz7i3T1L5ywFntGuE7Mj8dh zBE6tIMfTZ1yHz02pAk0wGQ6mcjnB+6Y4NLTQiq9daZ2URqQRDL5x83k25qEx8knVXFe gXfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bvUzRhOo; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=VUpUJjefdYqwIDL/s/KW2j6Mgjydarb1A7kXrCG78U4=; b=plR16PWrXLP+cBeHKhmsczAwRqw635dGuEK9ZzJKrfJxbaygG/cdsJX5Pu58rVeoyw 2ZtbuxyuIqI2Bchs6ENQndfRQbNetazMLgnQcIbqJijfckFdBv4TTzwGNNbEH8GIg7Cj LjcwyNKwYEi3NlUruAmDg/5wiXM+oyYRZHysQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=VUpUJjefdYqwIDL/s/KW2j6Mgjydarb1A7kXrCG78U4=; b=Jb4/2PmAns9eKLXm9cxfh/gYyF4pkgOu/NmLxCj53l5ptFwfQXMCyJ0h5qyW3xmi1o k6/0VWiE+r5EFNQv5q7wKWjSSmi1Eh8DbtGed1gcLq4SG65O2d+qqizhBKndtJQG9a+F /c/XyVhjJRjC6l8mm6gY1rKaEf4Jh2oIkQbBfUMSaFoIcx/bK8CQW8j0tTV/XN5+pmFQ R5O9z89cWRZUt+BSK4xbxCZ4saKNtwbdVQEExF2KwPcqTCKs8/MPxXAVToNgWOiFUkGM bLkLCDsFiu1lOr0v418aQzAqQ43sCaAlAaJBzDkEtcjNSrny7ixQ4ySltdxP5ako3Zfl iIvA== X-Gm-Message-State: AJIora/jGfYQ+3cL4Uadm4xy9R+RawnVSl3+GCtqRpP4wKy9QixMDJBb JvHXIBZgbkTL7OH7oc7yNHDFbIND X-Google-Smtp-Source: AGRyM1sXAVsvlsdITBthw3nWA4tiT2Sz1GJIpYWu3DvcBs85KYSSCcLy/EOXlIcaTMLkgFRPc2hduQ== X-Received: by 2002:a7b:c851:0:b0:3a3:19df:2673 with SMTP id c17-20020a7bc851000000b003a319df2673mr6784704wml.75.1658385905876; Wed, 20 Jul 2022 23:45:05 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:6547:0:b0:21d:668b:3503 with SMTP id z7-20020a5d6547000000b0021d668b3503ls243828wrv.2.-pod-prod-gmail; Wed, 20 Jul 2022 23:45:05 -0700 (PDT) X-Received: by 2002:a5d:5683:0:b0:21e:5469:88d1 with SMTP id f3-20020a5d5683000000b0021e546988d1mr1258308wrv.297.1658385904807; Wed, 20 Jul 2022 23:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385904; cv=none; d=google.com; s=arc-20160816; b=r44WamcR/x3L0yfaA+YG7tZnFBdztnRXTuCtSSnamCy5M3h11i1uGFRuHOefKzGnOM mLEo6at9tteiPov1NaSAfOmTqlwX8t+JSDcqh6B3lu7fsfz0/XYm0okJDFPGOqZ2xJ79 GdElSLBJIQQA5587GnIqZBdK7sI43phN125WJuZZBTfH5xJylhlKo6V4zU67KiOdJF3z LAa51vdKMv6vJAHxJo0x3yJY/MwxU3OIRx6UL2ioRZGw6NTK0snms0cR2mpi66oe8j3O LBW7Yoh/lO+xToI0JOJB8qY61iffJ/cYRXG6ESrCQddi8OREu1Zvn2sDXDUg4u/GCmyi ZAHw== 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:cc:to:from:dkim-signature; bh=FsZWT0Murd3SQ44lFE5DRzJg9mfkFK0I1DKwG/FJg6E=; b=dSf0RYqMPVc9hEgRrxq8UIduV160d1Ube1RFw9gbdRYpYxAamQM4z3J/pTMZSROfQu VdNSNWfPx9JuDzR5Qr8msKAykMEOz7SUFm4ZKNFA9lYH4qH3G6BxtLVx59uDa+6BJeR7 L0p6T6tGOfivxxeTrFxUzAg4RC/DKFEp2/b1v86QbRKB0Eh2pl2AIH4JyXmXyaCfgJZt Otl2uvBgCqkvJ1IHriKqqpezjJGXFzUFOsbuUE/TUqO2Uv+N46Z9dpGkhZquRZE5CQ4R i/8IpAyIAJ0pXalY34v6Ox5GVVpiIwzM32FYC3hSABU9RwHwqMqwDVl+UomE9kkXmCTC eGkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bvUzRhOo; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 p4-20020a05600c064400b003a2f1416c90sor189921wmm.31.2022.07.20.23.45.04 for (Google Transport Security); Wed, 20 Jul 2022 23:45:04 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a7b:c8ce:0:b0:3a3:2cf8:edb with SMTP id f14-20020a7bc8ce000000b003a32cf80edbmr4326163wml.70.1658385904581; Wed, 20 Jul 2022 23:45:04 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:45:04 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Patrice Chotard , Simon Glass , Wolfgang Denk Subject: [PATCH v3 11/13] mtd: nand: Move Macronix specific initialization in nand_macronix.c Date: Thu, 21 Jul 2022 08:44:33 +0200 Message-Id: <20220721064435.2456601-12-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bvUzRhOo; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit 3b5206f4be9b65. Move Macronix specific initialization logic into nand_macronix.c. This is part of the "separate vendor specific code from core" cleanup process. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Add the SPDX-License-Identifier tag. - Fix code style warnings raised by patman. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. - Adjust the include file in nand_macronix. drivers/mtd/nand/raw/Makefile | 4 +++- drivers/mtd/nand/raw/nand_base.c | 11 ---------- drivers/mtd/nand/raw/nand_ids.c | 2 +- drivers/mtd/nand/raw/nand_macronix.c | 31 ++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 1 + 5 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 drivers/mtd/nand/raw/nand_macronix.c diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile index 9c2ced9925d8..a398aa9d8864 100644 --- a/drivers/mtd/nand/raw/Makefile +++ b/drivers/mtd/nand/raw/Makefile @@ -14,7 +14,8 @@ obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o -obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_amd.o nand_hynix.o nand_micron.o \ +obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o nand_amd.o nand_hynix.o \ + nand_macronix.o nand_micron.o \ nand_samsung.o nand_toshiba.o obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o obj-$(CONFIG_TPL_NAND_INIT) += nand.o @@ -34,6 +35,7 @@ obj-y += nand_ecc.o obj-y += nand_base.o obj-y += nand_amd.o obj-y += nand_hynix.o +obj-y += nand_macronix.o obj-y += nand_micron.o obj-y += nand_samsung.o obj-y += nand_toshiba.o diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 68e6f4f14347..4b09a1128827 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4217,22 +4217,11 @@ static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type) static void nand_decode_bbm_options(struct mtd_info *mtd, struct nand_chip *chip) { - int maf_id = chip->id.data[0]; - /* Set the bad block position */ if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16)) chip->badblockpos = NAND_LARGE_BADBLOCK_POS; else chip->badblockpos = NAND_SMALL_BADBLOCK_POS; - - /* - * Bad block marker is stored in the last page of each block on Samsung - * and Hynix MLC devices; stored in first two pages of each block on - * Micron devices with 2KiB pages and on SLC Samsung, Hynix, Toshiba, - * AMD/Spansion, and Macronix. All others scan only the first page. - */ - if (nand_is_slc(chip) && maf_id == NAND_MFR_MACRONIX) - chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; } static inline bool is_full_id_nand(struct nand_flash_dev *type) diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index c78f2e088040..7602dd30f169 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -197,7 +197,7 @@ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_HYNIX, "Hynix", &hynix_nand_manuf_ops}, {NAND_MFR_MICRON, "Micron", µn_nand_manuf_ops}, {NAND_MFR_AMD, "AMD/Spansion", &amd_nand_manuf_ops}, - {NAND_MFR_MACRONIX, "Macronix"}, + {NAND_MFR_MACRONIX, "Macronix", ¯onix_nand_manuf_ops}, {NAND_MFR_EON, "Eon"}, {NAND_MFR_SANDISK, "SanDisk"}, {NAND_MFR_INTEL, "Intel"}, diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c new file mode 100644 index 000000000000..dc972e590922 --- /dev/null +++ b/drivers/mtd/nand/raw/nand_macronix.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2017 Free Electrons + * Copyright (C) 2017 NextThing Co + * + * Author: Boris Brezillon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +static int macronix_nand_init(struct nand_chip *chip) +{ + if (nand_is_slc(chip)) + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; + + return 0; +} + +const struct nand_manufacturer_ops macronix_nand_manuf_ops = { + .init = macronix_nand_init, +}; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index bb1a359a9c14..aa45558b3d41 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1143,6 +1143,7 @@ extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; extern const struct nand_manufacturer_ops hynix_nand_manuf_ops; extern const struct nand_manufacturer_ops micron_nand_manuf_ops; extern const struct nand_manufacturer_ops amd_nand_manuf_ops; +extern const struct nand_manufacturer_ops macronix_nand_manuf_ops; int nand_default_bbt(struct mtd_info *mtd); int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); From patchwork Thu Jul 21 06:44:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2227 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 24D8C44190 for ; Thu, 21 Jul 2022 08:45:07 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id h189-20020a1c21c6000000b003a2fdf9bd2asf567094wmh.8 for ; Wed, 20 Jul 2022 23:45:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385907; cv=pass; d=google.com; s=arc-20160816; b=zXa4Em/klKEKvMYxocIoP0KLjtqsj0HvC8B87Ffu743vUKPjwFRMJbNat8t8/dWvYa XdcDO4GJDTJ4gSEc483lziSYrdatZTCN2FEgRHmWBNaEAjW57X2GfebFiHhXuRMSvTRr FS6qETlfENFRoQxQOJ3NpO6FIRiA5cpki9mnAcc6PjvPhZ2vOCJ1R0IJ3ES21f29iWVX p3xwUyXSRCoWGti8Mh4F7fCAqOzb9jOtjS4RYf7IukxsKwBLA3LPcqVhmCJay4ononT+ njBPVoQ0kYTfzoOI/7aF967OsWyzNgeFg/F8PfhNYV6PlkxGWiR2eGjC0pC1fSU/6XP3 McCA== 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:cc:to:from:dkim-signature; bh=AA1i+EToWE0n1FqLJTOeU8TQI//J9XLEtARYqN6n4hk=; b=OAGIvmS3KyGle/KNS2qBW3Y1G6USY9I8lw1mhyLVyR8yzhkeg3LxSVKfQWaLUCFPU3 nNn7XtIrDL3GKSMQRdgqYGLtimCxfSUIfRAI9ERRjl0otyKnCM/Vt8+bFN067UO2BdmN vzF7RAENkUs2nUJM1sUF9HVLedhv8GfQuSIEp5t7izgeVhKBcAeicYNjne/pUkKfdmg6 eDtAGtz8KXVWoG9PNn+ZJiLUw/UciO8Z79Ir/YnqnshO9BE8JOPL4CESx7EaCuqnfFIQ 10mgsy3XkoO/nq272RrqOP3J406TiYNgL7g4rDJjrgTXVynawzPYQi6zmQBHZ+7ckhxi yS+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SM973YcK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=AA1i+EToWE0n1FqLJTOeU8TQI//J9XLEtARYqN6n4hk=; b=YXZNTOdmCXzhnePDszRIRopCxBtflJWg3KQFYOi2FlTBYnC4v3/vZ5EUbqFiOEqOig +zEEVQbybual87Lpy3UTvZqkv93KSZv+VzoSnV+d+IjCBo+5L5J9YfO9SqhrZi2xZhsG XuruiBjybxeAOhsXybtFvtOFQj77McI9Jdv7w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=AA1i+EToWE0n1FqLJTOeU8TQI//J9XLEtARYqN6n4hk=; b=5la59OlwUabTfce2kx/AXxJnVbbuGvn7UKQK62logVQH0oQpF2xYh3tL8zb6jgwuwy vbEfeeorY6Q8DdBHYZfgHl6xJNPfbgueEc91U7W+mg0r+2XkSQT06yPhO+yVHaL4SczC MHx7G+fG+/TkeJWm653NqQxVH/WhuG1IaU4wtn7rXiNWAUF6NVU2xvIJ2EeTQPRxoaqs B0wILVDoozEE+laIILXM5o3iGKAyMizdFjVXtaL/aUo46Cq+w7zQl2ny/JUe+se2YWsZ QY8xUuE6G58/hXbxbnBSFrFhRS+oscwPVZqZV+MlOvyYH/e6e20qx4LCrE8lSSrQQ5cl D8Ew== X-Gm-Message-State: AJIora8n13EyRycj1sGnBJhygZyXX2rVI4zQxYCOmtHxvQcpRG4AAJGQ v5nIUa67xlbMgaCp0r1+P6WNy793 X-Google-Smtp-Source: AGRyM1tRA+zwWqzKvzDK5P+D7h+8dKeojQklxHibXvFP9ms1AxKC9N634Vs6vg7HC2TY/lp3cVQz9A== X-Received: by 2002:a5d:6252:0:b0:21e:4457:1bca with SMTP id m18-20020a5d6252000000b0021e44571bcamr7177016wrv.287.1658385907026; Wed, 20 Jul 2022 23:45:07 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:a42:b0:39c:5927:3fa0 with SMTP id c2-20020a05600c0a4200b0039c59273fa0ls1448870wmq.2.-pod-canary-gmail; Wed, 20 Jul 2022 23:45:06 -0700 (PDT) X-Received: by 2002:a1c:21c3:0:b0:3a2:fdba:3f39 with SMTP id h186-20020a1c21c3000000b003a2fdba3f39mr7018959wmh.194.1658385905887; Wed, 20 Jul 2022 23:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385905; cv=none; d=google.com; s=arc-20160816; b=aXmIRdSpFwwRK1BXTDR+J8s0ZkTsSlLOzRYLmZ+bePaVptMFO7s+8ZrhFeIrBRJzOT uabyP1le90vzuxqN7HjoJkSAo584XWJaqLSKBoyd4Sdz3iQ/nmrmXd1+HQvVOIkn8e3i 7vsYnFNkdfIkV49kl5sQ1n7CYdv0rilw1/YuMLqjByMw1m6pFOjbpLMxRy7sHZ5iRATI XTWUMC4J3qwfRDaOpchuBx1tAglfX+fppe/W60DYDb4MjQii0kXpPNhIO+DO6qjy09Vx sNvAjhx1wMyKeAhHGEfXyifWIFGuFlgpcmMqPYtmvFlVGnJzp+sp8DYy+6qhqy8NtiXX wTOg== 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:cc:to:from:dkim-signature; bh=4XPtI2gySozaT1bhKNHj4Zg6C0g/GthDeXBCI412vEo=; b=luuREgNiZKktx2EagZc9W3jpVzAsYBlwNd31ku1yi3pzv8wWT/SnxQvEaOzNxHMO56 X6gh1cxo6Am3D6ZVE8/FWqUbK/dw6j//fTSe3B78mIeOUjkmZvfkSMNIgw08ZGLnHtds 1GZUmQsRl36Hu0gfDOZVsXTgrcZ+fxO5uo5KzqXMviCKqIGv/WPEn27DX7PZxTeaTT3K vm0fDXgwK6aBymY5mQg6pTKFxeKR8JfzTvOcYdFUfAndkfHnskoFO1J1kDmV+cp+IYZJ xTrzTnA4YQh+eLI6ytiYlcCkg6wIR2FC5Px1O/upHSTc/pSt0p7jZuWNNko/hw46FOef Q7yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SM973YcK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 p125-20020a1c2983000000b003a3262d9c61sor185722wmp.35.2022.07.20.23.45.05 for (Google Transport Security); Wed, 20 Jul 2022 23:45:05 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:600c:3ba3:b0:3a3:5dd:f10f with SMTP id n35-20020a05600c3ba300b003a305ddf10fmr6827723wms.185.1658385905669; Wed, 20 Jul 2022 23:45:05 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:45:05 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi Subject: [PATCH v3 12/13] mtd: nand: toshiba: Retrieve ECC requirements from extended ID Date: Thu, 21 Jul 2022 08:44:34 +0200 Message-Id: <20220721064435.2456601-13-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SM973YcK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit fb3bff5b407e58. This patch enables support to read the ECC strength and size from the NAND flash using Toshiba Memory SLC NAND extended-ID. This patch is based on the information of the 6th ID byte of the Toshiba Memory SLC NAND. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. drivers/mtd/nand/raw/nand_toshiba.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_toshiba.c b/drivers/mtd/nand/raw/nand_toshiba.c index f7426fa59f51..99dc44df671a 100644 --- a/drivers/mtd/nand/raw/nand_toshiba.c +++ b/drivers/mtd/nand/raw/nand_toshiba.c @@ -37,6 +37,32 @@ static void toshiba_nand_decode_id(struct nand_chip *chip) (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && !(chip->id.data[4] & 0x80) /* !BENAND */) mtd->oobsize = 32 * mtd->writesize >> 9; + + /* + * Extract ECC requirements from 6th id byte. + * For Toshiba SLC, ecc requrements are as follows: + * - 43nm: 1 bit ECC for each 512Byte is required. + * - 32nm: 4 bit ECC for each 512Byte is required. + * - 24nm: 8 bit ECC for each 512Byte is required. + */ + if (chip->id.len >= 6 && nand_is_slc(chip)) { + chip->ecc_step_ds = 512; + switch (chip->id.data[5] & 0x7) { + case 0x4: + chip->ecc_strength_ds = 1; + break; + case 0x5: + chip->ecc_strength_ds = 4; + break; + case 0x6: + chip->ecc_strength_ds = 8; + break; + default: + WARN(1, "Could not get ECC info"); + chip->ecc_step_ds = 0; + break; + } + } } static int toshiba_nand_init(struct nand_chip *chip) From patchwork Thu Jul 21 06:44:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2228 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5AC4044190 for ; Thu, 21 Jul 2022 08:45:08 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id v11-20020a1cf70b000000b003a318238826sf306138wmh.2 for ; Wed, 20 Jul 2022 23:45:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658385908; cv=pass; d=google.com; s=arc-20160816; b=gSXH97ogwRQKX0rgswdGiB8ECvcF+j7JfMdvORvSkwn7dzNtg/jQLrED56JJy78TEB jrcJHMvszzkSF//NrhQ9XTlQyHEO04vXg0o9rRU4xQRAOTJaKBUxWflGc6Z7Yk1EPgvD WS2454xFSEH1dsdkt1BUuJ8/zZIaW5ftbUUZA6NcItZ5u8y/LOeYjCP4/LN61usUVYsk I2D8d1aPtVEuH9wCUMjLXSWn9uRz7FM/TLgvyZwEffYNS3reSD1WLYglarL/958P64KB Rdy15bDP4gCE55v0QCtnIJdbS0eyhP+tsazeNJVXMllQGgmyroRgYJNOVDsLQnc/IqWn 7bqQ== 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:cc:to:from:dkim-signature; bh=bkx6x1YAIV3j7XXntAHOO2V/0BaXfU41fLqdIp2vHcs=; b=PdslX9EH0neB6iGPpRstL0enoYKWs1C76tdw7z3g7AT9jvI7IdK9eGmCM7PpFtpMSW QbZ8jKExpLbMS4jmr7UgC3iIZovuVYVWNxWJfrI7bIRcWnsZu+HZDmswb5DVnYmIUg1h xMrteaPTSuDSkdOhvatnJaDrNlbkdlw2OS338lcg8dn4HBhEt3kv0AWp0Gv6kv5MLkM/ YGJLGp+yV3yarxOnCg94K20PpPghyCC85SC6K/ycGhnIBiHY8fY9voTIqYYp7DPEMTPA MiV6CP4mb150j1sqCV/rQYq15TKQifyTEiKpxN+VIEL1bI3enqMNa5wJDgsnuHYE+1qN 5f0Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LXgNQHX1; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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:cc: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=bkx6x1YAIV3j7XXntAHOO2V/0BaXfU41fLqdIp2vHcs=; b=G24PYTv/DZyndDWz0CR6XQog6WJ85VZ1GjVGd/KjSrJkPkpjnTE9FS6DLVom6V64/7 dFMV3vIZQ33ymE4VQ8Q2lRh1CPk7ecZjOgsa/LV8wrf5VxwhhNNbuO70hiKcd2JstlBn Z/nKmHZdiCZ8u/6Gf/qHL/d2DBJz5dicBQP2A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc: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=bkx6x1YAIV3j7XXntAHOO2V/0BaXfU41fLqdIp2vHcs=; b=PZfTB62EYakxIhvQiOMekS2ao5hheVlNhp+InhYsE9V/F1m1MyP1rmALaDFP13cED4 koErh13rGh5HIrjsFLB+/yjjAK+zeMoDC8uGDWZJyVPnN91zLdlju4w2Uxsx236jrEAd 3cW67WG29WSpHOiaFyPftjxugYAFFdgPn3nadNtkLvOZsmJSpZrBUsNeDJBfS9gg37Qh dOh2i5KcPQOcLrtdXq9ABkmhcfjJEnwjGEnX0iLJHaan8YqOy3dLXiX5t1A9AsFEEeIf qoBit5KclVSBw0qvsvo/4rSaTFJbxrQoGoq9YxzjxZHahN3lysjImA6on2FiaN7ykHTD 86kA== X-Gm-Message-State: AJIora+rTJy1hKi7+9OQBKEkiWAClQ4mHGaqHVvAOxSNXN9XO87d9bI1 +CRXHk1HbHyfHEOWxJVE0Nq7/HAX X-Google-Smtp-Source: AGRyM1to7k43t9UKFeUWEQm7HV5OLtJkrQXnL7GCP9/xQ3s9y6ctAqPMckwGrXN5DWxHjY3NWn7hpw== X-Received: by 2002:a5d:5603:0:b0:21e:5136:34d with SMTP id l3-20020a5d5603000000b0021e5136034dmr2469293wrv.23.1658385908148; Wed, 20 Jul 2022 23:45:08 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6000:22a:b0:21d:a0b5:24ab with SMTP id l10-20020a056000022a00b0021da0b524abls244625wrz.1.-pod-prod-gmail; Wed, 20 Jul 2022 23:45:07 -0700 (PDT) X-Received: by 2002:a5d:4529:0:b0:21d:ce8e:7888 with SMTP id j9-20020a5d4529000000b0021dce8e7888mr23723631wra.705.1658385907034; Wed, 20 Jul 2022 23:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658385907; cv=none; d=google.com; s=arc-20160816; b=AjLIxhqxwl5phVXminMuTYCtBdNd6iFk+4ULcHyCcu/i59cZoP7pFFRa/IctPY1XP4 5TeSblNmfPjEI0eYbvpgqDbuUdAQ7ngIBh8xYrNlpgLVplCOtHO1794sr77iI2tEX9Ik VrvPSjjkpewY09MgbSVjp0+2LwiN8n2+NPBbEcdmVYEHMHg3DM4u45snwhBjfkMWA0j9 OjC1KjiRT4nJzkxwTG6ixDnM04ZdS/kvTqu3Z/H1Tko1e03d1z2af76GVvSKommMAGu3 D4HP3rt9K9nFpdqcKT9jqfTcyIDb/Ls7Xo8ZiuCmwFovqYLE2tipbRvZSxAT6aa6FPyr oWWQ== 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:cc:to:from:dkim-signature; bh=gUisilg7L4dd/aI3OSlcyXi7Asy/u+I+uAPdQHFBF94=; b=0dW2JZ3+3PibYIOhILVETHvF6Uvm0fdm9wR7IzwhtvPc4hiRT4sA8uc3NeAc5ubSo0 TGOidooBYIG5yzBtWa10NSxsDkqzGE0H9BoVLgJ5gcQ2qTOAQ8l33OO6EATjB3ylMmI0 WMH31OiaPqkFiJG/cJw79T8P8yFjvk8DEc5OWvQ/PTlBDi95Gjr2vgl4v8eENlSssaCg Ka9iw3ARkWrZxcPbD3Qn0PVaBuBXBGiEVno8v8fTtSrCXVtS3UcaPT5xeIHnk3hBAhXm 6X3Ya/hmWJFBLAwkBg15GBQD7f9McjEfwMgjz6qHJX70EZiP0DtShEy3FnKjJZ6lUpoH AfAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LXgNQHX1; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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 u2-20020adfb202000000b0021d92908400sor457413wra.7.2022.07.20.23.45.07 for (Google Transport Security); Wed, 20 Jul 2022 23:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a5d:5f01:0:b0:21e:5202:17f with SMTP id cl1-20020a5d5f01000000b0021e5202017fmr1980932wrb.392.1658385906760; Wed, 20 Jul 2022 23:45:06 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-140-42.net.vodafone.it. [5.90.140.42]) by smtp.gmail.com with ESMTPSA id c18-20020a056000105200b0021e4f446d43sm903711wrx.58.2022.07.20.23.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 23:45:06 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi Subject: [PATCH v3 13/13] mtd: decommission the NAND museum Date: Thu, 21 Jul 2022 08:44:35 +0200 Message-Id: <20220721064435.2456601-14-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> References: <20220721064435.2456601-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LXgNQHX1; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@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: , From: Michael Trimarchi Upstream linux commit f7025a43a9da26. The MTD subsystem has its own small museum of ancient NANDs in a form of the CONFIG_MTD_NAND_MUSEUM_IDS configuration option. The museum contains stone age NANDs with 256 bytes pages, as well as iron age NANDs with 512 bytes per page and up to 8MiB page size. It is with great sorrow that I inform you that the museum is being decommissioned. The MTD subsystem is out of budget for Kconfig options and already has too many of them, and there is a general kernel trend to simplify the configuration menu. We remove the stone age exhibits along with closing the museum REMARK Don't apply this part from upstream: Some of the iron age ones are transferred to the regular NAND depot. Namely, only those which have unique device IDs are transferred, and the ones which have conflicting device IDs are removed. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- Changes in v3: - Use commit sha1 with 13 digits. - Wrap commit description to a maximum of 75 chars. Changes in v2: - Use short-commit form. - Remove linux info. Uboot seems that backport without add this extra information. drivers/mtd/nand/raw/nand_ids.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c index 7602dd30f169..4dece1b20676 100644 --- a/drivers/mtd/nand/raw/nand_ids.c +++ b/drivers/mtd/nand/raw/nand_ids.c @@ -24,16 +24,6 @@ * extended chip ID. */ struct nand_flash_dev nand_flash_ids[] = { -#ifdef CONFIG_MTD_NAND_MUSEUM_IDS - LEGACY_ID_NAND("NAND 1MiB 5V 8-bit", 0x6e, 1, SZ_4K, SP_OPTIONS), - LEGACY_ID_NAND("NAND 2MiB 5V 8-bit", 0x64, 2, SZ_4K, SP_OPTIONS), - LEGACY_ID_NAND("NAND 1MiB 3,3V 8-bit", 0xe8, 1, SZ_4K, SP_OPTIONS), - LEGACY_ID_NAND("NAND 1MiB 3,3V 8-bit", 0xec, 1, SZ_4K, SP_OPTIONS), - LEGACY_ID_NAND("NAND 2MiB 3,3V 8-bit", 0xea, 2, SZ_4K, SP_OPTIONS), - LEGACY_ID_NAND("NAND 4MiB 3,3V 8-bit", 0xd5, 4, SZ_8K, SP_OPTIONS), - - LEGACY_ID_NAND("NAND 8MiB 3,3V 8-bit", 0xe6, 8, SZ_8K, SP_OPTIONS), -#endif /* * Some incompatible NAND chips share device ID's and so must be * listed by full ID. We list them first so that we can easily identify