| 1 | /* |
| 2 | * Copyright(C) 2009 Qi Hardware Inc., |
| 3 | * Authors: Marek Lindner <lindner_marek@yahoo.de> |
| 4 | * Xiangfu Liu <xiangfu@sharism.cc> |
| 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 __USB_BOOT_DEFINES_H__ |
| 21 | #define __USB_BOOT_DEFINES_H__ |
| 22 | |
| 23 | #define SDRAM_SIZE ( 16 * 1024 * 1024 ) |
| 24 | #define CODE_SIZE ( 4 * 1024 * 1024 ) |
| 25 | /* #define START_ADDR ( 0x80000000 + SDRAM_SIZE - CODE_SIZE ) */ |
| 26 | |
| 27 | #define NAND_MAX_BLK_NUM 10000000 /*((Hand.nand_pn / Hand.nand_ppb) + 1)*/ |
| 28 | #define NAND_MAX_PAGE_NUM 1073740824 /*Hand.nand_pn */ |
| 29 | #define NAND_SECTION_NUM 23 |
| 30 | #define MAX_TRANSFER_SIZE 0x100000 |
| 31 | #define MAX_LOAD_SIZE 0x3000 |
| 32 | #define NAND_MAX_BYTE_NUM (hand.nand_pn * hand.nand_ps) |
| 33 | #define MAX_DEV_NUM 16 |
| 34 | |
| 35 | enum CPUTYPE { |
| 36 | JZ4740, |
| 37 | JZ4750 |
| 38 | }; |
| 39 | |
| 40 | enum USB_Boot_State { |
| 41 | DISCONNECT, |
| 42 | CONNECT, |
| 43 | BOOT, |
| 44 | UNBOOT |
| 45 | }; |
| 46 | |
| 47 | enum OPTION { |
| 48 | OOB_ECC, |
| 49 | OOB_NO_ECC, |
| 50 | NO_OOB |
| 51 | }; |
| 52 | |
| 53 | enum NOR_OPS_TYPE { |
| 54 | NOR_INIT = 0, |
| 55 | NOR_QUERY, |
| 56 | NOR_WRITE, |
| 57 | NOR_ERASE_CHIP, |
| 58 | NOR_ERASE_SECTOR |
| 59 | }; |
| 60 | |
| 61 | enum NOR_FLASH_TYPE |
| 62 | { |
| 63 | NOR_AM29 = 0, |
| 64 | NOR_SST28, |
| 65 | NOR_SST39x16, |
| 66 | NOR_SST39x8 |
| 67 | }; |
| 68 | |
| 69 | enum NAND_OPS_TYPE { |
| 70 | NAND_QUERY = 0, |
| 71 | NAND_INIT, |
| 72 | NAND_MARK_BAD, |
| 73 | NAND_READ_OOB, |
| 74 | NAND_READ_RAW, |
| 75 | NAND_ERASE, |
| 76 | NAND_READ, |
| 77 | NAND_PROGRAM, |
| 78 | NAND_READ_TO_RAM |
| 79 | }; |
| 80 | |
| 81 | enum SDRAM_OPS_TYPE { |
| 82 | SDRAM_LOAD |
| 83 | }; |
| 84 | |
| 85 | enum DATA_STRUCTURE_OB { |
| 86 | DS_flash_info , |
| 87 | DS_hand |
| 88 | }; |
| 89 | |
| 90 | struct fw_args { |
| 91 | /* CPU ID */ |
| 92 | unsigned int cpu_id; |
| 93 | |
| 94 | /* PLL args */ |
| 95 | unsigned char ext_clk; |
| 96 | unsigned char cpu_speed; |
| 97 | unsigned char phm_div; |
| 98 | unsigned char use_uart; |
| 99 | unsigned int boudrate; |
| 100 | |
| 101 | /* SDRAM args */ |
| 102 | unsigned char bus_width; |
| 103 | unsigned char bank_num; |
| 104 | unsigned char row_addr; |
| 105 | unsigned char col_addr; |
| 106 | unsigned char is_mobile; |
| 107 | unsigned char is_busshare; |
| 108 | |
| 109 | /* debug args */ |
| 110 | char debug_ops; |
| 111 | unsigned char pin_num; |
| 112 | unsigned int start; |
| 113 | unsigned int size; |
| 114 | } __attribute__((packed)); |
| 115 | |
| 116 | struct hand { |
| 117 | /* nand flash info */ |
| 118 | int pt; /* cpu type */ |
| 119 | unsigned int nand_bw; /* bus width */ |
| 120 | unsigned int nand_rc; /* row cycle */ |
| 121 | unsigned int nand_ps; /* page size */ |
| 122 | unsigned int nand_ppb; /* page number per block */ |
| 123 | unsigned int nand_force_erase; |
| 124 | unsigned int nand_pn; /* page number in total */ |
| 125 | unsigned int nand_os; /* oob size */ |
| 126 | unsigned int nand_eccpos; |
| 127 | unsigned int nand_bbpage; |
| 128 | unsigned int nand_bbpos; |
| 129 | unsigned int nand_plane; |
| 130 | unsigned int nand_bchbit; |
| 131 | unsigned int nand_wppin; |
| 132 | unsigned int nand_bpc; /* block number per chip */ |
| 133 | |
| 134 | struct fw_args fw_args; |
| 135 | } __attribute__((packed)); |
| 136 | |
| 137 | struct nand_in { |
| 138 | unsigned char dev; |
| 139 | unsigned char max_chip; |
| 140 | unsigned char *buf; |
| 141 | unsigned char *cs_map; |
| 142 | unsigned int start; |
| 143 | unsigned int length; |
| 144 | unsigned int option; |
| 145 | |
| 146 | int (* check) (unsigned char *,unsigned char *,unsigned int); |
| 147 | }; |
| 148 | |
| 149 | struct nand_out { |
| 150 | unsigned char *status; |
| 151 | }; |
| 152 | |
| 153 | struct sdram_in { |
| 154 | unsigned char dev; |
| 155 | unsigned char *buf; |
| 156 | unsigned int start; |
| 157 | unsigned int length; |
| 158 | unsigned int option; |
| 159 | }; |
| 160 | |
| 161 | #endif /* __USB_BOOT_DEFINES_H__ */ |
| 162 | |
| 163 | |