From patchwork Wed Jul 13 06:54:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2120 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 097D03F1F7 for ; Wed, 13 Jul 2022 08:54:46 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id z5-20020a05640235c500b0043ae18edeeesf4114720edc.5 for ; Tue, 12 Jul 2022 23:54:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657695285; cv=pass; d=google.com; s=arc-20160816; b=0yYWfT2p/NWZWzCpUuISvKU9ZQNpUS3/6MbtH4f/UT0Qi6uhoCLEAUK5QiY+5GwgVO T4RXWoH1fBdgaMNqERjlfa0hd64LDo3x33Fn/mW1pHGuJw7VvCUoYoRJ4qfg3GPbc+AE P1gXPfgkYs/XR8tBXf10qk4P/+nQtT1lz/bzh6SY7ikb20XadFEBYqM+U6ZkZ/8xIV9M b+qRSprfUQGz2c9DJEqs+paws4EAtcHMnjAd10tmsrKQ6uN8Mba4k2v+/pogwQvAzT44 GGo0tlQC1RQ2ll/PhO4jC9PosTAV0uOraZu4qE2R3z44iETU/qss0Oqo9mBTxhM6HLvg ihkw== 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:message-id:date:subject:to :from:dkim-signature; bh=w6jeEffYbyh5yW4irRptvwg51uM2EHfMcnY/JdAF/24=; b=TqFRt10X02nJ1UCoBTrtCinlEWWpyA6EcSc3f5Pm5boSy8Pzu3SzA720zOVYAJ8jwj c0zDzGNFdgiFRcZkO+Cilt01dseAifc2Lak53V6GT0egUNX5m4lSxJS94YqP7Hd+asNE qZ7+dy/p7DmCffmLx9x0/y/JEgMdb39xQhJJ9OXI+wSP71uJf9Xl6HBtCiVVDrKprptT xPaCPId9m2Vj2B0guCnqVdh1Dseu/x+GwRPkQuh4lzm+s9CL9hiSy7PK0GnuvRL3G+L7 YCWZuLOIvjlkgKIxswxH8l6RXMxfo8lPATmysBPOPQV/W0UHBTmw5p543UDsj5tkhpFB qa6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=b64P4jEL; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=w6jeEffYbyh5yW4irRptvwg51uM2EHfMcnY/JdAF/24=; b=TPyCD4yh7ij6tWs0nN7DiTvDnOkEAV1591v3ZxX1w4U8/3Y9nEcWTLH0yJuddyVSBm yyeuO/OvMin+GcPnuvkqYMRKDdemgbRWAYYKKRBdTFUyXx/P4QiyfdXgj/BbSUwnXkaD sWj4LBOqQPt3M22OBTFcvd7NpjzQq7+4jNvHI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id: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=w6jeEffYbyh5yW4irRptvwg51uM2EHfMcnY/JdAF/24=; b=l8SLIQOLlG4d971qyPGlTrMqDZYmiJfemhY/wwfM8Fus9CEJ2DfU579SYa56NmO5Zz SBmsGdtj2HTnbDoN4totpQ2yxig3qUrS8dmlWep1YV5MKNxoWGTnMvUbqpaj+7/I/8aF rPkJjluGq5GgV/U9VNkdqh7PMEfcHx+BSVC+UlT79BIZLwF9/jA0z4eXciHcb3oCLPak Z54nxb+7kpxfXDEZzMliAsY52OfV+w3gSvq3BqUVeDk3ayEmljmyZ2KOZOF3Ebvg+JAF br7hilr19LQ4OVdJv4wUjVg1RV+grxYL9vLGc7NQlydl+1ONt65t5HtL9mDEqz55O7Zm 4vMA== X-Gm-Message-State: AJIora/RMhiJ7kwN7uzD9G731/zgnRZMJRc7oION4b/VGmx/rpcw34KK 4fOUFYDwqwTafBWSuFWlC5A55+51 X-Google-Smtp-Source: AGRyM1vLAN/xO/3PZJeBeM3Qedbap8E7wtLD73niBXC5r5OCivfz9ccugVUtNKR2wx+EQFJGTTFTZg== X-Received: by 2002:a17:907:9613:b0:72b:68df:8ada with SMTP id gb19-20020a170907961300b0072b68df8adamr1983069ejc.31.1657695285877; Tue, 12 Jul 2022 23:54:45 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:d0e:b0:43a:6e96:4ae7 with SMTP id eb14-20020a0564020d0e00b0043a6e964ae7ls151644edb.1.gmail; Tue, 12 Jul 2022 23:54:44 -0700 (PDT) X-Received: by 2002:a05:6402:1d97:b0:43a:7b45:8e14 with SMTP id dk23-20020a0564021d9700b0043a7b458e14mr2792928edb.418.1657695284500; Tue, 12 Jul 2022 23:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657695284; cv=none; d=google.com; s=arc-20160816; b=GNQD/11SCfW8oi/TmAX7jxA4mpUXqDZ8MAa91DiYZ0u3KXC7yustPZiTCSy+TA547o QBZONxEaVSSgW+/CYAruJZL00A8n7QhyjrKAGAocu2R9x6hlarfUG2i6n1ZmENUaO1LX S1qI/+IlKynCpmSkrkr/t0afPU9GbDmHuhVnuUbBsLnd7HwGlBhtiJLtZywYd4lBsm0l c2EaygzuUH1iVWxtYPzAJHFgfG4+S0VhJbxBDDkB8jK7vgkXQuijJYYJ3+CU1lUo3CFm /Qlsg5ejLSojwSSGMlgs2j5kb8GLinUJiUANcMhA+Mfx6J6VD7g4x238VVHEP00IlM2j XB/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:dkim-signature; bh=lIuIWLqqz2ogXeLR2OiG+YgBNXzZxQ2P6FCSJQWqai8=; b=0pFZI5AayBnGB6ojo9oXJaPQAQVrHRWFW7bHPEar3IsqgZx8Gi6DjgT/YjpAJSLCDu v8nE6HZ1l5dhyS7IKyHr6+tgkdorf7Rrlt3gmMwEPuW39ER0It1cvzEqhwC41nUYCbNT LtQq7yOWo0rXze3OWUm5N/gneb4pT5VAC8t6ZdSO/SDCqVhYkJiFqYBjJg4ezJ0QoUca dN+y7d48M684NBWFjkKX6SswuvWwSlxHhToy06VdMu8VfcEdQtGjm9ixWmcVpQu+mL6K u0o1J0mrBjaM1bIwYPssB6nbKPlzq3Y9CtckE/ilIXkdf1TnJKqY3q/qNKa+xxPBQk8+ kwlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=b64P4jEL; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id e21-20020a170906081500b007262f75c699sor3576142ejd.116.2022.07.12.23.54.44 for (Google Transport Security); Tue, 12 Jul 2022 23:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:6d98:b0:715:76eb:9e33 with SMTP id h24-20020a1709066d9800b0071576eb9e33mr1986477ejt.729.1657695284082; Tue, 12 Jul 2022 23:54:44 -0700 (PDT) Received: from panicking.amarulasolutions.com ([2.198.242.86]) by smtp.gmail.com with ESMTPSA id lz21-20020a170906fb1500b0072aa38d768esm4635263ejb.64.2022.07.12.23.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 23:54:43 -0700 (PDT) From: Michael Trimarchi To: Dario Binacchi , linux-amarula@amarulasolutions.com, Tommaso Merciai Subject: [PATCH 1/4] mtd: nand: Drop busw variable and use chip->options field Date: Wed, 13 Jul 2022 08:54:36 +0200 Message-Id: <20220713065439.272149-1-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=b64P4jEL; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , No functional change. Reduce the function parameters in preparation of support specific nand manufacture Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/nand_base.c | 58 ++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 6f81257cf1..cb22e0ec13 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3890,8 +3890,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]; @@ -3963,9 +3962,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; @@ -3995,8 +3992,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; } @@ -4005,8 +4001,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; @@ -4068,9 +4063,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]; @@ -4160,7 +4153,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 */ @@ -4213,7 +4206,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; @@ -4254,7 +4246,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); @@ -4267,7 +4258,7 @@ 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; + chip->options |= (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; /* * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per @@ -4293,15 +4284,14 @@ 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; + chip->options |= (type->options & NAND_BUSWIDTH_16) ? NAND_BUSWIDTH_16 : 0; /* All legacy ID NAND are small-page, SLC */ chip->bits_per_cell = 1; @@ -4363,7 +4353,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; @@ -4378,7 +4368,7 @@ 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; + chip->options |= (type->options & NAND_BUSWIDTH_16) ? NAND_BUSWIDTH_16 : 0; if (!mtd->name) mtd->name = type->name; @@ -4441,9 +4431,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; @@ -4453,11 +4458,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; } @@ -4471,10 +4476,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 Wed Jul 13 06:54:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2121 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id F04A33F1F7 for ; Wed, 13 Jul 2022 08:54:47 +0200 (CEST) Received: by mail-ej1-f71.google.com with SMTP id hp13-20020a1709073e0d00b0072b812bc5e9sf1389705ejc.9 for ; Tue, 12 Jul 2022 23:54:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657695287; cv=pass; d=google.com; s=arc-20160816; b=tLzoE+zXSxeVvwJ2yts453WomP5hEiHeunpq5AexZm2uWq/Br2HbMzSMBDsZM50G6n XG+TSRHRjM+0pHQVvISeo+SWC42UBZsriK02QgZ9at9PvqYmnzQNRXNjKYs1S8Qso7XT uZ9jDkH3nWDr3UHsXk4+OGCuEYvGdCZGmCu0EtQ/tf4+pYN7T8AEJzV0TnZG1OYh7rs7 ks+3RfPUprQ9t/mryNrQYkbxafOxTN6vE8paIh8dkPC8zbVup+BKN50hIKZ48hOk0C1o ynrLphawpocciCpR/h9yd4N4HTr1FHLl32sK2MRdpNl+7sHuFIrpjykU4tnwyTSRlSBA Z9/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=aW6GEdkD8zcDfiJNDIOT456mXapIcpvstleGv6GjrXo=; b=rKnH9b5u5PderAQ7Byj3sy2aFbdK5TQPsGdWTmvtsH8CpqYQeHP8bJY+19zbtXj06s XoCuHZMdI9NpYnm94lbsFNCBIuBI1ICWnUEY3xv4trg+Hn6wWGKF8WyhmNeGJ6KzfqH7 izNz07Qr+n9e5YVoSlplcaVv6GtEMEfIdDjPMetVNJMEZEBeudpvGr23k/McveosY43b r6+apKosHiyNO7V3fLw/NTK9hGpK6ZoVYYaybq5FraxsxmNygsnTnBVuy05ERuJfaBvd WFEC5W8iHl8D/d8/EVIuUnlk1j9adlPV28pSJceq1Xd3UG4ZqUaNWWRLpUCjtnuUF99w Iudg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GjYRNG49; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=aW6GEdkD8zcDfiJNDIOT456mXapIcpvstleGv6GjrXo=; b=fbWTHdSl56if5hAK022r8tEnG5s0UW4NR6iSVWyeVMgqHV3JXIQQ8O3zH17zeEGw1G Go1vWYBiVZqLfkwuq/mA3Rek0tov2G7Q0vxaqAbth2ZpCimKrZaM5Sutdb8u1T343K96 QDrpffOxUmgqXjWJtEbDqAi5Odyl0xwTm0FZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=aW6GEdkD8zcDfiJNDIOT456mXapIcpvstleGv6GjrXo=; b=21sk5NI8vjSSMM+Q4JFpxSgParoCr5d2dsXbdjGSMzdalq3nLyYFJKwtRLidcrQN4F eJu4Z7gvQG/zfC+2kLBjpEYkQyoz5be0AZbBRId++I2d/+Kk9xvyLoreX7FJNlltm2Ez Eo2tEjrI5Fwi7aPMcfhw8KDQZV8dTt17wzq7/bFfdJsmp5MhM7N77IFADhcLrupwctgM MWrKQ30QC5xq0msqnIl5iKwhrdpsHZN0G3JCTV1jmahm8qF41Tw4iolvwA6Pgt6kk48W KHerLYR/14OpaqYZmO1Y/eLTPEqmJJ6cdWGO3MP5jXzjtwsPsO3gdw8kYI/hVLl13Ak7 ilPw== X-Gm-Message-State: AJIora/eNFCvxfgRJJv2wSGYuAsIDJLhmJHMgjm1oUf2YFKX54YHp8fj PgFg150OZORClscjCiWWReMKdg71 X-Google-Smtp-Source: AGRyM1saujN1XGB3KpipUoDjPF0ICNe7PqqMm7Wn4ldom3z3+ldlL0sXVAE1xrbOnpX+JkhCbRcUJw== X-Received: by 2002:a05:6402:278e:b0:43a:9cf5:6608 with SMTP id b14-20020a056402278e00b0043a9cf56608mr2842714ede.76.1657695287819; Tue, 12 Jul 2022 23:54:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:5ac1:b0:6ff:ab8:e8f with SMTP id x1-20020a1709065ac100b006ff0ab80e8fls2506522ejs.6.gmail; Tue, 12 Jul 2022 23:54:46 -0700 (PDT) X-Received: by 2002:a17:907:75f1:b0:72b:9e40:c1a9 with SMTP id jz17-20020a17090775f100b0072b9e40c1a9mr1034605ejc.523.1657695286450; Tue, 12 Jul 2022 23:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657695286; cv=none; d=google.com; s=arc-20160816; b=LpKSstBb4hfV8aQ295gep9eMUQQmNnUo6WoqCAhSHoFqnhsOMNHTNF820oiaCnggz+ pAPovA/NbAZcVJCQOwKhygzJfLSs+xQxBtOj0wCCrkiCvkoTFSZB0BCbuOclURiyCaeH 3HxE4sEpE1yyVPgi7LGr0/7NOLASE/EQTzitpOtzxGtqfvKEsxVHoNx19+mdrnsk15NF /GkQuYG52Nbah4OJDO0rtxl6rXcXFFNIel2QEpNzEWW18a8zy44PFMGhJ8fwdTmhQZnx 5PEgN9JcNVcLQXCjevGuM/Od98+bC/oPMBNi7KPWfeaHdevJFvGGvqxTngm48Rwf0Hsi wggA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=2YfxGQzkFFT0sbnfqrBh3TwpjufxYi7kY4AAw9T7MuE=; b=FRqQV1DIh7RcLm1nDise6mPgL+Kgy85VNhisvEOl08XHAONpN7Y+T+QG1gKm2qNSkp x+P25u618JC8T7I3Eg/IxJF9ROGp70pZqeSp4lYHiIgtSePi8uZP87qBK7hrQ+K7RqAy yCv13fV5tipihgoSEwLAF0bvcsPo6NFWNJrGEqZYx4bru3TYAIj/HsOf1648fLwtKS+k f5sM8Rtt52Q2oFZxydMw36Fcz9VJwlCWnZozcIKoo7wZOcm1UIGJWH3QFVZeUhvPro1z DjiCNLvQHkSFxPWTzxritfbUOVXZLmsnn1iN6aQp7CEgJwBW97uhgOzS9Kn3wjq1nzLg qAAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GjYRNG49; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id qh20-20020a170906ecb400b006f3afcd1b7bsor3645046ejb.115.2022.07.12.23.54.46 for (Google Transport Security); Tue, 12 Jul 2022 23:54:46 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:1c11:b0:726:851e:179e with SMTP id nc17-20020a1709071c1100b00726851e179emr1933435ejc.39.1657695286101; Tue, 12 Jul 2022 23:54:46 -0700 (PDT) Received: from panicking.amarulasolutions.com ([2.198.242.86]) by smtp.gmail.com with ESMTPSA id lz21-20020a170906fb1500b0072aa38d768esm4635263ejb.64.2022.07.12.23.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 23:54:45 -0700 (PDT) From: Michael Trimarchi To: Dario Binacchi , linux-amarula@amarulasolutions.com, Tommaso Merciai Subject: [PATCH 2/4] mtd: nand: Store nand ID in struct nand_chip Date: Wed, 13 Jul 2022 08:54:37 +0200 Message-Id: <20220713065439.272149-2-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713065439.272149-1-michael@amarulasolutions.com> References: <20220713065439.272149-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GjYRNG49; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream commit 7f501f0a72036dc29ad9a53811474c393634b401 Store the NAND ID in struct nand_chip to avoid passing id_data and id_len as function parameters. Signed-off-by: Boris Brezillon Acked-by: Richard Weinberger Reviewed-by: Marek Vasut Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/nand_base.c | 54 ++++++++++++++++---------------- include/linux/mtd/rawnand.h | 15 +++++++++ 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index cb22e0ec13..6d8b892288 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4152,16 +4152,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: @@ -4172,8 +4170,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; @@ -4206,7 +4204,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; @@ -4268,10 +4266,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 && + if (id_len >= 6 && chip->id.data[0] == NAND_MFR_TOSHIBA && nand_is_slc(chip) && - (id_data[5] & 0x7) == 0x6 /* 24nm */ && - !(id_data[4] & 0x80) /* !BENAND */) { + (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && + !(chip->id.data[4] & 0x80) /* !BENAND */) { mtd->oobsize = 32 * mtd->writesize >> 9; } @@ -4284,9 +4282,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; @@ -4302,11 +4300,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 + 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); } } @@ -4316,9 +4314,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)) @@ -4353,14 +4351,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); @@ -4388,7 +4386,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) @@ -4446,9 +4444,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; @@ -4476,9 +4476,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 */ @@ -4516,7 +4516,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 3417ca2a0d..f2c6a978cb 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 Wed Jul 13 06:54:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2122 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B18053F1F7 for ; Wed, 13 Jul 2022 08:54:49 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id y21-20020a056402359500b0043adf65d1a0sf4425117edc.10 for ; Tue, 12 Jul 2022 23:54:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657695289; cv=pass; d=google.com; s=arc-20160816; b=mqR81cLSBfWRft9XNAbDhM6ki8g+35WDFfSk2tlPHbjTafsCWCXk53s2GmU4UKOJi9 12Rcbhdo23LQqUt0i3LHEcAteDIkOuFNTYSMM60QoVxVL/c/mXT6rADZZleY0VxioAov Cvk1DtXAX9er5s+mwqXygWwmhX8yVz+CfRnZXvX+nPXTnVW3il6E+C8BROUhpSY6hLOD 08sQ53lufOZJ7+QitEBNTvm+dfKdq5GO4UcIliq8XbbI33r73Enn1HKnv1BJj1FqiLRu dxMefI/wMhuWsnLsK48vTYRjKbtOG0sPkgrz0+o20Sq6i0l5hCT8Vx04nLup4PhkUq6L 1EVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=wilx1cJ3Q91m/NlChT8WG1/k99hqsAYd4TVg/efHXsk=; b=CsXfx+Ghzn9QvnZZWvg7V9AvJGvRAuFb1lCixCe1Vf23wO4fM0DyVDRp9kvOGEdfVp XwfBpk8+T13E4q9V4ZVFu+fRWrx8BJQoOdx0eTjQXUd0FWTywtnqqh0qhZP3cGSQKKkF yYKRB2w2HAx0s2yR/rqz3hiCV6FTMUu1SDzuKd/iruG/htjMrOUprhSpJp7gn7V4IwaU h/qae7rZJcTb8B3UKDcGtBMxOfAJHvq0OrDkUPnrZA+087+8vnS94ZUaa2tS1NyILEk7 BLIITMoHdJ0JX7Q7SWPmHve0i6nEGQYhLThh6XSeyQ8fVkEReudaU3lpJoOOS9Zx0leb 6NGw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=JvOq4nOu; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=wilx1cJ3Q91m/NlChT8WG1/k99hqsAYd4TVg/efHXsk=; b=PkVNLSbfgTeuHriqimK0H8cI3LqR3+d9LFpPpGuPmox1V+oFsrxerysrmjpgM8CYFv ZXqr5IzlRbAk88Iq3B/o2Ok4Hy0YQdcpyzSBNIn9iEI9ymWABP5aOrxlxgZOb7glH1my xfygkRBv1dN0tBriQU1kM1HpRzrtiagesJqv8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=wilx1cJ3Q91m/NlChT8WG1/k99hqsAYd4TVg/efHXsk=; b=N2UADuGd+LcoqjxrVZ4SgS2ABgEdWxTarfjoZmyQY7M63IEPe9FLG5hYsxCPgVEJGK adiXyphC79bC0xNyRd0QtLrubvIwOJVuNyUMUJqkmz+xxusrxRpPW+Ao9HBpHImVavqn qt2vYlTWn5AKr5kLVmyAFozNIYx/axB2LVvLdMF9K3faCRNTonnOSUbZW8LoOYu9b1EW qoXELt2V5OcnE1NYF/dnHd2Pv/eX+BmpOJCGSYs+cyFvnVv19OSKD9nJo2hUbSzUYNxA uf90PZKFFSdEiMAnp2HsRVnsoC98Mo4KUUIWqzntJqK70E2n/47Hc6YUzEJVHYbmCdLs EH4g== X-Gm-Message-State: AJIora9RWFJ6Lzcxcesc3AzfyCoU05n9MFSVRkvrheEXdl5IfX9i9Fwe us/l2CoiQL3QMvUy358X59SXfW4L X-Google-Smtp-Source: AGRyM1uxr4ieZA5mmmivb9U77mz3R+gfRdT7mSfoSYjnvuYTPdOR/30/sTYXIsl64xXJv4H462iRQg== X-Received: by 2002:a05:6402:5186:b0:43a:b43a:40bc with SMTP id q6-20020a056402518600b0043ab43a40bcmr2748907edd.388.1657695289491; Tue, 12 Jul 2022 23:54:49 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:42c7:b0:43a:82dc:c2a2 with SMTP id i7-20020a05640242c700b0043a82dcc2a2ls151931edc.3.gmail; Tue, 12 Jul 2022 23:54:48 -0700 (PDT) X-Received: by 2002:a05:6402:1d51:b0:41f:cf6c:35a5 with SMTP id dz17-20020a0564021d5100b0041fcf6c35a5mr2824591edb.25.1657695288172; Tue, 12 Jul 2022 23:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657695288; cv=none; d=google.com; s=arc-20160816; b=wsBjwa+MmoLHTZUrOuxej30Sa2CgjtrygnyhYVH7TQs/u8nqkAb4jxGAy967flxTi5 VHM50TZdW7j5oYhGSSImfyhvq37xWkjl88WxvwjGwfEa+n8xVJpgeVSybQQDvIIvVr3u HBWrkkrtiCACAT84/aoFZULQARcEvn04i85kIuJQ/ukngN6sdWixrT24at6UzvluXyUw N075QSO+WPyO/Ihj/10IZ7zeqO3k+C+sSJCJmAsXHdsZa9e2TmwOptAO9NmsWEFzZ4JK PcFTsJ7pnOYQZU9ByT4mh3Jdyao9J23jQaboJYxMWJfaqNy2uueeeA/QidIuY3f+SrzO S5Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=gJVGkB2EpFxqz1nkyX65cKT4A6W6dwwPZ79Io4s/HMI=; b=ZsskvrCCj7c9C89JU4KGfu8rnzmMV7okxenhubMgwrgpqk/A/T+ra3hR4RilhuwNbh i6CDbXYidjfrqYYDZxNCFImALAlp01uBKiPwa8UR5/7vG599S/ddqHP6Zfr5kg7CFv1F NNRDjC7OGllnOxCdFpjC+LnOzbWU4iubWHG7QcOrSoqtmjI56RK7Qqc0YKf29+6vOaxt Vs8Xg6ecO/pUSMfOuL3ow6TzDe+SVU8mguwCx6Y704EvqnotO44HglgvhxCCpkyyNGGd OIN0DjNOqDavP7a1en8bm2vyex6dWlwDz0P0gDP2JlRfrGBPSHLLPDxPjwsx+UKYu0NT yjpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=JvOq4nOu; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id p22-20020a1709060dd600b00722f38adefasor3465041eji.6.2022.07.12.23.54.48 for (Google Transport Security); Tue, 12 Jul 2022 23:54:48 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:9753:b0:722:f1e3:ec27 with SMTP id o19-20020a170906975300b00722f1e3ec27mr1889180ejy.355.1657695287829; Tue, 12 Jul 2022 23:54:47 -0700 (PDT) Received: from panicking.amarulasolutions.com ([2.198.242.86]) by smtp.gmail.com with ESMTPSA id lz21-20020a170906fb1500b0072aa38d768esm4635263ejb.64.2022.07.12.23.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 23:54:47 -0700 (PDT) From: Michael Trimarchi To: Dario Binacchi , linux-amarula@amarulasolutions.com, Tommaso Merciai Subject: [PATCH 3/4] mtd: nand: Add manufacturer specific initialization/detection steps Date: Wed, 13 Jul 2022 08:54:38 +0200 Message-Id: <20220713065439.272149-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713065439.272149-1-michael@amarulasolutions.com> References: <20220713065439.272149-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=JvOq4nOu; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upstream commit abbe26d144ec22bb067fa414d717b9f7ca2e12bd 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: Boris Brezillon Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/nand_base.c | 86 ++++++++++++++++++++++++++------ include/linux/mtd/rawnand.h | 30 +++++++++++ 2 files changed, 100 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 6d8b892288..02789789e9 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4276,6 +4276,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 @@ -4376,6 +4409,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. */ @@ -4384,8 +4437,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; /* @@ -4446,6 +4499,10 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, 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; + for (; type->name != NULL; type++) { if (is_full_id_nand(type)) { if (find_full_id_nand(mtd, chip, type)) @@ -4475,8 +4532,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); } @@ -4492,12 +4548,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; @@ -4509,7 +4559,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); @@ -4542,28 +4592,32 @@ 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, + 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, + pr_info("%s %s\n", manufacturer_desc->name, chip->jedec_params.model); else - pr_info("%s %s\n", nand_manuf_ids[maf_idx].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, + pr_info("%s %s\n", manufacturer_desc->name, chip->jedec_params.model); else - pr_info("%s %s\n", nand_manuf_ids[maf_idx].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 f2c6a978cb..57fe7fb47b 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 Wed Jul 13 06:54:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 2123 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D1F4D3F1F7 for ; Wed, 13 Jul 2022 08:54:51 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id b15-20020a056402278f00b0043acaf76f8dsf6364888ede.21 for ; Tue, 12 Jul 2022 23:54:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657695291; cv=pass; d=google.com; s=arc-20160816; b=CG+9T7Q/RNzMpGGdendNFSBK+lIoA4A+KOHt/y3FwGgVpQkLU8XczCngQVh+4jD2lk o4xmqJTmjqdXcKvOdYMPKN3ZNa3qjLjyhzR0b+Y3yWGRZWrO0PxFMa0aMkQeLwbdR3Lq 8dDHjkhEYclyRTrczhV2Ah2T64z7oKcxWF+cPVQnTS2fnypaCExmhNv4uYtkJ1LOAGDS BJzMlvTKRAqkb98PixEqKrTRXJmqd7v5e1sPUjmyurHomjRzZKgmfi5xMpVq6kXew63/ oik2ZV1p7DAAPUIu14WgzIUDPvuW72Khh/5aD1UJ80MUPI7TMFOMUhUvab61GFywvoCY aglA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=EKhWtY7EXFQNFDk29Odq5D84TnlUf61+KpGV+2icKiQ=; b=rxOhKAgEhK/lrX80yaRbxOvFbAI9++p4jV8OOVEvOwsAt61uIjTpsUW6YGgZhmhRvM 80riduFTyREW7VluTdCCsHGfCHvxJYvCJPMXpI23PNS+/S6q6+F8Sw3iZH71VLT1QpnO 2R7a1lUJIAfIQW9Uroejv951DbC5ple5UV+k7jpMaJAV46s6e7dYnTlV7KA2bz/tyi3G CnCYuueYRGa8FAM/7D8WSCqf7GJmpmQNGG8Hu5DKGCM7iA8yXl8XVl9ZIVYvts7wTE9C eusF8Lr0g/mId2Gwb8ZlhiF/HRxZk0n1Q6/F9R6BaXYPEY73Xy/CbU8WxSoJtDuE8qvV h1GQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BYf4wsXF; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=EKhWtY7EXFQNFDk29Odq5D84TnlUf61+KpGV+2icKiQ=; b=lzxnTCvl3kgWx8mvG+wJgoK7R5uxK0C2/rtK1dX/NGmG6/M+YFfhdRTTt4tW/sx+wJ tZ5t/Pw/cH3e4Rr8BD7bWMcv2VAm4b4XVRBzkB/Y31TZpZ+vAeGa6eTR+KogAJ1AUZC7 SAWdiKPAosg5ZqsiKlp7B/NosnIIXUoDe1z+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=EKhWtY7EXFQNFDk29Odq5D84TnlUf61+KpGV+2icKiQ=; b=3mmvrZN+I1/EEmvKJxMsd4Cf+RmhbA6oPWU0bsuixnxvF1Z9SK9qMieEvbIqdQqVD5 EvWAlq0On6iSCi141TaqzjzPwysgoWrhNzF6+VV7DXAfeiSkgJhxHVHYgPADnOjkQLpc 5u4J1NETuxktE5I8LAA8L2C1mqOGB2nKl0NvjnC1tFYaXaH87XaVaqoLtjgAvgm28oAp c1x8HCN1XCuT5w6n9Wf4VJhcXpkl9xN4gm0rLCqP2xZ+HU73EHrWXMHhTdELedJ/cJlq IjYXYvgbkO5YDC6h2hccRfzvB0a3YQLSwk+0fVSo6iy68EKkTN2VLKSAzykzPYjlp2v2 uTEw== X-Gm-Message-State: AJIora8YGOw85vmy0vbLmEKS8AnK15E1aqEJ7Pp9YfzeNG+bUNSVDWfn U2NwEtCnrCG03L+uKKAF5tWGsu4C X-Google-Smtp-Source: AGRyM1v2WbLXjXPT0rlpJ0dydeSVPluvWqWheUW/3v453Nuo7BOBl1rduq9oIP6OVgIds5TOmGcrhQ== X-Received: by 2002:a05:6402:1d53:b0:43a:9ba7:315b with SMTP id dz19-20020a0564021d5300b0043a9ba7315bmr2745010edb.350.1657695291692; Tue, 12 Jul 2022 23:54:51 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:d0e:b0:43a:6e96:4ae7 with SMTP id eb14-20020a0564020d0e00b0043a6e964ae7ls151866edb.1.gmail; Tue, 12 Jul 2022 23:54:50 -0700 (PDT) X-Received: by 2002:a05:6402:13:b0:439:ffe8:bec9 with SMTP id d19-20020a056402001300b00439ffe8bec9mr2767439edu.297.1657695290414; Tue, 12 Jul 2022 23:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657695290; cv=none; d=google.com; s=arc-20160816; b=AlXz3VGn56jttjAvO23nHVFQPH2QeZCsJlAc8KsrCZiPGBv6dckGEw6CaDYwDuAnVg jeV5jPLKb51tBTVq0YPQ6N/npVL8BKHdiuNwhUOK3xMGi1Q59/rRZrO7pDGa9eplmxwO Jctogx8QXtdB1lWD954ibOExtDM5MYQKuAmgZUrt8dgi6tk7xocdtSYzhMK6Tj6B7MKk F9rpeOyXI1X/89VxwnyGVAZx57FrJ/oOnrdxTH65RiGVw9RsIUi1EiF4WOyE31ye9/oz RwHueW+M2OB84OwDsj7+uLWzQg3xKSa3WgEjYm28B5KXgVNw+JSam9Zw9dvFm8C5+/gV ctKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=R0rMlj9Mu1Gv7wJS6s/+zrStFiz/O7ov8BZ7vBQQzXI=; b=P1QmmP1TnLeZ9uqJ5cRNpAZmv5rsQYDjLTgJbRbvTg5xNQ3kdkfnjUfg5SjNLKB20c aovk3Q51pNncywWyjm34aBQOhvKt5X4etfXW3xX0PQPsOeY4CTN5N1CNu2S3SNIQvuHX tZ/ESh1gKLx81VTyyIJ7EKIkcr38Nd2f5fA013OGw4RWMWwqfO0w4ofzHzSCbJ/utX2K mBpBdbhCQz5TmCiyGxWDR9MeUmgBvMsJGnDyJMoca2s65abVVYEERMKyw7oddVRp7GSr C/LSyvL1MdR9KtrMcbd1AMQrr/+Rez3H3plw7bCXoa++fdj65Eet4w0iLbJmOuTjBgBR fssg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BYf4wsXF; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id hj1-20020a170906874100b007263150e3a6sor3310225ejb.51.2022.07.12.23.54.50 for (Google Transport Security); Tue, 12 Jul 2022 23:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:3e81:b0:726:9615:d14d with SMTP id hs1-20020a1709073e8100b007269615d14dmr1861117ejc.517.1657695290120; Tue, 12 Jul 2022 23:54:50 -0700 (PDT) Received: from panicking.amarulasolutions.com ([2.198.242.86]) by smtp.gmail.com with ESMTPSA id lz21-20020a170906fb1500b0072aa38d768esm4635263ejb.64.2022.07.12.23.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 23:54:49 -0700 (PDT) From: Michael Trimarchi To: Dario Binacchi , linux-amarula@amarulasolutions.com, Tommaso Merciai Subject: [PATCH 4/4] mtd: nand: Get rid of mtd variable in function calls Date: Wed, 13 Jul 2022 08:54:39 +0200 Message-Id: <20220713065439.272149-4-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713065439.272149-1-michael@amarulasolutions.com> References: <20220713065439.272149-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BYf4wsXF; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , chip points to mtd. Passing chip is enough to have a reference to mtd when is necessary Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 11 ++++++----- include/linux/mtd/rawnand.h | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 05886fa025..29c25f774e 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -83,7 +83,7 @@ static int mxs_flash_full_ident(struct mtd_info *mtd) struct nand_chip *chip = mtd_to_nand(mtd); struct nand_flash_dev *type; - type = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); + type = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, NULL); if (IS_ERR(type)) { chip->select_chip(mtd, -1); diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 02789789e9..d7537f18c7 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4152,8 +4152,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_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); } /* @@ -4432,11 +4433,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, +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; @@ -4724,7 +4725,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 57fe7fb47b..d8141cb4d1 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);