Root/usbboot/src/ingenic_usb.h

1/*
2 * Copyright(C) 2009 Qi Hardware Inc.,
3 * Authors: Xiangfu Liu <xiangfu@sharism.cc>
4 * Marek Lindner <lindner_marek@yahoo.de>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __INGENIC_USB_H__
21#define __INGENIC_USB_H__
22
23#include <stdint.h>
24#include "cmd.h"
25
26#define INGENIC_OUT_ENDPOINT 0x01
27#define INGENIC_IN_ENDPOINT 0x81
28
29#define JZ4740V1 1
30#define JZ4750V1 2
31#define JZ4760V1 3
32#define BOOT4740 4
33#define BOOT4750 5
34#define BOOT4760 6
35
36#define STAGE_ADDR_MSB(addr) ((addr) >> 16)
37#define STAGE_ADDR_LSB(addr) ((addr) & 0xffff)
38
39#define USB_PACKET_SIZE 512
40#define USB_TIMEOUT 5000
41
42#define VENDOR_ID 0x601a
43#define PRODUCT_ID_4740 0x4740
44#define PRODUCT_ID_4750 0x4750
45#define PRODUCT_ID_4760 0x4760
46
47#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
48
49struct ingenic_dev {
50    struct usb_device *usb_dev;
51    struct usb_dev_handle *usb_handle;
52    uint8_t interface;
53    char cpu_info_buff[9];
54    unsigned char *file_buff;
55    unsigned int file_len;
56};
57
58int usb_ingenic_init(struct ingenic_dev *id);
59int usb_get_ingenic_cpu(struct ingenic_dev *id);
60int usb_ingenic_upload(struct ingenic_dev *id, int stage);
61void usb_ingenic_cleanup(struct ingenic_dev *id);
62int usb_send_data_address_to_ingenic(struct ingenic_dev *id,
63                     unsigned int stage_addr);
64int usb_send_data_to_ingenic(struct ingenic_dev *id);
65int usb_send_data_length_to_ingenic(struct ingenic_dev *id,
66                    int len);
67int usb_ingenic_nand_ops(struct ingenic_dev *id, int ops);
68int usb_ingenic_sdram_ops(struct ingenic_dev *id, int ops);
69int usb_read_data_from_ingenic(struct ingenic_dev *id, unsigned char *buff, unsigned int len);
70int usb_ingenic_reset(struct ingenic_dev *id, int ops);
71int usb_ingenic_start(struct ingenic_dev *id, int rqst, unsigned int stage_addr);
72int usb_ingenic_configration(struct ingenic_dev *id, int ops);
73
74#endif /* __INGENIC_USB_H__ */
75

Archive Download this file



interactive