mips_machine.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License version 2 as published
  6. * by the Free Software Foundation.
  7. *
  8. */
  9. #include <linux/mm.h>
  10. #include <linux/string.h>
  11. #include <linux/slab.h>
  12. #include <asm/mips_machine.h>
  13. #include <asm/prom.h>
  14. static struct mips_machine *mips_machine __initdata;
  15. #define for_each_machine(mach) \
  16. for ((mach) = (struct mips_machine *)&__mips_machines_start; \
  17. (mach) && \
  18. (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
  19. (mach)++)
  20. __init int mips_machtype_setup(char *id)
  21. {
  22. struct mips_machine *mach;
  23. for_each_machine(mach) {
  24. if (mach->mach_id == NULL)
  25. continue;
  26. if (strcmp(mach->mach_id, id) == 0) {
  27. mips_machtype = mach->mach_type;
  28. return 0;
  29. }
  30. }
  31. pr_err("MIPS: no machine found for id '%s', supported machines:\n", id);
  32. pr_err("%-24s %s\n", "id", "name");
  33. for_each_machine(mach)
  34. pr_err("%-24s %s\n", mach->mach_id, mach->mach_name);
  35. return 1;
  36. }
  37. __setup("machtype=", mips_machtype_setup);
  38. __init void mips_machine_setup(void)
  39. {
  40. struct mips_machine *mach;
  41. for_each_machine(mach) {
  42. if (mips_machtype == mach->mach_type) {
  43. mips_machine = mach;
  44. break;
  45. }
  46. }
  47. if (!mips_machine)
  48. return;
  49. mips_set_machine_name(mips_machine->mach_name);
  50. if (mips_machine->mach_setup)
  51. mips_machine->mach_setup();
  52. }