From 603032264a87f9a9e4bfdc1fdd2552798abbd22c Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Thu, 9 Jul 2009 23:27:46 +0800 Subject: [PATCH] cleanup the copyright Signed-off-by: Xiangfu Liu --- usbboot/debian/copyright | 20 ++- usbboot/debian/rules | 2 +- usbboot/xburst_include/configs.h | 2 +- usbboot/xburst_include/error.h | 2 +- usbboot/xburst_include/jz4740.h | 2 +- usbboot/xburst_include/jz4750.h | 2 +- usbboot/xburst_include/nandflash.h | 2 +- usbboot/xburst_include/udc.h | 2 +- usbboot/xburst_include/usb.h | 2 +- usbboot/xburst_include/usb_boot.h | 2 +- usbboot/xburst_stage1/board_4740.c | 2 +- usbboot/xburst_stage1/board_4750.c | 2 +- usbboot/xburst_stage1/common.c | 2 +- usbboot/xburst_stage1/debug.c | 2 +- usbboot/xburst_stage1/head.S | 2 +- usbboot/xburst_stage1/main.c | 2 +- usbboot/xburst_stage2/boothandler.c | 2 +- usbboot/xburst_stage2/head.S | 8 +- usbboot/xburst_stage2/main.c | 2 +- usbboot/xburst_stage2/nandflash_4740.c | 92 ++++++------- usbboot/xburst_stage2/nandflash_4750.c | 2 +- usbboot/xburst_stage2/serial.c | 2 +- usbboot/xburst_stage2/udc.c | 177 ++++++++++--------------- 23 files changed, 148 insertions(+), 187 deletions(-) diff --git a/usbboot/debian/copyright b/usbboot/debian/copyright index 0276a79..e080ffa 100644 --- a/usbboot/debian/copyright +++ b/usbboot/debian/copyright @@ -6,12 +6,26 @@ It was downloaded from Upstream Author: Xiangfu Liu -The Debian packaging is copyright 2009, xiangfu and -is licensed under the GPL, see `/usr/share/common-licenses/GPL-3'. +The Debian packaging is copyright 2009, + Xiangfu Liu and + Marek Lindner + Wolfgang Spraul + Ingenic Semiconductor Inc. + Seeger Chin + Michael Anburaj + Ralf Baechle + Silicon Graphics, Inc. + Paul M. Antoine + Kevin D. Kissell + Carsten Langgaard + MIPS Technologies, Inc. + Maciej W. Rozycki + Lucifer at Ingenic Semiconductor Inc. +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. You are free to distribute this software under the terms of the GNU General Public License either version 3 of the License, or (at your option) any later version. On Debian systems, the complete text of the GNU General Public -License can be found in the file `/usr/share/common-licenses/GPL-3'. +License can be found in the file `/usr/share/common-licenses/GPL'. diff --git a/usbboot/debian/rules b/usbboot/debian/rules index c46fd21..0a1f10e 100755 --- a/usbboot/debian/rules +++ b/usbboot/debian/rules @@ -83,7 +83,7 @@ binary-arch: install dh_testroot dh_installchangelogs ChangeLog dh_installdocs - dh_installexamples +# dh_installexamples # dh_install # dh_installmenu # dh_installdebconf diff --git a/usbboot/xburst_include/configs.h b/usbboot/xburst_include/configs.h index 73bc359..2b30898 100644 --- a/usbboot/xburst_include/configs.h +++ b/usbboot/xburst_include/configs.h @@ -1,7 +1,7 @@ /* * device board * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_include/error.h b/usbboot/xburst_include/error.h index baac775..0562ef8 100644 --- a/usbboot/xburst_include/error.h +++ b/usbboot/xburst_include/error.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_include/jz4740.h b/usbboot/xburst_include/jz4740.h index 39ddf10..612253b 100644 --- a/usbboot/xburst_include/jz4740.h +++ b/usbboot/xburst_include/jz4740.h @@ -1,7 +1,7 @@ /* * Include file for Ingenic Semiconductor's JZ4740 CPU. * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_include/jz4750.h b/usbboot/xburst_include/jz4750.h index 4bfe7fa..f9cee96 100755 --- a/usbboot/xburst_include/jz4750.h +++ b/usbboot/xburst_include/jz4750.h @@ -1,7 +1,7 @@ /* * Include file for Ingenic Semiconductor's JZ4750 CPU. * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_include/nandflash.h b/usbboot/xburst_include/nandflash.h index 4256550..82bf9bc 100644 --- a/usbboot/xburst_include/nandflash.h +++ b/usbboot/xburst_include/nandflash.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_include/udc.h b/usbboot/xburst_include/udc.h index 27823d2..8859513 100644 --- a/usbboot/xburst_include/udc.h +++ b/usbboot/xburst_include/udc.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_include/usb.h b/usbboot/xburst_include/usb.h index e518f12..756e7a5 100644 --- a/usbboot/xburst_include/usb.h +++ b/usbboot/xburst_include/usb.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_include/usb_boot.h b/usbboot/xburst_include/usb_boot.h index 1c06b0c..1b6070f 100644 --- a/usbboot/xburst_include/usb_boot.h +++ b/usbboot/xburst_include/usb_boot.h @@ -1,7 +1,7 @@ /* * "Ingenic flash tool" - flash the Ingenic CPU via USB * - * Copyright (C) 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage1/board_4740.c b/usbboot/xburst_stage1/board_4740.c index 76b51a8..aaedd9f 100644 --- a/usbboot/xburst_stage1/board_4740.c +++ b/usbboot/xburst_stage1/board_4740.c @@ -1,7 +1,7 @@ /* * device board * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage1/board_4750.c b/usbboot/xburst_stage1/board_4750.c index 31dce28..527d3e9 100755 --- a/usbboot/xburst_stage1/board_4750.c +++ b/usbboot/xburst_stage1/board_4750.c @@ -1,7 +1,7 @@ /* * Board init routines. * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage1/common.c b/usbboot/xburst_stage1/common.c index b7ffd38..36f0e8c 100644 --- a/usbboot/xburst_stage1/common.c +++ b/usbboot/xburst_stage1/common.c @@ -1,7 +1,7 @@ /* * device board * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage1/debug.c b/usbboot/xburst_stage1/debug.c index 8e17139..d5d7f41 100644 --- a/usbboot/xburst_stage1/debug.c +++ b/usbboot/xburst_stage1/debug.c @@ -1,7 +1,7 @@ /* * device board * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage1/head.S b/usbboot/xburst_stage1/head.S index 4188fe3..ad49104 100644 --- a/usbboot/xburst_stage1/head.S +++ b/usbboot/xburst_stage1/head.S @@ -4,7 +4,7 @@ * Entry point of the firmware. * The firmware code are executed in the ICache. * - * (C) Copyright 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage1/main.c b/usbboot/xburst_stage1/main.c index 00d6ea2..1d6beff 100644 --- a/usbboot/xburst_stage1/main.c +++ b/usbboot/xburst_stage1/main.c @@ -1,7 +1,7 @@ /* * Main routine of the firmware. * - * Copyright (C) 2009 + * Copyright 2009 (C) Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage2/boothandler.c b/usbboot/xburst_stage2/boothandler.c index 9e31184..2b30274 100644 --- a/usbboot/xburst_stage2/boothandler.c +++ b/usbboot/xburst_stage2/boothandler.c @@ -1,7 +1,7 @@ /* * USB_BOOT Handle routines * - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage2/head.S b/usbboot/xburst_stage2/head.S index 5078e31..528fa0e 100644 --- a/usbboot/xburst_stage2/head.S +++ b/usbboot/xburst_stage2/head.S @@ -26,11 +26,9 @@ _start: .word 0x0 real_start: - //---------------------------------------------------- - // setup stack, jump to C code - //---------------------------------------------------- - add $29, $20, 0x3ffff0 // sp locate at start address offset 0x2ffff0 - add $25, $20, 0x40 // t9 = usb_main() + /* setup stack, jump to C code */ + add $29, $20, 0x3ffff0 // sp locate at start address offset 0x2ffff0 + add $25, $20, 0x40 // t9 = usb_main() j $25 nop diff --git a/usbboot/xburst_stage2/main.c b/usbboot/xburst_stage2/main.c index 4301f7e..43f0502 100644 --- a/usbboot/xburst_stage2/main.c +++ b/usbboot/xburst_stage2/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage2/nandflash_4740.c b/usbboot/xburst_stage2/nandflash_4740.c index 447633e..e7e0b24 100644 --- a/usbboot/xburst_stage2/nandflash_4740.c +++ b/usbboot/xburst_stage2/nandflash_4740.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 QI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA */ + #include "nandflash.h" #include "jz4740.h" #include "usb_boot.h" @@ -68,7 +69,6 @@ static volatile unsigned char *cmdport = (volatile unsigned char *)0xb8008000; static int bus = 8, row = 2, pagesize = 2048, oobsize = 64, ppb = 128; static int bad_block_pos,bad_block_page,force_erase,ecc_pos,wp_pin; extern struct hand Hand; -//static u8 data_buf[2048] = {0}; static u8 oob_buf[256] = {0}; extern u16 handshake_PKT[4]; @@ -92,7 +92,8 @@ static inline void __nand_sync(void) static void select_chip(int block) { int t; - if (!Hand.nand_bpc) return; + if (!Hand.nand_bpc) + return; t = (block / Hand.nand_bpc) % 4; addrport = (volatile unsigned char *)(EMC_CSN[t] + 0x10000); dataport = (volatile unsigned char *)EMC_CSN[t]; @@ -109,27 +110,28 @@ static int (*read_proc)(char *, int) = NULL; static nand_init_gpio(void) { - //modify this fun to a specifical borad - //this fun init those gpio use by all flash chip - //select the gpio function related to flash chip + /* modify this fun to a specifical borad + * this fun init those gpio use by all flash chip + * select the gpio function related to flash chip + */ __gpio_as_nand(); } inline void nand_enable_4740(unsigned int csn) { - //modify this fun to a specifical borad - //this fun to enable the chip select pin csn - //the choosn chip can work after this fun - //dprintf("\n Enable chip select :%d",csn); + /* modify this fun to a specifical borad + * this fun to enable the chip select pin csn + * the choosn chip can work after this fun + */ __nand_enable(); } inline void nand_disable_4740(unsigned int csn) { - //modify this fun to a specifical borad - //this fun to enable the chip select pin csn - //the choosn chip can not work after this fun - //dprintf("\n Disable chip select :%d",csn); + /* modify this fun to a specifical borad + * this fun to enable the chip select pin csn + * the choosn chip can not work after this fun + */ __nand_disable(); } @@ -162,7 +164,6 @@ int nand_init_4740(int bus_width, int row_cycle, int page_size, int page_per_blo ecc_pos = ep; wp_pin = Hand.nand_wppin; -// nand_enable(0); /* Initialize NAND Flash Pins */ if (wp_pin) { @@ -218,47 +219,42 @@ u32 nand_read_oob_4740(void *buf, u32 startpage, u32 pagenum) static int nand_check_block(u32 block) { u32 pg,i; - - if ( bad_block_page >= ppb ) //do absolute bad block detect! - { + if ( bad_block_page >= ppb ) { + /* do absolute bad block detect! */ pg = block * ppb + 0; read_oob(oob_buf, oobsize, pg); - if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) { - serial_puts("Absolute skip a bad block\n"); - return 1; - } + if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) + goto bad; pg = block * ppb + 1; read_oob(oob_buf, oobsize, pg); - if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) { - serial_puts("Absolute skip a bad block\n"); - return 1; - } + if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) + goto bad; pg = block * ppb + ppb - 2 ; read_oob(oob_buf, oobsize, pg); - if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) { - serial_puts("Absolute skip a bad block\n"); - return 1; - } + if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) + goto bad; pg = block * ppb + ppb - 1 ; read_oob(oob_buf, oobsize, pg); - if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) { - serial_puts("Absolute skip a bad block\n"); - return 1; - } + if ( oob_buf[0] != 0xff || oob_buf[1] != 0xff ) + goto bad; } else { pg = block * ppb + bad_block_page; read_oob(oob_buf, oobsize, pg); - if (oob_buf[bad_block_pos] != 0xff) { - serial_puts("Skip a bad block\n"); - return 1; - } + if (oob_buf[bad_block_pos] != 0xff) + goto bad; } + return 0; + +bad: + serial_puts("Absolute skip a bad block\n"); + return 1; + } /* @@ -280,7 +276,7 @@ u32 nand_read_raw_4740(void *buf, u32 startpage, u32 pagecount, int option) select_chip(cnt / ppb); if ((cur_page % ppb) == 0) { if (nand_check_block(cur_page / ppb)) { - cur_page += ppb; // Bad block, set to next block + cur_page += ppb; //Bad block, set to next block continue; } } @@ -327,10 +323,8 @@ u32 nand_erase_4740(int blk_num, int sblk, int force) for (i = 0; i < blk_num; ) { rowaddr = cur; select_chip(cur / ppb); - if ( !force ) - { - if (nand_check_block(cur/ppb)) - { + if ( !force ) { + if (nand_check_block(cur/ppb)) { cur += ppb; blk_num += Hand.nand_plane; continue; @@ -347,8 +341,7 @@ u32 nand_erase_4740(int blk_num, int sblk, int force) __nand_sync(); __nand_cmd(CMD_READ_STATUS); - if (__nand_data8() & 0x01) - { + if (__nand_data8() & 0x01) { serial_puts("Erase fail at "); serial_put_hex(cur / ppb); nand_mark_bad_4740(cur/ppb); @@ -452,7 +445,7 @@ u32 nand_read_4740(void *buf, u32 startpage, u32 pagecount, int option) if ((cur_page % ppb) == 0) { cur_blk = cur_page / ppb; if (nand_check_block(cur_blk)) { - cur_page += ppb; // Bad block, set to next block + cur_page += ppb; //Bad block, set to next block continue; } } @@ -524,19 +517,19 @@ u32 nand_read_4740(void *buf, u32 startpage, u32 pagecount, int option) } switch (option) { - case OOB_ECC: + case OOB_ECC: for (j = 0; j < oobsize; j++) tmpbuf[j] = oob_buf[j]; tmpbuf += oobsize; break; - case OOB_NO_ECC: + case OOB_NO_ECC: for (j = 0; j < ecccnt * PAR_SIZE; j++) oob_buf[ecc_pos + j] = 0xff; for (j = 0; j < oobsize; j++) tmpbuf[j] = oob_buf[j]; tmpbuf += oobsize; break; - case NO_OOB: + case NO_OOB: break; } @@ -811,4 +804,3 @@ static int nand_data_read16(char *buf, int count) *p++ = __nand_data16(); return 0; } - diff --git a/usbboot/xburst_stage2/nandflash_4750.c b/usbboot/xburst_stage2/nandflash_4750.c index a46ae3b..9290b38 100644 --- a/usbboot/xburst_stage2/nandflash_4750.c +++ b/usbboot/xburst_stage2/nandflash_4750.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage2/serial.c b/usbboot/xburst_stage2/serial.c index fe74bba..acb110f 100644 --- a/usbboot/xburst_stage2/serial.c +++ b/usbboot/xburst_stage2/serial.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or diff --git a/usbboot/xburst_stage2/udc.c b/usbboot/xburst_stage2/udc.c index de029b7..8f074f9 100644 --- a/usbboot/xburst_stage2/udc.c +++ b/usbboot/xburst_stage2/udc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 PI + * Copyright (C) 2009 Qi Hardware Inc., * Author: Xiangfu Liu * * This program is free software; you can redistribute it and/or @@ -26,14 +26,14 @@ u32 Bulk_in_buf[BULK_IN_BUF_SIZE]; u32 Bulk_out_buf[BULK_OUT_BUF_SIZE]; -u32 Bulk_in_size,Bulk_in_finish,Bulk_out_size; -u16 handshake_PKT[4]={0,0,0,0}; +u32 Bulk_in_size, Bulk_in_finish, Bulk_out_size; +u16 handshake_PKT[4] = {0, 0, 0, 0}; u8 udc_state; static u32 rx_buf[32]; static u32 tx_buf[32]; -static u32 tx_size, rx_size, finished,fifo; -static u8 ep0state,USB_Version; +static u32 tx_size, rx_size, finished, fifo; +static u8 ep0state, USB_Version; static u32 fifoaddr[] = { @@ -93,30 +93,24 @@ static void udcWriteFifo(u8 *ptr, int size) void HW_SendPKT(int ep, const u8 *buf, int size) { -// dprintf("EP%d send pkt :%d\n", ep, size); fifo = fifoaddr[ep]; - if (ep!=0) - { + if (ep!=0) { Bulk_in_size = size; Bulk_in_finish = 0; jz_writeb(USB_REG_INDEX, ep); - if (Bulk_in_size - Bulk_in_finish <= fifosize[ep]) - { + if (Bulk_in_size - Bulk_in_finish <= fifosize[ep]) { udcWriteFifo((u8 *)((u32)buf+Bulk_in_finish), Bulk_in_size - Bulk_in_finish); usb_setb(USB_REG_INCSR, USB_INCSR_INPKTRDY); Bulk_in_finish = Bulk_in_size; - } else - { + } else { udcWriteFifo((u8 *)((u32)buf+Bulk_in_finish), fifosize[ep]); usb_setb(USB_REG_INCSR, USB_INCSR_INPKTRDY); Bulk_in_finish += fifosize[ep]; } - } - else //EP0 - { + } else { tx_size = size; finished = 0; memcpy((void *)tx_buf, buf, size); @@ -126,7 +120,6 @@ void HW_SendPKT(int ep, const u8 *buf, int size) void HW_GetPKT(int ep, const u8 *buf, int size) { -// dprintf("EP%d read pkt :%d\n", ep, size); memcpy((void *)buf, (u8 *)rx_buf, size); fifo = fifoaddr[ep]; if (rx_size > size) @@ -209,21 +202,20 @@ static struct { void sendDevDescString(int size) { u16 str_ret[13] = { - 0x031a,//0x1a=26 byte - 0x0041, - 0x0030, - 0x0030, - 0x0041, - 0x0030, - 0x0030, - 0x0041, - 0x0030, - 0x0030, - 0x0041, - 0x0030, - 0x0030 - }; -// dprintf("sendDevDescString size = %d\r\n",size); + 0x031a,//0x1a=26 byte + 0x0041, + 0x0030, + 0x0030, + 0x0041, + 0x0030, + 0x0030, + 0x0041, + 0x0030, + 0x0030, + 0x0041, + 0x0030, + 0x0030 + }; if(size >= 26) size = 26; str_ret[0] = (0x0300 | size); @@ -269,7 +261,6 @@ void EP0_init(u32 out, u32 out_size, u32 in, u32 in_size) static void udc_reset(void) { u8 byte; - //data init ep0state = USB_EP0_IDLE; Bulk_in_size = 0; Bulk_in_finish = 0; @@ -282,7 +273,6 @@ static void udc_reset(void) // REG_CPM_SCR |= CPM_SCR_USBPHY_ENABLE; /* Disable interrupts */ byte=jz_readb(USB_REG_POWER); -// dprintf("\nREG_POWER: %02x",byte); jz_writew(USB_REG_INTRINE, 0); jz_writew(USB_REG_INTROUTE, 0); jz_writeb(USB_REG_INTRUSBE, 0); @@ -301,9 +291,7 @@ static void udc_reset(void) jz_writeb(USB_REG_INTRUSBE,0x4); byte=jz_readb(USB_REG_POWER); -// dprintf("\nREG_POWER: %02x",byte); - if ((byte&0x10)==0) - { + if ((byte&0x10)==0) { jz_writeb(USB_REG_INDEX,1); jz_writew(USB_REG_INMAXP,64); jz_writew(USB_REG_INCSR,0x2048); @@ -313,9 +301,7 @@ static void udc_reset(void) USB_Version=USB_FS; fifosize[1]=64; EP0_init(1,64,1,64); - } - else - { + } else { jz_writeb(USB_REG_INDEX,1); jz_writew(USB_REG_INMAXP,512); jz_writew(USB_REG_INCSR,0x2048); @@ -336,8 +322,7 @@ void usbHandleStandDevReq(u8 *buf) switch (dreq->bRequest) { case GET_DESCRIPTOR: if (dreq->bmRequestType == 0x80) /* Dev2Host */ - switch(dreq->wValue >> 8) - { + switch(dreq->wValue >> 8) { case DEVICE_DESCRIPTOR: dprintf("get device\n"); sendDevDesc(dreq->wLength); @@ -351,7 +336,6 @@ void usbHandleStandDevReq(u8 *buf) HW_SendPKT(0, "\x04\x03", 2); else sendDevDescString(dreq->wLength); - //HW_SendPKT(0, "\x04\x03\x09\x04", 2); break; } dprintf("\nSet ep0state=TX!"); @@ -408,28 +392,22 @@ void usbHandleVendorReq(u8 *buf) case VR_NOR_OPS: ret_state=NOR_OPS_Handle(buf); Bulk_out_size = 0; - //Bulk_in_size = 0; break; case VR_NAND_OPS: NAND_OPS_Handle(buf); Bulk_out_size = 0; - //Bulk_in_size = 0; - //handshake_PKT[3]=(u16)ret_state; - //HW_SendPKT(0,handshake_PKT,sizeof(handshake_PKT)); break; case VR_CONFIGRATION: ret_state=CONFIGRATION_Handle(buf); handshake_PKT[3]=(u16)ret_state; HW_SendPKT(1,(u8 *)handshake_PKT,sizeof(handshake_PKT)); Bulk_out_size = 0; - //Bulk_in_size = 0; break; case VR_SDRAM_OPS: SDRAM_OPS_Handle(buf); Bulk_out_size = 0; break; } -// serial_puts("get here! \n"); } void Handshake_PKT() @@ -445,7 +423,6 @@ void Handshake_PKT() void usbHandleDevReq(u8 *buf) { -// dprintf("dev req:%d\n", (buf[0] & (3 << 5)) >> 5); switch ((buf[0] & (3 << 5)) >> 5) { case 0: /* Standard request */ usbHandleStandDevReq(buf); @@ -460,16 +437,15 @@ void usbHandleDevReq(u8 *buf) void EP0_Handler () { - u8 byCSR0; + u8 byCSR0; /* Read CSR0 */ jz_writeb(USB_REG_INDEX, 0); byCSR0 = jz_readb(USB_REG_CSR0); -/* Check for SentStall - if sendtall is set ,clear the sendstall bit*/ - if (byCSR0 & USB_CSR0_SENTSTALL) - { +/* Check for SentStall + * if sendtall is set ,clear the sendstall bit */ + if (byCSR0 & USB_CSR0_SENTSTALL) { jz_writeb(USB_REG_CSR0, (byCSR0 & ~USB_CSR0_SENDSTALL)); ep0state = USB_EP0_IDLE; dprintf("\nSentstall!"); @@ -477,18 +453,15 @@ void EP0_Handler () } /* Check for SetupEnd */ - if (byCSR0 & USB_CSR0_SETUPEND) - { + if (byCSR0 & USB_CSR0_SETUPEND) { jz_writeb(USB_REG_CSR0, (byCSR0 | USB_CSR0_SVDSETUPEND)); ep0state = USB_EP0_IDLE; dprintf("\nSetupend!"); return; } /* Call relevant routines for endpoint 0 state */ - if (ep0state == USB_EP0_IDLE) - { - if (byCSR0 & USB_CSR0_OUTPKTRDY) //There are datas in fifo - { + if (ep0state == USB_EP0_IDLE) { + if (byCSR0 & USB_CSR0_OUTPKTRDY) { //There are datas in fifo USB_DeviceRequest *dreq; fifo=fifoaddr[0]; udcReadFifo((u8 *)rx_buf, sizeof(USB_DeviceRequest)); @@ -505,26 +478,22 @@ void EP0_Handler () dreq->wLength); #endif usbHandleDevReq((u8 *)rx_buf); - } else - { + } else { dprintf("0:R DATA\n"); } rx_size = 0; } - if (ep0state == USB_EP0_TX) - { + if (ep0state == USB_EP0_TX) { fifo=fifoaddr[0]; - if (tx_size - finished <= 64) - { + if (tx_size - finished <= 64) { udcWriteFifo((u8 *)((u32)tx_buf+finished), tx_size - finished); finished = tx_size; usb_setb(USB_REG_CSR0, USB_CSR0_INPKTRDY); usb_setb(USB_REG_CSR0, USB_CSR0_DATAEND); //Set dataend! ep0state=USB_EP0_IDLE; - } else - { + } else { udcWriteFifo((u8 *)((u32)tx_buf+finished), 64); usb_setb(USB_REG_CSR0, USB_CSR0_INPKTRDY); finished += 64; @@ -538,20 +507,17 @@ void EPIN_Handler(u8 EP) jz_writeb(USB_REG_INDEX, EP); fifo = fifoaddr[EP]; - if (Bulk_in_size-Bulk_in_finish==0) - { + if (Bulk_in_size-Bulk_in_finish==0) { Handshake_PKT(); return; } - if (Bulk_in_size - Bulk_in_finish <= fifosize[EP]) - { + if (Bulk_in_size - Bulk_in_finish <= fifosize[EP]) { udcWriteFifo((u8 *)((u32)Bulk_in_buf+Bulk_in_finish), Bulk_in_size - Bulk_in_finish); usb_setw(USB_REG_INCSR, USB_INCSR_INPKTRDY); Bulk_in_finish = Bulk_in_size; - } else - { + } else { udcWriteFifo((u8 *)((u32)Bulk_in_buf+Bulk_in_finish), fifosize[EP]); usb_setw(USB_REG_INCSR, USB_INCSR_INPKTRDY); @@ -577,45 +543,39 @@ void udc4740Proc () volatile u16 IntrIn; volatile u16 IntrOut; /* Read interrupt registers */ -// while(1) -// { - IntrUSB = jz_readb(USB_REG_INTRUSB); - IntrIn = jz_readw(USB_REG_INTRIN); - IntrOut = jz_readw(USB_REG_INTROUT); + IntrUSB = jz_readb(USB_REG_INTRUSB); + IntrIn = jz_readw(USB_REG_INTRIN); + IntrOut = jz_readw(USB_REG_INTROUT); - if ( IntrUSB == 0 && IntrIn == 0 && IntrOut == 0) - return; + if ( IntrUSB == 0 && IntrIn == 0 && IntrOut == 0) + return; - if (IntrIn & 2) - { - dprintf("\nUDC EP1 IN operation!"); - EPIN_Handler(1); - } - if (IntrOut & 2) - { - dprintf("\nUDC EP1 OUT operation!"); - EPOUT_Handler(1); - } - if (IntrUSB & USB_INTR_RESET) - { - dprintf("\nUDC reset intrupt!"); - udc_reset(); - } + if (IntrIn & 2) { + dprintf("\nUDC EP1 IN operation!"); + EPIN_Handler(1); + } + + if (IntrOut & 2) { + dprintf("\nUDC EP1 OUT operation!"); + EPOUT_Handler(1); + } + + if (IntrUSB & USB_INTR_RESET) { + dprintf("\nUDC reset intrupt!"); + udc_reset(); + } /* Check for endpoint 0 interrupt */ - if (IntrIn & USB_INTR_EP0) - { - dprintf("\nUDC EP0 operations!"); - EP0_Handler(); - } + if (IntrIn & USB_INTR_EP0) { + dprintf("\nUDC EP0 operations!"); + EP0_Handler(); + } - if (USB_Version == USB_FS) - IntrIn = jz_readw(USB_REG_INTRIN); -// } + if (USB_Version == USB_FS) + IntrIn = jz_readw(USB_REG_INTRIN); return; } -//unsigned int g_stack[2049]; void usb_main() { u8 byte; @@ -633,14 +593,11 @@ void usb_main() finished = 0; byte=jz_readb(USB_REG_POWER); - if ((byte&0x10)==0) - { + if ((byte&0x10)==0) { USB_Version=USB_FS; fifosize[1]=64; EP0_init(1,64,1,64); - } - else - { + } else { USB_Version=USB_HS; fifosize[1]=512; EP0_init(1,512,1,512);