/* * cpu/spc300/eth_init.S * * Copyright (C) 2009 SPiDCOM Technologies * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include #include #define LAST_SECTOR 128 #define NVRAM_MAGIC_WORD "NVRAM\000\000\000" #define NVRAM_DEFAULT_WORD "NONVRAMFOUND\000\000\000\000" .file "nvram.S" .text .arm @ This is ARM code; performs the same action as .code 32 .align 2 @ Align to word boundary; "2" means the number of bits that must be zero .globl detect_nvram .type detect_nvram, %function /* ************************************************************************* * * NVRAM detection * ************************************************************************* */ detect_nvram: adr r10, nvram_dft /* if nvram is not found, we will have this value in r10 */ ldr r1, =-1 /* init value for loop counter */ ldr r4, =PHYS_FLASH_SPI_1 /* Offset of the SPI Direct access address */ .Lsect: add r1, r1, #1 cmp r1, #LAST_SECTOR bge .Lreturn /* we did not found it */ mov r0, r1, lsl #16 /* r0= r1<<16 = r1*0x10000 */ add r0, r0, r4 /* Add SPI Direct base address */ ldr r2, [r0, #0] /* load r2 with the first 4 bytes from the sector beginning */ adr r3, nvram_magic /* r3 = nvram_magic (previously defined : char *nvram_magic = "NVRAM\0\0\0";) */ ldr r3, [r3, #0] /* r3 <- first 4 bytes of magic word */ cmp r2, r3 bne .Lsect /* nvram not found in this sector */ ldr r2, [r0, #4] /* load r2 with the last 4 bytes from the sector beginning */ adr r3, nvram_magic ldr r3, [r3, #4] /* r3 <- last 4 bytes of magic word */ cmp r2, r3 bne .Lsect /* nvram not found in this sector */ .Lfound: /* * NVRAM found on begining of the sector, addr kept in r0. * move it to r10 and go back to caller */ mov r10, r0 .Lreturn: mov pc, lr /* back to my caller */ /* ************************************************************************* * * NVRAM default values * ************************************************************************* */ nvram_magic: nvram_dft: .ascii NVRAM_MAGIC_WORD /* magic word */ .word 0x0000020c /* pkg_cfg */ .word 0x00000000 /* gpio_0_7_cfg */ .word 0x00000000 /* gpio_8_15_cfg */ .word 0xffffffff /* gpio_allow_dir*/ .word 0x001c3168 /* sdram_config */ .word 0x022a569a /* sdram_timing0 */ .word 0x00070008 /* sdram_timing1 */ .word 0x00000927 /* sdram_refresh */ .word 0x00000007 /* flash_org */ .word 0x00140000 /* img_0_offset */ .word 0x00000001 /* nb_images */ .ascii NVRAM_DEFAULT_WORD /* product_name */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* product_partnb*/ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* product_desc */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* serial_number */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .word 0x00000000 /* eth_phy_addr */ .word 0x22334455 /* eth_address */ .word 0x00000011 /* */ .word 0x000000aa /* plc_address */ .word 0xbbccddee /* */ .ascii NVRAM_DEFAULT_WORD /* device_passwd */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* oem_info */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */ .ascii NVRAM_DEFAULT_WORD /* */