Skip to content

Commit

Permalink
firmware: bcm2835: Support ARCH_BCM270x
Browse files Browse the repository at this point in the history
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 <noralf@tronnes.org>
  • Loading branch information
notro authored and Thadeu Lima de Souza Cascardo committed Nov 2, 2017
1 parent a65af89 commit 150d8a3
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions drivers/firmware/raspberrypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct rpi_firmware {
u32 enabled;
};

static struct platform_device *g_pdev;

static DEFINE_MUTEX(transaction_lock);

static void response_callback(struct mbox_client *cl, void *msg)
Expand Down Expand Up @@ -183,6 +185,25 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
}
}

static int raspberrypi_firmware_set_power(struct rpi_firmware *fw,
u32 domain, bool on)
{
struct {
u32 domain;
u32 on;
} packet;
int ret;

packet.domain = domain;
packet.on = on;
ret = rpi_firmware_property(fw, RPI_FIRMWARE_SET_POWER_STATE,
&packet, sizeof(packet));
if (!ret && packet.on != on)
ret = -EINVAL;

return ret;
}

static int rpi_firmware_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
Expand All @@ -207,9 +228,13 @@ static int rpi_firmware_probe(struct platform_device *pdev)
init_completion(&fw->c);

platform_set_drvdata(pdev, fw);
g_pdev = pdev;

rpi_firmware_print_firmware_revision(fw);

if (raspberrypi_firmware_set_power(fw, 3, true))
dev_err(dev, "failed to turn on USB power\n");

return 0;
}

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

mbox_free_channel(fw->chan);
g_pdev = NULL;

return 0;
}
Expand All @@ -230,7 +256,7 @@ static int rpi_firmware_remove(struct platform_device *pdev)
*/
struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
{
struct platform_device *pdev = of_find_device_by_node(firmware_node);
struct platform_device *pdev = g_pdev;

if (!pdev)
return NULL;
Expand All @@ -253,7 +279,18 @@ static struct platform_driver rpi_firmware_driver = {
.probe = rpi_firmware_probe,
.remove = rpi_firmware_remove,
};
module_platform_driver(rpi_firmware_driver);

static int __init rpi_firmware_init(void)
{
return platform_driver_register(&rpi_firmware_driver);
}
subsys_initcall(rpi_firmware_init);

static void __init rpi_firmware_exit(void)
{
platform_driver_unregister(&rpi_firmware_driver);
}
module_exit(rpi_firmware_exit);

MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
MODULE_DESCRIPTION("Raspberry Pi firmware driver");
Expand Down

0 comments on commit 150d8a3

Please sign in to comment.