Enhance SPI/SPI flash probing, add support for Intel ICH controller
Subsystems (10)
v2 cover Enhance SPI/SPI flash probing, add support for Intel ICH controller
Adding new fields to struct spi_slave and struct spi_flash is painful, because most drivers don't zero the fields they don't use. Anyway it seems better to have the SPI/SPI flash infrastructure provide a simple way of doing this that all drivers can use.
So the first part of this series adds spi_alloc_slave(), for SPI, and spi_flash_alloc() for SPI flash.
Support is added for the Intel ICH SPI controller, possibly the oddest SPI controller in U-Boot. It is designed for use with SPI flash only, and has a number of high-level features which are dedicated to flash. As such it is a bit of a challenge to get it to behave just like a normal U-Boot SPI device.
The ICH driver has two interesting features. Firstly it is impossible to read or write more than 64 bytes at a time! For SPI reading it is possible to hide this within the SPI driver. For SPI writing it unfortunately isn't, since the spi_flash layer has to send an unlock command and a new address for every write. It would be an egregious hack to try to fake this in the driver. So a new property is added to spi_flash to allow the maximum transfer size to be set.
Secondly, the ICH SPI flash can be memory mapped. On a lot of x86 devices this improves performance significantly. For example, the standard driver gets maybe 12Mbps throughput from a 33Mbps dual interface, roughly 20% utilisation. With memory mapping, many platforms can achieve about 40Mbps. To implement memory mapping, a new property is provided in the device tree to set the memory map address, which varies by platform. Some x86 platforms will see a speed increase with memory mapping, some won't. The memory mapping feature only works for reading. When in use, the spi_flash layer bypasses the SPI driver completely, and just copies the flash data from the correct place in the memory map.
Changes in v2:
- Use spi_alloc_slave() in bfin_spi6xx.c
- Use spi_alloc_slave() in exynos_spi.c
- Support both 33MHz and 20MHz operation in ich driver
- Replace while() loop with memcpy_to/fromio() in ich driver
- Enable gettime command for coreboot also
- Add new patch to use unsigned type for buffers in 'sf test'
Simon Glass (15):
fdt: Add fdtdec_get_addr_size() to read reg properties
spi: Add function to allocate a new SPI slave
spi: Use spi_alloc_slave() in each SPI driver
sf: Add spi_flash_alloc() to create a new SPI flash struct
sf: Use spi_flash_alloc() in each SPI flash driver
x86: spi: Add Intel ICH driver
spi: Add parameter for maximum write size
sf: Respect maximum SPI write size
x86: spi: Set maximum write size for ICH
sf: Enable FDT-based configuration and memory mapping
x86: Move PCI init before SPI init
x86: Add FDT SPI node for link
x86: Enable SPI flash support for coreboot
x86: Enable time command for coreboot
sf: Use unsigned type for buffers
arch/x86/lib/board.c | 8 +- board/chromebook-x86/dts/link.dts | 11 + common/cmd_sf.c | 8 +- drivers/mtd/spi/atmel.c | 8 +- drivers/mtd/spi/eon.c | 8 +- drivers/mtd/spi/macronix.c | 8 +- drivers/mtd/spi/ramtron.c | 4 +- drivers/mtd/spi/spansion.c | 8 +- drivers/mtd/spi/spi_flash.c | 81 +++- drivers/mtd/spi/sst.c | 8 +- drivers/mtd/spi/stmicro.c | 8 +- drivers/mtd/spi/winbond.c | 8 +- drivers/spi/Makefile | 4 + drivers/spi/altera_spi.c | 4 +- drivers/spi/andes_spi.c | 4 +- drivers/spi/armada100_spi.c | 4 +- drivers/spi/atmel_spi.c | 4 +- drivers/spi/bfin_spi.c | 4 +- drivers/spi/bfin_spi6xx.c | 4 +- drivers/spi/cf_qspi.c | 4 +- drivers/spi/cf_spi.c | 4 +- drivers/spi/davinci_spi.c | 4 +- drivers/spi/exynos_spi.c | 4 +- drivers/spi/fsl_espi.c | 4 +- drivers/spi/ich.c | 755 ++++++++++++++++++++++++++++++++++++++ drivers/spi/ich.h | 144 ++++++++ drivers/spi/kirkwood_spi.c | 5 +- drivers/spi/mpc52xx_spi.c | 5 +- drivers/spi/mpc8xxx_spi.c | 5 +- drivers/spi/mxc_spi.c | 4 +- drivers/spi/mxs_spi.c | 4 +- drivers/spi/oc_tiny_spi.c | 5 +- drivers/spi/omap3_spi.c | 27 +- drivers/spi/sh_spi.c | 4 +- drivers/spi/soft_spi.c | 4 +- drivers/spi/spi.c | 39 ++ drivers/spi/tegra_slink.c | 4 +- drivers/spi/tegra_spi.c | 4 +- drivers/spi/xilinx_spi.c | 4 +- include/configs/coreboot.h | 14 +- include/fdtdec.h | 16 + include/spi.h | 44 +++ include/spi_flash.h | 39 ++ lib/fdtdec.c | 27 +- 44 files changed, 1215 insertions(+), 154 deletions(-) create mode 100644 drivers/spi/ich.c create mode 100644 drivers/spi/ich.h create mode 100644 drivers/spi/spi.c
Signature · 1 line
1.8.1.3
PATCH v2 1/15 fdt: Add fdtdec_get_addr_size() to read reg properties
It is common to have a "reg = <address size>" property in the FDT. Add a function to handle this, similar to the existing fdtdec_get_addr();
---
Changes in v2: None
include/fdtdec.h | 15 +++++++++++++++ lib/fdtdec.c | 26 +++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-)
include/fdtdec.h +15 -0
@@ -38,11 +38,13 @@*/ #ifdef CONFIG_PHYS_64BIT typedef u64 fdt_addr_t ; +typedef u64 fdt_size_t ;#define FDT_ADDR_T_NONE (-1ULL)#define fdt_addr_to_cpu (reg) be64_to_cpu(reg)#define fdt_size_to_cpu (reg) be64_to_cpu(reg)#else typedef u32 fdt_addr_t ; +typedef u32 fdt_size_t ;#define FDT_ADDR_T_NONE (-1U)#define fdt_addr_to_cpu (reg) be32_to_cpu(reg)#define fdt_size_to_cpu (reg) be32_to_cpu(reg)
@@ -197,6 +199,19 @@ fdt_addr_t fdtdec_get_addr(const void *blob, int node, const char *prop_name);/** +* Look up an address property in a node and return it as an address. +* The property must hold one address with a length. This is only tested +* on 32-bit machines. +* +* @param blob FDT blob +* @param node node to examine +* @param prop_name name of property to find +* @return address, if found, or FDT_ADDR_T_NONE if not +*/ +fdt_addr_t fdtdec_get_addr_size (const void *blob,int node, +const char *prop_name,fdt_size_t *sizep); + +/** * Look up a 32-bit integer property in a node and return it. The property * must have at least 4 bytes of data. The value of the first cell is * returned.
lib/fdtdec.c +21 -5
@@ -65,25 +65,41 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id)return compat_names[id]; } -fdt_addr_t fdtdec_get_addr (const void *blob,int node, -const char *prop_name) +fdt_addr_t fdtdec_get_addr_size (const void *blob,int node, +const char *prop_name,fdt_size_t *sizep) {const fdt_addr_t *cell;int len;debug ("%s: %s: " , __func__, prop_name); cell =fdt_getprop (blob, node, prop_name, &len); -if (cell && (len ==sizeof (fdt_addr_t) || +if (cell && ((!sizep && len ==sizeof (fdt_addr_t)) || len ==sizeof (fdt_addr_t) *2 )) { -fdt_addr_t addr =fdt_addr_to_cpu (*cell); -debug ("%p\n" , (void *)addr); +fdt_addr_t addr =fdt_addr_to_cpu (*cell); +if (sizep) { +const fdt_size_t *size; + + size = (fdt_size_t *)((char *)cell + +sizeof (fdt_addr_t)); + *sizep =fdt_size_to_cpu (*size); +debug ("addr=%p, size=%p\n" , (void *)addr, + (void *)*sizep); + }else { +debug ("%p\n" , (void *)addr); + }return addr; }debug ("(not found)\n" );return FDT_ADDR_T_NONE ; } +fdt_addr_t fdtdec_get_addr (const void *blob,int node, +const char *prop_name) +{ +return fdtdec_get_addr_size (blob, node, prop_name,NULL ); +} +s32 fdtdec_get_int (const void *blob,int node,const char *prop_name,s32 default_val) {
Signature · 1 line
1.8.1.3
PATCH v2 2/15 spi: Add function to allocate a new SPI slave
In reply to Simon GlassAt present it is difficult to extend the SPI structure since all drivers allocate it themselves, and few of them zero all fields. Add a new function spi_alloc_slave() which can be used by SPI drivers to perform this allocation, and thus ensure that all drivers can better cope with SPI structure changes.
---
Changes in v2: None
drivers/spi/Makefile | 3 +++ drivers/spi/spi.c | 39 +++++++++++++++++++++++++++++++++++++++ include/spi.h | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 drivers/spi/spi.c
drivers/spi/Makefile +3 -0
@@ -25,6 +25,9 @@ include $(TOPDIR)/config.mk LIB := $(obj)libspi.o +# There are many options which enable SPI, so make this library available +COBJS-y += spi.o + COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o COBJS-$(CONFIG_ANDES_SPI) += andes_spi.o COBJS-$(CONFIG_ARMADA100_SPI) += armada100_spi.o
drivers/spi/spi.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (c) 2011 The Chromium OS Authors. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but without any warranty; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#include <common.h> +#include <malloc.h> +#include <spi.h> + +void *spi_do_alloc_slave (int offset,int size,unsigned int bus, +unsigned int cs) +{ +struct spi_slave *slave; +void *ptr; + + ptr =malloc (size); +if (ptr) { +memset (ptr,'\0' , size); + slave = (struct spi_slave *)(ptr + offset); + slave->bus = bus; + slave->cs = cs; + } + +return ptr; +}
include/spi.h +41 -0
47 lines not on this page · raw message
Signature · 1 line
1.8.1.3
PATCH v2 3/15 spi: Use spi_alloc_slave() in each SPI driver
In reply to Simon GlassRather than each driver having its own way to allocate a SPI slave, use the new allocation function everywhere. This will make it easier to extend the interface without breaking drivers.
---
Changes in v2:
- Use spi_alloc_slave() in bfin_spi6xx.c
- Use spi_alloc_slave() in exynos_spi.c
drivers/spi/altera_spi.c | 4 +--- drivers/spi/andes_spi.c | 4 +--- drivers/spi/armada100_spi.c | 4 +--- drivers/spi/atmel_spi.c | 4 +--- drivers/spi/bfin_spi.c | 4 +--- drivers/spi/bfin_spi6xx.c | 4 +--- drivers/spi/cf_qspi.c | 4 +--- drivers/spi/cf_spi.c | 4 +--- drivers/spi/davinci_spi.c | 4 +--- drivers/spi/exynos_spi.c | 4 +--- drivers/spi/fsl_espi.c | 4 +--- drivers/spi/kirkwood_spi.c | 5 +---- drivers/spi/mpc52xx_spi.c | 5 +---- drivers/spi/mpc8xxx_spi.c | 5 +---- drivers/spi/mxc_spi.c | 4 +--- drivers/spi/mxs_spi.c | 4 +--- drivers/spi/oc_tiny_spi.c | 5 +---- drivers/spi/omap3_spi.c | 27 ++++++++++++++------------- drivers/spi/sh_spi.c | 4 +--- drivers/spi/soft_spi.c | 4 +--- drivers/spi/tegra_slink.c | 4 +--- drivers/spi/tegra_spi.c | 4 +--- drivers/spi/xilinx_spi.c | 4 +--- 23 files changed, 36 insertions(+), 83 deletions(-)
drivers/spi/altera_spi.c +1 -3
@@ -83,12 +83,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - altspi =malloc (sizeof (*altspi)); + altspi = spi_alloc_slave(struct altera_spi_slave, bus, cs);if (!altspi)return NULL ; - altspi->slave.bus = bus; - altspi->slave.cs = cs; altspi->base = altera_spi_base_list[bus];debug ("%s: bus:%i cs:%i base:%lx\n" , __func__, bus, cs, altspi->base);
drivers/spi/andes_spi.c +1 -3
@@ -53,12 +53,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - ds =malloc (sizeof (*ds)); + ds = spi_alloc_slave(struct andes_spi_slave, bus, cs);if (!ds)return NULL ; - ds->slave.bus = bus; - ds->slave.cs = cs; ds->regs = (struct andes_spi_regs *)CONFIG_SYS_SPI_BASE ;/*
drivers/spi/armada100_spi.c +1 -3
@@ -120,12 +120,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, {struct armd_spi_slave *pss; - pss =malloc (sizeof (*pss)); + pss = spi_alloc_slave(struct armd_spi_slave, bus, cs);if (!pss)return NULL ; - pss->slave.bus = bus; - pss->slave.cs = cs; pss->spi_reg = (struct ssp_reg *)SSP_REG_BASE (CONFIG_SYS_SSP_PORT ); pss->cr0 =SSCR0_MOTO |SSCR0_DATASIZE (DEFAULT_WORD_LEN ) |SSCR0_SSE ;
drivers/spi/atmel_spi.c +1 -3
@@ -84,12 +84,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (mode &SPI_CPOL ) csrx |= ATMEL_SPI_CSRx_CPOL; - as =malloc (sizeof (struct atmel_spi_slave )); + as = spi_alloc_slave(struct atmel_spi_slave, bus, cs);if (!as)return NULL ; - as->slave.bus = bus; - as->slave.cs = cs; as->regs = regs; as->mr = ATMEL_SPI_MR_MSTR | ATMEL_SPI_MR_MODFDIS#if defined(CONFIG_AT91SAM9X5 ) || defined(CONFIG_AT91SAM9M10G45 )
drivers/spi/bfin_spi.c +1 -3
@@ -182,12 +182,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,default :return NULL ; } - bss =malloc (sizeof (*bss)); + bss = spi_alloc_slave(struct bfin_spi_slave, bus, cs);if (!bss)return NULL ; - bss->slave.bus = bus; - bss->slave.cs = cs; bss->mmr_base = (void *)mmr_base; bss->ctl =SPE |MSTR |TDBR_CORE ;if (mode &SPI_CPHA ) bss->ctl |=CPHA ;
drivers/spi/bfin_spi6xx.c +1 -3
@@ -178,12 +178,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,return NULL ; } - bss =malloc (sizeof (*bss)); + bss = spi_alloc_slave(struct bfin_spi_slave, bus, cs);if (!bss)return NULL ; - bss->slave.bus = bus; - bss->slave.cs = cs; bss->regs = (struct bfin_spi_regs *)reg_base; bss->control =SPI_CTL_EN |SPI_CTL_MSTR ;if (mode &SPI_CPHA )
drivers/spi/cf_qspi.c +1 -3
@@ -120,13 +120,11 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - dev =malloc (sizeof (struct cf_qspi_slave )); + dev = spi_alloc_slave(struct cf_qspi_slave, bus, cs);if (!dev)return NULL ;/* Initialize to known value */ - dev->slave.bus = bus; - dev->slave.cs = cs; dev->regs = (qspi_t *)MMAP_QSPI ; dev->qmr =0 ; dev->qwr =0 ;
drivers/spi/cf_spi.c +1 -3
@@ -330,12 +330,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - cfslave =malloc (sizeof (struct cf_spi_slave )); + cfslave = spi_alloc_slave(struct cf_spi_slave, bus, cs);if (!cfslave)return NULL ; - cfslave->slave.bus = bus; - cfslave->slave.cs = cs; cfslave->baudrate = max_hz;/* specific setup */
drivers/spi/davinci_spi.c +1 -3
@@ -44,12 +44,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - ds =malloc (sizeof (*ds)); + ds = spi_alloc_slave(struct davinci_spi_slave, bus, cs);if (!ds)return NULL ; - ds->slave.bus = bus; - ds->slave.cs = cs; ds->regs = (struct davinci_spi_regs *)CONFIG_SYS_SPI_BASE ; ds->freq = max_hz;
drivers/spi/exynos_spi.c +1 -3
@@ -89,15 +89,13 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs,return NULL ; } - spi_slave =malloc (sizeof (*spi_slave)); + spi_slave = spi_alloc_slave(struct exynos_spi_slave, busnum, cs);if (!spi_slave) {debug ("%s: Could not allocate spi_slave\n" , __func__);return NULL ; } bus = &spi_bus[busnum]; - spi_slave->slave.bus = busnum; - spi_slave->slave.cs = cs; spi_slave->regs = bus->regs; spi_slave->mode = mode; spi_slave->periph_id = bus->periph_id;
drivers/spi/fsl_espi.c +1 -3
@@ -79,12 +79,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - fsl =malloc (sizeof (struct fsl_spi_slave )); + fsl = spi_alloc_slave(struct fsl_spi_slave, bus, cs);if (!fsl)return NULL ; - fsl->slave.bus = bus; - fsl->slave.cs = cs; fsl->mode = mode; fsl->max_transfer_length =ESPI_MAX_DATA_TRANSFER_LEN ;
drivers/spi/kirkwood_spi.c +1 -4
@@ -49,13 +49,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - slave =malloc (sizeof (struct spi_slave )); + slave =spi_alloc_slave_base (bus, cs);if (!slave)return NULL ; - slave->bus = bus; - slave->cs = cs; -writel (~KWSPI_CSN_ACT |KWSPI_SMEMRDY , &spireg->ctrl);/* calculate spi clock prescaller using max_hz */
drivers/spi/mpc52xx_spi.c +1 -4
@@ -48,13 +48,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, {struct spi_slave *slave; - slave =malloc (sizeof (struct spi_slave )); + slave =spi_alloc_slave_base (bus, cs);if (!slave)return NULL ; - slave->bus = bus; - slave->cs = cs; -return slave; }
drivers/spi/mpc8xxx_spi.c +1 -4
@@ -45,13 +45,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - slave =malloc (sizeof (struct spi_slave )); + slave =spi_alloc_slave_base (bus, cs);if (!slave)return NULL ; - slave->bus = bus; - slave->cs = cs; -/* * TODO: Some of the code in spi_init() should probably move * here, or into spi_claim_bus() below.
drivers/spi/mxc_spi.c +1 -3
@@ -408,7 +408,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (bus >=ARRAY_SIZE (spi_bases))return NULL ; - mxcs =calloc (sizeof (struct mxc_spi_slave ),1 ); + mxcs = spi_alloc_slave(struct mxc_spi_slave, bus, cs);if (!mxcs) {puts ("mxc_spi: SPI Slave not allocated !\n" );return NULL ;
@@ -424,8 +424,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, cs = ret; - mxcs->slave.bus = bus; - mxcs->slave.cs = cs; mxcs->base = spi_bases[bus]; ret =spi_cfg_mxc (mxcs, cs, max_hz, mode);
drivers/spi/mxs_spi.c +1 -3
@@ -88,15 +88,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,return NULL ; } - mxs_slave =calloc (sizeof (struct mxs_spi_slave ),1 ); + mxs_slave = spi_alloc_slave(struct mxs_spi_slave, bus, cs);if (!mxs_slave)return NULL ;if (mxs_dma_init_channel (bus)) goto err_init; - mxs_slave->slave.bus = bus; - mxs_slave->slave.cs = cs; mxs_slave->max_khz = max_hz /1000 ; mxs_slave->mode = mode; mxs_slave->regs =mxs_ssp_regs_by_bus (bus);
drivers/spi/oc_tiny_spi.c +1 -4
@@ -90,13 +90,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs) ||gpio_request (cs,"tiny_spi" ))return NULL ; - tiny_spi =malloc (sizeof (*tiny_spi)); + tiny_spi = spi_alloc_slave(struct tiny_spi_slave, bus, cs);if (!tiny_spi)return NULL ; -memset (tiny_spi,0 ,sizeof (*tiny_spi)); - tiny_spi->slave.bus = bus; - tiny_spi->slave.cs = cs; tiny_spi->host = &tiny_spi_host_list[bus]; tiny_spi->mode = mode & (SPI_CPOL |SPI_CPHA ); tiny_spi->flg = mode &SPI_CS_HIGH ?1 :0 ;
drivers/spi/omap3_spi.c +14 -13
@@ -80,12 +80,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int mode) {struct omap3_spi_slave *ds; - - ds =malloc (sizeof (struct omap3_spi_slave )); -if (!ds) { -printf ("SPI error: malloc of SPI structure failed\n" ); -return NULL ; - } +struct mcspi *regs;/* * OMAP3 McSPI (MultiChannel SPI) has 4 busses (modules)
@@ -98,21 +93,21 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,switch (bus) {case 0 : - ds->regs = (struct mcspi *)OMAP3_MCSPI1_BASE ; + regs = (struct mcspi *)OMAP3_MCSPI1_BASE ;break ;#ifdef OMAP3_MCSPI2_BASE case 1 : - ds->regs = (struct mcspi *)OMAP3_MCSPI2_BASE ; + regs = (struct mcspi *)OMAP3_MCSPI2_BASE ;break ;#endif #ifdef OMAP3_MCSPI3_BASE case 2 : - ds->regs = (struct mcspi *)OMAP3_MCSPI3_BASE ; + regs = (struct mcspi *)OMAP3_MCSPI3_BASE ;break ;#endif #ifdef OMAP3_MCSPI4_BASE case 3 : - ds->regs = (struct mcspi *)OMAP3_MCSPI4_BASE ; + regs = (struct mcspi *)OMAP3_MCSPI4_BASE ;break ;#endif default :
@@ -120,7 +115,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, Supported busses 0 - 3\n", bus); return NULL; } - ds->slave.bus = bus; if (((bus == 0) && (cs > 3)) || ((bus == 1) && (cs > 1)) ||
@@ -130,19 +124,26 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, on bus %i\n", cs, bus);return NULL ; } - ds->slave.cs = cs;if (max_hz >OMAP3_MCSPI_MAX_FREQ ) {printf ("SPI error: unsupported frequency %i Hz. \ Max frequency is 48 Mhz\n" , max_hz);return NULL ; } - ds->freq = max_hz;if (mode >SPI_MODE_3 ) {printf ("SPI error: unsupported SPI mode %i\n" , mode);return NULL ; } + + ds = spi_alloc_slave(struct omap3_spi_slave, bus, cs); +if (!ds) { +printf ("SPI error: malloc of SPI structure failed\n" ); +return NULL ; + } + + ds->regs = regs; + ds->freq = max_hz; ds->mode = mode;return &ds->slave;
drivers/spi/sh_spi.c +1 -3
@@ -103,12 +103,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - ss =malloc (sizeof (struct spi_slave )); + ss = spi_alloc_slave(struct sh_spi, bus, cs);if (!ss)return NULL ; - ss->slave.bus = bus; - ss->slave.cs = cs; ss->regs = (struct sh_spi_regs *)CONFIG_SH_SPI_BASE ;/* SPI sycle stop */
drivers/spi/soft_spi.c +1 -3
@@ -73,12 +73,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!spi_cs_is_valid (bus, cs))return NULL ; - ss =malloc (sizeof (struct soft_spi_slave )); + ss = spi_alloc_slave(struct soft_spi_slave, bus, cs);if (!ss)return NULL ; - ss->slave.bus = bus; - ss->slave.cs = cs; ss->mode = mode;/* TODO: Use max_hz to limit the SCK rate */
drivers/spi/tegra_slink.c +1 -3
@@ -81,13 +81,11 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,return NULL ; } - spi =malloc (sizeof (struct tegra_spi_slave )); + spi = spi_alloc_slave(struct tegra_spi_slave, bus, cs);if (!spi) {printf ("SPI error: malloc of SPI structure failed\n" );return NULL ; } - spi->slave.bus = bus; - spi->slave.cs = cs; spi->ctrl = &spi_ctrls[bus];if (!spi->ctrl) { printf("SPI error: could not find controller for bus %d\n",
drivers/spi/tegra_spi.c +1 -3
@@ -81,13 +81,11 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,return NULL ; } - spi =malloc (sizeof (struct tegra_spi_slave )); + spi = spi_alloc_slave(struct tegra_spi_slave, bus, cs);if (!spi) {printf ("SPI error: malloc of SPI structure failed\n" );return NULL ; } - spi->slave.bus = bus; - spi->slave.cs = cs;#ifdef CONFIG_OF_CONTROL int node =fdtdec_next_compatible (gd->fdt_blob,0 ,COMPAT_NVIDIA_TEGRA20_SFLASH );
drivers/spi/xilinx_spi.c +1 -3
@@ -85,14 +85,12 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,return NULL ; } - xilspi =malloc (sizeof (*xilspi)); + xilspi = spi_alloc_slave(struct xilinx_spi_slave, bus, cs);if (!xilspi) {printf ("XILSPI error: %s: malloc of SPI structure failed\n" , __func__);return NULL ; } - xilspi->slave.bus = bus; - xilspi->slave.cs = cs; xilspi->regs = (struct xilinx_spi_reg *)xilinx_spi_base_list[bus]; xilspi->freq = max_hz; xilspi->mode = mode;
Signature · 1 line
1.8.1.3
PATCH v2 4/15 sf: Add spi_flash_alloc() to create a new SPI flash struct
In reply to Simon GlassAt present it is difficult to extend the SPI flash structure since all devices allocate it themselves, and few of them zero all fields. Add a new function spi_flash_alloc() which can be used by SPI devices to perform this allocation, and thus ensure that all devices can better cope with SPI structure changes.
---
Changes in v2: None
drivers/mtd/spi/spi_flash.c | 25 +++++++++++++++++++++++++ include/spi_flash.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
drivers/mtd/spi/spi_flash.c +25 -0
@@ -401,6 +401,31 @@ err_claim_bus:return NULL ; } +void *spi_flash_do_alloc (int offset,int size,struct spi_slave *spi, +const char *name) +{ +struct spi_flash *flash; +void *ptr; + + ptr =malloc (size); +if (!ptr) { +debug ("SF: Failed to allocate memory\n" ); +return NULL ; + } +memset (ptr,'\0' , size); + flash = (struct spi_flash *)(ptr + offset); + +/* Set up some basic fields - caller will sort out sizes */ + flash->spi = spi; + flash->name = name; + + flash->read = spi_flash_cmd_read_fast; + flash->write = spi_flash_cmd_write_multi; + flash->erase = spi_flash_cmd_erase; + +return flash; +} +void spi_flash_free (struct spi_flash *flash) {spi_free_slave (flash->spi);
include/spi_flash.h +38 -0
@@ -47,6 +47,44 @@ struct spi_flash { size_t len); }; +/** +* spi_flash_do_alloc - Allocate a new spi flash structure +* +* The structure is allocated and cleared with default values for +* read, write and erase, which the caller can modify. The caller must set +* up size, page_size and sector_size. +* +* Use the helper macro spi_flash_alloc() to call this. +* +* @offset: Offset of struct spi_slave within slave structure +* @size: Size of slave structure +* @spi: SPI slave +* @name: Name of SPI flash device +*/ +void *spi_flash_do_alloc (int offset,int size,struct spi_slave *spi, +const char *name); + +/** +* spi_flash_alloc - Allocate a new SPI flash structure +* +* @_struct: Name of structure to allocate (e.g. struct ramtron_spi_fram). This +* structure must contain a member 'struct spi_flash *flash'. +* @spi: SPI slave +* @name: Name of SPI flash device +*/ +#define spi_flash_alloc (_struct, spi, name) \ + spi_flash_do_alloc(offsetof(_struct, flash), sizeof(_struct), \ + spi, name) + +/** +* spi_flash_alloc_base - Allocate a new SPI flash structure with no private data +* +* @spi: SPI slave +* @name: Name of SPI flash device +*/ +#define spi_flash_alloc_base (spi, name) \ + spi_flash_do_alloc(0, sizeof(struct spi_flash), spi, name) +struct spi_flash *spi_flash_probe (unsigned int bus,unsigned int cs,unsigned int max_hz,unsigned int spi_mode);void spi_flash_free (struct spi_flash *flash);
Signature · 1 line
1.8.1.3
PATCH v2 5/15 sf: Use spi_flash_alloc() in each SPI flash driver
In reply to Simon GlassRather than each device having its own way to allocate a SPI flash structure, use the new allocation function everywhere. This will make it easier to extend the interface without breaking devices.
---
Changes in v2: None
drivers/mtd/spi/atmel.c | 8 +------- drivers/mtd/spi/eon.c | 8 +------- drivers/mtd/spi/macronix.c | 8 +------- drivers/mtd/spi/ramtron.c | 4 +--- drivers/mtd/spi/spansion.c | 8 +------- drivers/mtd/spi/sst.c | 8 +------- drivers/mtd/spi/stmicro.c | 8 +------- drivers/mtd/spi/winbond.c | 8 +------- 8 files changed, 8 insertions(+), 52 deletions(-)
drivers/mtd/spi/atmel.c +1 -7
@@ -480,15 +480,13 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)return NULL ; } - asf =malloc (sizeof (struct atmel_spi_flash )); + asf = spi_flash_alloc(struct atmel_spi_flash, spi, params->name);if (!asf) {debug ("SF: Failed to allocate memory\n" );return NULL ; } asf->params = params; - asf->flash.spi = spi; - asf->flash.name = params->name;/* Assuming power-of-two page size initially. */ page_size =1 << params->l2_page_size;
@@ -513,7 +511,6 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode) asf->flash.erase = dataflash_erase_at45; page_size +=1 << (params->l2_page_size -5 ); }else { - asf->flash.read = spi_flash_cmd_read_fast; asf->flash.write = dataflash_write_p2; asf->flash.erase = dataflash_erase_p2; }
@@ -524,9 +521,6 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)case DF_FAMILY_AT26F :case DF_FAMILY_AT26DF : - asf->flash.read = spi_flash_cmd_read_fast; - asf->flash.write = spi_flash_cmd_write_multi; - asf->flash.erase = spi_flash_cmd_erase; asf->flash.page_size = page_size; asf->flash.sector_size =4096 ;/* clear SPRL# bit for locked flash */
drivers/mtd/spi/eon.c +1 -7
@@ -46,18 +46,12 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)return NULL ; } - flash =malloc (sizeof (*flash)); + flash =spi_flash_alloc_base (spi, params->name);if (!flash) {debug ("SF: Failed to allocate memory\n" );return NULL ; } - flash->spi = spi; - flash->name = params->name; - - flash->write = spi_flash_cmd_write_multi; - flash->erase = spi_flash_cmd_erase; - flash->read = spi_flash_cmd_read_fast; flash->page_size =256 ; flash->sector_size =256 *16 *16 ; flash->size =256 *16
drivers/mtd/spi/macronix.c +1 -7
@@ -97,18 +97,12 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)return NULL ; } - flash =malloc (sizeof (*flash)); + flash =spi_flash_alloc_base (spi, params->name);if (!flash) {debug ("SF: Failed to allocate memory\n" );return NULL ; } - flash->spi = spi; - flash->name = params->name; - - flash->write = spi_flash_cmd_write_multi; - flash->erase = spi_flash_cmd_erase; - flash->read = spi_flash_cmd_read_fast; flash->page_size =256 ; flash->sector_size =256 *16 *16 ; flash->size = flash->sector_size * params->nr_blocks;
drivers/mtd/spi/ramtron.c +1 -3
@@ -284,15 +284,13 @@ struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)return NULL ; found: - sn =malloc (sizeof (*sn)); + sn = spi_flash_alloc(struct ramtron_spi_fram, spi, params->name);if (!sn) {debug ("SF: Failed to allocate memory\n" );return NULL ; } sn->params = params; - sn->flash.spi = spi; - sn->flash.name = params->name; sn->flash.write = ramtron_write; sn->flash.read = ramtron_read;
drivers/mtd/spi/spansion.c +1 -7
@@ -128,18 +128,12 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)return NULL ; } - flash =malloc (sizeof (*flash)); + flash =spi_flash_alloc_base (spi, params->name);if (!flash) {debug ("SF: Failed to allocate memory\n" );return NULL ; } - flash->spi = spi; - flash->name = params->name; - - flash->write = spi_flash_cmd_write_multi; - flash->erase = spi_flash_cmd_erase; - flash->read = spi_flash_cmd_read_fast; flash->page_size =256 ; flash->sector_size =256 * params->pages_per_sector; flash->size = flash->sector_size * params->nr_sectors;
drivers/mtd/spi/sst.c +1 -7
@@ -203,22 +203,16 @@ spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)return NULL ; } - stm =malloc (sizeof (*stm)); + stm = spi_flash_alloc(struct sst_spi_flash, spi, params->name);if (!stm) {debug ("SF: Failed to allocate memory\n" );return NULL ; } stm->params = params; - stm->flash.spi = spi; - stm->flash.name = params->name;if (stm->params->flags &SST_FEAT_WP ) stm->flash.write = sst_write_wp; -else - stm->flash.write = spi_flash_cmd_write_multi; - stm->flash.erase = spi_flash_cmd_erase; - stm->flash.read = spi_flash_cmd_read_fast; stm->flash.page_size =256 ; stm->flash.sector_size =4096 ; stm->flash.size = stm->flash.sector_size * params->nr_sectors;
drivers/mtd/spi/stmicro.c +1 -7
@@ -176,18 +176,12 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)return NULL ; } - flash =malloc (sizeof (*flash)); + flash =spi_flash_alloc_base (spi, params->name);if (!flash) {debug ("SF: Failed to allocate memory\n" );return NULL ; } - flash->spi = spi; - flash->name = params->name; - - flash->write = spi_flash_cmd_write_multi; - flash->erase = spi_flash_cmd_erase; - flash->read = spi_flash_cmd_read_fast; flash->page_size =256 ; flash->sector_size =256 * params->pages_per_sector; flash->size = flash->sector_size * params->nr_sectors;
drivers/mtd/spi/winbond.c +1 -7
@@ -92,18 +92,12 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)return NULL ; } - flash =malloc (sizeof (*flash)); + flash =spi_flash_alloc_base (spi, params->name);if (!flash) {debug ("SF: Failed to allocate memory\n" );return NULL ; } - flash->spi = spi; - flash->name = params->name; - - flash->write = spi_flash_cmd_write_multi; - flash->erase = spi_flash_cmd_erase; - flash->read = spi_flash_cmd_read_fast; flash->page_size =256 ; flash->sector_size =4096 ; flash->size =4096 *16 * params->nr_blocks;
Signature · 1 line
1.8.1.3
PATCH v2 6/15 x86: spi: Add Intel ICH driver
In reply to Simon GlassThis supports Intel ICH7/9. The Intel controller is a little unusual in that it is mostly intended for use with SPI flash, and has some optimisations and features specifically for that application. In particular it is not possible to support ongoing transactions that continue over many calls with SPI_XFER_BEGIN and SPI_XFER_END.
This driver supports writes of up to 64 bytes at a time, the limit for the controller. Future work will improve this.
---
Changes in v2:
- Support both 33MHz and 20MHz operation in ich driver
- Replace while() loop with memcpy_to/fromio() in ich driver
drivers/spi/Makefile | 1 + drivers/spi/ich.c | 750 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/spi/ich.h | 144 ++++++++++ 3 files changed, 895 insertions(+) create mode 100644 drivers/spi/ich.c create mode 100644 drivers/spi/ich.h
drivers/spi/Makefile +1 -0
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_CF_SPI) += cf_spi.o COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o +COBJS-$(CONFIG_ICH_SPI) += ich.o COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
drivers/spi/ich.c new file +750 -0
750 lines not on this page · raw message
drivers/spi/ich.h new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
1.8.1.3
PATCH v2 7/15 spi: Add parameter for maximum write size
In reply to Simon GlassSome SPI controllers (e.g. Intel ICH) have a limit on the number of SPI bytes that can be written at a time. Add this as a parameter so that clients of the SPI interface can respect this value.
---
Changes in v2: None
include/spi.h | 3 +++ 1 file changed, 3 insertions(+)
include/spi.h +3 -0
@@ -49,10 +49,13 @@* * bus: ID of the bus that the slave is attached to. * cs: ID of the chip select connected to the slave. +* max_write_size: If non-zero, the maximum number of bytes which can +* be written at once, excluding command bytes. */ struct spi_slave {unsigned int bus;unsigned int cs; +unsigned int max_write_size; };/*-----------------------------------------------------------------------
Signature · 1 line
1.8.1.3
PATCH v2 8/15 sf: Respect maximum SPI write size
In reply to Simon GlassSome SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
---
Changes in v2: None
drivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/mtd/spi/spi_flash.c +8 -2
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ; - page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + } } debug("SF: program %s %zu bytes @ %#x\n",
Signature · 1 line
1.8.1.3
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Simon,
Quoted 26 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 10 lines
drivers/mtd/spi/spi_flash.c +5
-2@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ; - page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }
Does this change required to handle < page_size writes, means if the user is giving an offset other than
multiples of page_sizes?
Thanks,
Jagan.
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ;
Quoted 11 lines
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +5
-2- page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?
I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that byte_addr should become aligned to the page_size after the first transfer, and from then on it should start at 0 for each page.
Are you seeing a problem?
Regards,
Simon
Quoted 3 lines
Thanks,
Jagan.
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Simon,
Quoted 47 lines · Simon Glass
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ;Quoted 11 lines
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +5
-2- page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?
Quoted 7 lines
I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.Are you seeing a problem?
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned page_sizes?
Thanks,
Jagan.
Quoted 7 lines
Regards,
SimonQuoted 3 lines
Thanks,
Jagan.
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Jagan,
Quoted 52 lines · Jagan Teki
Hi Simon,
Quoted 49 lines · Simon Glass
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ;Quoted 11 lines
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +5
-2- page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?I'm not quite sure what you are saying, but let me try to response.
Quoted 8 lines
Quoted 5 lines
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.Are you seeing a problem?
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?
It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Regards,
Simon
Quoted 11 lines
Thanks,
Jagan.Quoted 7 lines
Regards,
SimonQuoted 3 lines
Thanks,
Jagan.
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Simon,
Quoted 59 lines · Simon Glass
Hi Jagan,
Quoted 56 lines · Jagan Teki
Hi Simon,
Quoted 53 lines · Simon Glass
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ;Quoted 11 lines
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +5
-2- page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Are you seeing a problem?
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned page_sizes, is it?
Thanks,
Jagan.
Quoted 15 lines
Regards,
SimonQuoted 11 lines
Thanks,
Jagan.Quoted 7 lines
Regards,
SimonQuoted 3 lines
Thanks,
Jagan.
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
Quoted 58 lines · Jagan Teki
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ;Quoted 11 lines
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +5
-2- page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Regards,
Simon
Quoted 19 lines
Thanks,
Jagan.Quoted 15 lines
Regards,
SimonQuoted 11 lines
Thanks,
Jagan.Quoted 7 lines
Regards,
SimonQuoted 3 lines
Thanks,
Jagan.
A message that is not in the archive (sent off-list or not yet received): CAD6G_RQUEKtQ2Lm4QQSeC+s28vXXyQ82AKgbGa7hHRq39tVAMQ@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAPnjgZ0fefjxPp_cBmgrfktq8B495NDyFsXQcZk=-eoWK7R9wg@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAD6G_RR6sywwzj2eqtmkPi-tSpEDcBO2QGE_283x1=ZhC19rag@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAD6G_RRrfwdOtXD2YB1LxD-8gQR_bWOnfY+WkwwR0ST5jGQe0g@mail.gmail.com
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
Quoted 58 lines · Jagan Teki
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ;Quoted 11 lines
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +5
-2- page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80
Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
Regards,
Simon
Quoted 6 lines
Thanks,
Jagan.Quoted 2 lines
May be the new code handle this situation as earlier may not have.?
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Simon,
Quoted 131 lines · Simon Glass
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
Quoted 58 lines · Jagan Teki
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,for (actual =0 ; actual < len; actual += chunk_len) { chunk_len =min (len - actual, page_size - byte_addr); +if (flash->spi->max_write_size) + chunk_len =min (chunk_len, flash->spi->max_write_size); + cmd[1 ] = page_addr >>8 ; cmd[2 ] = page_addr; cmd[3 ] = byte_addr;@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,if (ret)break ;Quoted 11 lines
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, · line 121
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +5
-2- page_addr++; - byte_addr =0 ; + byte_addr += chunk_len; +if (byte_addr == page_size) { + page_addr++; + byte_addr =0 ; + }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80
Quoted 6 lines
Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
Thanks,
Jagan.
Quoted 10 lines
Regards,
SimonQuoted 6 lines
Thanks,
Jagan.Quoted 2 lines
May be the new code handle this situation as earlier may not have.?
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Jagan,
Quoted 138 lines · Jagan Teki
Hi Simon,
Quoted 135 lines · Simon Glass
Hi,
Quoted 131 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
Quoted 58 lines · Jagan Teki
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jagan,
Quoted 32 lines · Jagan Teki
Hi Simon,
Quoted 29 lines · Simon Glass
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of
bytes that can be in a write transaction. Support this by breaking the
writes into multiple transactions.Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 17f3d3c..b82011d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
for (actual = 0; actual < len; actual += chunk_len) {
chunk_len = min(len - actual, page_size - byte_addr);+ if (flash->spi->max_write_size)
+ chunk_len = min(chunk_len, flash->spi->max_write_size);
+
cmd[1] = page_addr >> 8;
cmd[2] = page_addr;
cmd[3] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
if (ret)
break;Quoted 11 lines
Quoted 7 lines
- page_addr++;
- byte_addr = 0;
+ byte_addr += chunk_len;
+ if (byte_addr == page_size) {
+ page_addr++;
+ byte_addr = 0;
+ }Does this change required to handle <
page_sizewrites, means if the user is giving an offset other than
multiples ofpage_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Quoted 6 lines
Quoted 2 lines
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
If your driver is using spi_flash_alloc(), as it now should be, then it should work OK.
Regards,
Simon
Quoted 14 lines
Thanks,
Jagan.Quoted 10 lines
Regards,
SimonQuoted 6 lines
Thanks,
Jagan.Quoted 2 lines
May be the new code handle this situation as earlier may not have.?
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Simon,
Quoted 144 lines · Simon Glass
Hi Jagan,
Quoted 141 lines · Jagan Teki
Hi Simon,
Quoted 137 lines · Simon Glass
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
Quoted 58 lines · Jagan Teki
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jagan,
Quoted 43 lines · Jagan Teki
Hi Simon,
On Mon, Mar 11, 2013 at 9:38 PM, Simon Glass <[email protected]> wrote:
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of
bytes that can be in a write transaction. Support this by breaking the
writes into multiple transactions.Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 17f3d3c..b82011d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
for (actual = 0; actual < len; actual += chunk_len) {
chunk_len = min(len - actual, page_size - byte_addr);+ if (flash->spi->max_write_size)
+ chunk_len = min(chunk_len, flash->spi->max_write_size);
+
cmd[1] = page_addr >> 8;
cmd[2] = page_addr;
cmd[3] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
if (ret)
break;- page_addr++;
- byte_addr = 0;
+ byte_addr += chunk_len;
+ if (byte_addr == page_size) {
+ page_addr++;
+ byte_addr = 0;
+ }Does this change required to handle < page_size writes, means if the
user is giving an offset other than
multiples of page_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that
byte_addrshould become aligned to thepage_sizeafter the first transfer, and from then on it should start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
Quoted 6 lines
Quoted 3 lines
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
If your driver is using
spi_flash_alloc(), as it now should be, then it should work OK.
Sorry I couldn't understand.
As per as i know spi_flash_alloc is a generic call used for spi_flash read/write/erase calls.
When i use the code as it is i got the garbage value for slave.max_write_size and chunk_len on write call has 1
due to this flash write failed. I fixed when I explicitly assign 0 to slave.max_write_size on my controller driver.
Request for your comments.
Thanks,
Jagan.
Quoted 18 lines
Regards,
SimonQuoted 14 lines
Thanks,
Jagan.Quoted 10 lines
Regards,
SimonQuoted 6 lines
Thanks,
Jagan.Quoted 2 lines
May be the new code handle this situation as earlier may not have.?
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi,
Quoted 158 lines · Jagan Teki
Hi Simon,
Quoted 144 lines · Simon Glass
Hi Jagan,
Quoted 141 lines · Jagan Teki
Hi Simon,
Quoted 137 lines · Simon Glass
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
Quoted 58 lines · Jagan Teki
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jagan,
On Tue, Apr 23, 2013 at 1:44 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Mon, Mar 11, 2013 at 9:38 PM, Simon Glass <[email protected]> wrote:
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of
bytes that can be in a write transaction. Support this by breaking the
writes into multiple transactions.Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 17f3d3c..b82011d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
for (actual = 0; actual < len; actual += chunk_len) {
chunk_len = min(len - actual, page_size - byte_addr);+ if (flash->spi->max_write_size)
+ chunk_len = min(chunk_len, flash->spi->max_write_size);
+
cmd[1] = page_addr >> 8;
cmd[2] = page_addr;
cmd[3] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
if (ret)
break;- page_addr++;
- byte_addr = 0;
+ byte_addr += chunk_len;
+ if (byte_addr == page_size) {
+ page_addr++;
+ byte_addr = 0;
+ }Does this change required to handle < page_size writes, means if the
user is giving an offset other than
multiples of page_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that byte_addr should become aligned
to the page_size after the first transfer, and from then on it should
start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
My question,what if this change doesn't have.? Can't I able to write data starts from unaligned
page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
Quoted 6 lines
Quoted 3 lines
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
If your driver is using
spi_flash_alloc(), as it now should be, then it should work OK.Sorry I couldn't understand.
As per as i knowspi_flash_allocis a generic call used forspi_flashread/write/erase calls.
Quoted 6 lines
When i use the code as it is i got the garbage value for slave.max_write_size and
chunk_lenon write call has 1
due to this flash write failed. I fixed when I explicitly assign 0 to slave.max_write_size on my controller driver.Request for your comments.
Which SPI driver please? Does your SPI driver call spi_alloc_slave()?
Regards,
Simon
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Simon,
Quoted 161 lines · Simon Glass
Hi,
Quoted 158 lines · Jagan Teki
Hi Simon,
Quoted 144 lines · Simon Glass
Hi Jagan,
Quoted 141 lines · Jagan Teki
Hi Simon,
Quoted 137 lines · Simon Glass
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
Quoted 58 lines · Jagan Teki
Hi Simon,
On Wed, Apr 24, 2013 at 2:20 AM, Simon Glass <[email protected]> wrote:
Hi Jagan,On Tue, Apr 23, 2013 at 1:44 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Mon, Mar 11, 2013 at 9:38 PM, Simon Glass <[email protected]> wrote:
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of
bytes that can be in a write transaction. Support this by breaking the
writes into multiple transactions.Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 17f3d3c..b82011d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
for (actual = 0; actual < len; actual += chunk_len) {
chunk_len = min(len - actual, page_size - byte_addr);+ if (flash->spi->max_write_size)
+ chunk_len = min(chunk_len, flash->spi->max_write_size);
+
cmd[1] = page_addr >> 8;
cmd[2] = page_addr;
cmd[3] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
if (ret)
break;- page_addr++;
- byte_addr = 0;
+ byte_addr += chunk_len;
+ if (byte_addr == page_size) {
+ page_addr++;
+ byte_addr = 0;
+ }Does this change required to handle < page_size writes, means if the
user is giving an offset other than
multiples of page_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that byte_addr should become aligned
to the page_size after the first transfer, and from then on it should
start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
My question,what if this change doesn't have.?
Can't I able to write data starts from unaligned page_sizes?It should work fine - I did in fact find a problem in the driver in this case, which I fixed. Let me know if you see any problem.
Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
Quoted 6 lines
Quoted 3 lines
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
If your driver is using
spi_flash_alloc(), as it now should be, then it should work OK.Sorry I couldn't understand.
As per as i knowspi_flash_allocis a generic call used forspi_flashread/write/erase calls.
Quoted 8 lines
Quoted 6 lines
When i use the code as it is i got the garbage value for slave.max_write_size and
chunk_lenon write call has 1
due to this flash write failed. I fixed when I explicitly assign 0 to slave.max_write_size on my controller driver.Request for your comments.
Which SPI driver please? Does your SPI driver call
spi_alloc_slave()?
I am using xilinx zynq qspi controller driver, not mainline yet, planning to do.
Yes we have a spi_alloc_slave func where I am initializing slave and spi_dev members.
in that I have initialized slave.max_write_size = 0.
Thanks,
Jagan.
Quoted 3 lines
Regards,
Simon
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Jagan,
Quoted 171 lines · Jagan Teki
Hi Simon,
Quoted 168 lines · Simon Glass
Hi,
Quoted 164 lines · Jagan Teki
Hi Simon,
Quoted 144 lines · Simon Glass
Hi Jagan,
Quoted 141 lines · Jagan Teki
Hi Simon,
Quoted 137 lines · Simon Glass
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 64 lines · Jagan Teki
Hi Simon,
Quoted 61 lines · Simon Glass
Hi Jagan,
On Tue, Apr 23, 2013 at 2:01 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Wed, Apr 24, 2013 at 2:20 AM, Simon Glass <[email protected]> wrote:
Hi Jagan,On Tue, Apr 23, 2013 at 1:44 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Mon, Mar 11, 2013 at 9:38 PM, Simon Glass <[email protected]> wrote:
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of
bytes that can be in a write transaction. Support this by breaking the
writes into multiple transactions.Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 17f3d3c..b82011d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
for (actual = 0; actual < len; actual += chunk_len) {
chunk_len = min(len - actual, page_size - byte_addr);+ if (flash->spi->max_write_size)
+ chunk_len = min(chunk_len, flash->spi->max_write_size);
+
cmd[1] = page_addr >> 8;
cmd[2] = page_addr;
cmd[3] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
if (ret)
break;- page_addr++;
- byte_addr = 0;
+ byte_addr += chunk_len;
+ if (byte_addr == page_size) {
+ page_addr++;
+ byte_addr = 0;
+ }Does this change required to handle < page_size writes, means if the
user is giving an offset other than
multiples of page_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that byte_addr should become aligned
to the page_size after the first transfer, and from then on it should
start at 0 for each page.Are you seeing a problem?
Quoted 8 lines
Quoted 5 lines
My question,what if this change doesn't have.?
Can't I able to write data starts from unaligned page_sizes?It should work fine - I did in fact find a problem in the driver in
this case, which I fixed. Let me know if you see any problem.Means this change is for proper handling of write data starts from unaligned
page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
Quoted 6 lines
Quoted 3 lines
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
If your driver is using
spi_flash_alloc(), as it now should be, then it should work OK.Sorry I couldn't understand.
As per as i knowspi_flash_allocis a generic call used forspi_flashread/write/erase calls.When i use the code as it is i got the garbage value for slave.max_write_size and
chunk_lenon write call has 1
due to this flash write failed. I fixed when I explicitly assign 0 to slave.max_write_size on my controller driver.Request for your comments.
Quoted 7 lines
Quoted 1 line
Which SPI driver please? Does your SPI driver call
spi_alloc_slave()?I am using xilinx zynq qspi controller driver, not mainline yet, planning to do.
Yes we have a
spi_alloc_slavefunc where I am initializing slave andspi_devmembers.
in that I have initialized slave.max_write_size = 0.
OK, but this should be done by spi_do_alloc_slave() for you, if you are calling the mainline spi_alloc_slave() macro. Please see how other SPI drivers set themselves up.
Regards,
Simon
Quoted 7 lines
Thanks,
Jagan.Quoted 3 lines
Regards,
Simon
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi Simon,
Quoted 178 lines · Simon Glass
Hi Jagan,
Quoted 175 lines · Jagan Teki
Hi Simon,
Quoted 161 lines · Simon Glass
Hi,
Quoted 158 lines · Jagan Teki
Hi Simon,
Quoted 144 lines · Simon Glass
Hi Jagan,
Quoted 141 lines · Jagan Teki
Hi Simon,
Quoted 137 lines · Simon Glass
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 76 lines · Simon Glass
Hi Jagan,
Quoted 72 lines · Jagan Teki
Hi Simon,
On Wed, Apr 24, 2013 at 2:43 AM, Simon Glass <[email protected]> wrote:
Hi Jagan,On Tue, Apr 23, 2013 at 2:01 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Wed, Apr 24, 2013 at 2:20 AM, Simon Glass <[email protected]> wrote:
Hi Jagan,On Tue, Apr 23, 2013 at 1:44 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Mon, Mar 11, 2013 at 9:38 PM, Simon Glass <[email protected]> wrote:
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of
bytes that can be in a write transaction. Support this by breaking the
writes into multiple transactions.Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 17f3d3c..b82011d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
for (actual = 0; actual < len; actual += chunk_len) {
chunk_len = min(len - actual, page_size - byte_addr);+ if (flash->spi->max_write_size)
+ chunk_len = min(chunk_len, flash->spi->max_write_size);
+
cmd[1] = page_addr >> 8;
cmd[2] = page_addr;
cmd[3] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
if (ret)
break;- page_addr++;
- byte_addr = 0;
+ byte_addr += chunk_len;
+ if (byte_addr == page_size) {
+ page_addr++;
+ byte_addr = 0;
+ }Does this change required to handle < page_size writes, means if the
user is giving an offset other than
multiples of page_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that byte_addr should become aligned
to the page_size after the first transfer, and from then on it should
start at 0 for each page.Are you seeing a problem?
My question,what if this change doesn't have.?
Can't I able to write data starts from unaligned page_sizes?It should work fine - I did in fact find a problem in the driver in
this case, which I fixed. Let me know if you see any problem.Means this change is for proper handling of write data starts from
unaligned page_sizes, is it?Quoted 6 lines
Not really - it was designed to handle the case where the driver cannot write a whole page at once. The Intel ICH peripheral has this problem.
I believe that writing starting from unaligned page sizes worked OK before this change.
Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
Quoted 6 lines
Quoted 3 lines
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
If your driver is using
spi_flash_alloc(), as it now should be, then it should work OK.Sorry I couldn't understand.
As per as i knowspi_flash_allocis a generic call used forspi_flashread/write/erase calls.Quoted 8 lines
Quoted 6 lines
When i use the code as it is i got the garbage value for slave.max_write_size and
chunk_lenon write call has 1
due to this flash write failed. I fixed when I explicitly assign 0 to slave.max_write_size on my controller driver.Request for your comments.
Which SPI driver please? Does your SPI driver call
spi_alloc_slave()?I am using xilinx zynq qspi controller driver, not mainline yet, planning to do.
Quoted 7 lines
Quoted 3 lines
Yes we have a
spi_alloc_slavefunc where I am initializing slave andspi_devmembers.
in that I have initialized slave.max_write_size = 0.OK, but this should be done by
spi_do_alloc_slave()for you, if you are calling the mainlinespi_alloc_slave()macro. Please see how other SPI drivers set themselves up.
Thanks for your help, got the point.
Could you please any reference driver, I am planning to make this qspi driver to push on mainline.
Thanks,
Jagan.
Quoted 11 lines
Regards,
SimonQuoted 7 lines
Thanks,
Jagan.Quoted 3 lines
Regards,
Simon
PATCH v2 8/15 sf: Respect maximum SPI write size
Hi,
Quoted 185 lines · Jagan Teki
Hi Simon,
Quoted 182 lines · Simon Glass
Hi Jagan,
Quoted 178 lines · Jagan Teki
Hi Simon,
Quoted 161 lines · Simon Glass
Hi,
Quoted 158 lines · Jagan Teki
Hi Simon,
Quoted 144 lines · Simon Glass
Hi Jagan,
Quoted 141 lines · Jagan Teki
Hi Simon,
Quoted 137 lines · Simon Glass
Hi,
Quoted 128 lines · Jagan Teki
Hi Simon,
Quoted 109 lines · Jagan Teki
Hi Simon,
Quoted 98 lines · Simon Glass
Hi Jagan,
Quoted 86 lines · Jagan Teki
Hi Simon,
Quoted 82 lines · Simon Glass
Hi Jagan,
On Tue, Apr 23, 2013 at 2:15 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Wed, Apr 24, 2013 at 2:43 AM, Simon Glass <[email protected]> wrote:
Hi Jagan,On Tue, Apr 23, 2013 at 2:01 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Wed, Apr 24, 2013 at 2:20 AM, Simon Glass <[email protected]> wrote:
Hi Jagan,On Tue, Apr 23, 2013 at 1:44 PM, Jagan Teki <[email protected]> wrote:
Hi Simon,On Mon, Mar 11, 2013 at 9:38 PM, Simon Glass <[email protected]> wrote:
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of
bytes that can be in a write transaction. Support this by breaking the
writes into multiple transactions.Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 17f3d3c..b82011d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
for (actual = 0; actual < len; actual += chunk_len) {
chunk_len = min(len - actual, page_size - byte_addr);+ if (flash->spi->max_write_size)
+ chunk_len = min(chunk_len, flash->spi->max_write_size);
+
cmd[1] = page_addr >> 8;
cmd[2] = page_addr;
cmd[3] = byte_addr;
@@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
if (ret)
break;- page_addr++;
- byte_addr = 0;
+ byte_addr += chunk_len;
+ if (byte_addr == page_size) {
+ page_addr++;
+ byte_addr = 0;
+ }Does this change required to handle < page_size writes, means if the
user is giving an offset other than
multiples of page_sizes?I'm not quite sure what you are saying, but let me try to response.
I believe what should happen is that byte_addr should become aligned
to the page_size after the first transfer, and from then on it should
start at 0 for each page.Are you seeing a problem?
My question,what if this change doesn't have.?
Can't I able to write data starts from unaligned page_sizes?It should work fine - I did in fact find a problem in the driver in
this case, which I fixed. Let me know if you see any problem.Means this change is for proper handling of write data starts from
unaligned page_sizes, is it?Not really - it was designed to handle the case where the driver
cannot write a whole page at once. The Intel ICH peripheral has this
problem.I believe that writing starting from unaligned page sizes worked OK
before this change.Quoted 8 lines
Thanks.
But I am some how confusing instead of this change may be you may place the existing code as it is
page_addr++;
byte_addr= 0;
prior to above may be you can place intel ICH per hack as other will do whole page at once, i may be wrong.Quoted 7 lines
The old code assumed that it could skip to the start of the next page after each write. The new code skips forward by
chunk_len, which generally takes as to the start of the next page, but not always (e.g. with Intel ICH).Yes, AFAIK every other SPI driver can still do a whole page at a time, with or without this patch.
Quoted 7 lines
Thats what if the user is giving an unaligned page size suppose
0x80with 512 bytes (if the page_size=256)
sf write0x1000x800x200
the loop will goes 2 nonpage_sizesand 1pages_sizelike this iteration 1--- 128
iteration 2-- 256
iteration 3-- 128I was tested the old and new code w.r.t this unaligned
page_sizeas a start the result is same
uboot> sf write0x1000x800x200
actual = 0.....chunk_len = 128
actual = 128.....chunk_len = 256
actual = 384.....chunk_len = 128
SF: program success 512 bytes @0x80Quoted 3 lines
Means the old and new code does the same thing, but still i couldn't understand. What exactly this change is for, if it is specific to intel flash what is state in above condition.
Yes it is for the Intel SPI controller which has a strange limitation that it can only write 64 bytes at a time.
Quoted 6 lines
Quoted 3 lines
So I need to initialize slave.max_write_size to 0 on my controller driver? is that the good idea to make change in all drivers with this issue, may be i am wrong.?
If your driver is using
spi_flash_alloc(), as it now should be, then it should work OK.Sorry I couldn't understand.
As per as i knowspi_flash_allocis a generic call used forspi_flashread/write/erase calls.Quoted 8 lines
Quoted 6 lines
When i use the code as it is i got the garbage value for slave.max_write_size and
chunk_lenon write call has 1
due to this flash write failed. I fixed when I explicitly assign 0 to slave.max_write_size on my controller driver.Request for your comments.
Which SPI driver please? Does your SPI driver call
spi_alloc_slave()?I am using xilinx zynq qspi controller driver, not mainline yet, planning to do.
Yes we have a
spi_alloc_slavefunc where I am initializing slave andspi_devmembers.
in that I have initialized slave.max_write_size = 0.
Quoted 7 lines
Quoted 3 lines
OK, but this should be done by
spi_do_alloc_slave()for you, if you are calling the mainlinespi_alloc_slave()macro. Please see how other SPI drivers set themselves up.Thanks for your help, got the point.
Could you please any reference driver, I am planning to make this qspi driver to push on mainline.
drivers/spi/tegra_spi.c is a reasonable one to copy I think.
Regards,
Simon
Quoted 15 lines
Thanks,
Jagan.Quoted 11 lines
Regards,
SimonQuoted 7 lines
Thanks,
Jagan.Quoted 3 lines
Regards,
Simon
PATCH v2 9/15 x86: spi: Set maximum write size for ICH
In reply to Simon GlassThis SPI controller can only write 64 bytes at a time. Add this restriction in so that 'sf write' works correct for blocks larger than 64 bytes.
---
Changes in v2: None
drivers/spi/ich.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/spi/ich.c +5 -0
@@ -147,6 +147,11 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,return NULL ; } +/* +* Yes this controller can only write a small number of bytes at +* once! The limit is typically 64 bytes. +*/ + ich->slave.max_write_size = ctlr.databytes; ich->speed = max_hz;return &ich->slave;
Signature · 1 line
1.8.1.3
PATCH v2 10/15 sf: Enable FDT-based configuration and memory mapping
In reply to Simon GlassEnable device tree control of SPI flash, and use this to implement memory-mapped SPI flash, which is supported on Intel chips.
---
Changes in v2: None
drivers/mtd/spi/spi_flash.c | 46 ++++++++++++++++++++++++++++++++++++++++++++- include/fdtdec.h | 1 + include/spi_flash.h | 1 + lib/fdtdec.c | 1 + 4 files changed, 48 insertions(+), 1 deletion(-)
drivers/mtd/spi/spi_flash.c +45 -1
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <fdtdec.h> #include <malloc.h> #include <spi.h> #include <spi_flash.h>
@@ -15,6 +16,8 @@#include "spi_flash_internal.h" +DECLARE_GLOBAL_DATA_PTR ; +static void spi_flash_addr (u32 addr,u8 *cmd) {/* cmd[0] is actual command */
@@ -146,6 +149,10 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, {u8 cmd[5 ]; +/* Handle memory-mapped SPI */ +if (flash->memory_map) +memcpy (data, flash->memory_map + offset, len); + cmd[0 ] =CMD_READ_ARRAY_FAST ;spi_flash_addr (offset, cmd); cmd[4 ] =0x00 ;
@@ -275,6 +282,34 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)return 0 ; } +#ifdef CONFIG_OF_CONTROL +int spi_flash_decode_fdt (const void *blob,struct spi_flash *flash) +{ +fdt_addr_t addr; +fdt_size_t size; +int node; + +/* If there is no node, do nothing */ + node =fdtdec_next_compatible (blob,0 ,COMPAT_GENERIC_SPI_FLASH ); +if (node <0 ) +return 0 ; + + addr =fdtdec_get_addr_size (blob, node,"memory-map" , &size); +if (addr ==FDT_ADDR_T_NONE ) { +debug ("%s: Cannot decode address\n" , __func__); +return 0 ; + } + +if (flash->size != size) { +debug ("%s: Memory map must cover entire device\n" , __func__); +return -1 ; + } + flash->memory_map = (void *)addr; + +return 0 ; +} +#endif /* CONFIG_OF_CONTROL */ +/* * The following table holds all device probe functions *
@@ -391,9 +426,18 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, goto err_manufacturer_probe; } +#ifdef CONFIG_OF_CONTROL +if (spi_flash_decode_fdt (gd->fdt_blob, flash)) { +debug ("SF: FDT decode error\n" ); + goto err_manufacturer_probe; + } +#endif printf ("SF: Detected %s with page size " , flash->name);print_size (flash->sector_size,", total " ); -print_size (flash->size,"\n" ); +print_size (flash->size,"" ); +if (flash->memory_map) +printf (", mapped at %p" , flash->memory_map); +puts ("\n" );spi_release_bus (spi);
include/fdtdec.h +1 -0
@@ -83,6 +83,7 @@ enum fdt_compat_id {COMPAT_SAMSUNG_EXYNOS_EHCI ,/* Exynos EHCI controller */ COMPAT_SAMSUNG_EXYNOS_USB_PHY ,/* Exynos phy controller for usb2.0 */ COMPAT_MAXIM_MAX77686_PMIC ,/* MAX77686 PMIC */ +COMPAT_GENERIC_SPI_FLASH ,/* Generic SPI Flash chip */ COMPAT_COUNT, };
include/spi_flash.h +1 -0
@@ -39,6 +39,7 @@ struct spi_flash {/* Erase (sector) size */ u32 sector_size; +void *memory_map;/* Address of read-only SPI flash access */ int (*read)(struct spi_flash *flash,u32 offset,size_t len,void *buf); int (*write)(struct spi_flash *flash, u32 offset,
lib/fdtdec.c +1 -0
@@ -56,6 +56,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (SAMSUNG_EXYNOS_EHCI ,"samsung,exynos-ehci" ),COMPAT (SAMSUNG_EXYNOS_USB_PHY ,"samsung,exynos-usb-phy" ),COMPAT (MAXIM_MAX77686_PMIC ,"maxim,max77686_pmic" ), + COMPAT(GENERIC_SPI_FLASH, "spi-flash"), };const char *fdtdec_get_compatible (enum fdt_compat_id id)
Signature · 1 line
1.8.1.3
PATCH v2 10/15 sf: Enable FDT-based configuration and memory mapping
Hi Simon,
Quoted 35 lines · Simon Glass
Enable device tree control of SPI flash, and use this to implement memory-mapped SPI flash, which is supported on Intel chips.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 46 ++++++++++++++++++++++++++++++++++++++++++++- include/fdtdec.h | 1 + include/spi_flash.h | 1 + lib/fdtdec.c | 1 + 4 files changed, 48 insertions(+), 1 deletion(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -8,6 +8,7 @@*/ #include <common.h> +#include <fdtdec.h> #include <malloc.h> #include <spi.h> #include <spi_flash.h> @@ -15,6 +16,8 @@#include "spi_flash_internal.h" +DECLARE_GLOBAL_DATA_PTR ; +static void spi_flash_addr (u32 addr,u8 *cmd) {/* cmd[0] is actual command */
drivers/mtd/spi/spi_flash.c int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, · line 155
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +4
-0@@ -146,6 +149,10 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, {u8 cmd[5 ]; +/* Handle memory-mapped SPI */ +if (flash->memory_map) +memcpy (data, flash->memory_map + offset, len); +
What is this change implies, does this means for memory mapped flashes, read can do directly through memcpy()
and no need for spi_flash_read_common().
I am thinking what exactly this req' is for as you read the flash->memory_map + offset onto data and again your reading FAST_READ on data using spi_flash_read_common().
Can you please explain.
Thanks,
Jagan.
Quoted 101 lines
drivers/mtd/spi/spi_flash.c +38
-1cmd[0 ] =CMD_READ_ARRAY_FAST ;spi_flash_addr (offset, cmd); cmd[4 ] =0x00 ;@@ -275,6 +282,34 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)return 0 ; } +#ifdef CONFIG_OF_CONTROL +int spi_flash_decode_fdt (const void *blob,struct spi_flash *flash) +{ +fdt_addr_t addr; +fdt_size_t size; +int node; + +/* If there is no node, do nothing */ + node =fdtdec_next_compatible (blob,0 ,COMPAT_GENERIC_SPI_FLASH ); +if (node <0 ) +return 0 ; + + addr =fdtdec_get_addr_size (blob, node,"memory-map" , &size); +if (addr ==FDT_ADDR_T_NONE ) { +debug ("%s: Cannot decode address\n" , __func__); +return 0 ; + } + +if (flash->size != size) { +debug ("%s: Memory map must cover entire device\n" , __func__); +return -1 ; + } + flash->memory_map = (void *)addr; + +return 0 ; +} +#endif /* CONFIG_OF_CONTROL */ +/* * The following table holds all device probe functions * @@ -391,9 +426,18 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, goto err_manufacturer_probe; } +#ifdef CONFIG_OF_CONTROL +if (spi_flash_decode_fdt (gd->fdt_blob, flash)) { +debug ("SF: FDT decode error\n" ); + goto err_manufacturer_probe; + } +#endif printf ("SF: Detected %s with page size " , flash->name);print_size (flash->sector_size,", total " ); -print_size (flash->size,"\n" ); +print_size (flash->size,"" ); +if (flash->memory_map) +printf (", mapped at %p" , flash->memory_map); +puts ("\n" );spi_release_bus (spi);include/fdtdec.h +1
-0@@ -83,6 +83,7 @@ enum fdt_compat_id {COMPAT_SAMSUNG_EXYNOS_EHCI ,/* Exynos EHCI controller */ COMPAT_SAMSUNG_EXYNOS_USB_PHY ,/* Exynos phy controller for usb2.0 */ COMPAT_MAXIM_MAX77686_PMIC ,/* MAX77686 PMIC */ +COMPAT_GENERIC_SPI_FLASH ,/* Generic SPI Flash chip */ COMPAT_COUNT, };include/spi_flash.h +1
-0@@ -39,6 +39,7 @@ struct spi_flash {/* Erase (sector) size */ u32 sector_size; +void *memory_map;/* Address of read-only SPI flash access */ int (*read)(struct spi_flash *flash,u32 offset,size_t len,void *buf); int (*write)(struct spi_flash *flash, u32 offset,lib/fdtdec.c +1
-1@@ -56,6 +56,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (SAMSUNG_EXYNOS_EHCI ,"samsung,exynos-ehci" ),COMPAT (SAMSUNG_EXYNOS_USB_PHY ,"samsung,exynos-usb-phy" ),COMPAT (MAXIM_MAX77686_PMIC ,"maxim,max77686_pmic" ), + COMPAT(GENERIC_SPI_FLASH, "spi-flash"), };const char *fdtdec_get_compatible (enum fdt_compat_id id) --1.8.1.3
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH v2 10/15 sf: Enable FDT-based configuration and memory mapping
Hi Jagan,
Quoted 50 lines · Jagan Teki
Hi Simon,
Quoted 35 lines · Simon Glass
Enable device tree control of SPI flash, and use this to implement memory-mapped SPI flash, which is supported on Intel chips.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonedrivers/mtd/spi/spi_flash.c | 46 ++++++++++++++++++++++++++++++++++++++++++++- include/fdtdec.h | 1 + include/spi_flash.h | 1 + lib/fdtdec.c | 1 + 4 files changed, 48 insertions(+), 1 deletion(-)drivers/mtd/spi/spi_flash.c +3
-0@@ -8,6 +8,7 @@*/ #include <common.h> +#include <fdtdec.h> #include <malloc.h> #include <spi.h> #include <spi_flash.h> @@ -15,6 +16,8 @@#include "spi_flash_internal.h" +DECLARE_GLOBAL_DATA_PTR ; +static void spi_flash_addr (u32 addr,u8 *cmd) {/* cmd[0] is actual command */ drivers/mtd/spi/spi_flash.c int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, · line 155
Quoted 7 lines
drivers/mtd/spi/spi_flash.c +4
-0@@ -146,6 +149,10 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, {u8 cmd[5 ]; +/* Handle memory-mapped SPI */ +if (flash->memory_map) +memcpy (data, flash->memory_map + offset, len); +What is this change implies, does this means for memory mapped flashes, read can do directly through
memcpy()
and no need forspi_flash_read_common().
Quoted 5 lines
I am thinking what exactly this req' is for as you read the
flash->memory_map+ offset onto data and again your readingFAST_READon data usingspi_flash_read_common().Can you please explain.
Yes you are right, this should exit at this point - at present it is reading twice. I will prepare a patch.
Regards,
Simon
Quoted 105 lines
Thanks,
Jagan.Quoted 101 lines
drivers/mtd/spi/spi_flash.c +38
-1cmd[0 ] =CMD_READ_ARRAY_FAST ;spi_flash_addr (offset, cmd); cmd[4 ] =0x00 ;@@ -275,6 +282,34 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)return 0 ; } +#ifdef CONFIG_OF_CONTROL +int spi_flash_decode_fdt (const void *blob,struct spi_flash *flash) +{ +fdt_addr_t addr; +fdt_size_t size; +int node; + +/* If there is no node, do nothing */ + node =fdtdec_next_compatible (blob,0 ,COMPAT_GENERIC_SPI_FLASH ); +if (node <0 ) +return 0 ; + + addr =fdtdec_get_addr_size (blob, node,"memory-map" , &size); +if (addr ==FDT_ADDR_T_NONE ) { +debug ("%s: Cannot decode address\n" , __func__); +return 0 ; + } + +if (flash->size != size) { +debug ("%s: Memory map must cover entire device\n" , __func__); +return -1 ; + } + flash->memory_map = (void *)addr; + +return 0 ; +} +#endif /* CONFIG_OF_CONTROL */ +/* * The following table holds all device probe functions * @@ -391,9 +426,18 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, goto err_manufacturer_probe; } +#ifdef CONFIG_OF_CONTROL +if (spi_flash_decode_fdt (gd->fdt_blob, flash)) { +debug ("SF: FDT decode error\n" ); + goto err_manufacturer_probe; + } +#endif printf ("SF: Detected %s with page size " , flash->name);print_size (flash->sector_size,", total " ); -print_size (flash->size,"\n" ); +print_size (flash->size,"" ); +if (flash->memory_map) +printf (", mapped at %p" , flash->memory_map); +puts ("\n" );spi_release_bus (spi);include/fdtdec.h +1
-0@@ -83,6 +83,7 @@ enum fdt_compat_id {COMPAT_SAMSUNG_EXYNOS_EHCI ,/* Exynos EHCI controller */ COMPAT_SAMSUNG_EXYNOS_USB_PHY ,/* Exynos phy controller for usb2.0 */ COMPAT_MAXIM_MAX77686_PMIC ,/* MAX77686 PMIC */ +COMPAT_GENERIC_SPI_FLASH ,/* Generic SPI Flash chip */ COMPAT_COUNT, };include/spi_flash.h +1
-0@@ -39,6 +39,7 @@ struct spi_flash {/* Erase (sector) size */ u32 sector_size; +void *memory_map;/* Address of read-only SPI flash access */ int (*read)(struct spi_flash *flash,u32 offset,size_t len,void *buf); int (*write)(struct spi_flash *flash, u32 offset,lib/fdtdec.c +1
-1@@ -56,6 +56,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (SAMSUNG_EXYNOS_EHCI ,"samsung,exynos-ehci" ),COMPAT (SAMSUNG_EXYNOS_USB_PHY ,"samsung,exynos-usb-phy" ),COMPAT (MAXIM_MAX77686_PMIC ,"maxim,max77686_pmic" ), + COMPAT(GENERIC_SPI_FLASH, "spi-flash"), };const char *fdtdec_get_compatible (enum fdt_compat_id id) --1.8.1.3
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH v2 11/15 x86: Move PCI init before SPI init
In reply to Simon GlassIt is possible that our PCI bus will provide the SPI controller, so change the init order to make this work.
---
Changes in v2: None
arch/x86/lib/board.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/board.c +4 -4
@@ -163,13 +163,13 @@ init_fnc_t *init_sequence_r[] = {#ifndef CONFIG_SYS_NO_FLASH flash_init_r,#endif -#ifdef CONFIG_SPI - init_func_spi; -#endif - env_relocate_r,#ifdef CONFIG_PCI pci_init_r,#endif +#ifdef CONFIG_SPI + init_func_spi, +#endif + env_relocate_r, stdio_init, jumptable_init_r, console_init_r,
Signature · 1 line
1.8.1.3
PATCH v2 12/15 x86: Add FDT SPI node for link
In reply to Simon GlassAdd a memory-mapped 8GB SPI chip.
---
Changes in v2: None
board/chromebook-x86/dts/link.dts | 11 +++++++++++ 1 file changed, 11 insertions(+)
board/chromebook-x86/dts/link.dts +11 -0
@@ -21,4 +21,15 @@ chosen { }; memory { device_type = "memory"; reg = <0 0>; }; + + spi { + #address-cells = <1>; + #size-cells = <0>; + compatible = "intel,ich9"; + spi-flash at 0 { + reg = <0>; + compatible = "winbond,w25q64", "spi-flash"; + memory-map = <0xff800000 0x00800000>; + }; + }; };
Signature · 1 line
1.8.1.3
PATCH v2 13/15 x86: Enable SPI flash support for coreboot
In reply to Simon GlassTurn on SPI flash support and related commands.
---
Changes in v2: None
include/configs/coreboot.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
include/configs/coreboot.h +9 -3
@@ -257,10 +257,16 @@/*----------------------------------------------------------------------- * FLASH configuration */ +#define CONFIG_ICH_SPI +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_MACRONIX +#define CONFIG_SPI_FLASH_WINBOND +#define CONFIG_SPI_FLASH_GIGADEVICE #define CONFIG_SYS_NO_FLASH -#undef CONFIG_FLASH_CFI_DRIVER -#define CONFIG_SYS_MAX_FLASH_SECT 1 -#define CONFIG_SYS_MAX_FLASH_BANKS 1 +#define CONFIG_CMD_SF +#define CONFIG_CMD_SF_TEST +#define CONFIG_CMD_SPI +#define CONFIG_SPI /*----------------------------------------------------------------------- * Environment configuration
Signature · 1 line
1.8.1.3
PATCH v2 14/15 x86: Enable time command for coreboot
In reply to Simon GlassThis command is useful for measuring SPI flash load times and the like. Enable gettime as well to obtain absolute time tick values.
---
Changes in v2:
- Enable gettime command for coreboot also
include/configs/coreboot.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/coreboot.h +2 -0
@@ -179,6 +179,8 @@#define CONFIG_CMD_SAVEENV #define CONFIG_CMD_SETGETDCR #define CONFIG_CMD_SOURCE +#define CONFIG_CMD_TIME +#define CONFIG_CMD_GETTIME #define CONFIG_CMD_XIMG #define CONFIG_CMD_SCSI
Signature · 1 line
1.8.1.3
PATCH v2 15/15 sf: Use unsigned type for buffers
In reply to Simon GlassThe verify code is broken on archs with signed char. Fix it.
---
Changes in v2:
- Add new patch to use unsigned type for buffers in 'sf test'
common/cmd_sf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
common/cmd_sf.c +4 -4
@@ -369,8 +369,8 @@ static void spi_test_next_stage(struct test_info *test)* @param vbuf Verification buffer * @return 0 if ok, -1 on error */ -static int spi_flash_test (struct spi_flash *flash,char *buf,ulong len, -ulong offset,char *vbuf) +static int spi_flash_test (struct spi_flash *flash,uint8_t *buf,ulong len, +ulong offset,uint8_t *vbuf) {struct test_info test;int i;
@@ -431,9 +431,9 @@ static int do_spi_flash_test(int argc, char * const argv[]) {unsigned long offset;unsigned long len; -char *buf = (char *)CONFIG_SYS_TEXT_BASE ; +uint8_t *buf = (uint8_t *)CONFIG_SYS_TEXT_BASE ;char *endp; -char *vbuf; +uint8_t *vbuf;int ret; offset =simple_strtoul (argv[1 ], &endp,16 );
Signature · 1 line
1.8.1.3