020-mips_multi_machine_support.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. --- /dev/null
  2. +++ b/include/asm-mips/mips_machine.h
  3. @@ -0,0 +1,47 @@
  4. +/*
  5. + * Copyright (C) 2008 Gabor Juhos <[email protected]>
  6. + *
  7. + * This program is free software; you can redistribute it and/or modify it
  8. + * under the terms of the GNU General Public License version 2 as published
  9. + * by the Free Software Foundation.
  10. + *
  11. + */
  12. +
  13. +#ifndef __ASM_MIPS_MACHINE_H
  14. +#define __ASM_MIPS_MACHINE_H
  15. +
  16. +#include <linux/init.h>
  17. +#include <linux/list.h>
  18. +
  19. +#define MIPS_MACHINE_NAME_LEN 64
  20. +
  21. +struct mips_machine {
  22. + unsigned long mach_type;
  23. + void (*mach_setup)(void);
  24. + unsigned char mach_name[MIPS_MACHINE_NAME_LEN];
  25. + struct list_head list;
  26. +};
  27. +
  28. +void mips_machine_register(struct mips_machine *) __init;
  29. +void mips_machine_setup(unsigned long machtype) __init;
  30. +
  31. +extern unsigned char mips_machine_name[MIPS_MACHINE_NAME_LEN];
  32. +
  33. +#define MIPS_MACHINE(_type, _name, _setup) \
  34. +static struct mips_machine machine_##_type __initdata = \
  35. +{ \
  36. + .mach_type = _type, \
  37. + .mach_name = _name, \
  38. + .mach_setup = _setup, \
  39. +}; \
  40. + \
  41. +static int __init register_machine_##_type(void) \
  42. +{ \
  43. + mips_machine_register(&machine_##_type); \
  44. + return 0; \
  45. +} \
  46. + \
  47. +pure_initcall(register_machine_##_type)
  48. +
  49. +#endif /* __ASM_MIPS_MACHINE_H */
  50. +
  51. --- /dev/null
  52. +++ b/arch/mips/kernel/mips_machine.c
  53. @@ -0,0 +1,58 @@
  54. +/*
  55. + * Copyright (C) 2008 Gabor Juhos <[email protected]>
  56. + *
  57. + * This program is free software; you can redistribute it and/or modify it
  58. + * under the terms of the GNU General Public License version 2 as published
  59. + * by the Free Software Foundation.
  60. + *
  61. + */
  62. +
  63. +#include <asm/mips_machine.h>
  64. +#include <asm/bootinfo.h>
  65. +
  66. +static struct list_head mips_machines __initdata =
  67. + LIST_HEAD_INIT(mips_machines);
  68. +
  69. +unsigned char mips_machine_name[MIPS_MACHINE_NAME_LEN] = "Unknown";
  70. +
  71. +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
  72. +{
  73. + struct list_head *this;
  74. +
  75. + list_for_each(this, &mips_machines) {
  76. + struct mips_machine *mach;
  77. +
  78. + mach = list_entry(this, struct mips_machine, list);
  79. + if (mach->mach_type == machtype)
  80. + return mach;
  81. + }
  82. +
  83. + return NULL;
  84. +}
  85. +
  86. +void __init mips_machine_register(struct mips_machine *mach)
  87. +{
  88. + list_add_tail(&mach->list, &mips_machines);
  89. +}
  90. +
  91. +void __init mips_machine_setup(unsigned long machtype)
  92. +{
  93. + struct mips_machine *mach;
  94. +
  95. + mach = mips_machine_find(machtype);
  96. + if (!mach) {
  97. + printk(KERN_ALERT "MIPS: no machine registered for "
  98. + "machtype %lu\n", machtype);
  99. + return;
  100. + }
  101. +
  102. + if (mach->mach_name[0])
  103. + strncpy(mips_machine_name, mach->mach_name,
  104. + MIPS_MACHINE_NAME_LEN);
  105. +
  106. + printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
  107. +
  108. + if (mach->mach_setup)
  109. + mach->mach_setup();
  110. +}
  111. +
  112. --- a/arch/mips/kernel/Makefile
  113. +++ b/arch/mips/kernel/Makefile
  114. @@ -86,6 +86,7 @@ obj-$(CONFIG_GPIO_TXX9) += gpio_txx9.o
  115. obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
  116. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  117. +obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
  118. CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
  119. --- a/arch/mips/Kconfig
  120. +++ b/arch/mips/Kconfig
  121. @@ -858,6 +858,9 @@ config MIPS_DISABLE_OBSOLETE_IDE
  122. config SYNC_R4K
  123. bool
  124. +config MIPS_MACHINE
  125. + def_bool n
  126. +
  127. config NO_IOPORT
  128. def_bool n