1 /* 2 * USB boot definitions. 3 * 4 * Copyright (C) 2009 Qi Hardware Inc. 5 * Authors: Marek Lindner <lindner_marek@yahoo.de> 6 * Xiangfu Liu <xiangfu@sharism.cc> 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef __USB_BOOT_DEFINES_H__ 23 #define __USB_BOOT_DEFINES_H__ 24 25 #define SDRAM_SIZE ( 16 * 1024 * 1024 ) 26 #define CODE_SIZE ( 4 * 1024 * 1024 ) 27 /* #define START_ADDR ( 0x80000000 + SDRAM_SIZE - CODE_SIZE ) */ 28 29 #define NAND_MAX_BLK_NUM 10000000 /*((Hand.nand_pn / Hand.nand_ppb) + 1)*/ 30 #define NAND_MAX_PAGE_NUM 1073740824 /*Hand.nand_pn */ 31 #define NAND_SECTION_NUM 23 32 #define MAX_TRANSFER_SIZE 0x100000 33 #define MAX_LOAD_SIZE 0x3000 34 #define NAND_MAX_BYTE_NUM (hand.nand_pn * hand.nand_ps) 35 #define MAX_DEV_NUM 16 36 37 enum CPUTYPE { 38 JZ4740, 39 JZ4750 40 }; 41 42 enum USB_Boot_State { 43 DISCONNECT, 44 CONNECT, 45 BOOT, 46 UNBOOT 47 }; 48 49 enum OPTION { 50 OOB_ECC, 51 OOB_NO_ECC, 52 NO_OOB 53 }; 54 55 enum NOR_OPS_TYPE { 56 NOR_INIT = 0, 57 NOR_QUERY, 58 NOR_WRITE, 59 NOR_ERASE_CHIP, 60 NOR_ERASE_SECTOR 61 }; 62 63 enum NOR_FLASH_TYPE 64 { 65 NOR_AM29 = 0, 66 NOR_SST28, 67 NOR_SST39x16, 68 NOR_SST39x8 69 }; 70 71 enum NAND_OPS_TYPE { 72 NAND_QUERY = 0, 73 NAND_INIT, 74 NAND_MARK_BAD, 75 NAND_READ_OOB, 76 NAND_READ_RAW, 77 NAND_ERASE, 78 NAND_READ, 79 NAND_PROGRAM, 80 NAND_READ_TO_RAM 81 }; 82 83 enum SDRAM_OPS_TYPE { 84 SDRAM_LOAD 85 }; 86 87 enum DATA_STRUCTURE_OB { 88 DS_flash_info = 0, 89 DS_hand 90 }; 91 92 struct fw_args { 93 /* CPU ID */ 94 unsigned int cpu_id; 95 96 /* PLL args */ 97 unsigned char ext_clk; 98 unsigned char cpu_speed; 99 unsigned char phm_div; 100 unsigned char use_uart; 101 unsigned int boudrate; 102 103 /* SDRAM args */ 104 unsigned char bus_width; 105 unsigned char bank_num; 106 unsigned char row_addr; 107 unsigned char col_addr; 108 unsigned char is_mobile; 109 unsigned char is_busshare; 110 111 /* debug args */ 112 char debug_ops; 113 unsigned char pin_num; 114 unsigned int start; 115 unsigned int size; 116 } __attribute__((packed)); 117 118 struct hand { 119 /* nand flash info */ 120 int pt; /* cpu type */ 121 unsigned int nand_bw; /* bus width */ 122 unsigned int nand_rc; /* row cycle */ 123 unsigned int nand_ps; /* page size */ 124 unsigned int nand_ppb; /* page number per block */ 125 unsigned int nand_force_erase; 126 unsigned int nand_pn; /* page number in total */ 127 unsigned int nand_os; /* oob size */ 128 unsigned int nand_eccpos; 129 unsigned int nand_bbpage; 130 unsigned int nand_bbpos; 131 unsigned int nand_plane; 132 unsigned int nand_bchbit; 133 unsigned int nand_wppin; 134 unsigned int nand_bpc; /* block number per chip */ 135 136 struct fw_args fw_args; 137 } __attribute__((packed)); 138 139 struct nand_in { 140 unsigned char dev; 141 unsigned char max_chip; 142 unsigned char *buf; 143 unsigned char *cs_map; 144 unsigned int start; 145 unsigned int length; 146 unsigned int option; 147 148 int (* check) (unsigned char *,unsigned char *,unsigned int); 149 }; 150 151 struct nand_out { 152 unsigned char *status; 153 }; 154 155 struct sdram_in { 156 unsigned char dev; 157 unsigned char *buf; 158 unsigned int start; 159 unsigned int length; 160 unsigned int option; 161 }; 162 163 #endif /* __USB_BOOT_DEFINES_H__ */ 164