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
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Use the new firmware API instead of the legacy mailbox API.
11 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
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(-)
18 --- a/arch/arm/boot/dts/bcm2708_common.dtsi
19 +++ b/arch/arm/boot/dts/bcm2708_common.dtsi
21 reg = <0x7e00b840 0xf>;
23 cache-line-size = <32>;
24 + firmware = <&firmware>;
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
31 #include <linux/dma-mapping.h>
32 #include <linux/version.h>
34 -#include <linux/platform_data/mailbox-bcm2708.h>
35 #include <linux/platform_device.h>
36 #include <linux/uaccess.h>
38 #include <asm/pgtable.h>
39 +#include <soc/bcm2835/raspberrypi-firmware.h>
41 #define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32)
43 @@ -89,10 +89,12 @@ free_pagelist(PAGELIST_T *pagelist, int
44 int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state)
46 struct device *dev = &pdev->dev;
47 + struct rpi_firmware *fw = platform_get_drvdata(pdev);
48 VCHIQ_SLOT_ZERO_T *vchiq_slot_zero;
53 int slot_mem_size, frag_mem_size;
56 @@ -157,13 +159,12 @@ int vchiq_platform_init(struct platform_
59 /* Send the base address of the slots to VideoCore */
61 - dsb(); /* Ensure all writes have completed */
63 - err = bcm_mailbox_write(MBOX_CHAN_VCHIQ, (unsigned int)slot_phys);
65 - dev_err(dev, "mailbox write failed\n");
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;
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
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>
86 #include "vchiq_core.h"
87 #include "vchiq_ioctl.h"
88 @@ -2793,9 +2795,24 @@ void vchiq_platform_conn_state_changed(V
90 static int vchiq_probe(struct platform_device *pdev)
92 + struct device_node *fw_node;
93 + struct rpi_firmware *fw;
97 + fw_node = of_parse_phandle(pdev->dev.of_node, "firmware", 0);
98 +/* Remove comment when booting without Device Tree is no longer supported
100 + dev_err(&pdev->dev, "Missing firmware node\n");
104 + fw = rpi_firmware_get(fw_node);
106 + return -EPROBE_DEFER;
108 + platform_set_drvdata(pdev, fw);
110 /* create debugfs entries */
111 err = vchiq_debugfs_init();