ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * (C) Copyright 2007-2013
 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
 * Jerry Wang <wangflord@allwinnertech.com>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
 
#ifndef  __spare_head_h__
#define  __spare_head_h__
 
/* work mode */
#define WORK_MODE_PRODUCT      (1<<4)
#define WORK_MODE_UPDATE       (1<<5)
 
#define WORK_MODE_BOOT            0x00    //正常启动
#define WORK_MODE_USB_PRODUCT    0x10    //用于USB量产
#define WORK_MODE_CARD_PRODUCT    0x11    //用于卡量产
#define WORK_MODE_USB_DEBUG        0x12    //利用usb量产协议完成的测试
#define WORK_MODE_SPRITE_RECOVERY 0x13    //一键恢复
#define WORK_MODE_USB_UPDATE    0x20    //用于USB升级
#define WORK_MODE_OUTER_UPDATE    0x21    //用于外部盘升级
 
#define WORK_MODE_USB_TOOL_PRODUCT    0x04    //用于量产
#define WORK_MODE_USB_TOOL_UPDATE    0x08    //用于升级
#define WORK_MODE_ERASE_KEY            0x20    //用于擦除key
 
#define UBOOT_MAGIC                "uboot"
#define STAMP_VALUE             0x5F0A6C39
#define ALIGN_SIZE                16 * 1024
#define MAGIC_SIZE              8
#define STORAGE_BUFFER_SIZE     (256)
 
#define SUNXI_UPDATE_NEXT_ACTION_NORMAL            (1)
#define SUNXI_UPDATE_NEXT_ACTION_REBOOT            (2)
#define SUNXI_UPDATE_NEXT_ACTION_SHUTDOWN        (3)
#define SUNXI_UPDATE_NEXT_ACTION_REUPDATE        (4)
#define SUNXI_UPDATE_NEXT_ACTION_BOOT            (5)
#define SUNXI_UPDATA_NEXT_ACTION_SPRITE_TEST    (6)
 
#define SUNXI_VBUS_UNKNOWN                      (0)
#define SUNXI_VBUS_EXIST                        (1)
#define SUNXI_VBUS_NOT_EXIST                    (2)
 
#define BOOT0_SDMMC_START_ADDR                  (16)
#define BOOT0_SDMMC_BACKUP_START_ADDR           (256)
 
#define BOOT0_EMMC3_START_ADDR                  (384)
#define BOOT0_EMMC3_BACKUP_START_ADDR           (512)
 
 
#define UBOOT_START_SECTOR_IN_SDMMC             (32800)
 
#define SUNXI_NORMAL_MODE                            0
#define SUNXI_SECURE_MODE_WITH_SECUREOS              1
#define SUNXI_SECURE_MODE_NO_SECUREOS                2
 
typedef enum _SUNXI_BOOT_FILE_MODE
{
   SUNXI_BOOT_FILE_NORMAL =0,
   SUNXI_BOOT_FILE_TOC = 1,
   SUNXI_BOOT_FILE_RES0 = 2,
   SUNXI_BOOT_FILE_RES1 = 3,
   SUNXI_BOOT_FILE_PKG = 4
}SUNXI_BOOT_FILE_MODE;
 
 
 
#define   BOOT_FROM_SD0     0
#define   BOOT_FROM_SD2     2
#define   BOOT_FROM_NFC     1
#define   BOOT_FROM_SPI     3
 
//#define    TOC_MAIN_INFO_STATUS_ENCRYP_NOT_USED    0x00
//#define    TOC_MAIN_INFO_STATUS_ENCRYP_SSK            0x01
//#define    TOC_MAIN_INFO_STATUS_ENCRYP_BSSK        0x02
#define SUNXI_SECURE_MODE_USE_SEC_MONITOR             1
 
#define    TOC_ITEM_ENTRY_STATUS_ENCRYP_NOT_USED    0x00
#define    TOC_ITEM_ENTRY_STATUS_ENCRYP_USED        0x01
 
#define    TOC_ITEM_ENTRY_TYPE_NULL                0x00
#define    TOC_ITEM_ENTRY_TYPE_KEY_CERTIF            0x01
#define    TOC_ITEM_ENTRY_TYPE_BIN_CERTIF            0x02
#define    TOC_ITEM_ENTRY_TYPE_BIN                 0x03
 
typedef struct _normal_gpio_cfg
{
    char      port;                       //端口号
    char      port_num;                   //端口内编号
    char      mul_sel;                    //功能编号
    char      pull;                       //电阻状态
    char      drv_level;                  //驱动驱动能力
    char      data;                       //输出电平
    char      reserved[2];                //保留位,保证对齐
}
normal_gpio_cfg;
 
typedef struct _special_gpio_cfg
{
   unsigned char        port;                //端口号
   unsigned char        port_num;            //端口内编号
   char                mul_sel;            //功能编号
   char                data;                //输出电平
}special_gpio_cfg;
//SD卡相关数据结构
typedef struct sdcard_spare_info_t
{
   int             card_no[4];                   //当前启动的卡控制器编号
   int             speed_mode[4];                //卡的速度模式,0:低速,其它:高速
   int                line_sel[4];                  //卡的线制,0: 1线,其它,4线
   int                line_count[4];                //卡使用线的个数
}
sdcard_spare_info;
 
typedef enum
{
   STORAGE_NAND =0,
   STORAGE_SD,
   STORAGE_EMMC,
   STORAGE_NOR,
        STORAGE_EMMC3
}SUNXI_BOOT_STORAGE;
 
#endif