All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Wojtas <mw@semihalf.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	MTD Maling List <linux-mtd@lists.infradead.org>,
	linux-spi <linux-spi@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
	Marek Vasut <marek.vasut@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Nadav Haklai <nadavh@marvell.com>,
	Neta Zur Hershkovits <neta@marvell.com>,
	Omri Itach <omrii@marvell.com>, Hanna Hawa <hannah@marvell.com>,
	Grzegorz Jaszczyk <jaz@semihalf.com>,
	Tomasz Nowicki <tn@semihalf.com>
Subject: Re: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode
Date: Mon, 28 Aug 2017 23:54:03 +0200	[thread overview]
Message-ID: <CAPv3WKf3ra5tiK2gjQYUaTpiiM=kg=UGqceVesinqtjjk=RUnA@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdX0b=J9AuPAvdRXGGVXvc7f9n7TJ0_VKR13P05toq9REw@mail.gmail.com>

Hi Geert,

>> +- spi-3byte-addressing - Empty property indicating device access to be done
>> +                   only in 3byte addressing mode.
>
> spi-force-3byte-addressing?

I can change it, no problem. I thought of this, but was affraid if the
property wouldn't be too long.

>
>>  Some SPI controllers and devices support Dual and Quad SPI transfer mode.
>>  It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4
>> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
>> index 1413828..029c87d 100644
>> --- a/drivers/mtd/spi-nor/spi-nor.c
>> +++ b/drivers/mtd/spi-nor/spi-nor.c
>> @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>>                 if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
>>                     info->flags & SPI_NOR_4B_OPCODES)
>>                         spi_nor_set_4byte_opcodes(nor, info);
>> -               else
>> +               else if (of_property_read_bool(np, "spi-3byte-addressing")) {
>> +                       /*
>> +                        * Do not enter 4byte mode in order to prevent
>> +                        * the early bootloader to come up on non-default
>> +                        * SPI NOR memory during boot. Limit accessible
>> +                        * size to 16MiB.
>> +                        */
>> +                       nor->addr_width = 3;
>> +                       mtd->size = 0x1000000;
>
> What if the device is smaller than 16 MiB?
>
> mtd->size = min(mtd->size, 0x1000000);

Not needed - this code is executed only for mtd->size > 0x1000000. See
bigger context:

        if (info->addr_width)
                nor->addr_width = info->addr_width;
        else if (mtd->size > 0x1000000) {
                /* enable 4-byte addressing if the device exceeds 16MiB */
                nor->addr_width = 4;
                if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
                    info->flags & SPI_NOR_4B_OPCODES)
                        spi_nor_set_4byte_opcodes(nor, info);
                else if (of_property_read_bool(np, "spi-3byte-addressing")) {
                        /*
                         * Do not enter 4byte mode in order to prevent
                         * the early bootloader to come up on non-default
                         * SPI NOR memory during boot. Limit accessible
                         * size to 16MiB.
                         */
                        nor->addr_width = 3;
                        mtd->size = 0x1000000;
                        dev_info(dev, "Force 3B addressing mode\n");
                } else
                        set_4byte(nor, info, 1);
        } else {
                nor->addr_width = 3;
        }


Best regards,
Marcin

WARNING: multiple messages have this Message-ID (diff)
From: Marcin Wojtas <mw-nYOzD4b6Jr9Wk0Htik3J/w@public.gmane.org>
To: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	MTD Maling List
	<linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	linux-spi <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
	Cyrille Pitchen
	<cyrille.pitchen-yU5RGvR974pGWvitb5QawA@public.gmane.org>,
	Marek Vasut <marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Thomas Petazzoni
	<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Gregory Clement
	<gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Nadav Haklai <nadavh-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	Neta Zur Hershkovits
	<neta-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	Omri Itach <omrii-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	Hanna Hawa <hannah-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	Grzegorz Jaszczyk <jaz-nYOzD4b6Jr9Wk0Htik3J/w@public.gmane.org>,
	Tomasz Now
Subject: Re: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode
Date: Mon, 28 Aug 2017 23:54:03 +0200	[thread overview]
Message-ID: <CAPv3WKf3ra5tiK2gjQYUaTpiiM=kg=UGqceVesinqtjjk=RUnA@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdX0b=J9AuPAvdRXGGVXvc7f9n7TJ0_VKR13P05toq9REw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Geert,

>> +- spi-3byte-addressing - Empty property indicating device access to be done
>> +                   only in 3byte addressing mode.
>
> spi-force-3byte-addressing?

I can change it, no problem. I thought of this, but was affraid if the
property wouldn't be too long.

>
>>  Some SPI controllers and devices support Dual and Quad SPI transfer mode.
>>  It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4
>> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
>> index 1413828..029c87d 100644
>> --- a/drivers/mtd/spi-nor/spi-nor.c
>> +++ b/drivers/mtd/spi-nor/spi-nor.c
>> @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>>                 if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
>>                     info->flags & SPI_NOR_4B_OPCODES)
>>                         spi_nor_set_4byte_opcodes(nor, info);
>> -               else
>> +               else if (of_property_read_bool(np, "spi-3byte-addressing")) {
>> +                       /*
>> +                        * Do not enter 4byte mode in order to prevent
>> +                        * the early bootloader to come up on non-default
>> +                        * SPI NOR memory during boot. Limit accessible
>> +                        * size to 16MiB.
>> +                        */
>> +                       nor->addr_width = 3;
>> +                       mtd->size = 0x1000000;
>
> What if the device is smaller than 16 MiB?
>
> mtd->size = min(mtd->size, 0x1000000);

Not needed - this code is executed only for mtd->size > 0x1000000. See
bigger context:

        if (info->addr_width)
                nor->addr_width = info->addr_width;
        else if (mtd->size > 0x1000000) {
                /* enable 4-byte addressing if the device exceeds 16MiB */
                nor->addr_width = 4;
                if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
                    info->flags & SPI_NOR_4B_OPCODES)
                        spi_nor_set_4byte_opcodes(nor, info);
                else if (of_property_read_bool(np, "spi-3byte-addressing")) {
                        /*
                         * Do not enter 4byte mode in order to prevent
                         * the early bootloader to come up on non-default
                         * SPI NOR memory during boot. Limit accessible
                         * size to 16MiB.
                         */
                        nor->addr_width = 3;
                        mtd->size = 0x1000000;
                        dev_info(dev, "Force 3B addressing mode\n");
                } else
                        set_4byte(nor, info, 1);
        } else {
                nor->addr_width = 3;
        }


