[U-Boot] [PATCH v3 05/13] sf: Make flash->flags use for generic usage
Bin Meng
bmeng.cn at gmail.com
Tue Sep 15 08:32:47 CEST 2015
Hi Jagan,
On Wed, Sep 2, 2015 at 2:09 PM, Jagan Teki <jteki at openedev.com> wrote:
> Use the flash->flags for generic usage, not only for dm-spi-flash,
> this will be used for future flag additions.
>
> Signed-off-by: Jagan Teki <jteki at openedev.com>
> Cc: Bin Meng <bmeng.cn at gmail.com>
> ---
This v3 commit still breaks Intel Crown Bay. I've tested on latest
u-boot/master branch plus this single commit. A simple 'saveenv' just
erase all contents without reporting any error.
=> md ffe00000
ffe00000: a38ec887 64756162 65746172 3531313d ....baudrate=115
ffe00010: 00303032 746f6f62 73677261 6f6f723d 200.bootargs=roo
ffe00020: 642f3d74 732f7665 20336264 74696e69 t=/dev/sdb3 init
ffe00030: 62732f3d 692f6e69 2074696e 746f6f72 =/sbin/init root
ffe00040: 74696177 006f7220 746f6f62 3d646d63 wait ro.bootcmd=
ffe00050: 32747865 64616f6c 73637320 3a302069 ext2load scsi 0:
ffe00060: 31302033 30303030 2f203030 746f6f62 3 01000000 /boot
ffe00070: 6c6d762f 7a756e69 627a203b 20746f6f /vmlinuz; zboot
ffe00080: 30303130 30303030 6f6f6200 6c696674 01000000.bootfil
ffe00090: 7a623d65 67616d49 6f630065 6c6f736e e=bzImage.consol
ffe000a0: 76656465 7974743d 65003053 61316874 edev=ttyS0.eth1a
ffe000b0: 3d726464 313a3030 37313a35 3a63653a ddr=00:15:17:ec:
ffe000c0: 653a3165 74650038 64613268 303d7264 e1:e8.eth2addr=0
ffe000d0: 35313a30 3a37313a 653a6365 39653a31 0:15:17:ec:e1:e9
ffe000e0: 68746500 72646461 3a30303d 323a3331 .ethaddr=00:13:2
ffe000f0: 39663a30 3a65303a 67006439 77657461 0:f9:0e:9d.gatew
=> saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done
=> md ffe00000
ffe00000: ffffff01 ffffffff ffffffff ffffffff ................
Note there is a suspicious 01 at the first byte location. I think the
flash erase succeeded, but flash write does not and failed at the very
first byte. But I don't know why it does not report any error to
'saveenv' (the upper layer).
ffe00010: ffffffff ffffffff ffffffff ffffffff ................
ffe00020: ffffffff ffffffff ffffffff ffffffff ................
ffe00030: ffffffff ffffffff ffffffff ffffffff ................
ffe00040: ffffffff ffffffff ffffffff ffffffff ................
ffe00050: ffffffff ffffffff ffffffff ffffffff ................
ffe00060: ffffffff ffffffff ffffffff ffffffff ................
ffe00070: ffffffff ffffffff ffffffff ffffffff ................
ffe00080: ffffffff ffffffff ffffffff ffffffff ................
ffe00090: ffffffff ffffffff ffffffff ffffffff ................
ffe000a0: ffffffff ffffffff ffffffff ffffffff ................
ffe000b0: ffffffff ffffffff ffffffff ffffffff ................
ffe000c0: ffffffff ffffffff ffffffff ffffffff ................
ffe000d0: ffffffff ffffffff ffffffff ffffffff ................
ffe000e0: ffffffff ffffffff ffffffff ffffffff ..............
> Changes for v3:
> - none
> Changes for v2:
> - none
>
> drivers/mtd/spi/sf_internal.h | 4 ++++
> drivers/mtd/spi/sf_probe.c | 6 ++----
> include/spi_flash.h | 4 ++--
> 3 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
> index 9c95d56..53998fc 100644
> --- a/drivers/mtd/spi/sf_internal.h
> +++ b/drivers/mtd/spi/sf_internal.h
> @@ -51,6 +51,10 @@ enum {
>
> #define SST_WR (SST_BP | SST_WP)
>
> +enum spi_nor_option_flags {
> + SNOR_F_SST_WR = (1 << 0),
> +};
> +
> #define SPI_FLASH_3B_ADDR_LEN 3
> #define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)
> #define SPI_FLASH_16MB_BOUN 0x1000000
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index f17ec17..85390d4 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -163,15 +163,13 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
> flash->name = params->name;
> flash->memory_map = spi->memory_map;
> flash->dual_flash = flash->spi->option;
> -#ifdef CONFIG_DM_SPI_FLASH
> - flash->flags = params->flags;
> -#endif
>
> /* Assign spi_flash ops */
> #ifndef CONFIG_DM_SPI_FLASH
> flash->write = spi_flash_cmd_write_ops;
> #if defined(CONFIG_SPI_FLASH_SST)
> if (params->flags & SST_WR) {
> + flash->flags |= SNOR_F_SST_WR;
> if (flash->spi->op_mode_tx & SPI_OPM_TX_BP)
> flash->write = sst_write_bp;
> else
> @@ -466,7 +464,7 @@ int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
> struct spi_flash *flash = dev_get_uclass_priv(dev);
>
> #if defined(CONFIG_SPI_FLASH_SST)
> - if (flash->flags & SST_WR) {
> + if (flash->flags & SNOR_F_SST_WR) {
> if (flash->spi->op_mode_tx & SPI_OPM_TX_BP)
> return sst_write_bp(flash, offset, len, buf);
> else
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 3b2d555..8d85468 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -38,10 +38,10 @@ struct spi_slave;
> *
> * @spi: SPI slave
> * @dev: SPI flash device
> - * @flags: Indication of spi flash flags
> * @name: Name of SPI flash
> * @dual_flash: Indicates dual flash memories - dual stacked, parallel
> * @shift: Flash shift useful in dual parallel
> + * @flags: Indication of spi flash flags
> * @size: Total flash size
> * @page_size: Write (page) size
> * @sector_size: Sector size
> @@ -67,11 +67,11 @@ struct spi_flash {
> struct spi_slave *spi;
> #ifdef CONFIG_DM_SPI_FLASH
> struct udevice *dev;
> - u16 flags;
> #endif
> const char *name;
> u8 dual_flash;
> u8 shift;
> + u16 flags;
>
> u32 size;
> u32 page_size;
> --
Regards,
Bin
More information about the U-Boot
mailing list