1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-12-23 17:38:37 +02:00

add nand_ops function

This commit is contained in:
xiangfu 2009-05-03 15:06:23 +00:00
parent acc365174f
commit fac0cd77ea
3 changed files with 37 additions and 13 deletions

View File

@ -19,9 +19,6 @@
* Boston, MA 02110-1301, USA
*/
#include "ingenic_usb.h"
#include "usb_boot_defines.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@ -33,6 +30,8 @@
#include <ctype.h>
#include "cmd.h"
#include "ingenic_cfg.h"
#include "ingenic_usb.h"
#include "usb_boot_defines.h"
extern int com_argc;
extern char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
@ -202,8 +201,9 @@ int nand_erase(struct nand_in_t *nand_in)
printf("\n Erasing No.%d device No.%d flash......",
nand_in->dev, i);
JZ4740_USB_SET_DATA_ADDRESS(start_blk, hDevice);
JZ4740_USB_SET_DATA_LENGTH(blk_num, hDevice);
usb_send_data_address_to_ingenic(&ingenic_dev, start_blk);
ingenic_dev->file_len = blk_num;
usb_send_data_to_ingenic(&ingenic_dev);
unsigned short temp = ((i << 4) & 0xff0) + NAND_ERASE;
JZ4740_USB_NAND_OPS(temp,hDevice);
ReadFile(hDevice, ret, 8, &nRead, NULL);

View File

@ -300,3 +300,23 @@ void usb_ingenic_cleanup(struct ingenic_dev *ingenic_dev)
if (ingenic_dev->usb_handle)
usb_close(ingenic_dev->usb_handle);
}
int usb_ingenic_nand_ops(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_NAND_OPS,
/* wValue */ ops & 0xffff,
/* wIndex */ 0,
/* Data */ 0,
/* wLength */ 0,
USB_TIMEOUT);
if (status != 0) {
fprintf(stderr, "Error - can't set Ingenic device nand ops: %i\n", status);
return -1;
}
return status;
}

View File

@ -64,5 +64,9 @@ int usb_ingenic_init(struct ingenic_dev *ingenic_dev);
int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev);
int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage);
void usb_ingenic_cleanup(struct ingenic_dev *ingenic_dev);
int usb_send_data_address_to_ingenic(struct ingenic_dev *ingenic_dev,
unsigned int stage_addr);
int usb_send_data_to_ingenic(struct ingenic_dev *ingenic_dev);
#endif /* __INGENIC_USB_H__ */