mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-30 23:21:27 +01:00
sf: dataflash: Minor cleanups
- fix single line comments - remove unneeded spaces - ascending order of include files - rename SPI DATAFLASH to dataflash - rename SPI DataFlash to dataflash - return NULL replaced with error code Cc: Bin Meng <bmeng.cn@gmail.com> Cc: York Sun <york.sun@nxp.com> Signed-off-by: Jagan Teki <jagan@openedev.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jagan Teki <jagan@openedev.com>
This commit is contained in:
parent
11b93228a7
commit
25488ec193
@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Atmel DataFlash probing
|
* Atmel DataFlash probing
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004-2009, 2015 Freescale Semiconductor, Inc.
|
* Copyright (C) 2004-2009, 2015 Freescale Semiconductor, Inc.
|
||||||
@ -7,6 +6,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0+
|
* SPDX-License-Identifier: GPL-2.0+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -67,15 +67,12 @@
|
|||||||
#define OP_WRITE_SECURITY_REVC 0x9A
|
#define OP_WRITE_SECURITY_REVC 0x9A
|
||||||
#define OP_WRITE_SECURITY 0x9B /* revision D */
|
#define OP_WRITE_SECURITY 0x9B /* revision D */
|
||||||
|
|
||||||
|
|
||||||
struct dataflash {
|
struct dataflash {
|
||||||
uint8_t command[16];
|
uint8_t command[16];
|
||||||
unsigned short page_offset; /* offset in flash address */
|
unsigned short page_offset; /* offset in flash address */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/* Return the status of the DataFlash device */
|
||||||
* Return the status of the DataFlash device.
|
|
||||||
*/
|
|
||||||
static inline int dataflash_status(struct spi_slave *spi)
|
static inline int dataflash_status(struct spi_slave *spi)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -114,9 +111,7 @@ static int dataflash_waitready(struct spi_slave *spi)
|
|||||||
return -ETIME;
|
return -ETIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Erase pages of flash */
|
||||||
* Erase pages of flash.
|
|
||||||
*/
|
|
||||||
static int spi_dataflash_erase(struct udevice *dev, u32 offset, size_t len)
|
static int spi_dataflash_erase(struct udevice *dev, u32 offset, size_t len)
|
||||||
{
|
{
|
||||||
struct dataflash *dataflash;
|
struct dataflash *dataflash;
|
||||||
@ -147,7 +142,7 @@ static int spi_dataflash_erase(struct udevice *dev, u32 offset, size_t len)
|
|||||||
|
|
||||||
status = spi_claim_bus(spi);
|
status = spi_claim_bus(spi);
|
||||||
if (status) {
|
if (status) {
|
||||||
debug("SPI DATAFLASH: unable to claim SPI bus\n");
|
debug("dataflash: unable to claim SPI bus\n");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +227,7 @@ static int spi_dataflash_read(struct udevice *dev, u32 offset, size_t len,
|
|||||||
|
|
||||||
status = spi_claim_bus(spi);
|
status = spi_claim_bus(spi);
|
||||||
if (status) {
|
if (status) {
|
||||||
debug("SPI DATAFLASH: unable to claim SPI bus\n");
|
debug("dataflash: unable to claim SPI bus\n");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +285,7 @@ int spi_dataflash_write(struct udevice *dev, u32 offset, size_t len,
|
|||||||
|
|
||||||
status = spi_claim_bus(spi);
|
status = spi_claim_bus(spi);
|
||||||
if (status) {
|
if (status) {
|
||||||
debug("SPI DATAFLASH: unable to claim SPI bus\n");
|
debug("dataflash: unable to claim SPI bus\n");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +382,7 @@ int spi_dataflash_write(struct udevice *dev, u32 offset, size_t len,
|
|||||||
|
|
||||||
/* Check result of the compare operation */
|
/* Check result of the compare operation */
|
||||||
if (status & (1 << 6)) {
|
if (status & (1 << 6)) {
|
||||||
printf("SPI DataFlash: write compare page %u, err %d\n",
|
printf("dataflash: write compare page %u, err %d\n",
|
||||||
pageaddr, status);
|
pageaddr, status);
|
||||||
remaining = 0;
|
remaining = 0;
|
||||||
status = -EIO;
|
status = -EIO;
|
||||||
@ -539,7 +534,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
|
|||||||
if (info->flags & SUP_POW2PS) {
|
if (info->flags & SUP_POW2PS) {
|
||||||
status = dataflash_status(spi);
|
status = dataflash_status(spi);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
debug("SPI DataFlash: status error %d\n",
|
debug("dataflash: status error %d\n",
|
||||||
status);
|
status);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -561,10 +556,8 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
|
|||||||
* size (it might be binary) even when we can tell which density
|
* size (it might be binary) even when we can tell which density
|
||||||
* class is involved (legacy chip id scheme).
|
* class is involved (legacy chip id scheme).
|
||||||
*/
|
*/
|
||||||
printf("SPI DataFlash: Unsupported flash IDs: ");
|
printf("dataflash: JEDEC id %06x not handled\n", jedec);
|
||||||
printf("manuf %02x, jedec %04x, ext_jedec %04x\n",
|
return ERR_PTR(-ENODEV);
|
||||||
id[0], jedec, id[3] << 8 | id[4]);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -620,7 +613,7 @@ static int spi_dataflash_probe(struct udevice *dev)
|
|||||||
*/
|
*/
|
||||||
status = dataflash_status(spi);
|
status = dataflash_status(spi);
|
||||||
if (status <= 0 || status == 0xff) {
|
if (status <= 0 || status == 0xff) {
|
||||||
printf("SPI DataFlash: read status error %d\n", status);
|
printf("dataflash: read status error %d\n", status);
|
||||||
if (status == 0 || status == 0xff)
|
if (status == 0 || status == 0xff)
|
||||||
status = -ENODEV;
|
status = -ENODEV;
|
||||||
goto err_jedec_probe;
|
goto err_jedec_probe;
|
||||||
@ -656,8 +649,7 @@ static int spi_dataflash_probe(struct udevice *dev)
|
|||||||
break;
|
break;
|
||||||
/* obsolete AT45DB1282 not (yet?) supported */
|
/* obsolete AT45DB1282 not (yet?) supported */
|
||||||
default:
|
default:
|
||||||
dev_info(&spi->dev, "unsupported device (%x)\n",
|
printf("dataflash: unsupported device (%x)\n", status & 0x3c);
|
||||||
status & 0x3c);
|
|
||||||
status = -ENODEV;
|
status = -ENODEV;
|
||||||
goto err_status;
|
goto err_status;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user