Re: [U-Boot] [PATCH 1/2] SPI: Add struct spi_flash.sector_size parameter

2011-04-11 Thread Mike Frysinger
these patches have been integrated/superseded by my recent sf patchset
-mike


signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] SPI: Add struct spi_flash.sector_size parameter

2011-02-16 Thread Richard Retanubun
This patch adds a new member to struct spi_flash (u16 sector_size)
and updates the spi flash drivers to start populating it.

This parameter can be used by spi flash commands that need to round
up units of operation to the flash's sector_size.

Signed-off-by: Richard Retanubun 
---
v2: scrubbed via checkpatch, thanks WD!

 drivers/mtd/spi/atmel.c|1 +
 drivers/mtd/spi/macronix.c |1 +
 drivers/mtd/spi/spansion.c |4 ++--
 drivers/mtd/spi/sst.c  |3 ++-
 drivers/mtd/spi/stmicro.c  |4 ++--
 drivers/mtd/spi/winbond.c  |5 +++--
 include/spi_flash.h|2 ++
 7 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c
index a9910b1..180a52b 100644
--- a/drivers/mtd/spi/atmel.c
+++ b/drivers/mtd/spi/atmel.c
@@ -498,6 +498,7 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave 
*spi, u8 *idcode)
asf->flash.size = page_size * params->pages_per_block
* params->blocks_per_sector
* params->nr_sectors;
+   asf->flash.sector_size = page_size;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, page_size);
diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c
index 4155d4d..4a8e17f 100644
--- a/drivers/mtd/spi/macronix.c
+++ b/drivers/mtd/spi/macronix.c
@@ -217,6 +217,7 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave 
*spi, u8 *idcode)
mcx->flash.read = spi_flash_cmd_read_fast;
mcx->flash.size = params->page_size * params->pages_per_sector
* params->sectors_per_block * params->nr_blocks;
+   mcx->flash.sector_size = mcx->flash.size/params->nr_blocks;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, params->page_size);
diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
index d54a5fa..c88457b 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -199,8 +199,7 @@ static int spansion_write(struct spi_flash *flash,
 int spansion_erase(struct spi_flash *flash, u32 offset, size_t len)
 {
struct spansion_spi_flash *spsn = to_spansion_spi_flash(flash);
-   return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE,
-   spsn->params->page_size * spsn->params->pages_per_sector,
+   return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE, flash->sector_size,
offset, len);
 }
 
@@ -242,6 +241,7 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave 
*spi, u8 *idcode)
spsn->flash.read = spi_flash_cmd_read_fast;
spsn->flash.size = params->page_size * params->pages_per_sector
* params->nr_sectors;
+   spsn->flash.sector_size = spsn->flash.size/params->nr_sectors;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, params->page_size);
diff --git a/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c
index 792d04d..15de12b 100644
--- a/drivers/mtd/spi/sst.c
+++ b/drivers/mtd/spi/sst.c
@@ -201,7 +201,7 @@ sst_write(struct spi_flash *flash, u32 offset, size_t len, 
const void *buf)
 
 int sst_erase(struct spi_flash *flash, u32 offset, size_t len)
 {
-   return spi_flash_cmd_erase(flash, CMD_SST_SE, SST_SECTOR_SIZE,
+   return spi_flash_cmd_erase(flash, CMD_SST_SE, flash->sector_size,
offset, len);
 }
 
@@ -257,6 +257,7 @@ spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)
stm->flash.write = sst_write;
stm->flash.erase = sst_erase;
stm->flash.size = SST_SECTOR_SIZE * params->nr_sectors;
+   stm->flash.sector_size = SST_SECTOR_SIZE;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, SST_SECTOR_SIZE);
diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c
index 7ef690d..80d838e 100644
--- a/drivers/mtd/spi/stmicro.c
+++ b/drivers/mtd/spi/stmicro.c
@@ -200,8 +200,7 @@ static int stmicro_write(struct spi_flash *flash,
 int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
 {
struct stmicro_spi_flash *stm = to_stmicro_spi_flash(flash);
-   return spi_flash_cmd_erase(flash, CMD_M25PXX_SE,
-   stm->params->page_size * stm->params->pages_per_sector,
+   return spi_flash_cmd_erase(flash, CMD_M25PXX_SE, flash->sector_size,
offset, len);
 }
 
@@ -251,6 +250,7 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave 
*spi, u8 * idcode)
stm->flash.read = spi_flash_cmd_read_fast;
stm->flash.size = params->page_size * params->pages_per_sector
* params->nr_sectors;
+   stm->flash.sector_size = stm->flash.size/params->nr_sectors;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, params->page_size);
diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c
index e88802f..ec6fb79 100644
--- a/drivers/mtd/spi/winbond.c
+++ b/drivers/mtd/spi/winbond.c
@@ -173,8 +173,7

Re: [U-Boot] [PATCH 1/2] SPI: Add struct spi_flash.sector_size parameter

2011-02-16 Thread Wolfgang Denk
Dear Richard Retanubun,

