brcm2708: switch to linux 4.4 and update patches
[openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0134-vchiq-Use-firmware-API.patch
1 From ad24393030634a23ad382436138029912782bbd8 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
3 Date: Mon, 20 Jul 2015 12:13:18 +0200
4 Subject: [PATCH 134/222] vchiq: Use firmware API
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Use the new firmware API instead of the legacy mailbox API.
10
11 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
12 ---
13  arch/arm/boot/dts/bcm2708_common.dtsi                   |  1 +
14  .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c  | 17 +++++++++--------
15  .../misc/vc04_services/interface/vchiq_arm/vchiq_arm.c  | 17 +++++++++++++++++
16  3 files changed, 27 insertions(+), 8 deletions(-)
17
18 --- a/arch/arm/boot/dts/bcm2708_common.dtsi
19 +++ b/arch/arm/boot/dts/bcm2708_common.dtsi
20 @@ -225,6 +225,7 @@
21                         reg = <0x7e00b840 0xf>;
22                         interrupts = <0 2>;
23                         cache-line-size = <32>;
24 +                       firmware = <&firmware>;
25                 };
26  
27                 thermal: thermal {
28 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
29 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
30 @@ -39,11 +39,11 @@
31  #include <linux/dma-mapping.h>
32  #include <linux/version.h>
33  #include <linux/io.h>
34 -#include <linux/platform_data/mailbox-bcm2708.h>
35  #include <linux/platform_device.h>
36  #include <linux/uaccess.h>
37  #include <linux/of.h>
38  #include <asm/pgtable.h>
39 +#include <soc/bcm2835/raspberrypi-firmware.h>
40  
41  #define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32)
42  
43 @@ -89,10 +89,12 @@ free_pagelist(PAGELIST_T *pagelist, int
44  int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state)
45  {
46         struct device *dev = &pdev->dev;
47 +       struct rpi_firmware *fw = platform_get_drvdata(pdev);
48         VCHIQ_SLOT_ZERO_T *vchiq_slot_zero;
49         struct resource *res;
50         void *slot_mem;
51         dma_addr_t slot_phys;
52 +       u32 channelbase;
53         int slot_mem_size, frag_mem_size;
54         int err, irq, i;
55  
56 @@ -157,13 +159,12 @@ int vchiq_platform_init(struct platform_
57         }
58  
59         /* Send the base address of the slots to VideoCore */
60 -
61 -       dsb(); /* Ensure all writes have completed */
62 -
63 -       err = bcm_mailbox_write(MBOX_CHAN_VCHIQ, (unsigned int)slot_phys);
64 -       if (err) {
65 -               dev_err(dev, "mailbox write failed\n");
66 -               return err;
67 +       channelbase = slot_phys;
68 +       err = rpi_firmware_property(fw, RPI_FIRMWARE_VCHIQ_INIT,
69 +                                   &channelbase, sizeof(channelbase));
70 +       if (err || channelbase) {
71 +               dev_err(dev, "failed to set channelbase\n");
72 +               return err ? : -ENXIO;
73         }
74  
75         vchiq_log_info(vchiq_arm_log_level,
76 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
77 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
78 @@ -45,7 +45,9 @@
79  #include <linux/bug.h>
80  #include <linux/semaphore.h>
81  #include <linux/list.h>
82 +#include <linux/of.h>
83  #include <linux/platform_device.h>
84 +#include <soc/bcm2835/raspberrypi-firmware.h>
85  
86  #include "vchiq_core.h"
87  #include "vchiq_ioctl.h"
88 @@ -2793,9 +2795,24 @@ void vchiq_platform_conn_state_changed(V
89  
90  static int vchiq_probe(struct platform_device *pdev)
91  {
92 +       struct device_node *fw_node;
93 +       struct rpi_firmware *fw;
94         int err;
95         void *ptr_err;
96  
97 +       fw_node = of_parse_phandle(pdev->dev.of_node, "firmware", 0);
98 +/* Remove comment when booting without Device Tree is no longer supported
99 +       if (!fw_node) {
100 +               dev_err(&pdev->dev, "Missing firmware node\n");
101 +               return -ENOENT;
102 +       }
103 +*/
104 +       fw = rpi_firmware_get(fw_node);
105 +       if (!fw)
106 +               return -EPROBE_DEFER;
107 +
108 +       platform_set_drvdata(pdev, fw);
109 +
110         /* create debugfs entries */
111         err = vchiq_debugfs_init();
112         if (err != 0)