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
25#define INGENIC_OUT_ENDPOINT 0x01
26#define INGENIC_IN_ENDPOINT 0x81
27
28#define JZ4740V1 1
29#define JZ4750V1 2
30#define JZ4760V1 3
31#define BOOT4740 4
32#define BOOT4750 5
33#define BOOT4760 6
34
35#define STAGE_ADDR_MSB(addr) ((addr) >> 16)
36#define STAGE_ADDR_LSB(addr) ((addr) & 0xffff)
37
38#define USB_PACKET_SIZE 512
39#define USB_TIMEOUT 5000
40
41#define VENDOR_ID 0x601a
42#define PRODUCT_ID_4740 0x4740
43#define PRODUCT_ID_4750 0x4750
44#define PRODUCT_ID_4760 0x4760
45
46#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
47
48struct ingenic_dev {
49    struct usb_device *usb_dev;
50    struct usb_dev_handle *usb_handle;
51    uint8_t interface;
52    char cpu_info_buff[9];
53    char *file_buff;
54    unsigned int file_len;
55};
56
57int usb_ingenic_init(struct ingenic_dev *ingenic_dev);
58int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev);
59int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage);
60void usb_ingenic_cleanup(struct ingenic_dev *ingenic_dev);
61int usb_send_data_address_to_ingenic(struct ingenic_dev *ingenic_dev,
62                     unsigned int stage_addr);
63int usb_send_data_to_ingenic(struct ingenic_dev *ingenic_dev);
64int usb_send_data_length_to_ingenic(struct ingenic_dev *ingenic_dev,
65                    int len);
66int usb_ingenic_nand_ops(struct ingenic_dev *ingenic_dev, int ops);
67int usb_read_data_from_ingenic(struct ingenic_dev *ingenic_dev,unsigned char *buff, unsigned int len);
68int usb_ingenic_reset(struct ingenic_dev *ingenic_dev, int ops);
69
70#endif /* __INGENIC_USB_H__ */
71

Archive Download this file



interactive