756363034e6baccb85af7625918c82f69f7d394d
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0111-mailbox-bcm2835-Support-ARCH_BCM270x.patch
1 From 36301913195582a2398add6d60477be534d4f603 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:19:30 +0200
4 Subject: [PATCH 111/121] mailbox: bcm2835: Support ARCH_BCM270x
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Make it possible to use bcm2835-mailbox without Device Tree.
10 Load driver early because of lacking support for deferred probing
11 in many drivers.
12
13 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
14 ---
15 drivers/mailbox/Kconfig | 2 +-
16 drivers/mailbox/bcm2835-mailbox.c | 18 ++++++++++++++++--
17 drivers/mailbox/mailbox.c | 13 ++++++++++++-
18 3 files changed, 29 insertions(+), 4 deletions(-)
19
20 --- a/drivers/mailbox/Kconfig
21 +++ b/drivers/mailbox/Kconfig
22 @@ -69,7 +69,7 @@ config ALTERA_MBOX
23
24 config BCM2835_MBOX
25 tristate "BCM2835 Mailbox"
26 - depends on ARCH_BCM2835
27 + depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
28 help
29 An implementation of the BCM2385 Mailbox. It is used to invoke
30 the services of the Videocore. Say Y here if you want to use the
31 --- a/drivers/mailbox/bcm2835-mailbox.c
32 +++ b/drivers/mailbox/bcm2835-mailbox.c
33 @@ -51,12 +51,15 @@
34 #define MAIL1_WRT (ARM_0_MAIL1 + 0x00)
35 #define MAIL1_STA (ARM_0_MAIL1 + 0x18)
36
37 +/* On ARCH_BCM270x these come through <linux/interrupt.h> (arm_control.h ) */
38 +#ifndef ARM_MS_FULL
39 /* Status register: FIFO state. */
40 #define ARM_MS_FULL BIT(31)
41 #define ARM_MS_EMPTY BIT(30)
42
43 /* Configuration register: Enable interrupts. */
44 #define ARM_MC_IHAVEDATAIRQEN BIT(0)
45 +#endif
46
47 struct bcm2835_mbox {
48 void __iomem *regs;
49 @@ -151,7 +154,7 @@ static int bcm2835_mbox_probe(struct pla
50 return -ENOMEM;
51 spin_lock_init(&mbox->lock);
52
53 - ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
54 + ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
55 bcm2835_mbox_irq, 0, dev_name(dev), mbox);
56 if (ret) {
57 dev_err(dev, "Failed to register a mailbox IRQ handler: %d\n",
58 @@ -210,7 +213,18 @@ static struct platform_driver bcm2835_mb
59 .probe = bcm2835_mbox_probe,
60 .remove = bcm2835_mbox_remove,
61 };
62 -module_platform_driver(bcm2835_mbox_driver);
63 +
64 +static int __init bcm2835_mbox_init(void)
65 +{
66 + return platform_driver_register(&bcm2835_mbox_driver);
67 +}
68 +arch_initcall(bcm2835_mbox_init);
69 +
70 +static void __init bcm2835_mbox_exit(void)
71 +{
72 + platform_driver_unregister(&bcm2835_mbox_driver);
73 +}
74 +module_exit(bcm2835_mbox_exit);
75
76 MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
77 MODULE_DESCRIPTION("BCM2835 mailbox IPC driver");
78 --- a/drivers/mailbox/mailbox.c
79 +++ b/drivers/mailbox/mailbox.c
80 @@ -304,13 +304,23 @@ struct mbox_chan *mbox_request_channel(s
81 unsigned long flags;
82 int ret;
83
84 - if (!dev || !dev->of_node) {
85 + if (!dev) {
86 pr_debug("%s: No owner device node\n", __func__);
87 return ERR_PTR(-ENODEV);
88 }
89
90 mutex_lock(&con_mutex);
91
92 + if (!dev->of_node) {
93 + chan = NULL;
94 + /* pick the first controller in the list */
95 + list_for_each_entry(mbox, &mbox_cons, node) {
96 + chan = &mbox->chans[0];
97 + break;
98 + }
99 + goto skip_dt;
100 + }
101 +
102 if (of_parse_phandle_with_args(dev->of_node, "mboxes",
103 "#mbox-cells", index, &spec)) {
104 dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__);
105 @@ -327,6 +337,7 @@ struct mbox_chan *mbox_request_channel(s
106
107 of_node_put(spec.np);
108
109 +skip_dt:
110 if (!chan || chan->cl || !try_module_get(mbox->dev->driver->owner)) {
111 dev_dbg(dev, "%s: mailbox not free\n", __func__);
112 mutex_unlock(&con_mutex);