[adm5120] coding style fixes
[openwrt-10.03/.git] / target / linux / adm5120 / files / arch / mips / adm5120 / prom / myloader.c
1 /*
2  *  $Id$
3  *
4  *  Compex's MyLoader specific prom routines
5  *
6  *  Copyright (C) 2007 OpenWrt.org
7  *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
8  *
9  *  This program is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU General Public License
11  *  as published by the Free Software Foundation; either version 2
12  *  of the License, or (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the
21  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA  02110-1301, USA.
23  */
24
25 #include <linux/types.h>
26 #include <linux/autoconf.h>
27 #include <linux/kernel.h>
28 #include <linux/init.h>
29 #include <linux/string.h>
30
31 #include <asm/bootinfo.h>
32 #include <asm/addrspace.h>
33 #include <asm/byteorder.h>
34
35 #include <adm5120_defs.h>
36 #include <prom/myloader.h>
37 #include "prom_read.h"
38
39 #define SYS_PARAMS_ADDR         KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F000)
40 #define BOARD_PARAMS_ADDR       KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F800)
41 #define PART_TABLE_ADDR         KSEG1ADDR(ADM5120_SRAM0_BASE+0x10000)
42
43 static int myloader_found;
44
45 struct myloader_info myloader_info;
46
47 int __init myloader_present(void)
48 {
49         struct mylo_system_params *sysp;
50         struct mylo_board_params *boardp;
51         struct mylo_partition_table *parts;
52
53         if (myloader_found)
54                 goto out;
55
56         sysp = (struct mylo_system_params *)(SYS_PARAMS_ADDR);
57         boardp = (struct mylo_board_params *)(BOARD_PARAMS_ADDR);
58         parts = (struct mylo_partition_table *)(PART_TABLE_ADDR);
59
60         /* Check for some magic numbers */
61         if ((le32_to_cpu(sysp->magic) != MYLO_MAGIC_SYS_PARAMS) ||
62            (le32_to_cpu(boardp->magic) != MYLO_MAGIC_BOARD_PARAMS) ||
63            (le32_to_cpu(parts->magic) != MYLO_MAGIC_PARTITIONS))
64                 goto out;
65
66         myloader_info.vid = le32_to_cpu(sysp->vid);
67         myloader_info.did = le32_to_cpu(sysp->did);
68         myloader_info.svid = le32_to_cpu(sysp->svid);
69         myloader_info.sdid = le32_to_cpu(sysp->sdid);
70
71         myloader_found = 1;
72
73 out:
74         return myloader_found;
75 }