Best regards,
Marcin
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: mw@semihalf.com (Marcin Wojtas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode
Date: Mon, 28 Aug 2017 23:54:03 +0200	[thread overview]
Message-ID: <CAPv3WKf3ra5tiK2gjQYUaTpiiM=kg=UGqceVesinqtjjk=RUnA@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdX0b=J9AuPAvdRXGGVXvc7f9n7TJ0_VKR13P05toq9REw@mail.gmail.com>

Hi Geert,

>> +- spi-3byte-addressing - Empty property indicating device access to be done
>> +                   only in 3byte addressing mode.
>
> spi-force-3byte-addressing?

I can change it, no problem. I thought of this, but was affraid if the
property wouldn't be too long.

>
>>  Some SPI controllers and devices support Dual and Quad SPI transfer mode.
>>  It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4
>> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
>> index 1413828..029c87d 100644
>> --- a/drivers/mtd/spi-nor/spi-nor.c
>> +++ b/drivers/mtd/spi-nor/spi-nor.c
>> @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>>                 if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
>>                     info->flags & SPI_NOR_4B_OPCODES)
>>                         spi_nor_set_4byte_opcodes(nor, info);
>> -               else
>> +               else if (of_property_read_bool(np, "spi-3byte-addressing")) {
>> +                       /*
>> +                        * Do not enter 4byte mode in order to prevent
>> +                        * the early bootloader to come up on non-default
>> +                        * SPI NOR memory during boot. Limit accessible
>> +                        * size to 16MiB.
>> +                        */
>> +                       nor->addr_width = 3;
>> +                       mtd->size = 0x1000000;
>
> What if the device is smaller than 16 MiB?
>
> mtd->size = min(mtd->size, 0x1000000);

Not needed - this code is executed only for mtd->size > 0x1000000. See
bigger context:

        if (info->addr_width)
                nor->addr_width = info->addr_width;
        else if (mtd->size > 0x1000000) {
                /* enable 4-byte addressing if the device exceeds 16MiB */
                nor->addr_width = 4;
                if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
                    info->flags & SPI_NOR_4B_OPCODES)
                        spi_nor_set_4byte_opcodes(nor, info);
                else if (of_property_read_bool(np, "spi-3byte-addressing")) {
                        /*
                         * Do not enter 4byte mode in order to prevent
                         * the early bootloader to come up on non-default
                         * SPI NOR memory during boot. Limit accessible
                         * size to 16MiB.
                         */
                        nor->addr_width = 3;
                        mtd->size = 0x1000000;
                        dev_info(dev, "Force 3B addressing mode\n");
                } else
                        set_4byte(nor, info, 1);
        } else {
                nor->addr_width = 3;
        }


Best regards,
Marcin

  reply	other threads:[~2017-08-28 21:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 21:14 [PATCH 0/2] SPI NOR - force 3byte addressing mode Marcin Wojtas
2017-08-28 21:14 ` Marcin Wojtas
2017-08-28 21:14 ` Marcin Wojtas
2017-08-28 21:14 ` [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode Marcin Wojtas
2017-08-28 21:14   ` Marcin Wojtas
2017-08-28 21:18   ` Geert Uytterhoeven
2017-08-28 21:18     ` Geert Uytterhoeven
2017-08-28 21:18     ` Geert Uytterhoeven
2017-08-28 21:54     ` Marcin Wojtas [this message]
2017-08-28 21:54       ` Marcin Wojtas
2017-08-28 21:54       ` Marcin Wojtas
2017-08-28 21:54       ` Marcin Wojtas
2017-08-28 23:24   ` Marek Vasut
2017-08-28 23:24     ` Marek Vasut
2017-08-29  7:40     ` Marcin Wojtas
2017-08-29  7:40       ` Marcin Wojtas
2017-09-04 16:26   ` Pavel Machek
2017-09-04 16:26     ` Pavel Machek
2017-08-28 21:14 ` [PATCH 2/2] arm64: dts: marvell: Force 3byte addressing mode for SPI on A7040 DB Marcin Wojtas
2017-08-28 21:14   ` Marcin Wojtas

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='CAPv3WKf3ra5tiK2gjQYUaTpiiM=kg=UGqceVesinqtjjk=RUnA@mail.gmail.com' \
    --to=mw@semihalf.com \
    --cc=broonie@kernel.org \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=geert@linux-m68k.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=hannah@marvell.com \
    --cc=jaz@semihalf.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=marek.vasut@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=nadavh@marvell.com \
    --cc=neta@marvell.com \
    --cc=omrii@marvell.com \
    --cc=robh+dt@kernel.org \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=tn@semihalf.com \
    --cc=will.deacon@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.