2019-03-28 04:04:02

by Chris Packham

[permalink] [raw]
Subject: [PATCH 0/2] mtd: physmap: Using gpio-addrs

I have a system with ADDR24 of the flash chip connected to a gpio pin. This
series fixes a bug in physmap-core.c and adds an example for using gpio-addrs
to the dt-binding based on the system I'm using.

Chris Packham (2):
mtd: maps: physmap: Store gpio_values correctly
dt-binding: mtd: physmap: Add example using addr-gpios property

.../devicetree/bindings/mtd/mtd-physmap.txt | 16 ++++++++++++++++
drivers/mtd/maps/physmap-core.c | 2 ++
2 files changed, 18 insertions(+)

--
2.21.0



2019-03-28 04:04:02

by Chris Packham

[permalink] [raw]
Subject: [PATCH 1/2] mtd: maps: physmap: Store gpio_values correctly

When the gpio-addr-flash.c driver was merged with physmap-core.c the
code to store the current gpio_values was lost. This meant that once a
gpio was asserted it was never de-asserted. Fix this by storing the
current offset in gpio_values like the old driver used to.

Fixes: commit ba32ce95cbd9 ("mtd: maps: Merge gpio-addr-flash.c into physmap-core.c")
Signed-off-by: Chris Packham <[email protected]>
---
drivers/mtd/maps/physmap-core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index d9a3e4bebe5d..21b556afc305 100644
--- a/drivers/mtd/maps/physmap-core.c
+++ b/drivers/mtd/maps/physmap-core.c
@@ -132,6 +132,8 @@ static void physmap_set_addr_gpios(struct physmap_flash_info *info,

gpiod_set_value(info->gpios->desc[i], !!(BIT(i) & ofs));
}
+
+ info->gpio_values = ofs;
}

#define win_mask(order) (BIT(order) - 1)
--
2.21.0


2019-03-28 04:05:37

by Chris Packham

[permalink] [raw]
Subject: [PATCH 2/2] dt-binding: mtd: physmap: Add example using addr-gpios property

Add an example showing how to use the addr-gpios property to deal with a
system with limited IO space.

Cc: [email protected]
Signed-off-by: Chris Packham <[email protected]>
---
.../devicetree/bindings/mtd/mtd-physmap.txt | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
index 7df0dcaccb7d..c69f4f065d23 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
@@ -96,3 +96,19 @@ An example using SRAM:
bank-width = <2>;
};

+An example using gpio-addrs
+
+ flash@20000000 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "cfi-flash", "jedec-flash";
+ reg = <0x20000000 0x02000000>;
+ ranges = <0 0x00000000 0x02000000
+ 1 0x02000000 0x02000000>;
+ bank-width = <2>;
+ addr-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
+ partition@0 {
+ label = "test-part1";
+ reg = <0 0x04000000>;
+ };
+ };
--
2.21.0


2019-03-28 08:33:35

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 1/2] mtd: maps: physmap: Store gpio_values correctly

On Thu, 28 Mar 2019 17:02:15 +1300
Chris Packham <[email protected]> wrote:

> When the gpio-addr-flash.c driver was merged with physmap-core.c the
> code to store the current gpio_values was lost. This meant that once a
> gpio was asserted it was never de-asserted. Fix this by storing the
> current offset in gpio_values like the old driver used to.
>
> Fixes: commit ba32ce95cbd9 ("mtd: maps: Merge gpio-addr-flash.c into physmap-core.c")

You miss

Cc: <[email protected]>

> Signed-off-by: Chris Packham <[email protected]>

Reviewed-by: Boris Brezillon <[email protected]>

> ---
> drivers/mtd/maps/physmap-core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
> index d9a3e4bebe5d..21b556afc305 100644
> --- a/drivers/mtd/maps/physmap-core.c
> +++ b/drivers/mtd/maps/physmap-core.c
> @@ -132,6 +132,8 @@ static void physmap_set_addr_gpios(struct physmap_flash_info *info,
>
> gpiod_set_value(info->gpios->desc[i], !!(BIT(i) & ofs));
> }
> +
> + info->gpio_values = ofs;
> }
>
> #define win_mask(order) (BIT(order) - 1)


2019-03-28 20:01:28

by Chris Packham

[permalink] [raw]
Subject: Re: [PATCH 1/2] mtd: maps: physmap: Store gpio_values correctly

On 28/03/19 9:32 PM, Boris Brezillon wrote:
> On Thu, 28 Mar 2019 17:02:15 +1300
> Chris Packham <[email protected]> wrote:
>
>> When the gpio-addr-flash.c driver was merged with physmap-core.c the
>> code to store the current gpio_values was lost. This meant that once a
>> gpio was asserted it was never de-asserted. Fix this by storing the
>> current offset in gpio_values like the old driver used to.
>>
>> Fixes: commit ba32ce95cbd9 ("mtd: maps: Merge gpio-addr-flash.c into physmap-core.c")
>
> You miss
>
> Cc: <[email protected]>
>

I wasn't sure. As the original commit said there are no in-tree users of
addr-gpios so maybe no-one else noticed. I'll wait for any other
comments and send a v2 with a Cc for stable.

>> Signed-off-by: Chris Packham <[email protected]>
>
> Reviewed-by: Boris Brezillon <[email protected]>
>
>> ---
>> drivers/mtd/maps/physmap-core.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
>> index d9a3e4bebe5d..21b556afc305 100644
>> --- a/drivers/mtd/maps/physmap-core.c
>> +++ b/drivers/mtd/maps/physmap-core.c
>> @@ -132,6 +132,8 @@ static void physmap_set_addr_gpios(struct physmap_flash_info *info,
>>
>> gpiod_set_value(info->gpios->desc[i], !!(BIT(i) & ofs));
>> }
>> +
>> + info->gpio_values = ofs;
>> }
>>
>> #define win_mask(order) (BIT(order) - 1)
>
>