summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6/cpu/spc300-fcm3/nvram.S
blob: 999d29df8e8e9dc4ac00ba75f89835233055ebff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * 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 <config.h>
#include <asm/hardware.h>

#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      /*               */