Message ID | 1438234483-3738-8-git-send-email-vigneshr@ti.com |
---|---|
State | Superseded |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show |
On 30 July 2015 at 11:04, Vignesh R <vigneshr@ti.com> wrote: > From: Tom Rini <trini@ti.com> > > When doing a memory mapped copy we may have DMA available and thus need > to have this copy abstracted so that the driver can do it, rather than a > simple memcpy. > > Signed-off-by: Tom Rini <trini@ti.com> > Signed-off-by: Vignesh R <vigneshr@ti.com> > --- Reviewed-by: Jagan Teki <jteki@openedev.com> > drivers/mtd/spi/sf_ops.c | 8 +++++++- > include/spi.h | 3 +++ > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c > index 38592f518b72..900ec1f2a9ce 100644 > --- a/drivers/mtd/spi/sf_ops.c > +++ b/drivers/mtd/spi/sf_ops.c > @@ -14,6 +14,7 @@ > #include <spi.h> > #include <spi_flash.h> > #include <watchdog.h> > +#include <linux/compiler.h> > > #include "sf_internal.h" > > @@ -378,6 +379,11 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd, > return ret; > } > > +void __weak spi_flash_copy_mmap(void *data, void *offset, size_t len) > +{ > + memcpy(data, offset, len); > +} > + > int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, > size_t len, void *data) > { > @@ -394,7 +400,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, > return ret; > } > spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP); > - memcpy(data, flash->memory_map + offset, len); > + spi_flash_copy_mmap(data, flash->memory_map + offset, len); > spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP_END); > spi_release_bus(flash->spi); > return 0; > diff --git a/include/spi.h b/include/spi.h > index 18362364cf0e..51fdfd6d7360 100644 > --- a/include/spi.h > +++ b/include/spi.h > @@ -272,6 +272,9 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen); > int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, > void *din, unsigned long flags); > > +/* Copy memory mapped data */ > +void spi_flash_copy_mmap(void *data, void *offset, size_t len); > + > /** > * Determine if a SPI chipselect is valid. > * This function is provided by the board if the low-level SPI driver > -- > 2.5.0 > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot thanks!
diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 38592f518b72..900ec1f2a9ce 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -14,6 +14,7 @@ #include <spi.h> #include <spi_flash.h> #include <watchdog.h> +#include <linux/compiler.h> #include "sf_internal.h" @@ -378,6 +379,11 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd, return ret; } +void __weak spi_flash_copy_mmap(void *data, void *offset, size_t len) +{ + memcpy(data, offset, len); +} + int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, size_t len, void *data) { @@ -394,7 +400,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, return ret; } spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP); - memcpy(data, flash->memory_map + offset, len); + spi_flash_copy_mmap(data, flash->memory_map + offset, len); spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP_END); spi_release_bus(flash->spi); return 0; diff --git a/include/spi.h b/include/spi.h index 18362364cf0e..51fdfd6d7360 100644 --- a/include/spi.h +++ b/include/spi.h @@ -272,6 +272,9 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen); int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags); +/* Copy memory mapped data */ +void spi_flash_copy_mmap(void *data, void *offset, size_t len); + /** * Determine if a SPI chipselect is valid. * This function is provided by the board if the low-level SPI driver