368-MIPS-BCM63XX-add-support-for-matching-the-board_info.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From 25bf2b5836c892f091651d8a3384c9c57ce1b400 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Thu, 26 Jun 2014 12:51:00 +0200
  4. Subject: [PATCH 46/48] MIPS: BCM63XX: add support for matching the board_info
  5. by dtb
  6. Allow using the passed dtb's compatible property to match board_info
  7. structs instead of nvram's boardname field, which is not unique anyway.
  8. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  9. ---
  10. arch/mips/bcm63xx/boards/board_bcm963xx.c | 15 +++++++++++++++
  11. arch/mips/bcm63xx/boards/board_common.c | 18 ++++++++++++++++++
  12. arch/mips/bcm63xx/boards/board_common.h | 3 +++
  13. 3 files changed, 36 insertions(+)
  14. --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
  15. +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
  16. @@ -715,6 +715,10 @@ static const struct board_info __initcon
  17. #endif
  18. };
  19. +static struct of_device_id const bcm963xx_boards_dt[] = {
  20. + { },
  21. +};
  22. +
  23. /*
  24. * early init callback, read nvram data from flash and checksum it
  25. */
  26. @@ -726,6 +730,7 @@ void __init board_bcm963xx_init(void)
  27. char *board_name = NULL;
  28. u32 val;
  29. struct bcm_hcs *hcs;
  30. + const struct of_device_id *board_match;
  31. /* read base address of boot chip select (0)
  32. * 6328/6362 do not have MPI but boot from a fixed address
  33. @@ -765,6 +770,16 @@ void __init board_bcm963xx_init(void)
  34. } else {
  35. board_name = bcm63xx_nvram_get_name();
  36. }
  37. +
  38. + /* find board by compat */
  39. + board_match = bcm63xx_match_board(bcm963xx_boards_dt);
  40. + if (board_match) {
  41. + board_early_setup(board_match->data,
  42. + bcm63xx_nvram_get_mac_address);
  43. +
  44. + return;
  45. + }
  46. +
  47. /* find board by name */
  48. for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
  49. if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
  50. --- a/arch/mips/bcm63xx/boards/board_common.c
  51. +++ b/arch/mips/bcm63xx/boards/board_common.c
  52. @@ -281,3 +281,21 @@ int __init board_register_devices(void)
  53. return 0;
  54. }
  55. +
  56. +const struct of_device_id * __init bcm63xx_match_board(const struct of_device_id *m)
  57. +{
  58. + const struct of_device_id *match;
  59. + unsigned long dt_root;
  60. +
  61. + if (!IS_ENABLED(CONFIG_OF) || !initial_boot_params)
  62. + return NULL;
  63. +
  64. + dt_root = of_get_flat_dt_root();
  65. +
  66. + for (match = m; match->compatible[0]; match++) {
  67. + if (of_flat_dt_is_compatible(dt_root, match->compatible))
  68. + return match;
  69. + }
  70. +
  71. + return NULL;
  72. +}
  73. --- a/arch/mips/bcm63xx/boards/board_common.h
  74. +++ b/arch/mips/bcm63xx/boards/board_common.h
  75. @@ -1,11 +1,14 @@
  76. #ifndef __BOARD_COMMON_H
  77. #define __BOARD_COMMON_H
  78. +#include <linux/of.h>
  79. #include <board_bcm963xx.h>
  80. void board_early_setup(const struct board_info *board,
  81. int (*get_mac_address)(u8 mac[ETH_ALEN]));
  82. +const struct of_device_id *bcm63xx_match_board(const struct of_device_id *);
  83. +
  84. #if defined(CONFIG_BOARD_BCM963XX)
  85. void board_bcm963xx_init(void);
  86. #else