| 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/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/string.h> |
| 16 | |
| 17 | #include <asm/bootinfo.h> |
| 18 | #include <asm/addrspace.h> |
| 19 | #include <asm/byteorder.h> |
| 20 | |
| 21 | #include <asm/mach-adm5120/adm5120_defs.h> |
| 22 | #include <prom/myloader.h> |
| 23 | #include "prom_read.h" |
| 24 | |
| 25 | #define SYS_PARAMS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F000) |
| 26 | #define BOARD_PARAMS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F800) |
| 27 | #define PART_TABLE_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x10000) |
| 28 | |
| 29 | static int myloader_found; |
| 30 | |
| 31 | struct myloader_info myloader_info; |
| 32 | |
| 33 | int __init myloader_present(void) |
| 34 | { |
| 35 | struct mylo_system_params *sysp; |
| 36 | struct mylo_board_params *boardp; |
| 37 | struct mylo_partition_table *parts; |
| 38 | int i; |
| 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 | for (i = 0; i < MYLO_ETHADDR_COUNT; i++) { |
| 59 | int j; |
| 60 | for (j = 0; j < 6; j++) |
| 61 | myloader_info.macs[i][j] = boardp->addr[i].mac[j]; |
| 62 | } |
| 63 | |
| 64 | myloader_found = 1; |
| 65 | |
| 66 | out: |
| 67 | return myloader_found; |
| 68 | } |
| 69 | |