| 1 | /* |
| 2 | * (C) Copyright 2007 OpenMoko, Inc. |
| 3 | * Author: xiangfu liu <xiangfu@openmoko.org> |
| 4 | * Andy Green <andy@openmoko.com> |
| 5 | * |
| 6 | * Configuation settings for the OPENMOKO Neo GTA02 Linux GSM phone |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (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, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* NOTE this stuff runs in steppingstone context! */ |
| 25 | |
| 26 | |
| 27 | #include <qi.h> |
| 28 | #include <neo_om_3d7k.h> |
| 29 | #include <neo_smdk6410.h> |
| 30 | |
| 31 | #define stringify2(s) stringify1(s) |
| 32 | #define stringify1(s) #s |
| 33 | |
| 34 | extern void bootloader_second_phase(void); |
| 35 | |
| 36 | const struct board_api *boards[] = { |
| 37 | &board_api_om_3d7k, |
| 38 | &board_api_smdk6410, |
| 39 | NULL /* always last */ |
| 40 | }; |
| 41 | |
| 42 | struct board_api const * this_board; |
| 43 | extern int is_jtag; |
| 44 | |
| 45 | #include <serial-s3c64xx.h> |
| 46 | |
| 47 | void start_qi(void) |
| 48 | { |
| 49 | int flag = 0; |
| 50 | int board = 0; |
| 51 | unsigned int sd_sectors = 0; |
| 52 | |
| 53 | /* |
| 54 | * well, we can be running on this CPU two different ways. |
| 55 | * |
| 56 | * 1) We were copied into steppingstone and TEXT_BASE already |
| 57 | * by JTAG. We don't have to do anything else. JTAG script |
| 58 | * then sets data at address 0x4 to 0xffffffff as a signal we |
| 59 | * are running by JTAG. |
| 60 | * |
| 61 | * 2) We only got our first 4K into steppingstone, we need to copy |
| 62 | * the rest of ourselves into TEXT_BASE. |
| 63 | * |
| 64 | * So we do the copy out of NAND only if we see we did not come up |
| 65 | * under control of JTAG. |
| 66 | */ |
| 67 | |
| 68 | |
| 69 | /* ask all the boards we support in turn if they recognize this |
| 70 | * hardware we are running on, accept the first positive answer |
| 71 | */ |
| 72 | |
| 73 | this_board = boards[board]; |
| 74 | while (!flag && this_board) |
| 75 | /* check if it is the right board... */ |
| 76 | if (this_board->is_this_board()) |
| 77 | flag = 1; |
| 78 | else |
| 79 | this_board = boards[board++]; |
| 80 | |
| 81 | /* okay, do the critical port and serial init for our board */ |
| 82 | |
| 83 | if (this_board->early_port_init) |
| 84 | this_board->early_port_init(); |
| 85 | |
| 86 | set_putc_func(this_board->putc); |
| 87 | |
| 88 | /* stick some hello messages on debug console */ |
| 89 | |
| 90 | puts("\n\n\nQi Bootloader "stringify2(QI_CPU)" " |
| 91 | stringify2(BUILD_HOST)" " |
| 92 | stringify2(BUILD_VERSION)" " |
| 93 | "\n"); |
| 94 | |
| 95 | puts(stringify2(BUILD_DATE) " Copyright (C) 2008 Openmoko, Inc.\n\n"); |
| 96 | |
| 97 | if (!is_jtag) { |
| 98 | /* |
| 99 | * We got the first 8KBytes of the bootloader pulled into the |
| 100 | * steppingstone SRAM for free. Now we pull the whole bootloader |
| 101 | * image into SDRAM. |
| 102 | * |
| 103 | * This code and the .S files are arranged by the linker script |
| 104 | * to expect to run from 0x0. But the linker script has told |
| 105 | * everything else to expect to run from 0x53000000+. That's |
| 106 | * why we are going to be able to copy this code and not have it |
| 107 | * crash when we run it from there. |
| 108 | */ |
| 109 | |
| 110 | /* We randomly pull 32KBytes of bootloader */ |
| 111 | |
| 112 | extern unsigned int s3c6410_mmc_init(int verbose); |
| 113 | unsigned long s3c6410_mmc_bread(int dev_num, |
| 114 | unsigned long start_blk, unsigned long blknum, |
| 115 | void *dst); |
| 116 | sd_sectors = s3c6410_mmc_init(1); |
| 117 | s3c6410_mmc_bread(0, sd_sectors - 1026 - 16 - (256 * 2), |
| 118 | 32 * 2, (u8 *)0x53000000); |
| 119 | } |
| 120 | |
| 121 | /* all of Qi is in memory now, stuff outside steppingstone too */ |
| 122 | |
| 123 | if (this_board->port_init) |
| 124 | this_board->port_init(); |
| 125 | |
| 126 | puts("\n Detected: "); |
| 127 | puts(this_board->name); |
| 128 | puts(", "); |
| 129 | puts((this_board->get_board_variant)()->name); |
| 130 | puts("\n"); |
| 131 | |
| 132 | /* |
| 133 | * jump to bootloader_second_phase() running from DRAM copy |
| 134 | */ |
| 135 | bootloader_second_phase(); |
| 136 | } |
| 137 | |