1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-12-22 23:52:25 +02:00

add new command: reset, then we can reboot device after reflash

This commit is contained in:
Xiangfu Liu 2011-03-02 10:42:35 +08:00
parent aa59c6a7ec
commit ff3182da41
8 changed files with 54 additions and 11 deletions

View File

@ -962,3 +962,11 @@ close:
out:
return res;
}
int device_reset(int ops)
{
if (usb_ingenic_reset(&ingenic_dev, ops) < 1)
return -1;
return 1;
}

View File

@ -33,5 +33,6 @@ int nand_erase(struct nand_in *nand_in);
int debug_memory(int obj, unsigned int start, unsigned int size);
int debug_gpio(int obj, unsigned char ops, unsigned char pin);
int debug_go(void);
int device_reset(int ops);
#endif /* __CMD_H__ */

View File

@ -204,6 +204,8 @@ int command_handle(char *buf)
debug_go();
else if (!strcmp("memtest", com_argv[0]))
handle_memtest();
else if (!strcmp("reset", com_argv[0]))
device_reset(0);
else if (!strcmp("help", com_argv[0]))
handle_help();
else if (!strcmp("exit", com_argv[0]))

View File

@ -406,3 +406,24 @@ int usb_ingenic_sdram_ops(struct ingenic_dev *ingenic_dev, int ops)
return 1;
}
int usb_ingenic_reset(struct ingenic_dev *ingenic_dev, int ops)
{
int status;
status = usb_control_msg(ingenic_dev->usb_handle,
/* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
/* bRequest */ VR_RESET,
/* wValue */ ops,
/* wIndex */ 0,
/* Data */ 0,
/* wLength */ 0,
USB_TIMEOUT);
if (status != 0) {
fprintf(stderr, "Error - "
"reset XBurst device: %i\n", status);
return -1;
}
return 1;
}

View File

@ -35,7 +35,7 @@
#define VR_NAND_OPS 0x07
#define VR_SDRAM_OPS 0x08
#define VR_CONFIGRATION 0x09
#define VR_GET_NUM 0x0a
#define VR_RESET 0x0a
#define JZ4740V1 1
#define JZ4750V1 2
@ -77,5 +77,6 @@ int usb_send_data_length_to_ingenic(struct ingenic_dev *ingenic_dev,
int len);
int usb_ingenic_nand_ops(struct ingenic_dev *ingenic_dev, int ops);
int usb_read_data_from_ingenic(struct ingenic_dev *ingenic_dev,unsigned char *buff, unsigned int len);
int usb_ingenic_reset(struct ingenic_dev *ingenic_dev, int ops);
#endif /* __INGENIC_USB_H__ */

View File

@ -44,7 +44,7 @@ enum USB_JZ4740_REQUEST /* add for USB_BOOT */
VR_NAND_OPS,
VR_SDRAM_OPS,
VR_CONFIGRATION,
VR_OTHER
VR_RESET
};
#endif /* __USB_BOOT_H__ */

View File

@ -51,8 +51,8 @@ extern void *memset(void *s, int c, size_t count);
extern void *memcpy(void *dest, const void *src, size_t count);
u32 ret_dat;
u32 start_addr; //program operation start address or sector
u32 ops_length; //number of operation unit ,in byte or sector
u32 start_addr; /* program operation start address or sector */
u32 ops_length; /* number of operation unit ,in byte or sector */
u32 ram_addr;
void dump_data(unsigned int *p, int size)
@ -117,7 +117,6 @@ int PROGRAM_START1_Handle(u8 *buf)
{
USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
ram_addr=(((u32)dreq->wValue)<<16)+(u32)dreq->wIndex;
//dprintf("\n RAM ADDRESS :%x", ram_addr);
return ERR_OK;
}
@ -127,9 +126,9 @@ int PROGRAM_START2_Handle(u8 *buf)
USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
f=(void *) ((((u32)dreq->wValue)<<16)+(u32)dreq->wIndex);
__dcache_writeback_all();
//stop udc connet before execute program!
jz_writeb(USB_REG_POWER,0x0); //High speed
//dprintf("\n Execute program at %x",(u32)f);
/* stop udc connet before execute program! */
jz_writeb(USB_REG_POWER,0x0); /* High speed */
f();
return ERR_OK;
}
@ -273,7 +272,6 @@ int SDRAM_OPS_Handle(u8 *buf)
switch ((dreq->wValue)&0xf)
{
case SDRAM_LOAD:
//dprintf("\n Request : SDRAM_LOAD!");
ret_dat = (u32)memcpy((u8 *)start_addr,Bulk_out_buf,ops_length);
handshake_PKT[0] = (u16) ret_dat;
handshake_PKT[1] = (u16) (ret_dat>>16);
@ -291,7 +289,6 @@ void Borad_Init()
switch (Hand.fw_args.cpu_id)
{
case 0x4740:
//Init nand flash
nand_init_4740(Hand.nand_bw, Hand.nand_rc, Hand.nand_ps,
Hand.nand_ppb, Hand.nand_bbpage, Hand.nand_bbpos,
Hand.nand_force_erase, Hand.nand_eccpos);
@ -307,7 +304,6 @@ void Borad_Init()
nand_mark_bad = nand_mark_bad_4740;
break;
case 0x4760:
//Init nand flash
nand_init_4760(Hand.nand_bw, Hand.nand_rc, Hand.nand_ps,
Hand.nand_ppb, Hand.nand_bchbit, Hand.nand_eccpos,
Hand.nand_bbpos, Hand.nand_bbpage, Hand.nand_force_erase);
@ -351,3 +347,14 @@ int CONFIGRATION_Handle(u8 *buf)
}
int RESET_Handle(u8 *buf)
{
dprintf("\n RESET Device");
__wdt_select_extalclk();
__wdt_select_clk_div64();
__wdt_set_data(100);
__wdt_set_count(0);
__tcu_start_wdt_clock();
__wdt_start();
while(1);
}

View File

@ -418,6 +418,9 @@ void usbHandleVendorReq(u8 *buf)
SDRAM_OPS_Handle(buf);
Bulk_out_size = 0;
break;
case VR_RESET:
ret_state = RESET_Handle(buf);
break;
}
}