You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
freifunkist-firmware/target/linux/brcm2708/patches-4.14/950-0051-char-broadcom-Add-...

221 lines
5.3 KiB

brcm2708: add kernel 4.14 support Patch generation process: - rebase rpi/rpi-4.14.y on v4.14.89 from linux-stable - git format-patch v4.14.89 Patches skipped during rebase: - lan78xx: Read MAC address from DT if present - lan78xx: Enable LEDs and auto-negotiation - Revert "softirq: Let ksoftirqd do its job" - sc16is7xx: Fix for multi-channel stall - lan78xx: Ignore DT MAC address if already valid - lan78xx: Simple patch to prevent some crashes - tcp_write_queue_purge clears all the SKBs in the write queue - Revert "lan78xx: Simple patch to prevent some crashes" - lan78xx: Connect phy early - Arm: mm: ftrace: Only set text back to ro after kernel has been marked ro - Revert "Revert "softirq: Let ksoftirqd do its job"" - ASoC: cs4265: SOC_SINGLE register value error fix - Revert "ASoC: cs4265: SOC_SINGLE register value error fix" - Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends" - Revert "Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"" Patches dropped after rebase: - net: Add non-mainline source for rtl8192cu wlan - net: Fix rtl8192cu build errors on other platforms - brcm: adds support for BCM43341 wifi - brcmfmac: Mute expected startup 'errors' - ARM64: Fix build break for RTL8187/RTL8192CU wifi - ARM64: Enable RTL8187/RTL8192CU wifi in build config - This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator - brcmfmac: add CLM download support - brcmfmac: request_firmware_direct is quieter - Sets the BCDC priority to constant 0 - brcmfmac: Disable ARP offloading when promiscuous - brcmfmac: Avoid possible out-of-bounds read - brcmfmac: Delete redundant length check - net: rtl8192cu: Normalize indentation - net: rtl8192cu: Fix implicit fallthrough warnings - Revert "Sets the BCDC priority to constant 0" - media: cxd2880: Bump to match 4.18.y version - media: cxd2880-spi: Bump to match 4.18.y version - Revert "mm: alloc_contig: re-allow CMA to compact FS pages" - Revert "Revert "mm: alloc_contig: re-allow CMA to compact FS pages"" - cxd2880: CXD2880_SPI_DRV should select DVB_CXD2880 with MEDIA_SUBDRV_AUTOSELECT - 950-0421-HID-hid-bigbenff-driver-for-BigBen-Interactive-PS3OF.patch - 950-0453-Add-hid-bigbenff-to-list-of-have_special_driver-for-.patch Make I2C built-in instead of modular as in upstream defconfig; also the easiest way to get MFD_ARIZONA enabled, which is required by kmod-sound-soc-rpi-cirrus. Add missing compatible strings from 4.9/960-add-rasbperrypi-compatible.patch, using upstream names for compute modules. Add extra patch to enable the LEDs on lan78xx. Compile-tested: bcm2708, bcm2709, bcm2710 (with CONFIG_ALL_KMODS=y) Runtime-tested: bcm2708, bcm2710 Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
6 years ago
From 8783aa0977780bc848678c6d4c506128e1ff0b6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
Date: Fri, 26 Jun 2015 14:27:06 +0200
Subject: [PATCH 051/454] char: broadcom: Add vcio module
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add module for accessing the mailbox property channel through
/dev/vcio. Was previously in bcm2708-vcio.
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
drivers/char/broadcom/Kconfig | 6 ++
drivers/char/broadcom/Makefile | 1 +
drivers/char/broadcom/vcio.c | 175 +++++++++++++++++++++++++++++++++
3 files changed, 182 insertions(+)
create mode 100644 drivers/char/broadcom/vcio.c
--- a/drivers/char/broadcom/Kconfig
+++ b/drivers/char/broadcom/Kconfig
@@ -15,6 +15,12 @@ config BCM2708_VCMEM
help
Helper for videocore memory access and total size allocation.
+config BCM_VCIO
+ tristate "Mailbox userspace access"
+ depends on BCM2835_MBOX
+ help
+ Gives access to the mailbox property channel from userspace.
+
endif
config BCM_VC_SM
--- a/drivers/char/broadcom/Makefile
+++ b/drivers/char/broadcom/Makefile
@@ -1,4 +1,5 @@
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
+obj-$(CONFIG_BCM_VCIO) += vcio.o
obj-$(CONFIG_BCM_VC_SM) += vc_sm/
obj-$(CONFIG_BCM2835_DEVGPIOMEM)+= bcm2835-gpiomem.o
--- /dev/null
+++ b/drivers/char/broadcom/vcio.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2010 Broadcom
+ * Copyright (C) 2015 Noralf Trønnes
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/cdev.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include <soc/bcm2835/raspberrypi-firmware.h>
+
+#define MBOX_CHAN_PROPERTY 8
+
+#define VCIO_IOC_MAGIC 100
+#define IOCTL_MBOX_PROPERTY _IOWR(VCIO_IOC_MAGIC, 0, char *)
+
+static struct {
+ dev_t devt;
+ struct cdev cdev;
+ struct class *class;
+ struct rpi_firmware *fw;
+} vcio;
+
+static int vcio_user_property_list(void *user)
+{
+ u32 *buf, size;
+ int ret;
+
+ /* The first 32-bit is the size of the buffer */
+ if (copy_from_user(&size, user, sizeof(size)))
+ return -EFAULT;
+
+ buf = kmalloc(size, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ if (copy_from_user(buf, user, size)) {
+ kfree(buf);
+ return -EFAULT;
+ }
+
+ /* Strip off protocol encapsulation */
+ ret = rpi_firmware_property_list(vcio.fw, &buf[2], size - 12);
+ if (ret) {
+ kfree(buf);
+ return ret;
+ }
+
+ buf[1] = RPI_FIRMWARE_STATUS_SUCCESS;
+ if (copy_to_user(user, buf, size))
+ ret = -EFAULT;
+
+ kfree(buf);
+
+ return ret;
+}
+
+static int vcio_device_open(struct inode *inode, struct file *file)
+{
+ try_module_get(THIS_MODULE);
+
+ return 0;
+}
+
+static int vcio_device_release(struct inode *inode, struct file *file)
+{
+ module_put(THIS_MODULE);
+
+ return 0;
+}
+
+static long vcio_device_ioctl(struct file *file, unsigned int ioctl_num,
+ unsigned long ioctl_param)
+{
+ switch (ioctl_num) {
+ case IOCTL_MBOX_PROPERTY:
+ return vcio_user_property_list((void *)ioctl_param);
+ default:
+ pr_err("unknown ioctl: %d\n", ioctl_num);
+ return -EINVAL;
+ }
+}
+
+const struct file_operations vcio_fops = {
+ .unlocked_ioctl = vcio_device_ioctl,
+ .open = vcio_device_open,
+ .release = vcio_device_release,
+};
+
+static int __init vcio_init(void)
+{
+ struct device_node *np;
+ static struct device *dev;
+ int ret;
+
+ np = of_find_compatible_node(NULL, NULL,
+ "raspberrypi,bcm2835-firmware");
+/* Uncomment this when we only boot with Device Tree
+ if (!of_device_is_available(np))
+ return -ENODEV;
+*/
+ vcio.fw = rpi_firmware_get(np);
+ if (!vcio.fw)
+ return -ENODEV;
+
+ ret = alloc_chrdev_region(&vcio.devt, 0, 1, "vcio");
+ if (ret) {
+ pr_err("failed to allocate device number\n");
+ return ret;
+ }
+
+ cdev_init(&vcio.cdev, &vcio_fops);
+ vcio.cdev.owner = THIS_MODULE;
+ ret = cdev_add(&vcio.cdev, vcio.devt, 1);
+ if (ret) {
+ pr_err("failed to register device\n");
+ goto err_unregister_chardev;
+ }
+
+ /*
+ * Create sysfs entries
+ * 'bcm2708_vcio' is used for backwards compatibility so we don't break
+ * userspace. Raspian has a udev rule that changes the permissions.
+ */
+ vcio.class = class_create(THIS_MODULE, "bcm2708_vcio");
+ if (IS_ERR(vcio.class)) {
+ ret = PTR_ERR(vcio.class);
+ pr_err("failed to create class\n");
+ goto err_cdev_del;
+ }
+
+ dev = device_create(vcio.class, NULL, vcio.devt, NULL, "vcio");
+ if (IS_ERR(dev)) {
+ ret = PTR_ERR(dev);
+ pr_err("failed to create device\n");
+ goto err_class_destroy;
+ }
+
+ return 0;
+
+err_class_destroy:
+ class_destroy(vcio.class);
+err_cdev_del:
+ cdev_del(&vcio.cdev);
+err_unregister_chardev:
+ unregister_chrdev_region(vcio.devt, 1);
+
+ return ret;
+}
+module_init(vcio_init);
+
+static void __exit vcio_exit(void)
+{
+ device_destroy(vcio.class, vcio.devt);
+ class_destroy(vcio.class);
+ cdev_del(&vcio.cdev);
+ unregister_chrdev_region(vcio.devt, 1);
+}
+module_exit(vcio_exit);
+
+MODULE_AUTHOR("Gray Girling");
+MODULE_AUTHOR("Noralf Trønnes");
+MODULE_DESCRIPTION("Mailbox userspace access");
+MODULE_LICENSE("GPL");