367-MIPS-BCM63XX-add-support-for-loading-DTB.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From db896341299cbcb703821228574ba9b79b6a3565 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Tue, 24 Jun 2014 10:57:51 +0200
  4. Subject: [PATCH 45/48] MIPS: BCM63XX: add support for loading DTB
  5. ---
  6. arch/mips/bcm63xx/boards/Kconfig | 4 ++++
  7. arch/mips/bcm63xx/boards/board_common.c | 34 +++++++++++++++++++++++++++++++++
  8. 2 files changed, 38 insertions(+)
  9. --- a/arch/mips/bcm63xx/boards/Kconfig
  10. +++ b/arch/mips/bcm63xx/boards/Kconfig
  11. @@ -1,6 +1,10 @@
  12. menu "Board support"
  13. depends on BCM63XX
  14. +config BOARD_BCM63XX_DT
  15. + bool "Device Tree boards (experimential)"
  16. + select USE_OF
  17. +
  18. config BOARD_BCM963XX
  19. bool "Generic Broadcom 963xx boards"
  20. select SSB
  21. --- a/arch/mips/bcm63xx/boards/board_common.c
  22. +++ b/arch/mips/bcm63xx/boards/board_common.c
  23. @@ -10,6 +10,8 @@
  24. #include <linux/init.h>
  25. #include <linux/kernel.h>
  26. #include <linux/string.h>
  27. +#include <linux/of_fdt.h>
  28. +#include <linux/of_platform.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/ssb/ssb.h>
  31. #include <linux/gpio_keys.h>
  32. @@ -17,6 +19,7 @@
  33. #include <asm/addrspace.h>
  34. #include <asm/bootinfo.h>
  35. #include <asm/fw/cfe/cfe_api.h>
  36. +#include <asm/prom.h>
  37. #include <bcm63xx_board.h>
  38. #include <bcm63xx_cpu.h>
  39. #include <bcm63xx_dev_uart.h>
  40. @@ -129,8 +132,23 @@ void __init board_setup(void)
  41. /* make sure we're running on expected cpu */
  42. if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
  43. panic("unexpected CPU for bcm963xx board");
  44. +
  45. +#if CONFIG_OF
  46. + if (initial_boot_params)
  47. + __dt_setup_arch(initial_boot_params);
  48. +#endif
  49. }
  50. +#if CONFIG_OF
  51. +void __init device_tree_init(void)
  52. +{
  53. + if (!initial_boot_params)
  54. + return;
  55. +
  56. + unflatten_and_copy_device_tree();
  57. +}
  58. +#endif
  59. +
  60. static struct gpio_led_platform_data bcm63xx_led_data;
  61. static struct platform_device bcm63xx_gpio_leds = {
  62. @@ -149,6 +167,13 @@ static struct platform_device bcm63xx_gp
  63. .dev.platform_data = &bcm63xx_gpio_keys_data,
  64. };
  65. +#if CONFIG_OF
  66. +static struct of_device_id of_ids[] = {
  67. + { /* filled at runtime */ },
  68. + { .compatible = "simple-bus" },
  69. + { },
  70. +};
  71. +#endif
  72. /*
  73. * third stage init callback, register all board devices.
  74. */
  75. @@ -158,6 +183,15 @@ int __init board_register_devices(void)
  76. int led_count = 0;
  77. int usbh_ports = 0;
  78. +#if CONFIG_OF
  79. + if (of_have_populated_dt()) {
  80. + snprintf(of_ids[0].compatible, sizeof(of_ids[0].compatible),
  81. + "brcm,bcm%x", bcm63xx_get_cpu_id());
  82. +
  83. + of_platform_populate(NULL, of_ids, NULL, NULL);
  84. + }
  85. +#endif
  86. +
  87. if (board.has_uart0)
  88. bcm63xx_uart_register(0);