1 From 6c8c9ca56ce6039ade09d26c069132538e4de9f0 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/806] 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 drivers/char/broadcom/Kconfig | 8 +-
13 drivers/char/broadcom/Makefile | 2 +-
14 .../broadcom/{argon-mem.c => rpivid-mem.c} | 105 +++++++++---------
15 drivers/mfd/bcm2835-pm.c | 12 +-
16 drivers/soc/bcm/bcm2835-power.c | 6 +-
17 include/linux/mfd/bcm2835-pm.h | 2 +-
18 8 files changed, 71 insertions(+), 76 deletions(-)
19 rename drivers/char/broadcom/{argon-mem.c => rpivid-mem.c} (69%)
21 --- a/arch/arm/boot/dts/bcm2838.dtsi
22 +++ b/arch/arm/boot/dts/bcm2838.dtsi
26 hevc-decoder@7eb00000 {
27 - compatible = "raspberrypi,argon-hevc-decoder";
28 + compatible = "raspberrypi,rpivid-hevc-decoder";
29 reg = <0x0 0x7eb00000 0x10000>;
33 - argon-local-intc@7eb10000 {
34 - compatible = "raspberrypi,argon-local-intc";
35 + rpivid-local-intc@7eb10000 {
36 + compatible = "raspberrypi,rpivid-local-intc";
37 reg = <0x0 0x7eb10000 0x1000>;
39 interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
42 h264-decoder@7eb20000 {
43 - compatible = "raspberrypi,argon-h264-decoder";
44 + compatible = "raspberrypi,rpivid-h264-decoder";
45 reg = <0x0 0x7eb20000 0x10000>;
49 vp9-decoder@7eb30000 {
50 - compatible = "raspberrypi,argon-vp9-decoder";
51 + compatible = "raspberrypi,rpivid-vp9-decoder";
52 reg = <0x0 0x7eb30000 0x10000>;
55 --- a/drivers/char/broadcom/Kconfig
56 +++ b/drivers/char/broadcom/Kconfig
57 @@ -50,10 +50,10 @@ config BCM2835_SMI_DEV
58 Broadcom's Secondary Memory interface. The low-level functionality is provided
59 by the SMI driver itself.
62 - tristate "Character device driver for the Argon decoder hardware"
64 + tristate "Character device driver for the Raspberry Pi RPIVid video decoder hardware"
67 This driver provides a character device interface for memory-map operations
68 - so userspace tools can access the control and status registers of the Argon
69 - video decoder hardware.
70 + so userspace tools can access the control and status registers of the
71 + Raspberry Pi RPiVid video decoder hardware.
72 --- a/drivers/char/broadcom/Makefile
73 +++ b/drivers/char/broadcom/Makefile
74 @@ -4,4 +4,4 @@ obj-$(CONFIG_BCM_VC_SM) += vc_sm
76 obj-$(CONFIG_BCM2835_DEVGPIOMEM)+= bcm2835-gpiomem.o
77 obj-$(CONFIG_BCM2835_SMI_DEV) += bcm2835_smi_dev.o
78 -obj-$(CONFIG_ARGON_MEM) += argon-mem.o
79 +obj-$(CONFIG_RPIVID_MEM) += rpivid-mem.o
80 --- a/drivers/char/broadcom/argon-mem.c
84 - * argon-mem.c - character device access to the Argon decoder registers
86 - * Based on bcm2835-gpiomem.c. Provides IO memory access to the decoder
87 - * register blocks such that ffmpeg plugins can access the hardware.
89 - * Jonathan Bell <jonathan@raspberrypi.org>
90 - * Copyright (c) 2019, Raspberry Pi (Trading) Ltd.
92 - * Redistribution and use in source and binary forms, with or without
93 - * modification, are permitted provided that the following conditions
95 - * 1. Redistributions of source code must retain the above copyright
96 - * notice, this list of conditions, and the following disclaimer,
97 - * without modification.
98 - * 2. Redistributions in binary form must reproduce the above copyright
99 - * notice, this list of conditions and the following disclaimer in the
100 - * documentation and/or other materials provided with the distribution.
101 - * 3. The names of the above-listed copyright holders may not be used
102 - * to endorse or promote products derived from this software without
103 - * specific prior written permission.
105 - * ALTERNATIVELY, this software may be distributed under the terms of the
106 - * GNU General Public License ("GPL") version 2, as published by the Free
107 - * Software Foundation.
109 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
110 - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
111 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
112 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
113 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
114 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
115 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
116 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
117 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
118 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
119 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
122 -#include <linux/kernel.h>
123 -#include <linux/module.h>
124 -#include <linux/of.h>
125 -#include <linux/of_device.h>
126 -#include <linux/platform_device.h>
127 -#include <linux/mm.h>
128 -#include <linux/slab.h>
129 -#include <linux/cdev.h>
130 -#include <linux/pagemap.h>
131 -#include <linux/io.h>
133 -#define DRIVER_NAME "argon-mem"
134 -#define DEVICE_MINOR 0
136 -struct argon_mem_priv {
138 - struct class *class;
139 - struct cdev argon_mem_cdev;
140 - unsigned long regs_phys;
141 - unsigned long mem_window_len;
142 - struct device *dev;
146 -static int argon_mem_open(struct inode *inode, struct file *file)
148 - int dev = iminor(inode);
150 - struct argon_mem_priv *priv;
151 - if (dev != DEVICE_MINOR)
154 - priv = container_of(inode->i_cdev, struct argon_mem_priv,
158 - file->private_data = priv;
162 -static int argon_mem_release(struct inode *inode, struct file *file)
164 - int dev = iminor(inode);
167 - if (dev != DEVICE_MINOR)
173 -static const struct vm_operations_struct argon_mem_vm_ops = {
174 -#ifdef CONFIG_HAVE_IOREMAP_PROT
175 - .access = generic_access_phys
179 -static int argon_mem_mmap(struct file *file, struct vm_area_struct *vma)
181 - struct argon_mem_priv *priv;
182 - unsigned long pages;
184 - priv = file->private_data;
185 - pages = priv->regs_phys >> PAGE_SHIFT;
187 - * The address decode is far larger than the actual number of registers.
188 - * Just map the whole lot in.
190 - vma->vm_page_prot = phys_mem_access_prot(file, pages,
191 - priv->mem_window_len,
192 - vma->vm_page_prot);
193 - vma->vm_ops = &argon_mem_vm_ops;
194 - if (remap_pfn_range(vma, vma->vm_start,
196 - priv->mem_window_len,
197 - vma->vm_page_prot)) {
203 -static const struct file_operations
205 - .owner = THIS_MODULE,
206 - .open = argon_mem_open,
207 - .release = argon_mem_release,
208 - .mmap = argon_mem_mmap,
211 -static const struct of_device_id argon_mem_of_match[];
212 -static int argon_mem_probe(struct platform_device *pdev)
216 - const struct of_device_id *id;
217 - struct device *dev = &pdev->dev;
218 - struct device *argon_mem_dev;
219 - struct resource *ioresource;
220 - struct argon_mem_priv *priv;
223 - /* Allocate buffers and instance data */
225 - priv = kzalloc(sizeof(struct argon_mem_priv), GFP_KERNEL);
229 - goto failed_inst_alloc;
231 - platform_set_drvdata(pdev, priv);
234 - id = of_match_device(argon_mem_of_match, dev);
237 - priv->name = id->data;
239 - ioresource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
241 - priv->regs_phys = ioresource->start;
242 - priv->mem_window_len = ioresource->end - ioresource->start;
244 - dev_err(priv->dev, "failed to get IO resource");
246 - goto failed_get_resource;
249 - /* Create character device entries */
251 - err = alloc_chrdev_region(&priv->devid,
252 - DEVICE_MINOR, 1, priv->name);
254 - dev_err(priv->dev, "unable to allocate device number");
255 - goto failed_alloc_chrdev;
257 - cdev_init(&priv->argon_mem_cdev, &argon_mem_fops);
258 - priv->argon_mem_cdev.owner = THIS_MODULE;
259 - err = cdev_add(&priv->argon_mem_cdev, priv->devid, 1);
261 - dev_err(priv->dev, "unable to register device");
262 - goto failed_cdev_add;
265 - /* Create sysfs entries */
267 - priv->class = class_create(THIS_MODULE, priv->name);
268 - ptr_err = priv->class;
269 - if (IS_ERR(ptr_err))
270 - goto failed_class_create;
272 - argon_mem_dev = device_create(priv->class, NULL,
275 - ptr_err = argon_mem_dev;
276 - if (IS_ERR(ptr_err))
277 - goto failed_device_create;
279 - dev_info(priv->dev, "%s initialised: Registers at 0x%08lx length 0x%08lx",
280 - priv->name, priv->regs_phys, priv->mem_window_len);
284 -failed_device_create:
285 - class_destroy(priv->class);
286 -failed_class_create:
287 - cdev_del(&priv->argon_mem_cdev);
288 - err = PTR_ERR(ptr_err);
290 - unregister_chrdev_region(priv->devid, 1);
291 -failed_alloc_chrdev:
292 -failed_get_resource:
295 - dev_err(priv->dev, "could not load argon_mem");
299 -static int argon_mem_remove(struct platform_device *pdev)
301 - struct device *dev = &pdev->dev;
302 - struct argon_mem_priv *priv = platform_get_drvdata(pdev);
304 - device_destroy(priv->class, priv->devid);
305 - class_destroy(priv->class);
306 - cdev_del(&priv->argon_mem_cdev);
307 - unregister_chrdev_region(priv->devid, 1);
310 - dev_info(dev, "%s driver removed - OK", priv->name);
314 -static const char argon_hevc_name[] = "argon-hevcmem";
315 -static const char argon_h264_name[] = "argon-h264mem";
316 -static const char argon_vp9_name[] = "argon-vp9mem";
317 -static const char argon_intc_name[] = "argon-intcmem";
319 -static const struct of_device_id argon_mem_of_match[] = {
321 - .compatible = "raspberrypi,argon-hevc-decoder",
322 - .data = &argon_hevc_name,
325 - .compatible = "raspberrypi,argon-h264-decoder",
326 - .data = &argon_h264_name,
329 - .compatible = "raspberrypi,argon-vp9-decoder",
330 - .data = &argon_vp9_name,
332 - /* The "intc" is included as this block of hardware contains the
333 - * "frame done" status flags.
336 - .compatible = "raspberrypi,argon-local-intc",
337 - .data = &argon_intc_name,
339 - { /* sentinel */ },
342 -MODULE_DEVICE_TABLE(of, argon_mem_of_match);
344 -static struct platform_driver argon_mem_driver = {
345 - .probe = argon_mem_probe,
346 - .remove = argon_mem_remove,
348 - .name = DRIVER_NAME,
349 - .owner = THIS_MODULE,
350 - .of_match_table = argon_mem_of_match,
354 -module_platform_driver(argon_mem_driver);
356 -MODULE_ALIAS("platform:argon-mem");
357 -MODULE_LICENSE("GPL");
358 -MODULE_DESCRIPTION("Driver for accessing Argon decoder registers from userspace");
359 -MODULE_AUTHOR("Jonathan Bell <jonathan@raspberrypi.org>");
361 +++ b/drivers/char/broadcom/rpivid-mem.c
364 + * rpivid-mem.c - character device access to the RPiVid decoder registers
366 + * Based on bcm2835-gpiomem.c. Provides IO memory access to the decoder
367 + * register blocks such that ffmpeg plugins can access the hardware.
369 + * Jonathan Bell <jonathan@raspberrypi.org>
370 + * Copyright (c) 2019, Raspberry Pi (Trading) Ltd.
372 + * Redistribution and use in source and binary forms, with or without
373 + * modification, are permitted provided that the following conditions
375 + * 1. Redistributions of source code must retain the above copyright
376 + * notice, this list of conditions, and the following disclaimer,
377 + * without modification.
378 + * 2. Redistributions in binary form must reproduce the above copyright
379 + * notice, this list of conditions and the following disclaimer in the
380 + * documentation and/or other materials provided with the distribution.
381 + * 3. The names of the above-listed copyright holders may not be used
382 + * to endorse or promote products derived from this software without
383 + * specific prior written permission.
385 + * ALTERNATIVELY, this software may be distributed under the terms of the
386 + * GNU General Public License ("GPL") version 2, as published by the Free
387 + * Software Foundation.
389 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
390 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
391 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
392 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
393 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
394 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
395 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
396 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
397 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
398 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
399 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
402 +#include <linux/kernel.h>
403 +#include <linux/module.h>
404 +#include <linux/of.h>
405 +#include <linux/of_device.h>
406 +#include <linux/platform_device.h>
407 +#include <linux/mm.h>
408 +#include <linux/slab.h>
409 +#include <linux/cdev.h>
410 +#include <linux/pagemap.h>
411 +#include <linux/io.h>
413 +#define DRIVER_NAME "rpivid-mem"
414 +#define DEVICE_MINOR 0
416 +struct rpivid_mem_priv {
418 + struct class *class;
419 + struct cdev rpivid_mem_cdev;
420 + unsigned long regs_phys;
421 + unsigned long mem_window_len;
422 + struct device *dev;
426 +static int rpivid_mem_open(struct inode *inode, struct file *file)
428 + int dev = iminor(inode);
430 + struct rpivid_mem_priv *priv;
431 + if (dev != DEVICE_MINOR)
434 + priv = container_of(inode->i_cdev, struct rpivid_mem_priv,
438 + file->private_data = priv;
442 +static int rpivid_mem_release(struct inode *inode, struct file *file)
444 + int dev = iminor(inode);
447 + if (dev != DEVICE_MINOR)
453 +static const struct vm_operations_struct rpivid_mem_vm_ops = {
454 +#ifdef CONFIG_HAVE_IOREMAP_PROT
455 + .access = generic_access_phys
459 +static int rpivid_mem_mmap(struct file *file, struct vm_area_struct *vma)
461 + struct rpivid_mem_priv *priv;
462 + unsigned long pages;
464 + priv = file->private_data;
465 + pages = priv->regs_phys >> PAGE_SHIFT;
467 + * The address decode is far larger than the actual number of registers.
468 + * Just map the whole lot in.
470 + vma->vm_page_prot = phys_mem_access_prot(file, pages,
471 + priv->mem_window_len,
472 + vma->vm_page_prot);
473 + vma->vm_ops = &rpivid_mem_vm_ops;
474 + if (remap_pfn_range(vma, vma->vm_start,
476 + priv->mem_window_len,
477 + vma->vm_page_prot)) {
483 +static const struct file_operations
485 + .owner = THIS_MODULE,
486 + .open = rpivid_mem_open,
487 + .release = rpivid_mem_release,
488 + .mmap = rpivid_mem_mmap,
491 +static const struct of_device_id rpivid_mem_of_match[];
492 +static int rpivid_mem_probe(struct platform_device *pdev)
496 + const struct of_device_id *id;
497 + struct device *dev = &pdev->dev;
498 + struct device *rpivid_mem_dev;
499 + struct resource *ioresource;
500 + struct rpivid_mem_priv *priv;
503 + /* Allocate buffers and instance data */
505 + priv = kzalloc(sizeof(struct rpivid_mem_priv), GFP_KERNEL);
509 + goto failed_inst_alloc;
511 + platform_set_drvdata(pdev, priv);
514 + id = of_match_device(rpivid_mem_of_match, dev);
517 + priv->name = id->data;
519 + ioresource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
521 + priv->regs_phys = ioresource->start;
522 + priv->mem_window_len = ioresource->end - ioresource->start;
524 + dev_err(priv->dev, "failed to get IO resource");
526 + goto failed_get_resource;
529 + /* Create character device entries */
531 + err = alloc_chrdev_region(&priv->devid,
532 + DEVICE_MINOR, 1, priv->name);
534 + dev_err(priv->dev, "unable to allocate device number");
535 + goto failed_alloc_chrdev;
537 + cdev_init(&priv->rpivid_mem_cdev, &rpivid_mem_fops);
538 + priv->rpivid_mem_cdev.owner = THIS_MODULE;
539 + err = cdev_add(&priv->rpivid_mem_cdev, priv->devid, 1);
541 + dev_err(priv->dev, "unable to register device");
542 + goto failed_cdev_add;
545 + /* Create sysfs entries */
547 + priv->class = class_create(THIS_MODULE, priv->name);
548 + ptr_err = priv->class;
549 + if (IS_ERR(ptr_err))
550 + goto failed_class_create;
552 + rpivid_mem_dev = device_create(priv->class, NULL,
555 + ptr_err = rpivid_mem_dev;
556 + if (IS_ERR(ptr_err))
557 + goto failed_device_create;
559 + dev_info(priv->dev, "%s initialised: Registers at 0x%08lx length 0x%08lx",
560 + priv->name, priv->regs_phys, priv->mem_window_len);
564 +failed_device_create:
565 + class_destroy(priv->class);
566 +failed_class_create:
567 + cdev_del(&priv->rpivid_mem_cdev);
568 + err = PTR_ERR(ptr_err);
570 + unregister_chrdev_region(priv->devid, 1);
571 +failed_alloc_chrdev:
572 +failed_get_resource:
575 + dev_err(priv->dev, "could not load rpivid_mem");
579 +static int rpivid_mem_remove(struct platform_device *pdev)
581 + struct device *dev = &pdev->dev;
582 + struct rpivid_mem_priv *priv = platform_get_drvdata(pdev);
584 + device_destroy(priv->class, priv->devid);
585 + class_destroy(priv->class);
586 + cdev_del(&priv->rpivid_mem_cdev);
587 + unregister_chrdev_region(priv->devid, 1);
590 + dev_info(dev, "%s driver removed - OK", priv->name);
594 +static const struct of_device_id rpivid_mem_of_match[] = {
596 + .compatible = "raspberrypi,rpivid-hevc-decoder",
597 + .data = "rpivid-hevcmem",
600 + .compatible = "raspberrypi,rpivid-h264-decoder",
601 + .data = "rpivid-h264mem",
604 + .compatible = "raspberrypi,rpivid-vp9-decoder",
605 + .data = "rpivid-vp9mem",
607 + /* The "intc" is included as this block of hardware contains the
608 + * "frame done" status flags.
611 + .compatible = "raspberrypi,rpivid-local-intc",
612 + .data = "rpivid-intcmem",
614 + { /* sentinel */ },
617 +MODULE_DEVICE_TABLE(of, rpivid_mem_of_match);
619 +static struct platform_driver rpivid_mem_driver = {
620 + .probe = rpivid_mem_probe,
621 + .remove = rpivid_mem_remove,
623 + .name = DRIVER_NAME,
624 + .owner = THIS_MODULE,
625 + .of_match_table = rpivid_mem_of_match,
629 +module_platform_driver(rpivid_mem_driver);
631 +MODULE_ALIAS("platform:rpivid-mem");
632 +MODULE_LICENSE("GPL");
633 +MODULE_DESCRIPTION("Driver for accessing RPiVid decoder registers from userspace");
634 +MODULE_AUTHOR("Jonathan Bell <jonathan@raspberrypi.org>");
635 --- a/drivers/mfd/bcm2835-pm.c
636 +++ b/drivers/mfd/bcm2835-pm.c
637 @@ -50,14 +50,14 @@ static int bcm2835_pm_probe(struct platf
641 - /* Map the ARGON ASB regs if present. */
642 + /* Map the RPiVid ASB regs if present. */
643 res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
645 - pm->arg_asb = devm_ioremap_resource(dev, res);
646 - if (IS_ERR(pm->arg_asb)) {
647 - dev_err(dev, "Failed to map ARGON ASB: %ld\n",
648 - PTR_ERR(pm->arg_asb));
649 - return PTR_ERR(pm->arg_asb);
650 + pm->rpivid_asb = devm_ioremap_resource(dev, res);
651 + if (IS_ERR(pm->rpivid_asb)) {
652 + dev_err(dev, "Failed to map RPiVid ASB: %ld\n",
653 + PTR_ERR(pm->rpivid_asb));
654 + return PTR_ERR(pm->rpivid_asb);
658 --- a/drivers/soc/bcm/bcm2835-power.c
659 +++ b/drivers/soc/bcm/bcm2835-power.c
660 @@ -637,15 +637,15 @@ static int bcm2835_power_probe(struct pl
661 power->base = pm->base;
662 power->asb = pm->asb;
664 - /* 2711 hack: the new ARGON ASB took over V3D, which is our
665 + /* 2711 hack: the new RPiVid ASB took over V3D, which is our
666 * only consumer of this driver so far. The old ASB seems to
667 * still be present with ISP and H264 bits but no V3D, but I
668 * don't know if that's real or not. The V3D is in the same
669 * place in the new ASB as the old one, so just poke the new
673 - power->asb = pm->arg_asb;
674 + if (pm->rpivid_asb) {
675 + power->asb = pm->rpivid_asb;
676 power->is_2711 = true;
679 --- a/include/linux/mfd/bcm2835-pm.h
680 +++ b/include/linux/mfd/bcm2835-pm.h
681 @@ -9,7 +9,7 @@ struct bcm2835_pm {
685 - void __iomem *arg_asb;
686 + void __iomem *rpivid_asb;
689 #endif /* BCM2835_MFD_PM_H */