[U-Boot] [U-BOOT][PATCH 3/4] mflash : Use common libata function
unsik Kim
donari75 at gmail.com
Wed Feb 18 11:51:50 CET 2009
replace mg_ident_cpy to ata_id_c_string
Signed-off-by: unsik Kim <donari75 at gmail.com>
---
doc/README.mflash | 1 +
drivers/block/mg_disk.c | 67 ++++++++--------------------------------------
2 files changed, 13 insertions(+), 55 deletions(-)
diff --git a/doc/README.mflash b/doc/README.mflash
index d0d0f7b..50133b4 100644
--- a/doc/README.mflash
+++ b/doc/README.mflash
@@ -17,6 +17,7 @@ So the rest mflash repersents mflash and gflash altogether.
2-1. Board configuration
* Mflash driver support
#define CONFIG_CMD_MG_DISK
+#define CONFIG_LIBATA
* Environment variable support (optional)
#define CONFIG_ENV_IS_IN_MG_DISK
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 1f9debe..113aa79 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -85,37 +85,6 @@ static void mg_dump_status (const char *msg, unsigned int stat, unsigned err)
}
}
-/*
- * copy src to dest, skipping leading and trailing blanks and null
- * terminate the string
- * "len" is the size of available memory including the terminating '\0'
- */
-static void mg_ident_cpy (unsigned char *dst, unsigned char *src,
- unsigned int len)
-{
- unsigned char *end, *last;
-
- last = dst;
- end = src + len - 1;
-
- /* reserve space for '\0' */
- if (len < 2)
- goto OUT;
-
- /* skip leading white space */
- while ((*src) && (src < end) && (*src == ' '))
- ++src;
-
- /* copy string, omitting trailing white space */
- while ((*src) && (src < end)) {
- *dst++ = *src;
- if (*src++ != ' ')
- last = dst;
- }
-OUT:
- *last = '\0';
-}
-
static unsigned int mg_wait (u32 expect, u32 msec)
{
u8 status;
@@ -158,46 +127,34 @@ static unsigned int mg_wait (u32 expect, u32 msec)
static int mg_get_disk_id (void)
{
- u32 iobuf[(MG_SECTOR_SIZE / sizeof(u32))];
- hd_driveid_t *iop = (hd_driveid_t *)iobuf;
+ u16 id[(MG_SECTOR_SIZE / sizeof(u16))];
+ hd_driveid_t *iop = (hd_driveid_t *)id;
u32 i, err, res;
- u16 *buff = (u16 *)iobuf;
writeb(MG_CMD_ID, mg_base() + MG_REG_COMMAND);
err = mg_wait(MG_REG_STATUS_BIT_DATA_REQ, 3000);
if (err)
return err;
- for(i = 0; i < (MG_SECTOR_SIZE / sizeof(u32)) >> 1; i++)
- buff[i] = readw(mg_base() + MG_BUFF_OFFSET + i * 2);
+ for(i = 0; i < (MG_SECTOR_SIZE / sizeof(u16)); i++)
+ id[i] = readw(mg_base() + MG_BUFF_OFFSET + i * 2);
writeb(MG_CMD_RD_CONF, mg_base() + MG_REG_COMMAND);
err = mg_wait(MG_STAT_READY, 3000);
if (err)
return err;
+ ata_swap_buf_le16(id, MG_SECTOR_SIZE / sizeof(u16));
+
if((iop->field_valid & 1) == 0)
return MG_ERR_TRANSLATION;
- mg_ident_cpy((unsigned char*)mg_disk_dev.revision, iop->fw_rev,
- sizeof(mg_disk_dev.revision));
- mg_ident_cpy((unsigned char*)mg_disk_dev.vendor, iop->model,
- sizeof(mg_disk_dev.vendor));
- mg_ident_cpy((unsigned char*)mg_disk_dev.product, iop->serial_no,
- sizeof(mg_disk_dev.product));
-#ifdef __LITTLE_ENDIAN
- /*
- * firmware revision, model, and serial number have Big Endian Byte
- * order in Word. Convert all three to little endian.
- *
- * See CF+ and CompactFlash Specification Revision 2.0:
- * 6.2.1.6: Identify Drive, Table 39 for more details
- */
-
- strswab(mg_disk_dev.revision);
- strswab(mg_disk_dev.vendor);
- strswab(mg_disk_dev.product);
-#endif /* __LITTLE_ENDIAN */
+ ata_id_c_string(id, (unsigned char *)mg_disk_dev.revision,
+ ATA_ID_FW_REV, sizeof(mg_disk_dev.revision));
+ ata_id_c_string(id, (unsigned char *)mg_disk_dev.vendor,
+ ATA_ID_PROD, sizeof(mg_disk_dev.vendor));
+ ata_id_c_string(id, (unsigned char *)mg_disk_dev.product,
+ ATA_ID_SERNO, sizeof(mg_disk_dev.product));
#ifdef __BIG_ENDIAN
iop->lba_capacity = (iop->lba_capacity << 16) |
--
1.5.6.6
More information about the U-Boot
mailing list