[PATCH] gpio: da8xx_gpio: Fix gpio name with address
From: chao zeng The GPIO bank numbers do not appear in the device tree, so make the gpio name based on the address (ie gpio@4211_25 vs 25) Signed-off-by: chao zeng --- drivers/gpio/da8xx_gpio.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/gpio/da8xx_gpio.c b/drivers/gpio/da8xx_gpio.c index d106e9846d..b310f2dbf6 100644 --- a/drivers/gpio/da8xx_gpio.c +++ b/drivers/gpio/da8xx_gpio.c @@ -545,12 +545,20 @@ static int davinci_gpio_of_to_plat(struct udevice *dev) { struct davinci_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t addr; + char name[18], *str; addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; plat->base = addr; + + sprintf(name, "gpio@%4x_", (unsigned int)plat->base); + str = strdup(name); + if (!str) + return -ENOMEM; + plat->port_name = str; + return 0; } -- 2.34.1
[PATCH V3] sf: Querying write-protect status before operating the flash
From: chao zeng When operating the write-protection flash,spi_flash_std_write() and spi_flash_std_erase() would return wrong result.The flash is protected, but write or erase the flash would show "OK". Check the flash write protection state before operating the flash and give a prompt to show it has been locked if the write-protection has enbale Signed-off-by: chao zeng --- Changes for V2: - Return 0 not ENOPROTOOPT to refelect the flash feature - Output prompt information Changes for V3: - Modify output information - Delete return statement --- drivers/mtd/spi/sf_probe.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index f461082e03..f9e879aec5 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -109,6 +109,9 @@ static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len, struct mtd_info *mtd = >mtd; size_t retlen; + if (flash->flash_is_locked && flash->flash_is_locked(flash, offset, len)) + printf("SF: Operate on the protected area.Writes will be ignored\n"); + return mtd->_write(mtd, offset, len, , buf); } @@ -127,6 +130,9 @@ static int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len) instr.addr = offset; instr.len = len; + if (flash->flash_is_locked && flash->flash_is_locked(flash, offset, len)) + printf("SF: Operate on the protected area.Erase will be ignored\n"); + return mtd->_erase(mtd, ); } -- 2.33.1
[PATCH v2] sf: Querying write-protect status before operating the flash
From: chao zeng When operating the write-protection flash,spi_flash_std_write() and spi_flash_std_erase() would return wrong result.The flash is protected, but write or erase the flash would show "OK". Check the flash write protection state before operating the flash and give a prompt to show it has been locked if the write-protection has enbale Signed-off-by: chao zeng --- Changes for V2: - Return 0 not ENOPROTOOPT to refelect the flash feature - Output prompt information --- drivers/mtd/spi/sf_probe.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index f461082e03..995801817d 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -109,6 +109,11 @@ static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len, struct mtd_info *mtd = >mtd; size_t retlen; + if (flash->flash_is_locked && flash->flash_is_locked(flash, offset, len)) { + printf("SF: Flash is locked\n"); + return 0; + } + return mtd->_write(mtd, offset, len, , buf); } @@ -127,6 +132,11 @@ static int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len) instr.addr = offset; instr.len = len; + if (flash->flash_is_locked && flash->flash_is_locked(flash, offset, len)) { + printf("SF: Flash is locked\n"); + return 0; + } + return mtd->_erase(mtd, ); } -- 2.33.1
Re:Re: [PATCH] sf: Querying write-protect status before operating the flash
HI jagan and ta I might have a different view, the caller can not get the correct response even though we can not operate the device sucessfully. I think it is necessary to return a valid value. if return 0, the device cannot actually be operated but the correct results are not possible BRs Chao At 2021-11-06 02:08:04, "Jagan Teki" wrote: >On Fri, Nov 5, 2021 at 10:47 PM wrote: >> >> Hi, >> >> On 6/22/21 8:21 AM, chao zeng wrote: >> > From: Chao Zeng >> > >> > When operating the write-protection flash,spi_flash_std_write() and >> > spi_flash_std_erase() would return wrong result.The flash is protected, >> > but write or erase the flash would show "OK". >> > >> > Check the flash write protection state if the write-protection has enbale >> > before operating the flash. >> > >> > Signed-off-by: Chao Zeng >> > --- >> > >> > drivers/mtd/spi/sf_probe.c | 10 ++ >> > 1 file changed, 10 insertions(+) >> > >> > diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c >> > index 3befbe91ca..f06e6b88bd 100644 >> > --- a/drivers/mtd/spi/sf_probe.c >> > +++ b/drivers/mtd/spi/sf_probe.c >> > @@ -109,6 +109,11 @@ static int spi_flash_std_write(struct udevice *dev, >> > u32 offset, size_t len, >> > struct mtd_info *mtd = >mtd; >> > size_t retlen; >> > >> > + if (flash->flash_is_locked && flash->flash_is_locked(flash, offset, >> > len)) { >> > + debug("SF: Flash is locked\n"); >> > + return -ENOPROTOOPT; >> >> Keep a debug message, but return 0 please. Writes or erases on protected >> areas >> are ignored by the flash, we should reflect that in the code. > >Agreed this point, Chao are you fine to do this change while applying it? > >Jagan.
Re:Re: [PATCH] sf: Querying write-protect status before operating the flash
HI Jagan sorry for the delay response. And I have checked the maser. There is still a problem with this feature。 reproduce steps: 1. enable the flash protect function 2. using sf cmd to erase the flash. I can get the erase "OK",not the "error". I think the root cause is that the detection mechanism is missing and to judge the permissions of the action So pull this PR to improve the erase flow another question: how can I visit the u-boot-spi/next? do there any link? BRs Chao At 2021-06-29 21:50:28, "Jagan Teki" wrote: >On Tue, Jun 22, 2021 at 10:51 AM chao zeng wrote: >> >> From: Chao Zeng >> >> When operating the write-protection flash,spi_flash_std_write() and >> spi_flash_std_erase() would return wrong result.The flash is protected, >> but write or erase the flash would show "OK". >> >> Check the flash write protection state if the write-protection has enbale >> before operating the flash. >> >> Signed-off-by: Chao Zeng >> --- > >Does it broken on master? if yes can you check in u-boot-spi/next? > >Jagan.