1 From af60d6d916093924188d0d532dbe181fe58b4e0d Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Wed, 17 Jun 2015 16:07:06 +0100
4 Subject: [PATCH 013/148] vc_mem: Add vc_mem driver
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Signed-off-by: popcornmix <popcornmix@gmail.com>
13 Make the vc_mem module available for ARCH_BCM2835 by moving it.
15 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
17 arch/arm/mach-bcm2709/include/mach/vc_mem.h | 35 ---
18 arch/arm/mach-bcm2709/vc_mem.c | 431 ----------------------------
19 drivers/char/broadcom/Kconfig | 12 +-
20 drivers/char/broadcom/Makefile | 1 +
21 drivers/char/broadcom/vc_mem.c | 423 +++++++++++++++++++++++++++
22 include/linux/broadcom/vc_mem.h | 35 +++
23 6 files changed, 470 insertions(+), 467 deletions(-)
24 delete mode 100644 arch/arm/mach-bcm2709/include/mach/vc_mem.h
25 delete mode 100644 arch/arm/mach-bcm2709/vc_mem.c
26 create mode 100644 drivers/char/broadcom/vc_mem.c
27 create mode 100644 include/linux/broadcom/vc_mem.h
29 --- a/arch/arm/mach-bcm2709/include/mach/vc_mem.h
32 -/*****************************************************************************
33 -* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
35 -* Unless you and Broadcom execute a separate written software license
36 -* agreement governing use of this software, this software is licensed to you
37 -* under the terms of the GNU General Public License version 2, available at
38 -* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
40 -* Notwithstanding the above, under no circumstances may you combine this
41 -* software in any way with any other Broadcom software provided under a
42 -* license other than the GPL, without Broadcom's express prior written
44 -*****************************************************************************/
46 -#if !defined( VC_MEM_H )
49 -#include <linux/ioctl.h>
51 -#define VC_MEM_IOC_MAGIC 'v'
53 -#define VC_MEM_IOC_MEM_PHYS_ADDR _IOR( VC_MEM_IOC_MAGIC, 0, unsigned long )
54 -#define VC_MEM_IOC_MEM_SIZE _IOR( VC_MEM_IOC_MAGIC, 1, unsigned int )
55 -#define VC_MEM_IOC_MEM_BASE _IOR( VC_MEM_IOC_MAGIC, 2, unsigned int )
56 -#define VC_MEM_IOC_MEM_LOAD _IOR( VC_MEM_IOC_MAGIC, 3, unsigned int )
58 -#if defined( __KERNEL__ )
59 -#define VC_MEM_TO_ARM_ADDR_MASK 0x3FFFFFFF
61 -extern unsigned long mm_vc_mem_phys_addr;
62 -extern unsigned int mm_vc_mem_size;
63 -extern int vc_mem_get_current_size( void );
66 -#endif /* VC_MEM_H */
67 --- a/arch/arm/mach-bcm2709/vc_mem.c
70 -/*****************************************************************************
71 -* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
73 -* Unless you and Broadcom execute a separate written software license
74 -* agreement governing use of this software, this software is licensed to you
75 -* under the terms of the GNU General Public License version 2, available at
76 -* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
78 -* Notwithstanding the above, under no circumstances may you combine this
79 -* software in any way with any other Broadcom software provided under a
80 -* license other than the GPL, without Broadcom's express prior written
82 -*****************************************************************************/
84 -#include <linux/kernel.h>
85 -#include <linux/module.h>
86 -#include <linux/fs.h>
87 -#include <linux/device.h>
88 -#include <linux/cdev.h>
89 -#include <linux/mm.h>
90 -#include <linux/slab.h>
91 -#include <linux/debugfs.h>
92 -#include <asm/uaccess.h>
93 -#include <linux/dma-mapping.h>
94 -#include <linux/platform_data/mailbox-bcm2708.h>
96 -#ifdef CONFIG_ARCH_KONA
97 -#include <chal/chal_ipc.h>
98 -#elif defined(CONFIG_ARCH_BCM2708) || defined(CONFIG_ARCH_BCM2709)
100 -#include <csp/chal_ipc.h>
103 -#include "mach/vc_mem.h"
105 -#define DRIVER_NAME "vc-mem"
107 -// Device (/dev) related variables
108 -static dev_t vc_mem_devnum = 0;
109 -static struct class *vc_mem_class = NULL;
110 -static struct cdev vc_mem_cdev;
111 -static int vc_mem_inited = 0;
113 -#ifdef CONFIG_DEBUG_FS
114 -static struct dentry *vc_mem_debugfs_entry;
118 - * Videocore memory addresses and size
120 - * Drivers that wish to know the videocore memory addresses and sizes should
121 - * use these variables instead of the MM_IO_BASE and MM_ADDR_IO defines in
122 - * headers. This allows the other drivers to not be tied down to a a certain
123 - * address/size at compile time.
125 - * In the future, the goal is to have the videocore memory virtual address and
126 - * size be calculated at boot time rather than at compile time. The decision of
127 - * where the videocore memory resides and its size would be in the hands of the
128 - * bootloader (and/or kernel). When that happens, the values of these variables
129 - * would be calculated and assigned in the init function.
131 -// in the 2835 VC in mapped above ARM, but ARM has full access to VC space
132 -unsigned long mm_vc_mem_phys_addr = 0x00000000;
133 -unsigned int mm_vc_mem_size = 0;
134 -unsigned int mm_vc_mem_base = 0;
136 -EXPORT_SYMBOL(mm_vc_mem_phys_addr);
137 -EXPORT_SYMBOL(mm_vc_mem_size);
138 -EXPORT_SYMBOL(mm_vc_mem_base);
140 -static uint phys_addr = 0;
141 -static uint mem_size = 0;
142 -static uint mem_base = 0;
145 -/****************************************************************************
149 -***************************************************************************/
152 -vc_mem_open(struct inode *inode, struct file *file)
157 - pr_debug("%s: called file = 0x%p\n", __func__, file);
162 -/****************************************************************************
166 -***************************************************************************/
169 -vc_mem_release(struct inode *inode, struct file *file)
174 - pr_debug("%s: called file = 0x%p\n", __func__, file);
179 -/****************************************************************************
183 -***************************************************************************/
186 -vc_mem_get_size(void)
190 -/****************************************************************************
194 -***************************************************************************/
197 -vc_mem_get_base(void)
201 -/****************************************************************************
203 -* vc_mem_get_current_size
205 -***************************************************************************/
208 -vc_mem_get_current_size(void)
210 - return mm_vc_mem_size;
213 -EXPORT_SYMBOL_GPL(vc_mem_get_current_size);
215 -/****************************************************************************
219 -***************************************************************************/
222 -vc_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
229 - pr_debug("%s: called file = 0x%p\n", __func__, file);
232 - case VC_MEM_IOC_MEM_PHYS_ADDR:
234 - pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR=0x%p\n",
235 - __func__, (void *) mm_vc_mem_phys_addr);
237 - if (copy_to_user((void *) arg, &mm_vc_mem_phys_addr,
238 - sizeof (mm_vc_mem_phys_addr)) != 0) {
243 - case VC_MEM_IOC_MEM_SIZE:
245 - // Get the videocore memory size first
248 - pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%u\n", __func__,
251 - if (copy_to_user((void *) arg, &mm_vc_mem_size,
252 - sizeof (mm_vc_mem_size)) != 0) {
257 - case VC_MEM_IOC_MEM_BASE:
259 - // Get the videocore memory base
262 - pr_debug("%s: VC_MEM_IOC_MEM_BASE=%u\n", __func__,
265 - if (copy_to_user((void *) arg, &mm_vc_mem_base,
266 - sizeof (mm_vc_mem_base)) != 0) {
271 - case VC_MEM_IOC_MEM_LOAD:
273 - // Get the videocore memory base
276 - pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%u\n", __func__,
279 - if (copy_to_user((void *) arg, &mm_vc_mem_base,
280 - sizeof (mm_vc_mem_base)) != 0) {
290 - pr_debug("%s: file = 0x%p returning %d\n", __func__, file, rc);
295 -/****************************************************************************
299 -***************************************************************************/
302 -vc_mem_mmap(struct file *filp, struct vm_area_struct *vma)
305 - unsigned long length = vma->vm_end - vma->vm_start;
306 - unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
308 - pr_debug("%s: vm_start = 0x%08lx vm_end = 0x%08lx vm_pgoff = 0x%08lx\n",
309 - __func__, (long) vma->vm_start, (long) vma->vm_end,
310 - (long) vma->vm_pgoff);
312 - if (offset + length > mm_vc_mem_size) {
313 - pr_err("%s: length %ld is too big\n", __func__, length);
316 - // Do not cache the memory map
317 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
319 - rc = remap_pfn_range(vma, vma->vm_start,
320 - (mm_vc_mem_phys_addr >> PAGE_SHIFT) +
321 - vma->vm_pgoff, length, vma->vm_page_prot);
323 - pr_err("%s: remap_pfn_range failed (rc=%d)\n", __func__, rc);
329 -/****************************************************************************
331 -* File Operations for the driver.
333 -***************************************************************************/
335 -static const struct file_operations vc_mem_fops = {
336 - .owner = THIS_MODULE,
337 - .open = vc_mem_open,
338 - .release = vc_mem_release,
339 - .unlocked_ioctl = vc_mem_ioctl,
340 - .mmap = vc_mem_mmap,
343 -#ifdef CONFIG_DEBUG_FS
344 -static void vc_mem_debugfs_deinit(void)
346 - debugfs_remove_recursive(vc_mem_debugfs_entry);
347 - vc_mem_debugfs_entry = NULL;
351 -static int vc_mem_debugfs_init(
352 - struct device *dev)
354 - vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
355 - if (!vc_mem_debugfs_entry) {
356 - dev_warn(dev, "could not create debugfs entry\n");
360 - if (!debugfs_create_x32("vc_mem_phys_addr",
362 - vc_mem_debugfs_entry,
363 - (u32 *)&mm_vc_mem_phys_addr)) {
364 - dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
369 - if (!debugfs_create_x32("vc_mem_size",
371 - vc_mem_debugfs_entry,
372 - (u32 *)&mm_vc_mem_size)) {
373 - dev_warn(dev, "%s:could not create vc_mem_size entry\n",
378 - if (!debugfs_create_x32("vc_mem_base",
380 - vc_mem_debugfs_entry,
381 - (u32 *)&mm_vc_mem_base)) {
382 - dev_warn(dev, "%s:could not create vc_mem_base entry\n",
390 - vc_mem_debugfs_deinit();
394 -#endif /* CONFIG_DEBUG_FS */
397 -/****************************************************************************
401 -***************************************************************************/
407 - struct device *dev;
409 - pr_debug("%s: called\n", __func__);
411 - mm_vc_mem_phys_addr = phys_addr;
412 - mm_vc_mem_size = mem_size;
413 - mm_vc_mem_base = mem_base;
417 - pr_info("vc-mem: phys_addr:0x%08lx mem_base=0x%08x mem_size:0x%08x(%u MiB)\n",
418 - mm_vc_mem_phys_addr, mm_vc_mem_base, mm_vc_mem_size, mm_vc_mem_size / (1024 * 1024));
420 - if ((rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME)) < 0) {
421 - pr_err("%s: alloc_chrdev_region failed (rc=%d)\n",
426 - cdev_init(&vc_mem_cdev, &vc_mem_fops);
427 - if ((rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1)) != 0) {
428 - pr_err("%s: cdev_add failed (rc=%d)\n", __func__, rc);
429 - goto out_unregister;
432 - vc_mem_class = class_create(THIS_MODULE, DRIVER_NAME);
433 - if (IS_ERR(vc_mem_class)) {
434 - rc = PTR_ERR(vc_mem_class);
435 - pr_err("%s: class_create failed (rc=%d)\n", __func__, rc);
439 - dev = device_create(vc_mem_class, NULL, vc_mem_devnum, NULL,
443 - pr_err("%s: device_create failed (rc=%d)\n", __func__, rc);
444 - goto out_class_destroy;
447 -#ifdef CONFIG_DEBUG_FS
448 - /* don't fail if the debug entries cannot be created */
449 - vc_mem_debugfs_init(dev);
455 - device_destroy(vc_mem_class, vc_mem_devnum);
458 - class_destroy(vc_mem_class);
459 - vc_mem_class = NULL;
462 - cdev_del(&vc_mem_cdev);
465 - unregister_chrdev_region(vc_mem_devnum, 1);
471 -/****************************************************************************
475 -***************************************************************************/
480 - pr_debug("%s: called\n", __func__);
482 - if (vc_mem_inited) {
484 - vc_mem_debugfs_deinit();
486 - device_destroy(vc_mem_class, vc_mem_devnum);
487 - class_destroy(vc_mem_class);
488 - cdev_del(&vc_mem_cdev);
489 - unregister_chrdev_region(vc_mem_devnum, 1);
493 -module_init(vc_mem_init);
494 -module_exit(vc_mem_exit);
495 -MODULE_LICENSE("GPL");
496 -MODULE_AUTHOR("Broadcom Corporation");
498 -module_param(phys_addr, uint, 0644);
499 -module_param(mem_size, uint, 0644);
500 -module_param(mem_base, uint, 0644);
501 --- a/drivers/char/broadcom/Kconfig
502 +++ b/drivers/char/broadcom/Kconfig
503 @@ -7,9 +7,19 @@ menuconfig BRCM_CHAR_DRIVERS
505 Broadcom's char drivers
507 +if BRCM_CHAR_DRIVERS
511 - depends on CMA && BRCM_CHAR_DRIVERS && BCM2708_VCHIQ
512 + depends on CMA && BCM2708_VCHIQ
515 Helper for videocore CMA access.
517 +config BCM2708_VCMEM
518 + bool "Videocore Memory"
521 + Helper for videocore memory access and total size allocation.
524 --- a/drivers/char/broadcom/Makefile
525 +++ b/drivers/char/broadcom/Makefile
527 obj-$(CONFIG_BCM_VC_CMA) += vc_cma/
528 +obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
530 +++ b/drivers/char/broadcom/vc_mem.c
532 +/*****************************************************************************
533 +* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
535 +* Unless you and Broadcom execute a separate written software license
536 +* agreement governing use of this software, this software is licensed to you
537 +* under the terms of the GNU General Public License version 2, available at
538 +* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
540 +* Notwithstanding the above, under no circumstances may you combine this
541 +* software in any way with any other Broadcom software provided under a
542 +* license other than the GPL, without Broadcom's express prior written
544 +*****************************************************************************/
546 +#include <linux/kernel.h>
547 +#include <linux/module.h>
548 +#include <linux/fs.h>
549 +#include <linux/device.h>
550 +#include <linux/cdev.h>
551 +#include <linux/mm.h>
552 +#include <linux/slab.h>
553 +#include <linux/debugfs.h>
554 +#include <asm/uaccess.h>
555 +#include <linux/dma-mapping.h>
556 +#include <linux/platform_data/mailbox-bcm2708.h>
557 +#include <linux/broadcom/vc_mem.h>
559 +#define DRIVER_NAME "vc-mem"
561 +// Device (/dev) related variables
562 +static dev_t vc_mem_devnum = 0;
563 +static struct class *vc_mem_class = NULL;
564 +static struct cdev vc_mem_cdev;
565 +static int vc_mem_inited = 0;
567 +#ifdef CONFIG_DEBUG_FS
568 +static struct dentry *vc_mem_debugfs_entry;
572 + * Videocore memory addresses and size
574 + * Drivers that wish to know the videocore memory addresses and sizes should
575 + * use these variables instead of the MM_IO_BASE and MM_ADDR_IO defines in
576 + * headers. This allows the other drivers to not be tied down to a a certain
577 + * address/size at compile time.
579 + * In the future, the goal is to have the videocore memory virtual address and
580 + * size be calculated at boot time rather than at compile time. The decision of
581 + * where the videocore memory resides and its size would be in the hands of the
582 + * bootloader (and/or kernel). When that happens, the values of these variables
583 + * would be calculated and assigned in the init function.
585 +// in the 2835 VC in mapped above ARM, but ARM has full access to VC space
586 +unsigned long mm_vc_mem_phys_addr = 0x00000000;
587 +unsigned int mm_vc_mem_size = 0;
588 +unsigned int mm_vc_mem_base = 0;
590 +EXPORT_SYMBOL(mm_vc_mem_phys_addr);
591 +EXPORT_SYMBOL(mm_vc_mem_size);
592 +EXPORT_SYMBOL(mm_vc_mem_base);
594 +static uint phys_addr = 0;
595 +static uint mem_size = 0;
596 +static uint mem_base = 0;
599 +/****************************************************************************
603 +***************************************************************************/
606 +vc_mem_open(struct inode *inode, struct file *file)
611 + pr_debug("%s: called file = 0x%p\n", __func__, file);
616 +/****************************************************************************
620 +***************************************************************************/
623 +vc_mem_release(struct inode *inode, struct file *file)
628 + pr_debug("%s: called file = 0x%p\n", __func__, file);
633 +/****************************************************************************
637 +***************************************************************************/
640 +vc_mem_get_size(void)
644 +/****************************************************************************
648 +***************************************************************************/
651 +vc_mem_get_base(void)
655 +/****************************************************************************
657 +* vc_mem_get_current_size
659 +***************************************************************************/
662 +vc_mem_get_current_size(void)
664 + return mm_vc_mem_size;
667 +EXPORT_SYMBOL_GPL(vc_mem_get_current_size);
669 +/****************************************************************************
673 +***************************************************************************/
676 +vc_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
683 + pr_debug("%s: called file = 0x%p\n", __func__, file);
686 + case VC_MEM_IOC_MEM_PHYS_ADDR:
688 + pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR=0x%p\n",
689 + __func__, (void *) mm_vc_mem_phys_addr);
691 + if (copy_to_user((void *) arg, &mm_vc_mem_phys_addr,
692 + sizeof (mm_vc_mem_phys_addr)) != 0) {
697 + case VC_MEM_IOC_MEM_SIZE:
699 + // Get the videocore memory size first
702 + pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%u\n", __func__,
705 + if (copy_to_user((void *) arg, &mm_vc_mem_size,
706 + sizeof (mm_vc_mem_size)) != 0) {
711 + case VC_MEM_IOC_MEM_BASE:
713 + // Get the videocore memory base
716 + pr_debug("%s: VC_MEM_IOC_MEM_BASE=%u\n", __func__,
719 + if (copy_to_user((void *) arg, &mm_vc_mem_base,
720 + sizeof (mm_vc_mem_base)) != 0) {
725 + case VC_MEM_IOC_MEM_LOAD:
727 + // Get the videocore memory base
730 + pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%u\n", __func__,
733 + if (copy_to_user((void *) arg, &mm_vc_mem_base,
734 + sizeof (mm_vc_mem_base)) != 0) {
744 + pr_debug("%s: file = 0x%p returning %d\n", __func__, file, rc);
749 +/****************************************************************************
753 +***************************************************************************/
756 +vc_mem_mmap(struct file *filp, struct vm_area_struct *vma)
759 + unsigned long length = vma->vm_end - vma->vm_start;
760 + unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
762 + pr_debug("%s: vm_start = 0x%08lx vm_end = 0x%08lx vm_pgoff = 0x%08lx\n",
763 + __func__, (long) vma->vm_start, (long) vma->vm_end,
764 + (long) vma->vm_pgoff);
766 + if (offset + length > mm_vc_mem_size) {
767 + pr_err("%s: length %ld is too big\n", __func__, length);
770 + // Do not cache the memory map
771 + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
773 + rc = remap_pfn_range(vma, vma->vm_start,
774 + (mm_vc_mem_phys_addr >> PAGE_SHIFT) +
775 + vma->vm_pgoff, length, vma->vm_page_prot);
777 + pr_err("%s: remap_pfn_range failed (rc=%d)\n", __func__, rc);
783 +/****************************************************************************
785 +* File Operations for the driver.
787 +***************************************************************************/
789 +static const struct file_operations vc_mem_fops = {
790 + .owner = THIS_MODULE,
791 + .open = vc_mem_open,
792 + .release = vc_mem_release,
793 + .unlocked_ioctl = vc_mem_ioctl,
794 + .mmap = vc_mem_mmap,
797 +#ifdef CONFIG_DEBUG_FS
798 +static void vc_mem_debugfs_deinit(void)
800 + debugfs_remove_recursive(vc_mem_debugfs_entry);
801 + vc_mem_debugfs_entry = NULL;
805 +static int vc_mem_debugfs_init(
806 + struct device *dev)
808 + vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
809 + if (!vc_mem_debugfs_entry) {
810 + dev_warn(dev, "could not create debugfs entry\n");
814 + if (!debugfs_create_x32("vc_mem_phys_addr",
816 + vc_mem_debugfs_entry,
817 + (u32 *)&mm_vc_mem_phys_addr)) {
818 + dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
823 + if (!debugfs_create_x32("vc_mem_size",
825 + vc_mem_debugfs_entry,
826 + (u32 *)&mm_vc_mem_size)) {
827 + dev_warn(dev, "%s:could not create vc_mem_size entry\n",
832 + if (!debugfs_create_x32("vc_mem_base",
834 + vc_mem_debugfs_entry,
835 + (u32 *)&mm_vc_mem_base)) {
836 + dev_warn(dev, "%s:could not create vc_mem_base entry\n",
844 + vc_mem_debugfs_deinit();
848 +#endif /* CONFIG_DEBUG_FS */
851 +/****************************************************************************
855 +***************************************************************************/
861 + struct device *dev;
863 + pr_debug("%s: called\n", __func__);
865 + mm_vc_mem_phys_addr = phys_addr;
866 + mm_vc_mem_size = mem_size;
867 + mm_vc_mem_base = mem_base;
871 + pr_info("vc-mem: phys_addr:0x%08lx mem_base=0x%08x mem_size:0x%08x(%u MiB)\n",
872 + mm_vc_mem_phys_addr, mm_vc_mem_base, mm_vc_mem_size, mm_vc_mem_size / (1024 * 1024));
874 + if ((rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME)) < 0) {
875 + pr_err("%s: alloc_chrdev_region failed (rc=%d)\n",
880 + cdev_init(&vc_mem_cdev, &vc_mem_fops);
881 + if ((rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1)) != 0) {
882 + pr_err("%s: cdev_add failed (rc=%d)\n", __func__, rc);
883 + goto out_unregister;
886 + vc_mem_class = class_create(THIS_MODULE, DRIVER_NAME);
887 + if (IS_ERR(vc_mem_class)) {
888 + rc = PTR_ERR(vc_mem_class);
889 + pr_err("%s: class_create failed (rc=%d)\n", __func__, rc);
893 + dev = device_create(vc_mem_class, NULL, vc_mem_devnum, NULL,
897 + pr_err("%s: device_create failed (rc=%d)\n", __func__, rc);
898 + goto out_class_destroy;
901 +#ifdef CONFIG_DEBUG_FS
902 + /* don't fail if the debug entries cannot be created */
903 + vc_mem_debugfs_init(dev);
909 + device_destroy(vc_mem_class, vc_mem_devnum);
912 + class_destroy(vc_mem_class);
913 + vc_mem_class = NULL;
916 + cdev_del(&vc_mem_cdev);
919 + unregister_chrdev_region(vc_mem_devnum, 1);
925 +/****************************************************************************
929 +***************************************************************************/
934 + pr_debug("%s: called\n", __func__);
936 + if (vc_mem_inited) {
938 + vc_mem_debugfs_deinit();
940 + device_destroy(vc_mem_class, vc_mem_devnum);
941 + class_destroy(vc_mem_class);
942 + cdev_del(&vc_mem_cdev);
943 + unregister_chrdev_region(vc_mem_devnum, 1);
947 +module_init(vc_mem_init);
948 +module_exit(vc_mem_exit);
949 +MODULE_LICENSE("GPL");
950 +MODULE_AUTHOR("Broadcom Corporation");
952 +module_param(phys_addr, uint, 0644);
953 +module_param(mem_size, uint, 0644);
954 +module_param(mem_base, uint, 0644);
956 +++ b/include/linux/broadcom/vc_mem.h
958 +/*****************************************************************************
959 +* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
961 +* Unless you and Broadcom execute a separate written software license
962 +* agreement governing use of this software, this software is licensed to you
963 +* under the terms of the GNU General Public License version 2, available at
964 +* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
966 +* Notwithstanding the above, under no circumstances may you combine this
967 +* software in any way with any other Broadcom software provided under a
968 +* license other than the GPL, without Broadcom's express prior written
970 +*****************************************************************************/
975 +#include <linux/ioctl.h>
977 +#define VC_MEM_IOC_MAGIC 'v'
979 +#define VC_MEM_IOC_MEM_PHYS_ADDR _IOR( VC_MEM_IOC_MAGIC, 0, unsigned long )
980 +#define VC_MEM_IOC_MEM_SIZE _IOR( VC_MEM_IOC_MAGIC, 1, unsigned int )
981 +#define VC_MEM_IOC_MEM_BASE _IOR( VC_MEM_IOC_MAGIC, 2, unsigned int )
982 +#define VC_MEM_IOC_MEM_LOAD _IOR( VC_MEM_IOC_MAGIC, 3, unsigned int )
984 +#if defined( __KERNEL__ )
985 +#define VC_MEM_TO_ARM_ADDR_MASK 0x3FFFFFFF
987 +extern unsigned long mm_vc_mem_phys_addr;
988 +extern unsigned int mm_vc_mem_size;
989 +extern int vc_mem_get_current_size( void );
992 +#endif /* _VC_MEM_H */