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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. From 26546e5499d98616322fb3472b977e2e86603f3a 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. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  6. ---
  7. arch/mips/bcm63xx/boards/Kconfig | 4 ++++
  8. arch/mips/bcm63xx/boards/board_common.c | 34 +++++++++++++++++++++++++++++++
  9. arch/mips/bcm63xx/prom.c | 6 ++++++
  10. 3 files changed, 44 insertions(+)
  11. --- a/arch/mips/bcm63xx/boards/Kconfig
  12. +++ b/arch/mips/bcm63xx/boards/Kconfig
  13. @@ -1,6 +1,10 @@
  14. menu "Board support"
  15. depends on BCM63XX
  16. +config BOARD_BCM63XX_DT
  17. + bool "Device Tree boards (experimential)"
  18. + select USE_OF
  19. +
  20. config BOARD_BCM963XX
  21. bool "Generic Broadcom 963xx boards"
  22. select SSB
  23. --- a/arch/mips/bcm63xx/boards/board_common.c
  24. +++ b/arch/mips/bcm63xx/boards/board_common.c
  25. @@ -10,12 +10,15 @@
  26. #include <linux/init.h>
  27. #include <linux/kernel.h>
  28. #include <linux/string.h>
  29. +#include <linux/of_fdt.h>
  30. +#include <linux/of_platform.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/ssb/ssb.h>
  33. #include <linux/spi/spi.h>
  34. #include <asm/addrspace.h>
  35. #include <asm/bootinfo.h>
  36. #include <asm/fw/cfe/cfe_api.h>
  37. +#include <asm/prom.h>
  38. #include <bcm63xx_board.h>
  39. #include <bcm63xx_cpu.h>
  40. #include <bcm63xx_dev_uart.h>
  41. @@ -126,8 +129,23 @@ void __init board_setup(void)
  42. /* make sure we're running on expected cpu */
  43. if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
  44. panic("unexpected CPU for bcm963xx board");
  45. +
  46. +#if CONFIG_OF
  47. + if (initial_boot_params)
  48. + __dt_setup_arch(initial_boot_params);
  49. +#endif
  50. }
  51. +#if CONFIG_OF
  52. +void __init device_tree_init(void)
  53. +{
  54. + if (!initial_boot_params)
  55. + return;
  56. +
  57. + unflatten_and_copy_device_tree();
  58. +}
  59. +#endif
  60. +
  61. static struct gpio_led_platform_data bcm63xx_led_data;
  62. static struct platform_device bcm63xx_gpio_leds = {
  63. @@ -136,6 +154,13 @@ static struct platform_device bcm63xx_gp
  64. .dev.platform_data = &bcm63xx_led_data,
  65. };
  66. +#if CONFIG_OF
  67. +static struct of_device_id of_ids[] = {
  68. + { /* filled at runtime */ },
  69. + { .compatible = "simple-bus" },
  70. + { },
  71. +};
  72. +#endif
  73. /*
  74. * third stage init callback, register all board devices.
  75. */
  76. @@ -143,6 +168,15 @@ int __init board_register_devices(void)
  77. {
  78. int usbh_ports = 0;
  79. +#if CONFIG_OF
  80. + if (of_have_populated_dt()) {
  81. + snprintf(of_ids[0].compatible, sizeof(of_ids[0].compatible),
  82. + "brcm,bcm%x", bcm63xx_get_cpu_id());
  83. +
  84. + of_platform_populate(NULL, of_ids, NULL, NULL);
  85. + }
  86. +#endif
  87. +
  88. if (board.has_uart0)
  89. bcm63xx_uart_register(0);
  90. --- a/arch/mips/bcm63xx/prom.c
  91. +++ b/arch/mips/bcm63xx/prom.c
  92. @@ -8,6 +8,7 @@
  93. #include <linux/init.h>
  94. #include <linux/bootmem.h>
  95. +#include <linux/of_fdt.h>
  96. #include <linux/smp.h>
  97. #include <asm/bootinfo.h>
  98. #include <asm/bmips.h>
  99. @@ -23,6 +24,11 @@ void __init prom_init(void)
  100. {
  101. u32 reg, mask;
  102. +#if CONFIG_OF
  103. + if (fw_arg0 == -2)
  104. + early_init_dt_verify((void *)fw_arg1);
  105. +#endif
  106. +
  107. bcm63xx_cpu_init();
  108. /* stop any running watchdog */