369-MIPS-BCM63XX-add-support-for-matching-the-board_info.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From b9bc4eb19007fd35b57a10c4dfd442dd518ee345 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <[email protected]>
  3. Date: Thu, 26 Jun 2014 12:51:00 +0200
  4. Subject: [PATCH 47/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 <[email protected]>
  9. ---
  10. arch/mips/bcm63xx/boards/board_bcm963xx.c | 4 ++--
  11. arch/mips/bcm63xx/boards/board_common.c | 13 +++++++++++++
  12. arch/mips/bcm63xx/boards/board_common.h | 3 +++
  13. 3 files changed, 18 insertions(+), 2 deletions(-)
  14. --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
  15. +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
  16. @@ -785,9 +785,9 @@ void __init board_bcm963xx_init(void)
  17. } else {
  18. board_name = bcm63xx_nvram_get_name();
  19. }
  20. - /* find board by name */
  21. + /* find board by name/compat */
  22. for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
  23. - if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
  24. + if (!board_is_compatible(bcm963xx_boards[i], board_name))
  25. continue;
  26. /* copy, board desc array is marked initdata */
  27. board_early_setup(bcm963xx_boards[i],
  28. --- a/arch/mips/bcm63xx/boards/board_common.c
  29. +++ b/arch/mips/bcm63xx/boards/board_common.c
  30. @@ -281,3 +281,16 @@ int __init board_register_devices(void)
  31. return 0;
  32. }
  33. +
  34. +int __init board_is_compatible(const struct board_info *board,
  35. + const char *board_name)
  36. +{
  37. +#ifdef CONFIG_OF
  38. + if (initial_boot_params) {
  39. + unsigned long dt_root = of_get_flat_dt_root();
  40. +
  41. + return of_flat_dt_is_compatible(dt_root, board->of_board_id);
  42. + }
  43. +#endif
  44. + return !strncmp(board_name, board->name, 16);
  45. +}
  46. --- a/arch/mips/bcm63xx/boards/board_common.h
  47. +++ b/arch/mips/bcm63xx/boards/board_common.h
  48. @@ -6,6 +6,9 @@
  49. void board_early_setup(const struct board_info *board,
  50. int (*get_mac_address)(u8 mac[ETH_ALEN]));
  51. +int board_is_compatible(const struct board_info *board,
  52. + const char *board_name);
  53. +
  54. #if defined(CONFIG_BOARD_BCM963XX)
  55. void board_bcm963xx_init(void);
  56. #else