In message <1297888074-8344-2-git-send-email-richardretanu...@ruggedcom.com> 
you wrote:
> This patch adds a new member to struct spi_flash (u16 sector_size)
> and updates the spi flash drivers to start populating it.
> 
> This parameter can be used by spi flash commands that need to round
> up units of operation to the flash's sector_size.
> ---
>  drivers/mtd/spi/atmel.c|1 +
>  drivers/mtd/spi/macronix.c |1 +
>  drivers/mtd/spi/spansion.c |4 ++--
>  drivers/mtd/spi/sst.c  |3 ++-
>  drivers/mtd/spi/stmicro.c  |4 ++--
>  drivers/mtd/spi/winbond.c  |5 +++--
>  include/spi_flash.h|2 ++
>  7 files changed, 13 insertions(+), 7 deletions(-)

Rejected - Signed-off-by: line missing.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
God made the integers; all else is the work of Man.   - Kronecker
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] SPI: Add struct spi_flash.sector_size parameter

2011-02-16 Thread Richard Retanubun
This patch adds a new member to struct spi_flash (u16 sector_size)
and updates the spi flash drivers to start populating it.

This parameter can be used by spi flash commands that need to round
up units of operation to the flash's sector_size.
---
 drivers/mtd/spi/atmel.c|1 +
 drivers/mtd/spi/macronix.c |1 +
 drivers/mtd/spi/spansion.c |4 ++--
 drivers/mtd/spi/sst.c  |3 ++-
 drivers/mtd/spi/stmicro.c  |4 ++--
 drivers/mtd/spi/winbond.c  |5 +++--
 include/spi_flash.h|2 ++
 7 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c
index a9910b1..180a52b 100644
--- a/drivers/mtd/spi/atmel.c
+++ b/drivers/mtd/spi/atmel.c
@@ -498,6 +498,7 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave 
*spi, u8 *idcode)
asf->flash.size = page_size * params->pages_per_block
* params->blocks_per_sector
* params->nr_sectors;
+   asf->flash.sector_size = page_size;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, page_size);
diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c
index 4155d4d..4a8e17f 100644
--- a/drivers/mtd/spi/macronix.c
+++ b/drivers/mtd/spi/macronix.c
@@ -217,6 +217,7 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave 
*spi, u8 *idcode)
mcx->flash.read = spi_flash_cmd_read_fast;
mcx->flash.size = params->page_size * params->pages_per_sector
* params->sectors_per_block * params->nr_blocks;
+   mcx->flash.sector_size = mcx->flash.size/params->nr_blocks;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, params->page_size);
diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
index d54a5fa..c88457b 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -199,8 +199,7 @@ static int spansion_write(struct spi_flash *flash,
 int spansion_erase(struct spi_flash *flash, u32 offset, size_t len)
 {
struct spansion_spi_flash *spsn = to_spansion_spi_flash(flash);
-   return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE,
-   spsn->params->page_size * spsn->params->pages_per_sector,
+   return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE, flash->sector_size,
offset, len);
 }
 
@@ -242,6 +241,7 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave 
*spi, u8 *idcode)
spsn->flash.read = spi_flash_cmd_read_fast;
spsn->flash.size = params->page_size * params->pages_per_sector
* params->nr_sectors;
+   spsn->flash.sector_size = spsn->flash.size/params->nr_sectors;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, params->page_size);
diff --git a/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c
index 792d04d..15de12b 100644
--- a/drivers/mtd/spi/sst.c
+++ b/drivers/mtd/spi/sst.c
@@ -201,7 +201,7 @@ sst_write(struct spi_flash *flash, u32 offset, size_t len, 
const void *buf)
 
 int sst_erase(struct spi_flash *flash, u32 offset, size_t len)
 {
-   return spi_flash_cmd_erase(flash, CMD_SST_SE, SST_SECTOR_SIZE,
+   return spi_flash_cmd_erase(flash, CMD_SST_SE, flash->sector_size,
offset, len);
 }
 
@@ -257,6 +257,7 @@ spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)
stm->flash.write = sst_write;
stm->flash.erase = sst_erase;
stm->flash.size = SST_SECTOR_SIZE * params->nr_sectors;
+   stm->flash.sector_size = SST_SECTOR_SIZE;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, SST_SECTOR_SIZE);
diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c
index 7ef690d..80d838e 100644
--- a/drivers/mtd/spi/stmicro.c
+++ b/drivers/mtd/spi/stmicro.c
@@ -200,8 +200,7 @@ static int stmicro_write(struct spi_flash *flash,
 int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
 {
struct stmicro_spi_flash *stm = to_stmicro_spi_flash(flash);
-   return spi_flash_cmd_erase(flash, CMD_M25PXX_SE,
-   stm->params->page_size * stm->params->pages_per_sector,
+   return spi_flash_cmd_erase(flash, CMD_M25PXX_SE, flash->sector_size,
offset, len);
 }
 
@@ -251,6 +250,7 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave 
*spi, u8 * idcode)
stm->flash.read = spi_flash_cmd_read_fast;
stm->flash.size = params->page_size * params->pages_per_sector
* params->nr_sectors;
+   stm->flash.sector_size = stm->flash.size/params->nr_sectors;
 
printf("SF: Detected %s with page size %u, total ",
   params->name, params->page_size);
diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c
index e88802f..ec6fb79 100644
--- a/drivers/mtd/spi/winbond.c
+++ b/drivers/mtd/spi/winbond.c
@@ -173,8 +173,7 @@ out:
 int winbond_erase(struct spi_flash *flash, u32 offset, size_t len)