adm5120: include r21398 actual changes
[openwrt/svn-archive/archive.git] / target / linux / adm5120 / files-2.6.33 / 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 <generated/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 int i;
40
41 if (myloader_found)
42 goto out;
43
44 sysp = (struct mylo_system_params *)(SYS_PARAMS_ADDR);
45 boardp = (struct mylo_board_params *)(BOARD_PARAMS_ADDR);
46 parts = (struct mylo_partition_table *)(PART_TABLE_ADDR);
47
48 /* Check for some magic numbers */
49 if ((le32_to_cpu(sysp->magic) != MYLO_MAGIC_SYS_PARAMS) ||
50 (le32_to_cpu(boardp->magic) != MYLO_MAGIC_BOARD_PARAMS) ||
51 (le32_to_cpu(parts->magic) != MYLO_MAGIC_PARTITIONS))
52 goto out;
53
54 myloader_info.vid = le32_to_cpu(sysp->vid);
55 myloader_info.did = le32_to_cpu(sysp->did);
56 myloader_info.svid = le32_to_cpu(sysp->svid);
57 myloader_info.sdid = le32_to_cpu(sysp->sdid);
58
59 for (i = 0; i < MYLO_ETHADDR_COUNT; i++) {
60 int j;
61 for (j = 0; j < 6; j++)
62 myloader_info.macs[i][j] = boardp->addr[i].mac[j];
63 }
64
65 myloader_found = 1;
66
67 out:
68 return myloader_found;
69 }