[Aesop-embedded-devel] u-boot-aesop/board/aesop2440 aesop2440.c config.mk logo-howto.txt usbd_24x0.c
Status: Beta
Brought to you by:
linuxpark
From: jeenspa <je...@li...> - 2005-07-05 14:16:49
|
jeenspa 2005/07/05 07:16:42 Modified: board/aesop2440 aesop2440.c config.mk logo-howto.txt usbd_24x0.c usbd_common.c usbd_mass.c usbd_media.c usbd_scsi.c usbd_scsi.h Log: usbdmass fixup, nand, mkyaffs Revision Changes Path 1.2 +190 -17 u-boot-aesop/board/aesop2440/aesop2440.c Index: aesop2440.c =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/aesop2440.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- aesop2440.c 27 Jun 2005 17:04:23 -0000 1.1 +++ aesop2440.c 5 Jul 2005 14:16:41 -0000 1.2 @@ -27,47 +27,72 @@ * Created date : 2005. 06. 26. 22:56:57 KST * Description : * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Log: aesop2440.c,v $ - * Revision 1.1 2005/06/27 17:04:23 linuxpark - * Initial revision + * Revision 1.2 2005/07/05 14:16:41 jeenspa + * usbdmass fixup, nand, mkyaffs + * + * Revision 1.1.1.1 2005/06/27 17:04:23 linuxpark + * Initial import. * * * */ -#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/aesop2440.c,v 1.1 2005/06/27 17:04:23 linuxpark Exp $" +#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/aesop2440.c,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" #include <common.h> #include <s3c2440.h> #include <command.h> #include <bmp_layout.h> +#include <asm/sizes.h> #include "sd.h" /* ------------------------------------------------------------------------- */ #define FCLK_SPEED 1 +#define USB_CLOCK 1 -#if FCLK_SPEED==0 /* Fout = 296.35MHz */ +#if CONFIG_SYS_CLK_FREQ == 16934400 +#if FCLK_SPEED == 0 /* Fout = 296.35MHz */ #define M_MDIV 0x61 #define M_PDIV 0x1 #define M_SDIV 0x2 -#elif FCLK_SPEED==1 /* Fout = 399.65MHz */ +#elif FCLK_SPEED == 1 /* Fout = 399.65MHz */ #define M_MDIV 0x6E #define M_PDIV 0x3 #define M_SDIV 0x1 #endif - -#define USB_CLOCK 1 - -#if USB_CLOCK==0 +#if USB_CLOCK == 0 #define U_M_MDIV 0x3C #define U_M_PDIV 0x4 #define U_M_SDIV 0x1 -#elif USB_CLOCK==1 +#elif USB_CLOCK == 1 #define U_M_MDIV 0x3C #define U_M_PDIV 0x4 #define U_M_SDIV 0x2 #endif +#elif CONFIG_SYS_CLK_FREQ == 12000000 +#if FCLK_SPEED == 0 /* Fout = 304.00MHz */ +#define M_MDIV 0x44 +#define M_PDIV 0x1 +#define M_SDIV 0x1 +#elif FCLK_SPEED == 1 /* Fout = 405.00MHz */ +#define M_MDIV 0x7f +#define M_PDIV 0x2 +#define M_SDIV 0x1 +#endif +#if USB_CLOCK == 0 +#define U_M_MDIV 0x38 +#define U_M_PDIV 0x2 +#define U_M_SDIV 0x1 +#elif USB_CLOCK == 1 +#define U_M_MDIV 0x38 +#define U_M_PDIV 0x2 +#define U_M_SDIV 0x2 +#endif +#else +#error CONFIG_SYS_CLK_FREQ Not Defined +#endif #define LCD_WIDTH 480 #define LCD_HEIGHT 272 @@ -301,6 +326,25 @@ return 0; } +#if defined(CONFIG_COMMANDS) && defined(CFG_CMD_NAND) +#include <linux/mtd/nand.h> +int nand_init(void) +{ + S3C2440_NAND * const nand = S3C2440_GetBase_NAND(); + extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; + + nand->NFCONF = 1 << 12 | 5 << 8 | 1 << 4 | 0 << 0; + nand->NFCONT = 0 << 12 | 0 << 8 | 1 << 6 | 1 << 5 | 1 << 1 | 1 << 0; + + nand_probe(0); + if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) { + print_size(nand_dev_desc[0].totlen, "\n"); + } + return 0; +} +#endif /* defined(CONFIG_COMMANDS) && defined(CFG_CMD_NAND) */ + +#if defined(CONFIG_COMMANDS) && defined(CFG_CMD_BSP) #ifdef CONFIG_AESOP_LCD int do_bmpload_sub(unsigned char *imgaddr, int pos_x, int pos_y, int disp_info) @@ -376,11 +420,7 @@ } return 0; } -#endif /* CONFIG_AESOP_LCD */ -#if (CONFIG_COMMANDS & CFG_CMD_BSP) - -#ifdef CONFIG_AESOP_LCD /* ------------------------------------------------------------------------- */ int do_bmpload(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { @@ -407,7 +447,7 @@ return do_bmpload_sub(imgaddr, x_off, y_off, 1); } U_BOOT_CMD( - bmpload, 4, 1, do_bmpload, + bmpload, 4, 0, do_bmpload, "bmpload - BMP Image load\n", "[address] [x y] - BMP Image Load\n" " address - BMP Image address\n" @@ -417,6 +457,7 @@ #endif /* CONFIG_AESOP_LCD */ +#ifdef CONFIG_AESOP_USBDMASS /* ------------------------------------------------------------------------- */ int do_usbdmass (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { @@ -428,11 +469,143 @@ } U_BOOT_CMD( - usbdmass, 2, 1, do_usbdmass, + usbdmass, 2, 0, do_usbdmass, "usbdmass- USB Device Mass-storage\n", "media - start USB Device Mass-storage class handler with specified media\n" " media - ram, sd, nand\n" ); +#endif /* CONFIG_AESOP_USBDMASS */ + +#ifdef CONFIG_AESOP_YAFFS +/* ------------------------------------------------------------------------- */ +#define MTDBLOCK0_OFFSET 0 +#define MTDBLOCK0_SIZE 4 * SZ_1M +#define MTDBLOCK1_OFFSET MTDBLOCK0_OFFSET + MTDBLOCK0_SIZE +#define MTDBLOCK1_SIZE 16 * SZ_1M +#define MTDBLOCK2_OFFSET MTDBLOCK1_OFFSET + MTDBLOCK1_SIZE +#define MTDBLOCK2_SIZE 44 * SZ_1M +#define MTDBLOCK_MAX 3 +#define SZ_OOB 16 +#define SZ_PAGE_WOOB 528 +#define SZ_PAGE 512 +#define SZ_BLOCK 512 * 32 +#include <linux/mtd/nand.h> + +// countBits is a quick way of counting the number of bits in a byte. +// ie. countBits[n] holds the number of 1 bits in a byte with the value n. +static const char countBits[256] = +{ +0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4, +1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, +1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, +2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, +1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, +2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, +2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, +3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, +1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, +2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, +2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, +3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, +2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, +3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, +3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, +4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8 +}; + +int nand_read_oob(struct nand_chip *, size_t, size_t, size_t *, u_char *); +int nand_write_oob(struct nand_chip *, size_t, size_t, size_t *, const u_char *); +int nand_erase(struct nand_chip *, size_t, size_t, int); +int nand_write_page_yaffs (int, u_char *); +int do_mkyaffs(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; + struct nand_chip *nand = &nand_dev_desc[0]; + struct {unsigned long offset; unsigned long size;} + mtdblk[MTDBLOCK_MAX] = { + { MTDBLOCK0_OFFSET, MTDBLOCK0_SIZE }, + { MTDBLOCK1_OFFSET, MTDBLOCK1_SIZE }, + { MTDBLOCK2_OFFSET, MTDBLOCK2_SIZE } }; + unsigned long source, target, count, count_save, addr_blk, addr_sec; + unsigned char *src_ptr, *src_ptr_save, oob_buff[SZ_OOB]; + int i, ret; + size_t retlen; + + if (argc != 4) { + printf ("Usage:\n%s\n", cmdtp->usage); + return -1; + } + + source = simple_strtoul(argv[1], NULL, 16); + target = simple_strtoul(argv[2], NULL, 10); + count = simple_strtoul(argv[3], NULL, 16); + + if (target < 0 || target >= MTDBLOCK_MAX) { + printf ("Error - target block no. should be between 0 and %d\n", MTDBLOCK_MAX - 1); + return -1; + } + + if (count % SZ_PAGE_WOOB) { + printf ("Error - Image not a multiple of 528 bytes\n"); + return -1; + } + + if (mtdblk[target].size < ((count / SZ_PAGE_WOOB) * SZ_PAGE)) { + printf ("Error - Image is too big for MTDBLOCK%d\n", target); + printf (" MTDBLOCK%d size - 0x%lx\n", target, mtdblk[target].size); + return -1; + } + + src_ptr = (unsigned char *)source; + for (addr_blk = mtdblk[target].offset; addr_blk < mtdblk[target].offset + mtdblk[target].size; addr_blk += SZ_BLOCK) { + count_save = count; + src_ptr_save = src_ptr; + nand_read_oob(nand, addr_blk, SZ_OOB, &retlen, oob_buff); + if (countBits[oob_buff[5]] < 7) { + printf("Block at 0x%lx is marked BAD and is not being formatted\n",addr_blk); + continue; + } + + ret = nand_erase(nand, addr_blk, nand->erasesize, 0); + if (ret == -1) { + for (i = 0; i < SZ_OOB; i++) oob_buff[i] = 0; + nand_write_oob( nand, addr_blk, SZ_OOB, &retlen, oob_buff); + printf("Block erase error at 0x%lx, not formatted\n",addr_blk); + continue; + } + + if (addr_blk == mtdblk[target].offset) continue; + for (addr_sec = addr_blk; addr_sec < addr_blk + SZ_BLOCK; addr_sec += SZ_PAGE) { + if (src_ptr < (unsigned char *)(source + count)) { + ret = nand_write_page_yaffs(addr_sec >> 9, src_ptr); + if (ret == -1) { + src_ptr = src_ptr_save; + for (i = 0; i < SZ_OOB; i++) oob_buff[i] = 0; + nand_write_oob( nand, addr_blk, SZ_OOB, &retlen, oob_buff); + printf("Block write error at 0x%lx, mark bad and not formatted\n",addr_sec); + continue; + } + src_ptr += SZ_PAGE_WOOB; + } + } + } + if (src_ptr != (unsigned char *)(count + source)) { + printf("Error - Insufficient NAND flash space.\n"); + printf(" mkyaffs failed\n"); + return -1; + } + printf("mkyaffs completed.\n"); + return 0; +} +U_BOOT_CMD( + mkyaffs, 4, 0, do_mkyaffs, + "mkyaffs - Write YAFFS Image to NAND Flash\n", + "source target count\n" + " source - YAFFS Image address\n" + " target - NAND Flash destination MTDBlock No.\n" + " count - byte count of YAFFS image\n" +); +#endif /* CONFIG_AESOP_YAFFS */ -#endif /* (CONFIG_COMMANDS & CFG_CMD_BSP) */ +#endif /* defined(CONFIG_COMMANDS) && defined(CFG_CMD_BSP) */ 1.2 +7 -4 u-boot-aesop/board/aesop2440/config.mk Index: config.mk =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/config.mk,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- config.mk 27 Jun 2005 17:03:53 -0000 1.1 +++ config.mk 5 Jul 2005 14:16:41 -0000 1.2 @@ -28,15 +28,18 @@ # Created date : 2005. 06. 26. 22:59:04 KST # Description : # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # $Log: config.mk,v $ -# Revision 1.1 2005/06/27 17:03:53 linuxpark -# Initial revision +# Revision 1.2 2005/07/05 14:16:41 jeenspa +# usbdmass fixup, nand, mkyaffs +# +# Revision 1.1.1.1 2005/06/27 17:03:53 linuxpark +# Initial import. # # # # -#ident "@(#) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/config.mk,v 1.1 2005/06/27 17:03:53 linuxpark Exp $" +#ident "@(#) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/config.mk,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" # @@ -68,6 +71,6 @@ # LCD framebuffer address: 0x33000000(48M offset) # ramdisk optionally with a ramdisk at 3080'0000 # parameter tag: 0x30000100 -TEXT_BASE = 0x33800000 +TEXT_BASE = 0x33C00000 1.2 +11 -4 u-boot-aesop/board/aesop2440/logo-howto.txt <<Binary file>> 1.2 +22 -5 u-boot-aesop/board/aesop2440/usbd_24x0.c Index: usbd_24x0.c =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_24x0.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- usbd_24x0.c 27 Jun 2005 17:04:30 -0000 1.1 +++ usbd_24x0.c 5 Jul 2005 14:16:41 -0000 1.2 @@ -27,15 +27,18 @@ * Created date : 2005. 06. 26. 23:07:52 KST * Description : * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Log: usbd_24x0.c,v $ - * Revision 1.1 2005/06/27 17:04:30 linuxpark - * Initial revision + * Revision 1.2 2005/07/05 14:16:41 jeenspa + * usbdmass fixup, nand, mkyaffs + * + * Revision 1.1.1.1 2005/06/27 17:04:30 linuxpark + * Initial import. * * * */ -#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_24x0.c,v 1.1 2005/06/27 17:04:30 linuxpark Exp $" +#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_24x0.c,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" /* @@ -66,7 +69,10 @@ #endif #include <common.h> -#include <s3c2410.h> + +#ifdef CONFIG_AESOP_USBDMASS + +#include <s3c2440.h> #include "usbd_common.h" #include "usbd_24x0.h" @@ -305,11 +311,19 @@ usbd_24x0_init_gpio(); -/* clock & power init */ +/* +#if 0 udelay(10000); // delay 10msec clockpower->UPLLCON = (120 << 12) | (2 << 4) | (3 << 0); udelay(10000); // delay 10msec clockpower->CLKCON = clockpower->CLKCON | 0x80; +#else + udelay(10000); // delay 10msec + clockpower->UPLLCON = (0x38 << 12) | (2 << 4) | (2 << 0); + udelay(10000); // delay 10msec + clockpower->CLKCON = clockpower->CLKCON | 0x80; +#endif +*/ #ifndef IGNORE_VBUS if (!usbd_24x0_check_vbus()) return FALSE; @@ -582,3 +596,6 @@ usbd->OUT_CSR1_REG = (( out_csr1 & (~EPO_WR_BITS)) & (~EPO_OUT_PKT_READY)); return TRUE; } + +#endif /* CONFIG_AESOP_USBDMASS */ + 1.2 +12 -5 u-boot-aesop/board/aesop2440/usbd_common.c Index: usbd_common.c =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_common.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- usbd_common.c 27 Jun 2005 17:04:29 -0000 1.1 +++ usbd_common.c 5 Jul 2005 14:16:41 -0000 1.2 @@ -27,15 +27,18 @@ * Created date : 2005. 06. 26. 23:08:57 KST * Description : * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Log: usbd_common.c,v $ - * Revision 1.1 2005/06/27 17:04:29 linuxpark - * Initial revision + * Revision 1.2 2005/07/05 14:16:41 jeenspa + * usbdmass fixup, nand, mkyaffs + * + * Revision 1.1.1.1 2005/06/27 17:04:29 linuxpark + * Initial import. * * * */ -#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_common.c,v 1.1 2005/06/27 17:04:29 linuxpark Exp $" +#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_common.c,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" /* @@ -60,10 +63,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ +#include <common.h> +#ifdef CONFIG_AESOP_USBDMASS -#include <common.h> -#include <s3c2410.h> +#include <s3c2440.h> #include <stdarg.h> #include "usbd_common.h" @@ -151,3 +155,6 @@ printf("\n"); return; } + +#endif /* CONFIG_AESOP_USBDMASS */ + 1.2 +11 -4 u-boot-aesop/board/aesop2440/usbd_mass.c Index: usbd_mass.c =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_mass.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- usbd_mass.c 27 Jun 2005 17:04:30 -0000 1.1 +++ usbd_mass.c 5 Jul 2005 14:16:41 -0000 1.2 @@ -27,15 +27,18 @@ * Created date : 2005. 06. 26. 23:10:33 KST * Description : * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Log: usbd_mass.c,v $ - * Revision 1.1 2005/06/27 17:04:30 linuxpark - * Initial revision + * Revision 1.2 2005/07/05 14:16:41 jeenspa + * usbdmass fixup, nand, mkyaffs + * + * Revision 1.1.1.1 2005/06/27 17:04:30 linuxpark + * Initial import. * * * */ -#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_mass.c,v 1.1 2005/06/27 17:04:30 linuxpark Exp $" +#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_mass.c,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" /* @@ -66,7 +69,10 @@ #endif #include <common.h> -#include <s3c2410.h> + +#ifdef CONFIG_AESOP_USBDMASS + +#include <s3c2440.h> #include <asm/types.h> #include "usbd_common.h" #include "usbd_24x0.h" @@ -667,4 +673,5 @@ wide[i] = (u16) str[i]; } +#endif /* CONFIG_AESOP_USBDMASS */ 1.2 +10 -3 u-boot-aesop/board/aesop2440/usbd_media.c Index: usbd_media.c =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_media.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- usbd_media.c 27 Jun 2005 17:03:53 -0000 1.1 +++ usbd_media.c 5 Jul 2005 14:16:41 -0000 1.2 @@ -27,15 +27,18 @@ * Created date : 2005. 06. 26. 23:11:58 KST * Description : * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Log: usbd_media.c,v $ - * Revision 1.1 2005/06/27 17:03:53 linuxpark - * Initial revision + * Revision 1.2 2005/07/05 14:16:41 jeenspa + * usbdmass fixup, nand, mkyaffs + * + * Revision 1.1.1.1 2005/06/27 17:03:53 linuxpark + * Initial import. * * * */ -#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_media.c,v 1.1 2005/06/27 17:03:53 linuxpark Exp $" +#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_media.c,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" /* @@ -66,6 +69,9 @@ #endif #include <common.h> + +#ifdef CONFIG_AESOP_USBDMASS + #include "usbd_common.h" #include "usbd_mass.h" #include "usbd_media.h" @@ -375,4 +381,5 @@ return; } +#endif /* CONFIG_AESOP_USBDMASS */ 1.2 +41 -4 u-boot-aesop/board/aesop2440/usbd_scsi.c Index: usbd_scsi.c =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_scsi.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- usbd_scsi.c 27 Jun 2005 17:04:30 -0000 1.1 +++ usbd_scsi.c 5 Jul 2005 14:16:41 -0000 1.2 @@ -27,15 +27,18 @@ * Created date : 2005. 06. 26. 23:13:50 KST * Description : * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Log: usbd_scsi.c,v $ - * Revision 1.1 2005/06/27 17:04:30 linuxpark - * Initial revision + * Revision 1.2 2005/07/05 14:16:41 jeenspa + * usbdmass fixup, nand, mkyaffs + * + * Revision 1.1.1.1 2005/06/27 17:04:30 linuxpark + * Initial import. * * * */ -#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_scsi.c,v 1.1 2005/06/27 17:04:30 linuxpark Exp $" +#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_scsi.c,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" /* @@ -66,7 +69,10 @@ #endif #include <common.h> -#include <s3c2410.h> + +#ifdef CONFIG_AESOP_USBDMASS + +#include <s3c2440.h> #include "usbd_common.h" #include "usbd_24x0.h" #include "usbd_mass.h" @@ -177,6 +183,9 @@ case SCSI_ComSendDiagnostic: return usbd_scsi_com_senddiagnostic(ma); + case SCSI_ComReadFormatCapacities: + return usbd_scsi_com_readformatcapacities(ma); + case SCSI_ComReadCapacity: return usbd_scsi_com_readcapacity(ma); @@ -427,6 +436,31 @@ return usbd_scsi_command_end_send(ma); } +char usbd_scsi_com_readformatcapacities(usbd_mass_instance *ma) +{ + unsigned long lba; + + debugvs(1, "%s : %s - SCSI ReadFormatCapacities\n", __FILE__, __FUNCTION__); + usbd_media_probe(ma); + if (ma->media.status == ABSENT) { + usbd_scsi_set_error(ma, SCSI_ERROR_MediumNotPresent, 0); + ma->state = SEND_CSW; + return CSW_STATUS_CommandFailed; + } + + lba = ma->media.total_sector - 1; + usbd_scsi_put_bigendian(ma->buff, 0, 4); /* Capacity List Header */ + usbd_scsi_put_bigendian(ma->buff + 4, lba, 4); /* Number of Blocks */ + ma->buff[8] = 0x02; /* Descriptor type = Foratted Media */ + usbd_scsi_put_bigendian(ma->buff + 9, 0x200, 3); /* Block Length */ + ma->buff_ptr = 0; + ma->buff_length = 12; + + debugvs(2, "%s : %s - SCSI ReadFormatCapacities : Report %ld Sectors\n", __FILE__, __FUNCTION__, lba); + + return usbd_scsi_command_end_send(ma); +} + char usbd_scsi_com_readcapacity(usbd_mass_instance *ma) { unsigned long lba; @@ -724,3 +758,6 @@ ma->buff_ptr = 0; return; } + +#endif /* CONFIG_AESOP_USBDMASS */ + 1.2 +8 -3 u-boot-aesop/board/aesop2440/usbd_scsi.h Index: usbd_scsi.h =================================================================== RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_scsi.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- usbd_scsi.h 27 Jun 2005 17:04:30 -0000 1.1 +++ usbd_scsi.h 5 Jul 2005 14:16:41 -0000 1.2 @@ -27,15 +27,18 @@ * Created date : 2005. 06. 26. 23:14:24 KST * Description : * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Log: usbd_scsi.h,v $ - * Revision 1.1 2005/06/27 17:04:30 linuxpark - * Initial revision + * Revision 1.2 2005/07/05 14:16:41 jeenspa + * usbdmass fixup, nand, mkyaffs + * + * Revision 1.1.1.1 2005/06/27 17:04:30 linuxpark + * Initial import. * * * */ -#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_scsi.h,v 1.1 2005/06/27 17:04:30 linuxpark Exp $" +#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_scsi.h,v 1.2 2005/07/05 14:16:41 jeenspa Exp $" /* @@ -81,6 +84,7 @@ #define SCSI_ComStartStopUnit 0x1b #define SCSI_ComPreAllMedRemoval 0x1e #define SCSI_ComSendDiagnostic 0x1d +#define SCSI_ComReadFormatCapacities 0x23 #define SCSI_ComReadCapacity 0x25 #define SCSI_ComWriteVerify 0x2e #define SCSI_ComVerify 0x2f @@ -117,6 +121,7 @@ char usbd_scsi_com_(usbd_mass_instance *); char usbd_scsi_com_unknown(usbd_mass_instance *); char usbd_scsi_com_inquiry(usbd_mass_instance *); +char usbd_scsi_com_readformatcapacities(usbd_mass_instance *); char usbd_scsi_com_readcapacity(usbd_mass_instance *); char usbd_scsi_com_testunitready(usbd_mass_instance *); char usbd_scsi_com_requestsense(usbd_mass_instance *); |