Root/
Source at commit ff3182da41eef87f6707159e6616f354a488f8b6 created 13 years 27 days ago. By Xiangfu Liu, add new command: reset, then we can reboot device after reflash | |
---|---|
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 VR_GET_CPU_INFO 0x00 |
29 | #define VR_SET_DATA_ADDRESS 0x01 |
30 | #define VR_SET_DATA_LENGTH 0x02 |
31 | #define VR_FLUSH_CACHES 0x03 |
32 | #define VR_PROGRAM_START1 0x04 |
33 | #define VR_PROGRAM_START2 0x05 |
34 | #define VR_NOR_OPS 0x06 |
35 | #define VR_NAND_OPS 0x07 |
36 | #define VR_SDRAM_OPS 0x08 |
37 | #define VR_CONFIGRATION 0x09 |
38 | #define VR_RESET 0x0a |
39 | |
40 | #define JZ4740V1 1 |
41 | #define JZ4750V1 2 |
42 | #define JZ4760V1 3 |
43 | #define BOOT4740 4 |
44 | #define BOOT4750 5 |
45 | #define BOOT4760 6 |
46 | |
47 | #define STAGE_ADDR_MSB(addr) ((addr) >> 16) |
48 | #define STAGE_ADDR_LSB(addr) ((addr) & 0xffff) |
49 | |
50 | #define USB_PACKET_SIZE 512 |
51 | #define USB_TIMEOUT 5000 |
52 | |
53 | #define VENDOR_ID 0x601a |
54 | #define PRODUCT_ID_4740 0x4740 |
55 | #define PRODUCT_ID_4750 0x4750 |
56 | #define PRODUCT_ID_4760 0x4760 |
57 | |
58 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
59 | |
60 | struct ingenic_dev { |
61 | struct usb_device *usb_dev; |
62 | struct usb_dev_handle *usb_handle; |
63 | uint8_t interface; |
64 | char cpu_info_buff[9]; |
65 | char *file_buff; |
66 | unsigned int file_len; |
67 | }; |
68 | |
69 | int usb_ingenic_init(struct ingenic_dev *ingenic_dev); |
70 | int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev); |
71 | int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage); |
72 | void usb_ingenic_cleanup(struct ingenic_dev *ingenic_dev); |
73 | int usb_send_data_address_to_ingenic(struct ingenic_dev *ingenic_dev, |
74 | unsigned int stage_addr); |
75 | int usb_send_data_to_ingenic(struct ingenic_dev *ingenic_dev); |
76 | int usb_send_data_length_to_ingenic(struct ingenic_dev *ingenic_dev, |
77 | int len); |
78 | int usb_ingenic_nand_ops(struct ingenic_dev *ingenic_dev, int ops); |
79 | int usb_read_data_from_ingenic(struct ingenic_dev *ingenic_dev,unsigned char *buff, unsigned int len); |
80 | int usb_ingenic_reset(struct ingenic_dev *ingenic_dev, int ops); |
81 | |
82 | #endif /* __INGENIC_USB_H__ */ |
83 |