0047-firmware-bcm2835-Support-ARCH_BCM270x.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From 3ab001bd58d4578bf2beb293f93a91f81e3ad3b4 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
  3. Date: Fri, 26 Jun 2015 14:25:01 +0200
  4. Subject: [PATCH 047/381] firmware: bcm2835: Support ARCH_BCM270x
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Support booting without Device Tree.
  9. Turn on USB power.
  10. Load driver early because of lacking support for deferred probing
  11. in many drivers.
  12. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
  13. ---
  14. drivers/firmware/raspberrypi.c | 41 +++++++++++++++++++++++++++++++++++++++--
  15. 1 file changed, 39 insertions(+), 2 deletions(-)
  16. --- a/drivers/firmware/raspberrypi.c
  17. +++ b/drivers/firmware/raspberrypi.c
  18. @@ -28,6 +28,8 @@ struct rpi_firmware {
  19. u32 enabled;
  20. };
  21. +static struct platform_device *g_pdev;
  22. +
  23. static DEFINE_MUTEX(transaction_lock);
  24. static void response_callback(struct mbox_client *cl, void *msg)
  25. @@ -183,6 +185,25 @@ rpi_firmware_print_firmware_revision(str
  26. }
  27. }
  28. +static int raspberrypi_firmware_set_power(struct rpi_firmware *fw,
  29. + u32 domain, bool on)
  30. +{
  31. + struct {
  32. + u32 domain;
  33. + u32 on;
  34. + } packet;
  35. + int ret;
  36. +
  37. + packet.domain = domain;
  38. + packet.on = on;
  39. + ret = rpi_firmware_property(fw, RPI_FIRMWARE_SET_POWER_STATE,
  40. + &packet, sizeof(packet));
  41. + if (!ret && packet.on != on)
  42. + ret = -EINVAL;
  43. +
  44. + return ret;
  45. +}
  46. +
  47. static int rpi_firmware_probe(struct platform_device *pdev)
  48. {
  49. struct device *dev = &pdev->dev;
  50. @@ -207,9 +228,13 @@ static int rpi_firmware_probe(struct pla
  51. init_completion(&fw->c);
  52. platform_set_drvdata(pdev, fw);
  53. + g_pdev = pdev;
  54. rpi_firmware_print_firmware_revision(fw);
  55. + if (raspberrypi_firmware_set_power(fw, 3, true))
  56. + dev_err(dev, "failed to turn on USB power\n");
  57. +
  58. return 0;
  59. }
  60. @@ -218,6 +243,7 @@ static int rpi_firmware_remove(struct pl
  61. struct rpi_firmware *fw = platform_get_drvdata(pdev);
  62. mbox_free_channel(fw->chan);
  63. + g_pdev = NULL;
  64. return 0;
  65. }
  66. @@ -230,7 +256,7 @@ static int rpi_firmware_remove(struct pl
  67. */
  68. struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
  69. {
  70. - struct platform_device *pdev = of_find_device_by_node(firmware_node);
  71. + struct platform_device *pdev = g_pdev;
  72. if (!pdev)
  73. return NULL;
  74. @@ -253,7 +279,18 @@ static struct platform_driver rpi_firmwa
  75. .probe = rpi_firmware_probe,
  76. .remove = rpi_firmware_remove,
  77. };
  78. -module_platform_driver(rpi_firmware_driver);
  79. +
  80. +static int __init rpi_firmware_init(void)
  81. +{
  82. + return platform_driver_register(&rpi_firmware_driver);
  83. +}
  84. +subsys_initcall(rpi_firmware_init);
  85. +
  86. +static void __init rpi_firmware_exit(void)
  87. +{
  88. + platform_driver_unregister(&rpi_firmware_driver);
  89. +}
  90. +module_exit(rpi_firmware_exit);
  91. MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
  92. MODULE_DESCRIPTION("Raspberry Pi firmware driver");