mflash u-boot support (a little change)
Subsystems (2)
PATCH 1/1 mflash u-boot support (a little change)
Hello?
I fixed miscalculated total sectors when using reserve area feature.
Also I changed CONFIG_MG_DISK_RES's unit to KB. (Byte is too small and also needs sector size alignment.)
Any comments will be appreciated.
--- common/Makefile | 2 + common/cmd_mgdisk.c | 76 +++++ common/cmd_nvedit.c | 8 +- common/env_mgdisk.c | 90 ++++++ disk/part.c | 8 +- disk/part_amiga.c | 5 +- disk/part_dos.c | 1 + disk/part_efi.c | 1 + disk/part_iso.c | 1 + disk/part_mac.c | 1 + doc/README.mflash | 93 +++++++ drivers/block/Makefile | 5 +- drivers/block/mg_disk.c | 635 +++++++++++++++++++++++++++++++++++++++++++ drivers/block/mg_disk_prv.h | 140 ++++++++++ fs/fat/fat.c | 2 + include/config_cmd_all.h | 1 + include/environment.h | 12 + include/mg_disk.h | 51 ++++ include/part.h | 1 + 19 files changed, 1125 insertions(+), 8 deletions(-)
common/Makefile +2 -0
@@ -53,6 +53,7 @@ COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-y += env_embedded.o COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o +COBJS-$(CONFIG_ENV_IS_IN_MG_DISK) += env_mgdisk.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
@@ -104,6 +105,7 @@ COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o COBJS-$(CONFIG_CMD_MEMORY) += cmd_mem.o COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o +COBJS-$(CONFIG_CMD_MG_DISK) += cmd_mgdisk.o COBJS-$(CONFIG_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += cmd_mii.o
common/cmd_mgdisk.c new file +76 -0
76 lines not on this page · raw message
common/cmd_nvedit.c +3 -3
@@ -52,15 +52,17 @@DECLARE_GLOBAL_DATA_PTR ; -#if !defined(CONFIG_ENV_IS_IN_NVRAM ) && \ - !defined(CONFIG_ENV_IS_IN_EEPROM ) && \ +#if !defined(CONFIG_ENV_IS_IN_EEPROM ) && \ !defined(CONFIG_ENV_IS_IN_FLASH ) && \ !defined(CONFIG_ENV_IS_IN_DATAFLASH ) && \ + !defined(CONFIG_ENV_IS_IN_MG_DISK ) && \ !defined(CONFIG_ENV_IS_IN_NAND ) && \ + !defined(CONFIG_ENV_IS_IN_NVRAM ) && \ !defined(CONFIG_ENV_IS_IN_ONENAND ) && \ !defined(CONFIG_ENV_IS_IN_SPI_FLASH ) && \ !defined(CONFIG_ENV_IS_NOWHERE ) -# error Define one of
CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE} +# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
+SPI_FLASH|MG_DISK|NVRAM|NOWHERE}
#endif
#define XMK_STR(x) #x
common/env_mgdisk.c new file +90 -0
90 lines not on this page · raw message
disk/part.c +7 -1
@@ -35,6 +35,7 @@#endif #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_USB) || \
@@ -65,6 +66,9 @@ static const struct block_drvr block_drvr[] = { #if defined(CONFIG_SYSTEMACE) { .name = "ace", .get_dev = systemace_get_dev, }, #endif +#if defined(CONFIG_CMD_MG_DISK) + { .name = "mgd", .get_dev = mg_disk_get_dev, }, +#endif { }, };
@@ -91,6 +95,7 @@ block_dev_desc_t *get_dev(char* ifname, int dev)#endif #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_USB) || \
@@ -203,11 +208,12 @@ void dev_print (block_dev_desc_t *dev_desc)#endif #if (defined(CONFIG_CMD_IDE ) || \ + defined(CONFIG_CMD_MG_DISK ) || \ defined(CONFIG_CMD_SATA ) || \ defined(CONFIG_CMD_SCSI ) || \ defined(CONFIG_CMD_USB ) || \ defined(CONFIG_MMC ) || \ - defined(CONFIG_SYSTEMACE ) ) + defined(CONFIG_SYSTEMACE ) ) #if defined(CONFIG_MAC_PARTITION) || \ defined(CONFIG_DOS_PARTITION) || \
disk/part_amiga.c +1 -0
@@ -27,6 +27,7 @@#include "part_amiga.h" #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_USB) || \ defined(CONFIG_MMC) || \
@@ -154,7 +155,7 @@ struct rigid_disk_block
*get_rdisk(block_dev_desc_t *dev_desc)
s = getenv("amiga_scanlimit");
if (s)- limit = atoi(s);
+ limit = simple_strtoul(s, NULL, 10);
else
limit = AMIGA_BLOCK_LIMIT;
@@ -195,7 +196,7 @@ struct bootcode_block
*get_bootcode(block_dev_desc_t *dev_desc)
s = getenv("amiga_scanlimit");
if (s)- limit = atoi(s);
+ limit = simple_strtoul(s, NULL, 10);
else
limit = AMIGA_BLOCK_LIMIT;
disk/part_dos.c +1 -0
@@ -36,6 +36,7 @@#include "part_dos.h" #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_USB) || \
disk/part_efi.c +1 -0
@@ -37,6 +37,7 @@#include "part_efi.h" #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_USB) || \
disk/part_iso.c +1 -0
@@ -26,6 +26,7 @@#include "part_iso.h" #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_USB) || \
disk/part_mac.c +1 -0
@@ -35,6 +35,7 @@#include "part_mac.h" #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_USB) || \
doc/README.mflash new file +93 -0
93 lines not on this page · raw message
drivers/block/Makefile +3 -2
@@ -25,13 +25,14 @@ include $(TOPDIR)/config.mk LIB := $(obj)libblock.a -COBJS-$(CONFIG_SCSI_AHCI) += ahci.o COBJS-$(CONFIG_ATA_PIIX) += ata_piix.o +COBJS-$(CONFIG_CMD_MG_DISK) += mg_disk.o COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o +COBJS-$(CONFIG_IDE_SIL680) += sil680.o COBJS-$(CONFIG_LIBATA) += libata.o COBJS-$(CONFIG_PATA_BFIN) += pata_bfin.o COBJS-$(CONFIG_SATA_SIL3114) += sata_sil3114.o -COBJS-$(CONFIG_IDE_SIL680) += sil680.o +COBJS-$(CONFIG_SCSI_AHCI) += ahci.o COBJS-$(CONFIG_SCSI_SYM53C8XX) += sym53c8xx.o COBJS-$(CONFIG_SYSTEMACE) += systemace.o
drivers/block/mg_disk.c new file +635 -0
635 lines not on this page · raw message
drivers/block/mg_disk_prv.h new file +134 -0
134 lines not on this page · raw message
__LINE__,##args)
+#else /* CONFIG_MG_DEBUG */
+# define MG_DBG(fmt, args...) do { } while(0)
+#endif /* CONFIG_MG_DEBUG */
+
+#endif
+
fs/fat/fat.c +2 -0
@@ -84,6 +84,7 @@ fat_register_device(block_dev_desc_t *dev_desc, int part_no)return -1 ; } #if (defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_USB) || \
@@ -987,6 +988,7 @@ file_fat_detectfs(void)return 1 ; } #if defined(CONFIG_CMD_IDE) || \ + defined(CONFIG_CMD_MG_DISK) || \ defined(CONFIG_CMD_SATA) || \ defined(CONFIG_CMD_SCSI) || \ defined(CONFIG_CMD_USB) || \
include/config_cmd_all.h +1 -0
@@ -83,5 +83,6 @@#define CONFIG_CMD_VFD /* VFD support (TRAB) */ #define CONFIG_CMD_XIMG /* Load part of Multi Image */ #define CONFIG_CMD_AT91_SPIMUX /* AT91 MMC/SPI Mux Support */ +#define CONFIG_CMD_MG_DISK /* mGine m(g)flash IO node support */ #endif /* _CONFIG_CMD_ALL_H */
include/environment.h +9 -0
@@ -84,6 +84,18 @@# endif #endif /* CONFIG_ENV_IS_IN_NAND */ +#if defined(CONFIG_ENV_IS_IN_MG_DISK ) +# ifndef CONFIG_ENV_ADDR +# error "Need to define CONFIG_ENV_ADDR when using CONFIG_ENV_IS_IN_MG_DISK" +# endif +# ifndef CONFIG_ENV_SIZE +# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_MG_DISK" +# endif +# ifdef CONFIG_ENV_IS_EMBEDDED +# error "CONFIG_ENV_IS_EMBEDDED not supported when using
CONFIG_ENV_IS_IN_MG_DISK"
+# endif
+#endif /* CONFIG_ENV_IS_IN_MG_DISK */
+
#ifdef USE_HOSTCC
# include <stdint.h> #else
include/mg_disk.h new file +51 -0
51 lines not on this page · raw message
include/part.h +1 -0
@@ -100,6 +100,7 @@ block_dev_desc_t* scsi_get_dev(int dev);block_dev_desc_t *usb_stor_get_dev (int dev);block_dev_desc_t *mmc_get_dev (int dev);block_dev_desc_t *systemace_get_dev (int dev); +block_dev_desc_t *mg_disk_get_dev (int dev);/* disk/part.c */ int get_partition_info (block_dev_desc_t * dev_desc, int part,
disk_partition_t *info);
---
2009/2/2 unsik Kim <[email protected]>:
Quoted 421 lines
Hello?
I fixed and added followings for your requests.
1. too long line length => fixed
2. not a linux coding style => fixed
3. add document (doc/README.mflash)
4. ARM only dependency and always init problem => fixed
5.
msecs_to_hzfunction is changed.
In some ARM platform,CONFIG_SYS_HZis not 1000 (samsung s3c24xx, intel pxa25x, pxa27x)
andget_timer()just return elapsed tick of OS timer. For the compatibility of these, I use #ifdef.Any comments, advice will be appreciated.
Here is fixed patch.
unsik Kim
2009/1/28 Wolfgang Denk <[email protected]>:
Quoted 395 lines
Dear Kim,
Quoted 2 lines · In message <[email protected]> you…
I wrote mflash IO mode block device driver for U-Boot.
Thanks for your contribution. Here a few comments:
Quoted 13 lines
common/Makefile +1
-0@@ -57,6 +57,7 @@ COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o +COBJS-$(CONFIG_ENV_IS_IN_MG_DISK) += env_mgdisk.o COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o # commandcommon/Makefile endif · line 142
Quoted 4 lines
common/Makefile +1
-0@@ -138,6 +139,7 @@ endif COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o COBJS-$(CONFIG_VFD) += cmd_vfd.o +COBJS-$(CONFIG_CMD_MG_DISK) += cmd_mgdisk.oPlease keep such lists sorted.
...
Quoted 7 lines
common/Makefile +7
-0+U_BOOT_CMD( + mgd, 5, 0, do_mg_disk_cmd, + "mgd - mgine m[g]flash command\n", + ": mgine mflash IO mode (disk) command\n" + "\t- initialize : mgd init\n" + "\t- random read : mgd read [from] [to] [size]\n" + "\t\tbelow example read 256 bytes from 0x300000 of mflash\n"common/Makefile endif
Quoted 10 lines
common/Makefile +10
-0+ "\t\tto 0xA0100000 of host memory\n" + "\t\tex) mgd read 0x300000 0xA0100000 256\n" + "\t- random write : mgd write [from] [to] [size]\n" + "\t\tex) mgd write 0xA0100000 0x300000 256\n" + "\t- sector read : mgd readsec [sector] [to] [counts]\n" + "\t\tbelow example read 10 sectors starts from 400 sector\n" + "\t\tto 0xA0100000\n" + "\t\tex) mgd readsec 400 0xA0100000 10\n" + "\t- sector write : mgd writesec [from] [sector] [counts]\n" +);Please avoid using TAB characters here.
Also,pleas ebe terse - don;t give examples here. Rather add a README.mflash file to the doc/ directory.
common/cmd_nvedit.c DECLARE_GLOBAL_DATA_PTR; · line 63
Quoted 10 lines
common/cmd_nvedit.c +1
-0@@ -59,8 +59,9 @@ DECLARE_GLOBAL_DATA_PTR; !defined (CONFIG_ENV_IS_IN_NAND ) && \ !defined (CONFIG_ENV_IS_IN_ONENAND ) && \ !defined (CONFIG_ENV_IS_IN_SPI_FLASH ) && \ + !defined (CONFIG_ENV_IS_IN_MG_DISK ) && \ !defined (CONFIG_ENV_IS_NOWHERE )Please keep lists sorted.
common/cmd_nvedit.c DECLARE_GLOBAL_DATA_PTR; · line 66
Quoted 4 lines
common/cmd_nvedit.c +1
-1-# error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE} +# error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|MG_DISK|NOWHERE}Please keep lists sorted.
Also note that your mailer wrapped long lines here, thus corrupting the patch. Please fix your mailer.
And please avoid such long lines, too!
...
common/cmd_nvedit.c DECLARE_GLOBAL_DATA_PTR;
Quoted 6 lines
common/cmd_nvedit.c +6
-0+void env_relocate_spec (void ) +{ +unsigned int err; + err =mg_disk_read (CONFIG_ENV_ADDR , (u_char *) env_ptr,CONFIG_ENV_SIZE ); +if (err) { +puts ("*** Warning - mg_disk_read error, using default environment\n\n" );Line too long.
Quoted 5 lines
common/cmd_nvedit.c +5
-0+set_default_env (); +return ; + } + +if (crc32 (0 , env_ptr->data,ENV_SIZE ) != env_ptr->crc) {common/cmd_nvedit.c
Quoted 10 lines
common/cmd_nvedit.c +10
-0+puts ("*** Warning - CRC error, using default environment\n\n" ); +set_default_env (); + } +} + +int saveenv (void ) +{ +unsigned int err; + env_ptr->crc =crc32 (0 , env_ptr->data,ENV_SIZE ); + err =mg_disk_write (CONFIG_ENV_ADDR , (u_char *) env_ptr,CONFIG_ENV_SIZE );Line too long.
common/cmd_nvedit.c
Quoted 3 lines
common/cmd_nvedit.c +3
-0+if (err) +puts ("*** Warning - mg_disk_write error\n\n" ); +return (int )err;The cast should not be needed here.
disk/part.c line 43
Quoted 11 lines
disk/part.c +2
-1@@ -39,7 +39,8 @@defined (CONFIG_CMD_SCSI ) || \defined (CONFIG_CMD_USB ) || \defined (CONFIG_MMC ) || \ - defined(CONFIG_SYSTEMACE) ) +defined (CONFIG_SYSTEMACE ) || \ + defined(CONFIG_CMD_MG_DISK))Please keep lists sorted.
disk/part.c block_dev_desc_t *get_dev(char* ifname, int dev) · line 103
Quoted 7 lines
disk/part.c +2
-1@@ -95,7 +99,8 @@ block_dev_desc_t *get_dev(char* ifname, int dev)defined (CONFIG_CMD_SCSI ) || \defined (CONFIG_CMD_USB ) || \defined (CONFIG_MMC ) || \ - defined(CONFIG_SYSTEMACE) ) +defined (CONFIG_SYSTEMACE ) || \ + defined(CONFIG_CMD_MG_DISK))Ditto.
disk/part.c void dev_print (block_dev_desc_t *dev_desc) · line 216
Quoted 7 lines
disk/part.c +2
-1@@ -207,7 +212,8 @@ void dev_print (block_dev_desc_t *dev_desc)defined (CONFIG_CMD_SCSI ) || \defined (CONFIG_CMD_USB ) || \defined (CONFIG_MMC ) || \ - defined(CONFIG_SYSTEMACE) ) +defined (CONFIG_SYSTEMACE ) || \ + defined(CONFIG_CMD_MG_DISK))Ditto.
disk/part_amiga.c line 34
Quoted 11 lines
disk/part_amiga.c +2
-1@@ -30,7 +30,8 @@defined (CONFIG_CMD_SCSI ) || \defined (CONFIG_CMD_USB ) || \defined (CONFIG_MMC ) || \ - defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_AMIGA_PARTITION) +defined (CONFIG_SYSTEMACE ) || \ + defined(CONFIG_CMD_MG_DISK)) && defined(CONFIG_AMIGA_PARTITION)Ditto.
disk/part_amiga.c line 44
Quoted 5 lines
disk/part_amiga.c +1
-0@@ -40,6 +41,8 @@ #define PRINTF(fmt, args...)#endif +#define atoi (x) simple_strtoul(x,NULL,10)Please avoid that.
Quoted 8 lines
disk/part_amiga.c +0
-0struct block_header {u32 id;disk/part_dos.c +0
-0disk/part_dos.c line 44
Quoted 6 lines
disk/part_dos.c +2
-1@@ -40,7 +40,8 @@defined (CONFIG_CMD_SCSI ) || \defined (CONFIG_CMD_USB ) || \defined (CONFIG_MMC ) || \ - defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_DOS_PARTITION) +defined (CONFIG_SYSTEMACE ) || \ + defined(CONFIG_CMD_MG_DISK)) && defined(CONFIG_DOS_PARTITION)more incorrect sort order, even more following below.
Quoted 29 lines
drivers/block/mg_disk.c new file +23
-0@@ -0,0 +1,595 @@ +/* +* (C) Copyright 2009 mGine co. +* unsik Kim <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ +drivers/block/mg_disk.c line 33
Quoted 10 lines
drivers/block/mg_disk.c new file +10
-0+#include <common.h> +#include <malloc.h> +#include <part.h> +#include <ata.h> +#include "mg_disk_prv.h" + +#ifdef CONFIG_CMD_MG_DISK + +#undef printk +#define printk printfPlease don't.
drivers/block/mg_disk.c line 39
Quoted 6 lines
drivers/block/mg_disk.c new file +6
-0+#undef KERN_ERR +#define KERN_ERR +#undef KERN_DEBUG +#define KERN_DEBUG +#undef KERN_INFO +#define KERN_INFO Please don't.
drivers/block/mg_disk.c line 48
Quoted 9 lines
drivers/block/mg_disk.c new file +9
-0+#undef inb +#undef inw +#undef outb +#undef outw + +#define inb (a) (*(volatile unsigned char *)(a)) +#define inw (a) (*(volatile unsigned short *)(a)) +#define outb (v, a) (*(volatile unsigned char *)(a) = (v)) +#define outw (v, a) (*(volatile unsigned short *)(a) = (v))A strict NO, NO here. Please never do that.
Please do use theproper accessor functions that are needed for the respective architecture. PLain volatile pointer accesses are bound to fail. Never do that.
...
drivers/block/mg_disk.c line 56
Quoted 8 lines
drivers/block/mg_disk.c new file +8
-0+printk ("%s: %s: status=0x%02x { " , name, msg, stat &0xff ); +if (stat &MG_REG_STATUS_BIT_BUSY )printk ("Busy " ); +if (stat &MG_REG_STATUS_BIT_READY )printk ("DriveReady " ); +if (stat &MG_REG_STATUS_BIT_WRITE_FAULT )printk ("WriteFault " ); +if (stat &MG_REG_STATUS_BIT_SEEK_DONE )printk ("SeekComplete " ); +if (stat &MG_REG_STATUS_BIT_DATA_REQ )printk ("DataRequest " ); +if (stat &MG_REG_STATUS_BIT_CORRECTED_ERROR )printk ("CorrectedError " ); +if (stat &MG_REG_STATUS_BIT_ERROR )printk ("Error " );Bad coding style. Please reformat.
drivers/block/mg_disk.c line 64
Quoted 8 lines
drivers/block/mg_disk.c new file +8
-0+printk ("}\n" ); +if ((stat &MG_REG_STATUS_BIT_ERROR )) { +printk ("%s: %s: error=0x%02x { " , name, msg, err &0xff ); +if (err &MG_REG_ERR_BBK )printk ("BadSector " ); +if (err &MG_REG_ERR_UNC )printk ("UncorrectableError " ); +if (err &MG_REG_ERR_IDNF )printk ("SectorIdNotFound " ); +if (err &MG_REG_ERR_ABRT )printk ("DriveStatusError " ); +if (err &MG_REG_ERR_AMNF )printk ("AddrMarkNotFound " );Ditto.
drivers/block/mg_disk.c line 72
Quoted 8 lines
drivers/block/mg_disk.c new file +8
-0+static unsigned int msecs_to_hz (u32 msec) +{ +u32 hz =CONFIG_SYS_HZ /1000 * msec; + +if (!hz) + hz =1 ; + +return hz;This makes no sense.
CONFIG_SYS_HZis always 1000. Please consider it a constant....
drivers/block/mg_disk.c line 74
Quoted 2 lines
drivers/block/mg_disk.c new file +2
-0+ from =get_timer (0 ); + expire = from +msecs_to_hz (msec);I don;t understand y ou logic here.
get_timer()is defined to operate in munits of millisconds. What's themsecs_to_hz()stuff gotta do here?drivers/block/mg_disk.c line 75
Quoted 1 line
drivers/block/mg_disk.c new file +1
-0+ }while (cur < expire);You are aware of the overflow issues buried here, are you?
Quoted 10 lines
drivers/block/mg_disk.c new file +5
-0+if (!err) { +if ((iop->field_valid &1 ) ==0 ) { + err =MG_ERR_TRANSLATION ; + }else { + 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));Lines way too long, and wrapped by mailer.
drivers/block/mg_disk.c
Quoted 10 lines
drivers/block/mg_disk.c new file +10
-0+static int mg_disk_reset (void ) +{ +struct mg_drv_data *prv_data =MG_HOST ->drv_data; +s32 err; +u8 init_status; + +/* hdd rst low */ + prv_data->mg_hdrst_pin (0 ); + err =mg_wait (MG_REG_STATUS_BIT_BUSY ,300 ); +if (err)return err;Please refoemat according to CodingStyle requirements.
drivers/block/mg_disk.c
Quoted 3 lines
drivers/block/mg_disk.c new file +3
-0+if ((err =mg_wait (MG_STAT_READY ,3000 ))) { +return err; + }No braces for one-liners, please.
drivers/block/mg_disk.c
Quoted 8 lines
drivers/block/mg_disk.c new file +8
-0+static unsigned int mg_do_read_sects (void *buff,u32 sect_num,u32 sect_cnt) +{ +u32 i, j, err; +u8 *buff_ptr = buff; + +if ((err =mg_out (sect_num, sect_cnt,MG_CMD_RD ))) { +return err; + }Ditto.
drivers/block/mg_disk.c
Quoted 4 lines
drivers/block/mg_disk.c new file +4
-0+for (i =0 ; i < sect_cnt; i++) { +if ((err =mg_wait (MG_REG_STATUS_BIT_DATA_REQ ,3000 ))) { +return err; + }Ditto. And so on.
Quoted 2 lines
+ MG_DBG("%u (0x%8.8x) sector read",
sect_num+ i, (sect_num+ i) *MG_SECTOR_SIZE);Please check all line lengths!
Quoted 13 lines
lib_arm/board.c +1
-0@@ -48,6 +48,7 @@#include <serial.h> #include <nand.h> #include <onenand_uboot.h> +#include <mg_disk.h> #ifdef CONFIG_DRIVER_SMC91111 #include "../drivers/net/smc91111.h" lib_arm/board.c void start_armboot (void) · line 354
Quoted 6 lines
lib_arm/board.c +3
-0@@ -348,6 +349,10 @@ void start_armboot (void)onenand_init ();#endif +#if defined(CONFIG_CMD_MG_DISK ) +mg_disk_init (); +#endif Please don't.
First it's wrong to add it for ARM only - what about other architectures that want to use that technology?
Second it's wrong to always call the init code. This shall be done only upon first access. See the longish discussion we had for example about how to handle the S-ATA init code - please see the archives.
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: wd at denx.de What is wanted is not the will to believe, but the will to find out, which is the exact opposite.
-- Bertrand Russell, "Skeptical Essays", 1928
Signature · 1 line
unsik Kim <[email protected]>
PATCH 1/1 mflash u-boot support (a little change)
Dear unsik Kim,
Quoted 5 lines · In message <[email protected]> you…
I fixed miscalculated total sectors when using reserve area feature.
Also I changed CONFIG_MG_DISK_RES's unit to KB. (Byte is too small and also needs sector size alignment.)
Please split these two changes into separate commits.
Quoted 70 lines
common/cmd_mgdisk.c new file +64
-0@@ -0,0 +1,76 @@ +/* +* (C) Copyright 2009 mGine co. +* unsik Kim <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#include <common.h> +#include <command.h> + +#if defined (CONFIG_CMD_MG_DISK ) + +#include <mg_disk.h> + +int do_mg_disk_cmd (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) +{ +u32 from, to, size; + +switch (argc) { +case 2 : +if (!strcmp (argv[1 ],"init" )) +mg_disk_init (); +else +return 1 ; +break ; +case 4 : + from =simple_strtoul (argv[2 ],NULL ,0 ); + to =simple_strtoul (argv[3 ],NULL ,0 ); + size =simple_strtoul (argv[4 ],NULL ,0 ); + +if (!strcmp (argv[1 ],"read" )) +mg_disk_read (from, (u8 *)to, size); +else if (!strcmp (argv[1 ],"write" )) +mg_disk_write (to, (u8 *)from, size); +else if (!strcmp (argv[1 ],"readsec" )) +mg_disk_read_sects ((void *)to, from, size); +else if (!strcmp (argv[1 ],"writesec" )) +mg_disk_write_sects ((void *)from, to, size); +else +return 1 ; +break ; +default : +printf ("Usage:\n%s\n" , cmdtp->usage); +return 1 ; + } +return 0 ; +} +
common/cmd_mgdisk.c line 74
Quoted 10 lines
common/cmd_mgdisk.c new file +10
-0+U_BOOT_CMD ( + mgd,5 ,0 , do_mg_disk_cmd, +"mgd - mgine m[g]flash command\n" , +": mgine mflash IO mode (disk) command\n" +" - initialize : mgd init\n" +" - random read : mgd read [from] [to] [size]\n" +" - random write : mgd write [from] [to] [size]\n" +" - sector read : mgd readsec [sector] [to] [counts]\n" +" - sector write : mgd writesec [from] [sector] [counts]\n" +);
This doesn't look like the changes you subscribe in the commit message above. Instead, this looks as if iyou were adding completely new code.
common/env_mgdisk.c
Quoted 6 lines
common/env_mgdisk.c new file +0
-0@@ -0,0 +1,90 @@
Ditto.
Your commit message seems terribly wrong. Please fix.
Best regards,
Wolfgang Denk
Signature · 6 lines
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: wd at denx.de HEALTH WARNING: Care Should Be Taken When Lifting This Product, Since Its Mass, and Thus Its Weight, Is Dependent on Its Velocity Relative to the User.