2009-04-26 13:37:31 +03:00
|
|
|
/*
|
2009-07-05 07:43:21 +03:00
|
|
|
* Authors: Xiangfu Liu <xiangfu@qi-hardware.com>
|
2009-06-25 07:33:46 +03:00
|
|
|
* Marek Lindner <lindner_marek@yahoo.de>
|
2009-04-26 13:37:31 +03:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2009-06-25 07:33:46 +03:00
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 3 of the License, or (at your option) any later version.
|
2009-04-26 13:37:31 +03:00
|
|
|
*/
|
2009-06-25 07:33:46 +03:00
|
|
|
|
2009-04-28 20:07:43 +03:00
|
|
|
#ifndef __INGENIC_USB_H__
|
|
|
|
#define __INGENIC_USB_H__
|
2009-04-26 13:37:31 +03:00
|
|
|
|
2009-04-28 18:57:53 +03:00
|
|
|
#include <stdint.h>
|
2009-04-26 13:37:31 +03:00
|
|
|
|
2009-04-26 23:08:14 +03:00
|
|
|
#define INGENIC_OUT_ENDPOINT 0x01
|
2009-05-04 17:36:51 +03:00
|
|
|
#define INGENIC_IN_ENDPOINT 0x81
|
2009-04-26 13:37:31 +03:00
|
|
|
|
|
|
|
#define VR_GET_CPU_INFO 0x00
|
|
|
|
#define VR_SET_DATA_ADDRESS 0x01
|
|
|
|
#define VR_SET_DATA_LENGTH 0x02
|
|
|
|
#define VR_FLUSH_CACHES 0x03
|
|
|
|
#define VR_PROGRAM_START1 0x04
|
|
|
|
#define VR_PROGRAM_START2 0x05
|
2009-04-26 21:17:38 +03:00
|
|
|
#define VR_NOR_OPS 0x06
|
|
|
|
#define VR_NAND_OPS 0x07
|
|
|
|
#define VR_SDRAM_OPS 0x08
|
|
|
|
#define VR_CONFIGRATION 0x09
|
|
|
|
#define VR_GET_NUM 0x0a
|
2009-04-26 13:37:31 +03:00
|
|
|
|
2009-04-27 11:54:10 +03:00
|
|
|
#define STAGE_ADDR_MSB(addr) ((addr) >> 16)
|
|
|
|
#define STAGE_ADDR_LSB(addr) ((addr) & 0xffff)
|
2009-04-26 13:37:31 +03:00
|
|
|
|
|
|
|
#define USB_PACKET_SIZE 512
|
|
|
|
#define USB_TIMEOUT 5000
|
|
|
|
|
2009-04-28 18:57:53 +03:00
|
|
|
#define VENDOR_ID 0x601a
|
|
|
|
#define PRODUCT_ID 0x4740
|
|
|
|
|
2009-07-02 12:22:33 +03:00
|
|
|
#define STAGE1_FILE_PATH "/usr/share/xburst-tools/xburst_stage1.bin"
|
|
|
|
#define STAGE2_FILE_PATH "/usr/share/xburst-tools/xburst_stage2.bin"
|
2009-04-30 20:26:14 +03:00
|
|
|
|
2009-04-28 20:07:43 +03:00
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
2009-04-28 18:57:53 +03:00
|
|
|
|
|
|
|
struct ingenic_dev {
|
|
|
|
struct usb_device *usb_dev;
|
|
|
|
struct usb_dev_handle *usb_handle;
|
|
|
|
uint8_t interface;
|
|
|
|
char cpu_info_buff[9];
|
|
|
|
char *file_buff;
|
2009-05-04 17:36:51 +03:00
|
|
|
unsigned int file_len;
|
2009-04-28 18:57:53 +03:00
|
|
|
};
|
2009-04-26 13:37:31 +03:00
|
|
|
|
|
|
|
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);
|
2009-05-03 18:06:23 +03:00
|
|
|
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);
|
2009-05-03 18:33:56 +03:00
|
|
|
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);
|
2009-05-14 20:11:03 +03:00
|
|
|
int usb_read_data_from_ingenic(struct ingenic_dev *ingenic_dev,unsigned char *buff, unsigned int len);
|
2009-04-28 20:07:43 +03:00
|
|
|
|
|
|
|
#endif /* __INGENIC_USB_H__ */
|
2009-05-03 18:06:23 +03:00
|
|
|
|