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