1 /* 2 * Ben NanoNote stage 1 payload test. 3 * 4 * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> 5 * Copyright (C) Wolfgang Spraul <wolfgang@sharism.cc> 6 * 7 * This program is free software; you can redistribute it and/or modify it under 8 * the terms of the GNU General Public License as published by the Free Software 9 * Foundation; either version 3 of the License, or (at your option) any later 10 * version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 * details. 16 * 17 * You should have received a copy of the GNU General Public License along with 18 * this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #include "jz4740.h" 22 #include "board-nanonote.h" 23 24 struct fw_args *fw_args; 25 volatile u32 CPU_ID; 26 volatile u32 UART_BASE; 27 volatile u32 CONFIG_BAUDRATE; 28 volatile u8 SDRAM_BW16; 29 volatile u8 SDRAM_BANK4; 30 volatile u8 SDRAM_ROW; 31 volatile u8 SDRAM_COL; 32 volatile u8 CONFIG_MOBILE_SDRAM; 33 volatile u32 CFG_CPU_SPEED; 34 volatile u32 CFG_EXTAL; 35 volatile u8 PHM_DIV; 36 volatile u8 IS_SHARE; 37 38 void load_args(void) 39 { 40 fw_args = (struct fw_args *)0x80002008; /* get the fw args from memory */ 41 CPU_ID = fw_args->cpu_id ; 42 CFG_EXTAL = (u32)fw_args->ext_clk * 1000000; 43 CFG_CPU_SPEED = (u32)fw_args->cpu_speed * CFG_EXTAL ; 44 if (CFG_EXTAL == 19000000) { 45 CFG_EXTAL = 19200000; 46 CFG_CPU_SPEED = 192000000; 47 } 48 PHM_DIV = fw_args->phm_div; 49 UART_BASE = UART0_BASE + fw_args->use_uart * 0x1000; 50 CONFIG_BAUDRATE = fw_args->boudrate; 51 SDRAM_BW16 = fw_args->bus_width; 52 SDRAM_BANK4 = fw_args->bank_num; 53 SDRAM_ROW = fw_args->row_addr; 54 SDRAM_COL = fw_args->col_addr; 55 CONFIG_MOBILE_SDRAM = fw_args->is_mobile; 56 IS_SHARE = fw_args->is_busshare; 57 } 58 59 void c_main(void) 60 { 61 load_args(); 62 gpio_init(); 63 pll_init(); 64 sdram_init(); 65 nand_init(); 66 }