MTD FLASH driver: Clone Sebastien Lorquet's m25px change to at25, is25xp, ramtron, and sst25xx.
This commit is contained in:
parent
2851959dee
commit
0a85a41678
|
@ -524,6 +524,12 @@ static ssize_t at25_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
|||
|
||||
finfo("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes);
|
||||
|
||||
/* Lock the SPI bus NOW because the following call must be executed with
|
||||
* the bus locked.
|
||||
*/
|
||||
|
||||
at25_lock(priv->dev);
|
||||
|
||||
/* Wait for any preceding write to complete. We could simplify things by
|
||||
* perform this wait at the end of each write operation (rather than at
|
||||
* the beginning of ALL operations), but have the wait first will slightly
|
||||
|
@ -532,9 +538,8 @@ static ssize_t at25_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
|||
|
||||
at25_waitwritecomplete(priv);
|
||||
|
||||
/* Lock the SPI bus and select this FLASH part */
|
||||
/* Select this FLASH part */
|
||||
|
||||
at25_lock(priv->dev);
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH(0), true);
|
||||
|
||||
/* Send "Read from Memory " instruction */
|
||||
|
|
|
@ -749,6 +749,12 @@ static ssize_t is25xp_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbyte
|
|||
|
||||
finfo("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes);
|
||||
|
||||
/* Lock the SPI bus NOW because the following call must be executed with
|
||||
* the bus locked.
|
||||
*/
|
||||
|
||||
is25xp_lock(priv->dev);
|
||||
|
||||
/* Wait for any preceding write to complete. We could simplify things by
|
||||
* perform this wait at the end of each write operation (rather than at
|
||||
* the beginning of ALL operations), but have the wait first will slightly
|
||||
|
@ -760,9 +766,8 @@ static ssize_t is25xp_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbyte
|
|||
is25xp_waitwritecomplete(priv);
|
||||
}
|
||||
|
||||
/* Lock the SPI bus and select this FLASH part */
|
||||
/* Select this FLASH part */
|
||||
|
||||
is25xp_lock(priv->dev);
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH(0), true);
|
||||
|
||||
/* Send "Read from Memory " instruction */
|
||||
|
@ -783,6 +788,7 @@ static ssize_t is25xp_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbyte
|
|||
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH(0), false);
|
||||
is25xp_unlock(priv->dev);
|
||||
|
||||
finfo("return nbytes: %d\n", (int)nbytes);
|
||||
return nbytes;
|
||||
}
|
||||
|
|
|
@ -532,8 +532,8 @@ static inline void ramtron_sendaddr(const struct ramtron_dev_s *priv, uint32_t a
|
|||
* Name: ramtron_pagewrite
|
||||
************************************************************************************/
|
||||
|
||||
static inline int ramtron_pagewrite(struct ramtron_dev_s *priv, FAR const uint8_t *buffer,
|
||||
off_t page)
|
||||
static inline int ramtron_pagewrite(struct ramtron_dev_s *priv,
|
||||
FAR const uint8_t *buffer, off_t page)
|
||||
{
|
||||
off_t offset = page << priv->pageshift;
|
||||
|
||||
|
@ -663,6 +663,12 @@ static ssize_t ramtron_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbyt
|
|||
|
||||
finfo("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes);
|
||||
|
||||
/* Lock the SPI bus NOW because the ramtron_waitwritecomplete call must be
|
||||
* executed with the bus locked.
|
||||
*/
|
||||
|
||||
ramtron_lock(priv);
|
||||
|
||||
#ifndef CONFIG_RAMTRON_WRITEWAIT
|
||||
/* Wait for any preceding write to complete. We could simplify things by
|
||||
* perform this wait at the end of each write operation (rather than at
|
||||
|
@ -673,9 +679,8 @@ static ssize_t ramtron_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbyt
|
|||
(void)ramtron_waitwritecomplete(priv);
|
||||
#endif
|
||||
|
||||
/* Lock the SPI bus and select this FLASH part */
|
||||
/* Select this FLASH part */
|
||||
|
||||
ramtron_lock(priv);
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH(0), true);
|
||||
|
||||
/* Send "Read from Memory " instruction */
|
||||
|
|
|
@ -680,7 +680,8 @@ static ssize_t sst25xx_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
|||
|
||||
/* On this device, we can handle the block read just like the byte-oriented read */
|
||||
|
||||
nbytes = sst25xx_read(dev, startblock << priv->pageshift, nblocks << priv->pageshift, buffer);
|
||||
nbytes = sst25xx_read(dev, startblock << priv->pageshift,
|
||||
nblocks << priv->pageshift, buffer);
|
||||
if (nbytes > 0)
|
||||
{
|
||||
return nbytes >> priv->pageshift;
|
||||
|
@ -727,6 +728,12 @@ static ssize_t sst25xx_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbyt
|
|||
|
||||
finfo("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes);
|
||||
|
||||
/* Lock the SPI bus NOW because the following conditional call to
|
||||
* sst25xx_waitwritecomplete must be executed with the bus locked.
|
||||
*/
|
||||
|
||||
sst25xx_lock(priv->dev);
|
||||
|
||||
/* Wait for any preceding write to complete. We could simplify things by
|
||||
* perform this wait at the end of each write operation (rather than at
|
||||
* the beginning of ALL operations), but have the wait first will slightly
|
||||
|
@ -738,9 +745,8 @@ static ssize_t sst25xx_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbyt
|
|||
sst25xx_waitwritecomplete(priv);
|
||||
}
|
||||
|
||||
/* Lock the SPI bus and select this FLASH part */
|
||||
/* Select this FLASH part */
|
||||
|
||||
sst25xx_lock(priv->dev);
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH(0), true);
|
||||
|
||||
/* Send "Read from Memory " instruction */
|
||||
|
|
|
@ -1070,6 +1070,7 @@ static ssize_t w25_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nbl
|
|||
{
|
||||
nbytes >>= W25_SECTOR512_SHIFT;
|
||||
}
|
||||
|
||||
#else
|
||||
nbytes = w25_read(dev, startblock << W25_PAGE_SHIFT, nblocks << W25_PAGE_SHIFT, buffer);
|
||||
if (nbytes > 0)
|
||||
|
|
Loading…
Reference in New Issue