b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 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/kernel.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/string.h> |
| 16 | |
| 17 | #include <asm/addrspace.h> |
| 18 | #include <asm/fw/myloader/myloader.h> |
| 19 | |
| 20 | #define SYS_PARAMS_ADDR KSEG1ADDR(0x80000800) |
| 21 | #define BOARD_PARAMS_ADDR KSEG1ADDR(0x80000A00) |
| 22 | #define PART_TABLE_ADDR KSEG1ADDR(0x80000C00) |
| 23 | #define BOOT_PARAMS_ADDR KSEG1ADDR(0x80000E00) |
| 24 | |
| 25 | static struct myloader_info myloader_info __initdata; |
| 26 | static int myloader_found __initdata; |
| 27 | |
| 28 | struct myloader_info * __init myloader_get_info(void) |
| 29 | { |
| 30 | struct mylo_system_params *sysp; |
| 31 | struct mylo_board_params *boardp; |
| 32 | struct mylo_partition_table *parts; |
| 33 | |
| 34 | if (myloader_found) |
| 35 | return &myloader_info; |
| 36 | |
| 37 | sysp = (struct mylo_system_params *)(SYS_PARAMS_ADDR); |
| 38 | boardp = (struct mylo_board_params *)(BOARD_PARAMS_ADDR); |
| 39 | parts = (struct mylo_partition_table *)(PART_TABLE_ADDR); |
| 40 | |
| 41 | printk(KERN_DEBUG "MyLoader: sysp=%08x, boardp=%08x, parts=%08x\n", |
| 42 | sysp->magic, boardp->magic, parts->magic); |
| 43 | |
| 44 | /* Check for some magic numbers */ |
| 45 | if (sysp->magic != MYLO_MAGIC_SYS_PARAMS || |
| 46 | boardp->magic != MYLO_MAGIC_BOARD_PARAMS || |
| 47 | le32_to_cpu(parts->magic) != MYLO_MAGIC_PARTITIONS) |
| 48 | return NULL; |
| 49 | |
| 50 | printk(KERN_DEBUG "MyLoader: id=%04x:%04x, sub_id=%04x:%04x\n", |
| 51 | sysp->vid, sysp->did, sysp->svid, sysp->sdid); |
| 52 | |
| 53 | myloader_info.vid = sysp->vid; |
| 54 | myloader_info.did = sysp->did; |
| 55 | myloader_info.svid = sysp->svid; |
| 56 | myloader_info.sdid = sysp->sdid; |
| 57 | |
| 58 | memcpy(myloader_info.macs, boardp->addr, sizeof(myloader_info.macs)); |
| 59 | |
| 60 | myloader_found = 1; |
| 61 | |
| 62 | return &myloader_info; |
| 63 | } |