public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Michael Walle <mwalle@kernel.org>
To: Jaime Liao <jaimeliao.tw@gmail.com>
Cc: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org,
	pratyush@kernel.org, miquel.raynal@bootlin.com,
	leoyu@mxic.com.tw, JaimeLiao <jaimeliao@mxic.com.tw>
Subject: Re: [PATCH v3 2/5] mtd: spi-nor: core: Hook manufacture by checking first byte ID
Date: Mon, 07 Aug 2023 08:37:44 +0200	[thread overview]
Message-ID: <70e42ee5e4c5aba05ac896cb94956f25@kernel.org> (raw)
In-Reply-To: <20230804095409.278419-3-jaimeliao.tw@gmail.com>

Am 2023-08-04 11:54, schrieb Jaime Liao:
> From: JaimeLiao <jaimeliao@mxic.com.tw>
> 
> Patch ID for flash support is a thing that we keep striving to do.
> Follow the optimization of software architecture, parse SFDP is
> the mainstream in SPI-NOR subsystem.
> Label "spi-nor-generic" to the flash which didn't include in ID table
> but support SFDP, is a good way for flash support.
> Building upon this fundation, achieve hooking the manufacturer using 
> the
> 1st ID byte.

This won't work beacuse the manufacturer id is not always
one byte long, think of continuation codes. In fact, as the
flash_info table is of now, we cannot even rely on the
continuation codes, but we have to always check for the
complete id_len, i.e. there is at least one hack where
the id is reversed and the manufacturer is the last byte,
iirc. some oddball cypress mram chip.

If you want to get the correct manufacturer for spi-nor-generic,
you should extract it from the SFDP tables. It seems that the
BFPT don't include a manufacturer id, but if there are proprietary
tables, you *might* use that id. I say might, because it only works
with one byte manufacturer ids, no continuation codes... *sigh*

-michael


> Consequently, extend support even for parts not descibed in SFDP.
> 
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> ---
>  drivers/mtd/spi-nor/core.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 5f29fac8669a..eb0a09c06bf4 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2036,10 +2036,13 @@ static const struct flash_info 
> *spi_nor_match_id(struct spi_nor *nor,
>  	for (i = 0; i < ARRAY_SIZE(manufacturers); i++) {
>  		for (j = 0; j < manufacturers[i]->nparts; j++) {
>  			part = &manufacturers[i]->parts[j];
> -			if (part->id_len &&
> -			    !memcmp(part->id, id, part->id_len)) {
> -				nor->manufacturer = manufacturers[i];
> -				return part;
> +			if (part->id_len) {
> +				/* Hook manufacturers when first byte (maf ID) is same as other 
> IDs on ID table */
> +				if (!nor->manufacturer && !memcmp(part->id, id, 1))
> +					nor->manufacturer = manufacturers[i];
> +
> +				if (!memcmp(part->id, id, part->id_len))
> +					return part;
>  			}
>  		}
>  	}

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2023-08-07  6:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04  9:54 [PATCH v3 0/5] Add octal DTR support for Macronix flash Jaime Liao
2023-08-04  9:54 ` [PATCH v3 1/5] mtd: spi-nor: add Octal " Jaime Liao
2023-08-07  6:44   ` Michael Walle
2023-08-04  9:54 ` [PATCH v3 2/5] mtd: spi-nor: core: Hook manufacture by checking first byte ID Jaime Liao
2023-08-07  6:37   ` Michael Walle [this message]
2023-08-09  1:04     ` liao jaime
2023-08-10  7:27       ` Michael Walle
2023-08-11  9:03         ` liao jaime
2023-08-11 10:11           ` Tudor Ambarus
2023-08-14  8:04             ` liao jaime
2023-08-11 10:20           ` Michael Walle
2023-08-14  8:24             ` liao jaime
2023-08-31  3:18               ` liao jaime
2023-09-04 14:54                 ` Michael Walle
2023-08-04  9:54 ` [PATCH v3 3/5] spi: spi-mem: Allow specifying the byte order in DTR mode Jaime Liao
2023-08-07  6:40   ` Michael Walle
2023-08-09  1:36     ` liao jaime
2023-08-10  7:31       ` Michael Walle
2023-08-04  9:54 ` [PATCH v3 4/5] mtd: spi-nor: core: " Jaime Liao
2023-08-04  9:54 ` [PATCH v3 5/5] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT Jaime Liao
2023-08-07  6:42 ` [PATCH v3 0/5] Add octal DTR support for Macronix flash Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70e42ee5e4c5aba05ac896cb94956f25@kernel.org \
    --to=mwalle@kernel.org \
    --cc=jaimeliao.tw@gmail.com \
    --cc=jaimeliao@mxic.com.tw \
    --cc=leoyu@mxic.com.tw \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=pratyush@kernel.org \
    --cc=tudor.ambarus@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox