1 From d9f79dce7a7a2fef2da7bf16c855d083c1ec6c54 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Sun, 28 Jul 2019 22:22:36 +0100
4 Subject: [PATCH 728/782] drivers: char: Use correct name for the Raspberry Pi
7 Replace the old code name with a more appropriate name - RPiVid.
9 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
11 arch/arm/boot/dts/bcm2838.dtsi | 10 +-
12 arch/arm/configs/bcm2711_defconfig | 2 +-
13 drivers/char/broadcom/Kconfig | 8 +-
14 drivers/char/broadcom/Makefile | 2 +-
15 .../broadcom/{argon-mem.c => rpivid-mem.c} | 105 +++++++++---------
16 drivers/mfd/bcm2835-pm.c | 12 +-
17 drivers/soc/bcm/bcm2835-power.c | 6 +-
18 include/linux/mfd/bcm2835-pm.h | 2 +-
19 8 files changed, 71 insertions(+), 76 deletions(-)
20 rename drivers/char/broadcom/{argon-mem.c => rpivid-mem.c} (69%)
22 --- a/arch/arm/boot/dts/bcm2838.dtsi
23 +++ b/arch/arm/boot/dts/bcm2838.dtsi
27 hevc-decoder@7eb00000 {
28 - compatible = "raspberrypi,argon-hevc-decoder";
29 + compatible = "raspberrypi,rpivid-hevc-decoder";
30 reg = <0x0 0x7eb00000 0x10000>;
34 - argon-local-intc@7eb10000 {
35 - compatible = "raspberrypi,argon-local-intc";
36 + rpivid-local-intc@7eb10000 {
37 + compatible = "raspberrypi,rpivid-local-intc";
38 reg = <0x0 0x7eb10000 0x1000>;
40 interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
43 h264-decoder@7eb20000 {
44 - compatible = "raspberrypi,argon-h264-decoder";
45 + compatible = "raspberrypi,rpivid-h264-decoder";
46 reg = <0x0 0x7eb20000 0x10000>;
50 vp9-decoder@7eb30000 {
51 - compatible = "raspberrypi,argon-vp9-decoder";
52 + compatible = "raspberrypi,rpivid-vp9-decoder";
53 reg = <0x0 0x7eb30000 0x10000>;
56 --- a/arch/arm/configs/bcm2711_defconfig
57 +++ b/arch/arm/configs/bcm2711_defconfig
58 @@ -650,7 +650,7 @@ CONFIG_BRCM_CHAR_DRIVERS=y
61 CONFIG_BCM2835_DEVGPIOMEM=y
64 # CONFIG_LEGACY_PTYS is not set
66 # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
67 --- a/drivers/char/broadcom/Kconfig
68 +++ b/drivers/char/broadcom/Kconfig
69 @@ -50,10 +50,10 @@ config BCM2835_SMI_DEV
70 Broadcom's Secondary Memory interface. The low-level functionality is provided
71 by the SMI driver itself.
74 - tristate "Character device driver for the Argon decoder hardware"
76 + tristate "Character device driver for the Raspberry Pi RPIVid video decoder hardware"
79 This driver provides a character device interface for memory-map operations
80 - so userspace tools can access the control and status registers of the Argon
81 - video decoder hardware.
82 + so userspace tools can access the control and status registers of the
83 + Raspberry Pi RPiVid video decoder hardware.
84 --- a/drivers/char/broadcom/Makefile
85 +++ b/drivers/char/broadcom/Makefile
86 @@ -4,4 +4,4 @@ obj-$(CONFIG_BCM_VC_SM) += vc_sm
88 obj-$(CONFIG_BCM2835_DEVGPIOMEM)+= bcm2835-gpiomem.o
89 obj-$(CONFIG_BCM2835_SMI_DEV) += bcm2835_smi_dev.o
90 -obj-$(CONFIG_ARGON_MEM) += argon-mem.o
91 +obj-$(CONFIG_RPIVID_MEM) += rpivid-mem.o
92 --- a/drivers/char/broadcom/argon-mem.c
96 - * argon-mem.c - character device access to the Argon decoder registers
98 - * Based on bcm2835-gpiomem.c. Provides IO memory access to the decoder
99 - * register blocks such that ffmpeg plugins can access the hardware.
101 - * Jonathan Bell <jonathan@raspberrypi.org>
102 - * Copyright (c) 2019, Raspberry Pi (Trading) Ltd.
104 - * Redistribution and use in source and binary forms, with or without
105 - * modification, are permitted provided that the following conditions
107 - * 1. Redistributions of source code must retain the above copyright
108 - * notice, this list of conditions, and the following disclaimer,
109 - * without modification.
110 - * 2. Redistributions in binary form must reproduce the above copyright
111 - * notice, this list of conditions and the following disclaimer in the
112 - * documentation and/or other materials provided with the distribution.
113 - * 3. The names of the above-listed copyright holders may not be used
114 - * to endorse or promote products derived from this software without
115 - * specific prior written permission.
117 - * ALTERNATIVELY, this software may be distributed under the terms of the
118 - * GNU General Public License ("GPL") version 2, as published by the Free
119 - * Software Foundation.
121 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
122 - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
123 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
124 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
125 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
126 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
127 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
128 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
129 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
130 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
131 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
134 -#include <linux/kernel.h>
135 -#include <linux/module.h>
136 -#include <linux/of.h>
137 -#include <linux/of_device.h>
138 -#include <linux/platform_device.h>
139 -#include <linux/mm.h>
140 -#include <linux/slab.h>
141 -#include <linux/cdev.h>
142 -#include <linux/pagemap.h>
143 -#include <linux/io.h>
145 -#define DRIVER_NAME "argon-mem"
146 -#define DEVICE_MINOR 0
148 -struct argon_mem_priv {
150 - struct class *class;
151 - struct cdev argon_mem_cdev;
152 - unsigned long regs_phys;
153 - unsigned long mem_window_len;
154 - struct device *dev;
158 -static int argon_mem_open(struct inode *inode, struct file *file)
160 - int dev = iminor(inode);
162 - struct argon_mem_priv *priv;
163 - if (dev != DEVICE_MINOR)
166 - priv = container_of(inode->i_cdev, struct argon_mem_priv,
170 - file->private_data = priv;
174 -static int argon_mem_release(struct inode *inode, struct file *file)
176 - int dev = iminor(inode);
179 - if (dev != DEVICE_MINOR)
185 -static const struct vm_operations_struct argon_mem_vm_ops = {
186 -#ifdef CONFIG_HAVE_IOREMAP_PROT
187 - .access = generic_access_phys
191 -static int argon_mem_mmap(struct file *file, struct vm_area_struct *vma)
193 - struct argon_mem_priv *priv;
194 - unsigned long pages;
196 - priv = file->private_data;
197 - pages = priv->regs_phys >> PAGE_SHIFT;
199 - * The address decode is far larger than the actual number of registers.
200 - * Just map the whole lot in.
202 - vma->vm_page_prot = phys_mem_access_prot(file, pages,
203 - priv->mem_window_len,
204 - vma->vm_page_prot);
205 - vma->vm_ops = &argon_mem_vm_ops;
206 - if (remap_pfn_range(vma, vma->vm_start,
208 - priv->mem_window_len,
209 - vma->vm_page_prot)) {
215 -static const struct file_operations
217 - .owner = THIS_MODULE,
218 - .open = argon_mem_open,
219 - .release = argon_mem_release,
220 - .mmap = argon_mem_mmap,
223 -static const struct of_device_id argon_mem_of_match[];
224 -static int argon_mem_probe(struct platform_device *pdev)
228 - const struct of_device_id *id;
229 - struct device *dev = &pdev->dev;
230 - struct device *argon_mem_dev;
231 - struct resource *ioresource;
232 - struct argon_mem_priv *priv;
235 - /* Allocate buffers and instance data */
237 - priv = kzalloc(sizeof(struct argon_mem_priv), GFP_KERNEL);
241 - goto failed_inst_alloc;
243 - platform_set_drvdata(pdev, priv);
246 - id = of_match_device(argon_mem_of_match, dev);
249 - priv->name = id->data;
251 - ioresource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
253 - priv->regs_phys = ioresource->start;
254 - priv->mem_window_len = ioresource->end - ioresource->start;
256 - dev_err(priv->dev, "failed to get IO resource");
258 - goto failed_get_resource;
261 - /* Create character device entries */
263 - err = alloc_chrdev_region(&priv->devid,
264 - DEVICE_MINOR, 1, priv->name);
266 - dev_err(priv->dev, "unable to allocate device number");
267 - goto failed_alloc_chrdev;
269 - cdev_init(&priv->argon_mem_cdev, &argon_mem_fops);
270 - priv->argon_mem_cdev.owner = THIS_MODULE;
271 - err = cdev_add(&priv->argon_mem_cdev, priv->devid, 1);
273 - dev_err(priv->dev, "unable to register device");
274 - goto failed_cdev_add;
277 - /* Create sysfs entries */
279 - priv->class = class_create(THIS_MODULE, priv->name);
280 - ptr_err = priv->class;
281 - if (IS_ERR(ptr_err))
282 - goto failed_class_create;
284 - argon_mem_dev = device_create(priv->class, NULL,
287 - ptr_err = argon_mem_dev;
288 - if (IS_ERR(ptr_err))
289 - goto failed_device_create;
291 - dev_info(priv->dev, "%s initialised: Registers at 0x%08lx length 0x%08lx",
292 - priv->name, priv->regs_phys, priv->mem_window_len);
296 -failed_device_create:
297 - class_destroy(priv->class);
298 -failed_class_create:
299 - cdev_del(&priv->argon_mem_cdev);
300 - err = PTR_ERR(ptr_err);
302 - unregister_chrdev_region(priv->devid, 1);
303 -failed_alloc_chrdev:
304 -failed_get_resource:
307 - dev_err(priv->dev, "could not load argon_mem");
311 -static int argon_mem_remove(struct platform_device *pdev)
313 - struct device *dev = &pdev->dev;
314 - struct argon_mem_priv *priv = platform_get_drvdata(pdev);
316 - device_destroy(priv->class, priv->devid);
317 - class_destroy(priv->class);
318 - cdev_del(&priv->argon_mem_cdev);
319 - unregister_chrdev_region(priv->devid, 1);
322 - dev_info(dev, "%s driver removed - OK", priv->name);
326 -static const char argon_hevc_name[] = "argon-hevcmem";
327 -static const char argon_h264_name[] = "argon-h264mem";
328 -static const char argon_vp9_name[] = "argon-vp9mem";
329 -static const char argon_intc_name[] = "argon-intcmem";
331 -static const struct of_device_id argon_mem_of_match[] = {
333 - .compatible = "raspberrypi,argon-hevc-decoder",
334 - .data = &argon_hevc_name,
337 - .compatible = "raspberrypi,argon-h264-decoder",
338 - .data = &argon_h264_name,
341 - .compatible = "raspberrypi,argon-vp9-decoder",
342 - .data = &argon_vp9_name,
344 - /* The "intc" is included as this block of hardware contains the
345 - * "frame done" status flags.
348 - .compatible = "raspberrypi,argon-local-intc",
349 - .data = &argon_intc_name,
351 - { /* sentinel */ },
354 -MODULE_DEVICE_TABLE(of, argon_mem_of_match);
356 -static struct platform_driver argon_mem_driver = {
357 - .probe = argon_mem_probe,
358 - .remove = argon_mem_remove,
360 - .name = DRIVER_NAME,
361 - .owner = THIS_MODULE,
362 - .of_match_table = argon_mem_of_match,
366 -module_platform_driver(argon_mem_driver);
368 -MODULE_ALIAS("platform:argon-mem");
369 -MODULE_LICENSE("GPL");
370 -MODULE_DESCRIPTION("Driver for accessing Argon decoder registers from userspace");
371 -MODULE_AUTHOR("Jonathan Bell <jonathan@raspberrypi.org>");
373 +++ b/drivers/char/broadcom/rpivid-mem.c
376 + * rpivid-mem.c - character device access to the RPiVid decoder registers
378 + * Based on bcm2835-gpiomem.c. Provides IO memory access to the decoder
379 + * register blocks such that ffmpeg plugins can access the hardware.
381 + * Jonathan Bell <jonathan@raspberrypi.org>
382 + * Copyright (c) 2019, Raspberry Pi (Trading) Ltd.
384 + * Redistribution and use in source and binary forms, with or without
385 + * modification, are permitted provided that the following conditions
387 + * 1. Redistributions of source code must retain the above copyright
388 + * notice, this list of conditions, and the following disclaimer,
389 + * without modification.
390 + * 2. Redistributions in binary form must reproduce the above copyright
391 + * notice, this list of conditions and the following disclaimer in the
392 + * documentation and/or other materials provided with the distribution.
393 + * 3. The names of the above-listed copyright holders may not be used
394 + * to endorse or promote products derived from this software without
395 + * specific prior written permission.
397 + * ALTERNATIVELY, this software may be distributed under the terms of the
398 + * GNU General Public License ("GPL") version 2, as published by the Free
399 + * Software Foundation.
401 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
402 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
403 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
404 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
405 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
406 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
407 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
408 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
409 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
410 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
411 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
414 +#include <linux/kernel.h>
415 +#include <linux/module.h>
416 +#include <linux/of.h>
417 +#include <linux/of_device.h>
418 +#include <linux/platform_device.h>
419 +#include <linux/mm.h>
420 +#include <linux/slab.h>
421 +#include <linux/cdev.h>
422 +#include <linux/pagemap.h>
423 +#include <linux/io.h>
425 +#define DRIVER_NAME "rpivid-mem"
426 +#define DEVICE_MINOR 0
428 +struct rpivid_mem_priv {
430 + struct class *class;
431 + struct cdev rpivid_mem_cdev;
432 + unsigned long regs_phys;
433 + unsigned long mem_window_len;
434 + struct device *dev;
438 +static int rpivid_mem_open(struct inode *inode, struct file *file)
440 + int dev = iminor(inode);
442 + struct rpivid_mem_priv *priv;
443 + if (dev != DEVICE_MINOR)
446 + priv = container_of(inode->i_cdev, struct rpivid_mem_priv,
450 + file->private_data = priv;
454 +static int rpivid_mem_release(struct inode *inode, struct file *file)
456 + int dev = iminor(inode);
459 + if (dev != DEVICE_MINOR)
465 +static const struct vm_operations_struct rpivid_mem_vm_ops = {
466 +#ifdef CONFIG_HAVE_IOREMAP_PROT
467 + .access = generic_access_phys
471 +static int rpivid_mem_mmap(struct file *file, struct vm_area_struct *vma)
473 + struct rpivid_mem_priv *priv;
474 + unsigned long pages;
476 + priv = file->private_data;
477 + pages = priv->regs_phys >> PAGE_SHIFT;
479 + * The address decode is far larger than the actual number of registers.
480 + * Just map the whole lot in.
482 + vma->vm_page_prot = phys_mem_access_prot(file, pages,
483 + priv->mem_window_len,
484 + vma->vm_page_prot);
485 + vma->vm_ops = &rpivid_mem_vm_ops;
486 + if (remap_pfn_range(vma, vma->vm_start,
488 + priv->mem_window_len,
489 + vma->vm_page_prot)) {
495 +static const struct file_operations
497 + .owner = THIS_MODULE,
498 + .open = rpivid_mem_open,
499 + .release = rpivid_mem_release,
500 + .mmap = rpivid_mem_mmap,
503 +static const struct of_device_id rpivid_mem_of_match[];
504 +static int rpivid_mem_probe(struct platform_device *pdev)
508 + const struct of_device_id *id;
509 + struct device *dev = &pdev->dev;
510 + struct device *rpivid_mem_dev;
511 + struct resource *ioresource;
512 + struct rpivid_mem_priv *priv;
515 + /* Allocate buffers and instance data */
517 + priv = kzalloc(sizeof(struct rpivid_mem_priv), GFP_KERNEL);
521 + goto failed_inst_alloc;
523 + platform_set_drvdata(pdev, priv);
526 + id = of_match_device(rpivid_mem_of_match, dev);
529 + priv->name = id->data;
531 + ioresource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
533 + priv->regs_phys = ioresource->start;
534 + priv->mem_window_len = ioresource->end - ioresource->start;
536 + dev_err(priv->dev, "failed to get IO resource");
538 + goto failed_get_resource;
541 + /* Create character device entries */
543 + err = alloc_chrdev_region(&priv->devid,
544 + DEVICE_MINOR, 1, priv->name);
546 + dev_err(priv->dev, "unable to allocate device number");
547 + goto failed_alloc_chrdev;
549 + cdev_init(&priv->rpivid_mem_cdev, &rpivid_mem_fops);
550 + priv->rpivid_mem_cdev.owner = THIS_MODULE;
551 + err = cdev_add(&priv->rpivid_mem_cdev, priv->devid, 1);
553 + dev_err(priv->dev, "unable to register device");
554 + goto failed_cdev_add;
557 + /* Create sysfs entries */
559 + priv->class = class_create(THIS_MODULE, priv->name);
560 + ptr_err = priv->class;
561 + if (IS_ERR(ptr_err))
562 + goto failed_class_create;
564 + rpivid_mem_dev = device_create(priv->class, NULL,
567 + ptr_err = rpivid_mem_dev;
568 + if (IS_ERR(ptr_err))
569 + goto failed_device_create;
571 + dev_info(priv->dev, "%s initialised: Registers at 0x%08lx length 0x%08lx",
572 + priv->name, priv->regs_phys, priv->mem_window_len);
576 +failed_device_create:
577 + class_destroy(priv->class);
578 +failed_class_create:
579 + cdev_del(&priv->rpivid_mem_cdev);
580 + err = PTR_ERR(ptr_err);
582 + unregister_chrdev_region(priv->devid, 1);
583 +failed_alloc_chrdev:
584 +failed_get_resource:
587 + dev_err(priv->dev, "could not load rpivid_mem");
591 +static int rpivid_mem_remove(struct platform_device *pdev)
593 + struct device *dev = &pdev->dev;
594 + struct rpivid_mem_priv *priv = platform_get_drvdata(pdev);
596 + device_destroy(priv->class, priv->devid);
597 + class_destroy(priv->class);
598 + cdev_del(&priv->rpivid_mem_cdev);
599 + unregister_chrdev_region(priv->devid, 1);
602 + dev_info(dev, "%s driver removed - OK", priv->name);
606 +static const struct of_device_id rpivid_mem_of_match[] = {
608 + .compatible = "raspberrypi,rpivid-hevc-decoder",
609 + .data = "rpivid-hevcmem",
612 + .compatible = "raspberrypi,rpivid-h264-decoder",
613 + .data = "rpivid-h264mem",
616 + .compatible = "raspberrypi,rpivid-vp9-decoder",
617 + .data = "rpivid-vp9mem",
619 + /* The "intc" is included as this block of hardware contains the
620 + * "frame done" status flags.
623 + .compatible = "raspberrypi,rpivid-local-intc",
624 + .data = "rpivid-intcmem",
626 + { /* sentinel */ },
629 +MODULE_DEVICE_TABLE(of, rpivid_mem_of_match);
631 +static struct platform_driver rpivid_mem_driver = {
632 + .probe = rpivid_mem_probe,
633 + .remove = rpivid_mem_remove,
635 + .name = DRIVER_NAME,
636 + .owner = THIS_MODULE,
637 + .of_match_table = rpivid_mem_of_match,
641 +module_platform_driver(rpivid_mem_driver);
643 +MODULE_ALIAS("platform:rpivid-mem");
644 +MODULE_LICENSE("GPL");
645 +MODULE_DESCRIPTION("Driver for accessing RPiVid decoder registers from userspace");
646 +MODULE_AUTHOR("Jonathan Bell <jonathan@raspberrypi.org>");
647 --- a/drivers/mfd/bcm2835-pm.c
648 +++ b/drivers/mfd/bcm2835-pm.c
649 @@ -50,14 +50,14 @@ static int bcm2835_pm_probe(struct platf
653 - /* Map the ARGON ASB regs if present. */
654 + /* Map the RPiVid ASB regs if present. */
655 res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
657 - pm->arg_asb = devm_ioremap_resource(dev, res);
658 - if (IS_ERR(pm->arg_asb)) {
659 - dev_err(dev, "Failed to map ARGON ASB: %ld\n",
660 - PTR_ERR(pm->arg_asb));
661 - return PTR_ERR(pm->arg_asb);
662 + pm->rpivid_asb = devm_ioremap_resource(dev, res);
663 + if (IS_ERR(pm->rpivid_asb)) {
664 + dev_err(dev, "Failed to map RPiVid ASB: %ld\n",
665 + PTR_ERR(pm->rpivid_asb));
666 + return PTR_ERR(pm->rpivid_asb);
670 --- a/drivers/soc/bcm/bcm2835-power.c
671 +++ b/drivers/soc/bcm/bcm2835-power.c
672 @@ -637,15 +637,15 @@ static int bcm2835_power_probe(struct pl
673 power->base = pm->base;
674 power->asb = pm->asb;
676 - /* 2711 hack: the new ARGON ASB took over V3D, which is our
677 + /* 2711 hack: the new RPiVid ASB took over V3D, which is our
678 * only consumer of this driver so far. The old ASB seems to
679 * still be present with ISP and H264 bits but no V3D, but I
680 * don't know if that's real or not. The V3D is in the same
681 * place in the new ASB as the old one, so just poke the new
685 - power->asb = pm->arg_asb;
686 + if (pm->rpivid_asb) {
687 + power->asb = pm->rpivid_asb;
688 power->is_2711 = true;
691 --- a/include/linux/mfd/bcm2835-pm.h
692 +++ b/include/linux/mfd/bcm2835-pm.h
693 @@ -9,7 +9,7 @@ struct bcm2835_pm {
697 - void __iomem *arg_asb;
698 + void __iomem *rpivid_asb;
701 #endif /* BCM2835_MFD_PM_H */