[adm5120] license cleanup
[openwrt/svn-archive/archive.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 modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 *
13 */
14
15 #include <linux/types.h>
16 #include <linux/autoconf.h>
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/string.h>
20
21 #include <asm/bootinfo.h>
22 #include <asm/addrspace.h>
23 #include <asm/byteorder.h>
24
25 #include <adm5120_defs.h>
26 #include <prom/myloader.h>
27 #include "prom_read.h"
28
29 #define SYS_PARAMS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F000)
30 #define BOARD_PARAMS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F800)
31 #define PART_TABLE_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x10000)
32
33 static int myloader_found;
34
35 struct myloader_info myloader_info;
36
37 int __init myloader_present(void)
38 {
39 struct mylo_system_params *sysp;
40 struct mylo_board_params *boardp;
41 struct mylo_partition_table *parts;
42
43 if (myloader_found)
44 goto out;
45
46 sysp = (struct mylo_system_params *)(SYS_PARAMS_ADDR);
47 boardp = (struct mylo_board_params *)(BOARD_PARAMS_ADDR);
48 parts = (struct mylo_partition_table *)(PART_TABLE_ADDR);
49
50 /* Check for some magic numbers */
51 if ((le32_to_cpu(sysp->magic) != MYLO_MAGIC_SYS_PARAMS) ||
52 (le32_to_cpu(boardp->magic) != MYLO_MAGIC_BOARD_PARAMS) ||
53 (le32_to_cpu(parts->magic) != MYLO_MAGIC_PARTITIONS))
54 goto out;
55
56 myloader_info.vid = le32_to_cpu(sysp->vid);
57 myloader_info.did = le32_to_cpu(sysp->did);
58 myloader_info.svid = le32_to_cpu(sysp->svid);
59 myloader_info.sdid = le32_to_cpu(sysp->sdid);
60
61 myloader_found = 1;
62
63 out:
64 return myloader_found;
65 }