2 * Compex's MyLoader specific prom routines
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
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.
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>
18 #include <asm/bootinfo.h>
19 #include <asm/addrspace.h>
20 #include <asm/byteorder.h>
22 #include <asm/mach-adm5120/adm5120_defs.h>
23 #include <prom/myloader.h>
24 #include "prom_read.h"
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)
30 static int myloader_found
;
32 struct myloader_info myloader_info
;
34 int __init
myloader_present(void)
36 struct mylo_system_params
*sysp
;
37 struct mylo_board_params
*boardp
;
38 struct mylo_partition_table
*parts
;
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
);
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
))
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
);
59 for (i
= 0; i
< MYLO_ETHADDR_COUNT
; i
++) {
61 for (j
= 0; j
< 6; j
++)
62 myloader_info
.macs
[i
][j
] = boardp
->addr
[i
].mac
[j
];
68 return myloader_found
;