brcm2708: add linux 4.1 support
[openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0115-firmware-bcm2835-Support-legacy-mailbox-API.patch
1 From be083fb29207201d3db279f9d5654c5f8c2cb6de 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:26:10 +0200
4 Subject: [PATCH 115/121] firmware: bcm2835: Support legacy mailbox API
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Add support for the bcm_mailbox_*() functions.
10 This is temporary until all drivers have been converted to the
11 firmware API (rpi_firmware_property*()).
12
13 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
14 ---
15  drivers/firmware/raspberrypi.c             | 15 +++++++++++++--
16  include/soc/bcm2835/raspberrypi-firmware.h |  2 ++
17  2 files changed, 15 insertions(+), 2 deletions(-)
18
19 --- a/drivers/firmware/raspberrypi.c
20 +++ b/drivers/firmware/raspberrypi.c
21 @@ -19,6 +19,7 @@
22  #define MBOX_MSG(chan, data28)         (((data28) & ~0xf) | ((chan) & 0xf))
23  #define MBOX_CHAN(msg)                 ((msg) & 0xf)
24  #define MBOX_DATA28(msg)               ((msg) & ~0xf)
25 +#define MBOX_CHAN_VCHIQ                        3
26  #define MBOX_CHAN_PROPERTY             8
27  
28  struct rpi_firmware {
29 @@ -26,6 +27,7 @@ struct rpi_firmware {
30         struct mbox_chan *chan; /* The property channel. */
31         struct completion c;
32         u32 enabled;
33 +       u32 received;
34  };
35  
36  static struct platform_device *g_pdev;
37 @@ -35,6 +37,7 @@ static DEFINE_MUTEX(transaction_lock);
38  static void response_callback(struct mbox_client *cl, void *msg)
39  {
40         struct rpi_firmware *fw = container_of(cl, struct rpi_firmware, cl);
41 +       fw->received = *(u32 *)msg;
42         complete(&fw->c);
43  }
44  
45 @@ -42,7 +45,7 @@ static void response_callback(struct mbo
46   * Sends a request to the firmware through the BCM2835 mailbox driver,
47   * and synchronously waits for the reply.
48   */
49 -static int
50 +int
51  rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)
52  {
53         u32 message = MBOX_MSG(chan, data);
54 @@ -54,7 +57,8 @@ rpi_firmware_transaction(struct rpi_firm
55         reinit_completion(&fw->c);
56         ret = mbox_send_message(fw->chan, &message);
57         if (ret >= 0) {
58 -               wait_for_completion(&fw->c);
59 +               if (chan != MBOX_CHAN_VCHIQ)
60 +                       wait_for_completion(&fw->c);
61                 ret = 0;
62         } else {
63                 dev_err(fw->cl.dev, "mbox_send_message returned %d\n", ret);
64 @@ -63,6 +67,13 @@ rpi_firmware_transaction(struct rpi_firm
65  
66         return ret;
67  }
68 +EXPORT_SYMBOL(rpi_firmware_transaction);
69 +
70 +u32 rpi_firmware_transaction_received(struct rpi_firmware *fw)
71 +{
72 +       return MBOX_DATA28(fw->received);
73 +}
74 +EXPORT_SYMBOL(rpi_firmware_transaction_received);
75  
76  /**
77   * rpi_firmware_property_list - Submit firmware property list
78 --- a/include/soc/bcm2835/raspberrypi-firmware.h
79 +++ b/include/soc/bcm2835/raspberrypi-firmware.h
80 @@ -116,6 +116,8 @@ enum rpi_firmware_property_tag {
81         RPI_FIRMWARE_GET_DMA_CHANNELS =                       0x00060001,
82  };
83  
84 +int rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data);
85 +u32 rpi_firmware_transaction_received(struct rpi_firmware *fw);
86  int rpi_firmware_property(struct rpi_firmware *fw,
87                           u32 tag, void *data, size_t len);
88  int rpi_firmware_property_list(struct rpi_firmware *fw,