0200-MIPS-read-the-mips_machine-name-from-OF-and-output-i.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. From 0184f7b64c68fe9606559e86bdd288de01c87a85 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Sun, 17 Mar 2013 10:30:48 +0100
  4. Subject: [PATCH 200/208] MIPS: read the mips_machine name from OF and output
  5. it in /proc/cpuinfo
  6. This allows the userland to be compatible to the devive probing of mips_machine.
  7. Signed-off-by: John Crispin <[email protected]>
  8. ---
  9. arch/mips/include/asm/prom.h | 3 +++
  10. arch/mips/kernel/proc.c | 6 +++++-
  11. arch/mips/kernel/prom.c | 24 ++++++++++++++++++++++++
  12. 3 files changed, 32 insertions(+), 1 deletion(-)
  13. --- a/arch/mips/include/asm/prom.h
  14. +++ b/arch/mips/include/asm/prom.h
  15. @@ -44,8 +44,11 @@ extern void __dt_setup_arch(struct boot_
  16. __dt_setup_arch(&__dtb_##sym##_begin); \
  17. })
  18. +extern char *of_mips_get_machine_name(void);
  19. +
  20. #else /* CONFIG_OF */
  21. static inline void device_tree_init(void) { }
  22. +static char *of_mips_get_machine_name(void) { return NULL; }
  23. #endif /* CONFIG_OF */
  24. #endif /* __ASM_PROM_H */
  25. --- a/arch/mips/kernel/proc.c
  26. +++ b/arch/mips/kernel/proc.c
  27. @@ -12,6 +12,7 @@
  28. #include <asm/cpu-features.h>
  29. #include <asm/mipsregs.h>
  30. #include <asm/processor.h>
  31. +#include <asm/prom.h>
  32. #include <asm/mips_machine.h>
  33. unsigned int vced_count, vcei_count;
  34. @@ -34,7 +35,10 @@ static int show_cpuinfo(struct seq_file
  35. */
  36. if (n == 0) {
  37. seq_printf(m, "system type\t\t: %s\n", get_system_type());
  38. - if (mips_get_machine_name())
  39. + if (of_mips_get_machine_name())
  40. + seq_printf(m, "machine\t\t\t: %s\n",
  41. + of_mips_get_machine_name());
  42. + else if (mips_get_machine_name())
  43. seq_printf(m, "machine\t\t\t: %s\n",
  44. mips_get_machine_name());
  45. }
  46. --- a/arch/mips/kernel/prom.c
  47. +++ b/arch/mips/kernel/prom.c
  48. @@ -23,6 +23,13 @@
  49. #include <asm/page.h>
  50. #include <asm/prom.h>
  51. +static char of_mips_machine_name[64] = "Unknown";
  52. +
  53. +char *of_mips_get_machine_name(void)
  54. +{
  55. + return of_mips_machine_name;
  56. +}
  57. +
  58. int __init early_init_dt_scan_memory_arch(unsigned long node,
  59. const char *uname, int depth,
  60. void *data)
  61. @@ -50,6 +57,20 @@ void __init early_init_dt_setup_initrd_a
  62. }
  63. #endif
  64. +int __init early_init_dt_scan_model(unsigned long node,
  65. + const char *uname, int depth,
  66. + void *data)
  67. +{
  68. + if (!depth) {
  69. + char *model = of_get_flat_dt_prop(node, "model", NULL);
  70. + if (model) {
  71. + snprintf(of_mips_machine_name, sizeof(of_mips_machine_name), model);
  72. + pr_info("MIPS: machine is %s\n", of_mips_machine_name);
  73. + }
  74. + }
  75. + return 0;
  76. +}
  77. +
  78. void __init early_init_devtree(void *params)
  79. {
  80. /* Setup flat device-tree pointer */
  81. @@ -65,6 +86,9 @@ void __init early_init_devtree(void *par
  82. /* Scan memory nodes */
  83. of_scan_flat_dt(early_init_dt_scan_root, NULL);
  84. of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
  85. +
  86. + /* try to load the mips machine name */
  87. + of_scan_flat_dt(early_init_dt_scan_model, NULL);
  88. }
  89. void __init __dt_setup_arch(struct boot_param_header *bph)