Skip to content

Commit 7d63c82

Browse files
notropopcornmix
authored andcommitted
firmware: bcm2835: Support ARCH_BCM270x
Support booting without Device Tree. Turn on USB power. Load driver early because of lacking support for deferred probing in many drivers. Signed-off-by: Noralf Trønnes <[email protected]>
1 parent 882f54d commit 7d63c82

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

drivers/firmware/raspberrypi.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ struct rpi_firmware {
2828
u32 enabled;
2929
};
3030

31+
static struct platform_device *g_pdev;
32+
3133
static DEFINE_MUTEX(transaction_lock);
3234

3335
static void response_callback(struct mbox_client *cl, void *msg)
@@ -183,6 +185,25 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
183185
}
184186
}
185187

188+
static int raspberrypi_firmware_set_power(struct rpi_firmware *fw,
189+
u32 domain, bool on)
190+
{
191+
struct {
192+
u32 domain;
193+
u32 on;
194+
} packet;
195+
int ret;
196+
197+
packet.domain = domain;
198+
packet.on = on;
199+
ret = rpi_firmware_property(fw, RPI_FIRMWARE_SET_POWER_STATE,
200+
&packet, sizeof(packet));
201+
if (!ret && packet.on != on)
202+
ret = -EINVAL;
203+
204+
return ret;
205+
}
206+
186207
static int rpi_firmware_probe(struct platform_device *pdev)
187208
{
188209
struct device *dev = &pdev->dev;
@@ -207,9 +228,13 @@ static int rpi_firmware_probe(struct platform_device *pdev)
207228
init_completion(&fw->c);
208229

209230
platform_set_drvdata(pdev, fw);
231+
g_pdev = pdev;
210232

211233
rpi_firmware_print_firmware_revision(fw);
212234

235+
if (raspberrypi_firmware_set_power(fw, 3, true))
236+
dev_err(dev, "failed to turn on USB power\n");
237+
213238
return 0;
214239
}
215240

@@ -218,6 +243,7 @@ static int rpi_firmware_remove(struct platform_device *pdev)
218243
struct rpi_firmware *fw = platform_get_drvdata(pdev);
219244

220245
mbox_free_channel(fw->chan);
246+
g_pdev = NULL;
221247

222248
return 0;
223249
}
@@ -230,7 +256,7 @@ static int rpi_firmware_remove(struct platform_device *pdev)
230256
*/
231257
struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
232258
{
233-
struct platform_device *pdev = of_find_device_by_node(firmware_node);
259+
struct platform_device *pdev = g_pdev;
234260

235261
if (!pdev)
236262
return NULL;
@@ -253,7 +279,18 @@ static struct platform_driver rpi_firmware_driver = {
253279
.probe = rpi_firmware_probe,
254280
.remove = rpi_firmware_remove,
255281
};
256-
module_platform_driver(rpi_firmware_driver);
282+
283+
static int __init rpi_firmware_init(void)
284+
{
285+
return platform_driver_register(&rpi_firmware_driver);
286+
}
287+
subsys_initcall(rpi_firmware_init);
288+
289+
static void __init rpi_firmware_exit(void)
290+
{
291+
platform_driver_unregister(&rpi_firmware_driver);
292+
}
293+
module_exit(rpi_firmware_exit);
257294

258295
MODULE_AUTHOR("Eric Anholt <[email protected]>");
259296
MODULE_DESCRIPTION("Raspberry Pi firmware driver");

0 commit comments

Comments
 (0)