summaryrefslogtreecommitdiff
path: root/polux/linux-2.6.10/arch/arm/mach-mse500/nvram.c
blob: 315b2e8928a1e30b8074514d1761c5a4020c3f47 (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
/*
 * arch/arm/mach-mse500/nvram.c
 *
 * (C) Copyright 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 <linux/module.h>
#include <linux/vmalloc.h>
#include <linux/proc_fs.h>
#include <asm/arch/nvram.h>
#include <asm/arch/hardware.h>

/* Global NVRAM structure. */
spidcom_nvram_t spidcom_nvram;
EXPORT_SYMBOL(spidcom_nvram);

int proc_r_nvram (char *buf, char **start, off_t offset, int count, int *eof, void *data)
{
    char *p;

    p = buf;
    if(!NVRAM_IS_VALID(&spidcom_nvram))
    {
        p += sprintf(p, "Invalid NVRAM\n");
    }
    else
    {
        p += sprintf(p, "Serial Number: %s\n", spidcom_nvram.serialNumber);
        p += sprintf(p, "System description: %s\n", spidcom_nvram.sysDescr);
        p += sprintf(p, "ETH mac address: %02x:%02x:%02x:%02x:%02x:%02x\n",
                spidcom_nvram.ethPhysAddress[0], spidcom_nvram.ethPhysAddress[1],
                spidcom_nvram.ethPhysAddress[2], spidcom_nvram.ethPhysAddress[3],
                spidcom_nvram.ethPhysAddress[4], spidcom_nvram.ethPhysAddress[5]);
        p += sprintf(p, "PLC mac address: %02x:%02x:%02x:%02x:%02x:%02x\n",
                spidcom_nvram.plcPhysAddress[0], spidcom_nvram.plcPhysAddress[1],
                spidcom_nvram.plcPhysAddress[2], spidcom_nvram.plcPhysAddress[3],
                spidcom_nvram.plcPhysAddress[4], spidcom_nvram.plcPhysAddress[5]);
        p += sprintf(p, "Board description: %s\n", spidcom_nvram.boardDesc);
        p += sprintf(p, "Vendor info: %s\n", spidcom_nvram.vendorInfo);
        p += sprintf(p, "Image 0 offset: %08x\n", spidcom_nvram.imageOffset0);
        p += sprintf(p, "Eth port nb: %d\n", spidcom_nvram.ethPortNum);
        p += sprintf(p, "Manufactory info: %s\n", spidcom_nvram.manufactoryInfo);
    }
    *eof = 1;
    return p - buf + 1;
}

/**
 * Function:     mse500_init_nvram
 * Parameters:   nvram_offset: physical offset from SPI base address.
 * Purpose:      Initialize MSE500 NVRAM
 * Return Value: void
 */
void mse500_init_nvram (unsigned int nvram_offset)
{
    /* Copy NVRAM into our global structure to avoid future access. */
    spidcom_nvram_copy (&spidcom_nvram, (void *)(SPI_BASE_DIR + nvram_offset),
                        sizeof (spidcom_nvram_t));

    /* Initialize NVRAM proc entry. */
    create_proc_read_entry ("nvram", 0, NULL, proc_r_nvram, NULL);
}