myloader.c 1.8 KB

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