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 #include "usb_boot_defines.h" 24 25 struct fw_args *fw_args; 26 volatile u32 CPU_ID; 27 volatile u32 UART_BASE; 28 volatile u32 CONFIG_BAUDRATE; 29 volatile u8 SDRAM_BW16; 30 volatile u8 SDRAM_BANK4; 31 volatile u8 SDRAM_ROW; 32 volatile u8 SDRAM_COL; 33 volatile u8 CONFIG_MOBILE_SDRAM; 34 volatile u32 CFG_CPU_SPEED; 35 volatile u32 CFG_EXTAL; 36 volatile u8 PHM_DIV; 37 volatile u8 IS_SHARE; 38 39 void load_args(void) 40 { 41 fw_args = (struct fw_args *)0x80002008; /* get the fw args from memory */ 42 CPU_ID = fw_args->cpu_id ; 43 CFG_EXTAL = (u32)fw_args->ext_clk * 1000000; 44 CFG_CPU_SPEED = (u32)fw_args->cpu_speed * CFG_EXTAL ; 45 if (CFG_EXTAL == 19000000) { 46 CFG_EXTAL = 19200000; 47 CFG_CPU_SPEED = 192000000; 48 } 49 PHM_DIV = fw_args->phm_div; 50 UART_BASE = UART0_BASE + fw_args->use_uart * 0x1000; 51 CONFIG_BAUDRATE = fw_args->boudrate; 52 SDRAM_BW16 = fw_args->bus_width; 53 SDRAM_BANK4 = fw_args->bank_num; 54 SDRAM_ROW = fw_args->row_addr; 55 SDRAM_COL = fw_args->col_addr; 56 CONFIG_MOBILE_SDRAM = fw_args->is_mobile; 57 IS_SHARE = fw_args->is_busshare; 58 } 59 60 void c_main(void) 61 { 62 load_args(); 63 gpio_init(); 64 pll_init(); 65 sdram_init(); 66 }