/
a10-evb.c
166 lines (137 loc) · 4.27 KB
/
a10-evb.c
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* (C) Copyright 2007-2011
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
* Tom Cubie <tangliang@allwinnertech.com>
*
* Some board init for the Allwinner A10-evb board.
*
* 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
*/
#include <common.h>
#include <asm/io.h>
#include <fastboot.h>
#include <asm/arch/nand_fspart.h>
#include <asm/arch/nand_bsp.h>
#include <asm/arch/android_misc.h>
#include <asm/arch/gpio.h>
DECLARE_GLOBAL_DATA_PTR;
static sunxi_boot_type_t boot_type;
int save_boot_type(void) {
boot_type = boot_from();
printf("boot type: %d\n", boot_type);
return 0;
}
sunxi_boot_type_t get_boot_type(void) {
return boot_type;
}
void fastboot_partition_init(void)
{
fastboot_ptentry fb_part;
int index,part_total;
puts("--------fastboot partitions--------\n");
//TODO part_total = sunxi_nand_getpart_num();
printf("-total partitions:%d-\n", part_total);
printf("%-12s %-12s %-12s\n", "-name-", "-start-", "-size-");
for(index = 0; index < part_total && index < MBR_MAX_PART_COUNT; index++) {
//TODO sunxi_nand_getpart_name(index, &fb_part.name[0]);
//TODO fb_part.start = sunxi_nand_getpart_offset(index) * 512;
//TODO fb_part.length = sunxi_nand_getpart_size(index) * 512;
fb_part.flags = 0;
printf("%-12s: %-12x %-12x\n", fb_part.name, fb_part.start, fb_part.length);
fastboot_flash_add_ptn(&fb_part);
}
puts("-----------------------------------\n");
}
static struct bootloader_message misc_message;
int check_android_misc() {
loff_t misc_offset = 0, misc_size = 0;
size_t count = sizeof(misc_message);
//TODO sunxi_nand_getpart_info_byname("misc", &misc_offset, &misc_size);
if(!misc_offset || !misc_size) {
//TODO sunxi_nand_getpart_info_byname("MISC", &misc_offset, &misc_size);
if(!misc_offset || !misc_size) {
puts("no misc partition is found\n");
return 0;
}
}
//TODO sunxi_nand_read_opts(&nand_info[0], misc_offset, &count,
// (u_char *)&misc_message, 0);
#ifdef DEBUG
printf("misc.command : %s\n", misc_message.command);
printf("misc.status : %s\n", misc_message.status);
printf("misc.recovery : %s\n", misc_message.recovery);
#endif
if(!strcmp(misc_message.command, "boot-recovery")) {
/* there is a recovery command */
setenv("bootcmd", "run setargs boot_recovery");
puts("Recovery detected, will boot recovery\n");
/* android recovery will clean the misc */
}
if(!strcmp(misc_message.command, "boot-fastboot")) {
/* there is a fastboot command */
setenv("bootcmd", "run setargs boot_fastboot");
puts("Fastboot detected, will enter fastboot\n");
/* clean the misc partition ourself */
memset(&misc_message, 0, sizeof(misc_message));
//TODO sunxi_nand_write_opts(&nand_info[0], misc_offset, &count,
// (u_char *)&misc_message, 0);
}
return 0;
}
/* TODO add board specific code here */
int board_init(void)
{
gd->bd->bi_arch_number = 3495;
gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100);
save_boot_type();
return 0;
}
/* Partition init must be after NAND init, so we put the fastboot
* partition init here in the board late init.
*/
int board_late_init(void)
{
fastboot_partition_init();
check_android_misc();
return 0;
}
void dram_init_banksize(void)
{
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
}
int dram_init(void)
{
gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
return 0;
}
#ifdef CONFIG_GENERIC_MMC
int board_mmc_init(bd_t *bis)
{
sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
return 0;
}
#endif
#ifdef CONFIG_DISPLAY_BOARDINFO
int checkboard(void)
{
puts("Board: A10-EVB\n");
return 0;
}
#endif