add 2.6.26 specific files
[librecmc/librecmc.git] / target / linux / adm5120 / files-2.6.26 / arch / mips / adm5120 / prom / myloader.c
1 /*
2  *  Compex's MyLoader specific prom routines
3  *
4  *  Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  *
10  */
11
12 #include <linux/types.h>
13 #include <linux/autoconf.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/string.h>
17
18 #include <asm/bootinfo.h>
19 #include <asm/addrspace.h>
20 #include <asm/byteorder.h>
21
22 #include <asm/mach-adm5120/adm5120_defs.h>
23 #include <prom/myloader.h>
24 #include "prom_read.h"
25
26 #define SYS_PARAMS_ADDR         KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F000)
27 #define BOARD_PARAMS_ADDR       KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F800)
28 #define PART_TABLE_ADDR         KSEG1ADDR(ADM5120_SRAM0_BASE+0x10000)
29
30 static int myloader_found;
31
32 struct myloader_info myloader_info;
33
34 int __init myloader_present(void)
35 {
36         struct mylo_system_params *sysp;
37         struct mylo_board_params *boardp;
38         struct mylo_partition_table *parts;
39
40         if (myloader_found)
41                 goto out;
42
43         sysp = (struct mylo_system_params *)(SYS_PARAMS_ADDR);
44         boardp = (struct mylo_board_params *)(BOARD_PARAMS_ADDR);
45         parts = (struct mylo_partition_table *)(PART_TABLE_ADDR);
46
47         /* Check for some magic numbers */
48         if ((le32_to_cpu(sysp->magic) != MYLO_MAGIC_SYS_PARAMS) ||
49            (le32_to_cpu(boardp->magic) != MYLO_MAGIC_BOARD_PARAMS) ||
50            (le32_to_cpu(parts->magic) != MYLO_MAGIC_PARTITIONS))
51                 goto out;
52
53         myloader_info.vid = le32_to_cpu(sysp->vid);
54         myloader_info.did = le32_to_cpu(sysp->did);
55         myloader_info.svid = le32_to_cpu(sysp->svid);
56         myloader_info.sdid = le32_to_cpu(sysp->sdid);
57
58         myloader_found = 1;
59
60 out:
61         return myloader_found;
62 }