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 #include "nanonote.h" 25 26 /* These arguments are initialised by usbboot and are defined in... 27 /etc/xburst-tools/usbboot.cfg. */ 28 29 struct fw_args *fw_args; 30 volatile u32 CPU_ID; 31 volatile u32 UART_BASE; 32 volatile u32 CONFIG_BAUDRATE; 33 volatile u8 SDRAM_BW16; 34 volatile u8 SDRAM_BANK4; 35 volatile u8 SDRAM_ROW; 36 volatile u8 SDRAM_COL; 37 volatile u8 CONFIG_MOBILE_SDRAM; 38 volatile u32 CFG_CPU_SPEED; 39 volatile u32 CFG_EXTAL; 40 volatile u8 PHM_DIV; 41 volatile u8 IS_SHARE; 42 43 void load_args(void) 44 { 45 /* Get the fw args from memory. See head.S for the memory layout. */ 46 47 fw_args = (struct fw_args *)0x80002008; 48 CPU_ID = fw_args->cpu_id ; 49 CFG_EXTAL = (u32)fw_args->ext_clk * 1000000; 50 CFG_CPU_SPEED = (u32)fw_args->cpu_speed * CFG_EXTAL ; 51 if (CFG_EXTAL == 19000000) { 52 CFG_EXTAL = 19200000; 53 CFG_CPU_SPEED = 192000000; 54 } 55 PHM_DIV = fw_args->phm_div; 56 UART_BASE = UART0_BASE + fw_args->use_uart * 0x1000; 57 CONFIG_BAUDRATE = fw_args->boudrate; 58 SDRAM_BW16 = fw_args->bus_width; 59 SDRAM_BANK4 = fw_args->bank_num; 60 SDRAM_ROW = fw_args->row_addr; 61 SDRAM_COL = fw_args->col_addr; 62 CONFIG_MOBILE_SDRAM = fw_args->is_mobile; 63 IS_SHARE = fw_args->is_busshare; 64 } 65 66 void c_main(void) 67 { 68 load_args(); 69 gpio_init(); 70 pll_init(); 71 sdram_init(); 72 }