1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/stage1.c Fri May 22 18:37:44 2015 +0200
1.3 @@ -0,0 +1,66 @@
1.4 +/*
1.5 + * Ben NanoNote stage 1 payload test.
1.6 + *
1.7 + * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) Wolfgang Spraul <wolfgang@sharism.cc>
1.9 + *
1.10 + * This program is free software; you can redistribute it and/or modify it under
1.11 + * the terms of the GNU General Public License as published by the Free Software
1.12 + * Foundation; either version 3 of the License, or (at your option) any later
1.13 + * version.
1.14 + *
1.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 + * details.
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License along with
1.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 + */
1.23 +
1.24 +#include "jz4740.h"
1.25 +#include "board-nanonote.h"
1.26 +
1.27 +struct fw_args *fw_args;
1.28 +volatile u32 CPU_ID;
1.29 +volatile u32 UART_BASE;
1.30 +volatile u32 CONFIG_BAUDRATE;
1.31 +volatile u8 SDRAM_BW16;
1.32 +volatile u8 SDRAM_BANK4;
1.33 +volatile u8 SDRAM_ROW;
1.34 +volatile u8 SDRAM_COL;
1.35 +volatile u8 CONFIG_MOBILE_SDRAM;
1.36 +volatile u32 CFG_CPU_SPEED;
1.37 +volatile u32 CFG_EXTAL;
1.38 +volatile u8 PHM_DIV;
1.39 +volatile u8 IS_SHARE;
1.40 +
1.41 +void load_args(void)
1.42 +{
1.43 + fw_args = (struct fw_args *)0x80002008; /* get the fw args from memory */
1.44 + CPU_ID = fw_args->cpu_id ;
1.45 + CFG_EXTAL = (u32)fw_args->ext_clk * 1000000;
1.46 + CFG_CPU_SPEED = (u32)fw_args->cpu_speed * CFG_EXTAL ;
1.47 + if (CFG_EXTAL == 19000000) {
1.48 + CFG_EXTAL = 19200000;
1.49 + CFG_CPU_SPEED = 192000000;
1.50 + }
1.51 + PHM_DIV = fw_args->phm_div;
1.52 + UART_BASE = UART0_BASE + fw_args->use_uart * 0x1000;
1.53 + CONFIG_BAUDRATE = fw_args->boudrate;
1.54 + SDRAM_BW16 = fw_args->bus_width;
1.55 + SDRAM_BANK4 = fw_args->bank_num;
1.56 + SDRAM_ROW = fw_args->row_addr;
1.57 + SDRAM_COL = fw_args->col_addr;
1.58 + CONFIG_MOBILE_SDRAM = fw_args->is_mobile;
1.59 + IS_SHARE = fw_args->is_busshare;
1.60 +}
1.61 +
1.62 +void c_main(void)
1.63 +{
1.64 + load_args();
1.65 + gpio_init();
1.66 + pll_init();
1.67 + sdram_init();
1.68 + nand_init();
1.69 +}