1 From f5cce853dbe19f479d61c2d91a009edbea5735fc 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 037/381] 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 | 422 +++++++++++++++++++++++++++
22 include/linux/broadcom/vc_mem.h | 35 +++
23 6 files changed, 469 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/broadcom/vc_mem.h>
558 +#define DRIVER_NAME "vc-mem"
560 +// Device (/dev) related variables
561 +static dev_t vc_mem_devnum = 0;
562 +static struct class *vc_mem_class = NULL;
563 +static struct cdev vc_mem_cdev;
564 +static int vc_mem_inited = 0;
566 +#ifdef CONFIG_DEBUG_FS
567 +static struct dentry *vc_mem_debugfs_entry;
571 + * Videocore memory addresses and size
573 + * Drivers that wish to know the videocore memory addresses and sizes should
574 + * use these variables instead of the MM_IO_BASE and MM_ADDR_IO defines in
575 + * headers. This allows the other drivers to not be tied down to a a certain
576 + * address/size at compile time.
578 + * In the future, the goal is to have the videocore memory virtual address and
579 + * size be calculated at boot time rather than at compile time. The decision of
580 + * where the videocore memory resides and its size would be in the hands of the
581 + * bootloader (and/or kernel). When that happens, the values of these variables
582 + * would be calculated and assigned in the init function.
584 +// in the 2835 VC in mapped above ARM, but ARM has full access to VC space
585 +unsigned long mm_vc_mem_phys_addr = 0x00000000;
586 +unsigned int mm_vc_mem_size = 0;
587 +unsigned int mm_vc_mem_base = 0;
589 +EXPORT_SYMBOL(mm_vc_mem_phys_addr);
590 +EXPORT_SYMBOL(mm_vc_mem_size);
591 +EXPORT_SYMBOL(mm_vc_mem_base);
593 +static uint phys_addr = 0;
594 +static uint mem_size = 0;
595 +static uint mem_base = 0;
598 +/****************************************************************************
602 +***************************************************************************/
605 +vc_mem_open(struct inode *inode, struct file *file)
610 + pr_debug("%s: called file = 0x%p\n", __func__, file);
615 +/****************************************************************************
619 +***************************************************************************/
622 +vc_mem_release(struct inode *inode, struct file *file)
627 + pr_debug("%s: called file = 0x%p\n", __func__, file);
632 +/****************************************************************************
636 +***************************************************************************/
639 +vc_mem_get_size(void)
643 +/****************************************************************************
647 +***************************************************************************/
650 +vc_mem_get_base(void)
654 +/****************************************************************************
656 +* vc_mem_get_current_size
658 +***************************************************************************/
661 +vc_mem_get_current_size(void)
663 + return mm_vc_mem_size;
666 +EXPORT_SYMBOL_GPL(vc_mem_get_current_size);
668 +/****************************************************************************
672 +***************************************************************************/
675 +vc_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
682 + pr_debug("%s: called file = 0x%p\n", __func__, file);
685 + case VC_MEM_IOC_MEM_PHYS_ADDR:
687 + pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR=0x%p\n",
688 + __func__, (void *) mm_vc_mem_phys_addr);
690 + if (copy_to_user((void *) arg, &mm_vc_mem_phys_addr,
691 + sizeof (mm_vc_mem_phys_addr)) != 0) {
696 + case VC_MEM_IOC_MEM_SIZE:
698 + // Get the videocore memory size first
701 + pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%u\n", __func__,
704 + if (copy_to_user((void *) arg, &mm_vc_mem_size,
705 + sizeof (mm_vc_mem_size)) != 0) {
710 + case VC_MEM_IOC_MEM_BASE:
712 + // Get the videocore memory base
715 + pr_debug("%s: VC_MEM_IOC_MEM_BASE=%u\n", __func__,
718 + if (copy_to_user((void *) arg, &mm_vc_mem_base,
719 + sizeof (mm_vc_mem_base)) != 0) {
724 + case VC_MEM_IOC_MEM_LOAD:
726 + // Get the videocore memory base
729 + pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%u\n", __func__,
732 + if (copy_to_user((void *) arg, &mm_vc_mem_base,
733 + sizeof (mm_vc_mem_base)) != 0) {
743 + pr_debug("%s: file = 0x%p returning %d\n", __func__, file, rc);
748 +/****************************************************************************
752 +***************************************************************************/
755 +vc_mem_mmap(struct file *filp, struct vm_area_struct *vma)
758 + unsigned long length = vma->vm_end - vma->vm_start;
759 + unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
761 + pr_debug("%s: vm_start = 0x%08lx vm_end = 0x%08lx vm_pgoff = 0x%08lx\n",
762 + __func__, (long) vma->vm_start, (long) vma->vm_end,
763 + (long) vma->vm_pgoff);
765 + if (offset + length > mm_vc_mem_size) {
766 + pr_err("%s: length %ld is too big\n", __func__, length);
769 + // Do not cache the memory map
770 + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
772 + rc = remap_pfn_range(vma, vma->vm_start,
773 + (mm_vc_mem_phys_addr >> PAGE_SHIFT) +
774 + vma->vm_pgoff, length, vma->vm_page_prot);
776 + pr_err("%s: remap_pfn_range failed (rc=%d)\n", __func__, rc);
782 +/****************************************************************************
784 +* File Operations for the driver.
786 +***************************************************************************/
788 +static const struct file_operations vc_mem_fops = {
789 + .owner = THIS_MODULE,
790 + .open = vc_mem_open,
791 + .release = vc_mem_release,
792 + .unlocked_ioctl = vc_mem_ioctl,
793 + .mmap = vc_mem_mmap,
796 +#ifdef CONFIG_DEBUG_FS
797 +static void vc_mem_debugfs_deinit(void)
799 + debugfs_remove_recursive(vc_mem_debugfs_entry);
800 + vc_mem_debugfs_entry = NULL;
804 +static int vc_mem_debugfs_init(
805 + struct device *dev)
807 + vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
808 + if (!vc_mem_debugfs_entry) {
809 + dev_warn(dev, "could not create debugfs entry\n");
813 + if (!debugfs_create_x32("vc_mem_phys_addr",
815 + vc_mem_debugfs_entry,
816 + (u32 *)&mm_vc_mem_phys_addr)) {
817 + dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
822 + if (!debugfs_create_x32("vc_mem_size",
824 + vc_mem_debugfs_entry,
825 + (u32 *)&mm_vc_mem_size)) {
826 + dev_warn(dev, "%s:could not create vc_mem_size entry\n",
831 + if (!debugfs_create_x32("vc_mem_base",
833 + vc_mem_debugfs_entry,
834 + (u32 *)&mm_vc_mem_base)) {
835 + dev_warn(dev, "%s:could not create vc_mem_base entry\n",
843 + vc_mem_debugfs_deinit();
847 +#endif /* CONFIG_DEBUG_FS */
850 +/****************************************************************************
854 +***************************************************************************/
860 + struct device *dev;
862 + pr_debug("%s: called\n", __func__);
864 + mm_vc_mem_phys_addr = phys_addr;
865 + mm_vc_mem_size = mem_size;
866 + mm_vc_mem_base = mem_base;
870 + pr_info("vc-mem: phys_addr:0x%08lx mem_base=0x%08x mem_size:0x%08x(%u MiB)\n",
871 + mm_vc_mem_phys_addr, mm_vc_mem_base, mm_vc_mem_size, mm_vc_mem_size / (1024 * 1024));
873 + if ((rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME)) < 0) {
874 + pr_err("%s: alloc_chrdev_region failed (rc=%d)\n",
879 + cdev_init(&vc_mem_cdev, &vc_mem_fops);
880 + if ((rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1)) != 0) {
881 + pr_err("%s: cdev_add failed (rc=%d)\n", __func__, rc);
882 + goto out_unregister;
885 + vc_mem_class = class_create(THIS_MODULE, DRIVER_NAME);
886 + if (IS_ERR(vc_mem_class)) {
887 + rc = PTR_ERR(vc_mem_class);
888 + pr_err("%s: class_create failed (rc=%d)\n", __func__, rc);
892 + dev = device_create(vc_mem_class, NULL, vc_mem_devnum, NULL,
896 + pr_err("%s: device_create failed (rc=%d)\n", __func__, rc);
897 + goto out_class_destroy;
900 +#ifdef CONFIG_DEBUG_FS
901 + /* don't fail if the debug entries cannot be created */
902 + vc_mem_debugfs_init(dev);
908 + device_destroy(vc_mem_class, vc_mem_devnum);
911 + class_destroy(vc_mem_class);
912 + vc_mem_class = NULL;
915 + cdev_del(&vc_mem_cdev);
918 + unregister_chrdev_region(vc_mem_devnum, 1);
924 +/****************************************************************************
928 +***************************************************************************/
933 + pr_debug("%s: called\n", __func__);
935 + if (vc_mem_inited) {
937 + vc_mem_debugfs_deinit();
939 + device_destroy(vc_mem_class, vc_mem_devnum);
940 + class_destroy(vc_mem_class);
941 + cdev_del(&vc_mem_cdev);
942 + unregister_chrdev_region(vc_mem_devnum, 1);
946 +module_init(vc_mem_init);
947 +module_exit(vc_mem_exit);
948 +MODULE_LICENSE("GPL");
949 +MODULE_AUTHOR("Broadcom Corporation");
951 +module_param(phys_addr, uint, 0644);
952 +module_param(mem_size, uint, 0644);
953 +module_param(mem_base, uint, 0644);
955 +++ b/include/linux/broadcom/vc_mem.h
957 +/*****************************************************************************
958 +* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
960 +* Unless you and Broadcom execute a separate written software license
961 +* agreement governing use of this software, this software is licensed to you
962 +* under the terms of the GNU General Public License version 2, available at
963 +* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
965 +* Notwithstanding the above, under no circumstances may you combine this
966 +* software in any way with any other Broadcom software provided under a
967 +* license other than the GPL, without Broadcom's express prior written
969 +*****************************************************************************/
974 +#include <linux/ioctl.h>
976 +#define VC_MEM_IOC_MAGIC 'v'
978 +#define VC_MEM_IOC_MEM_PHYS_ADDR _IOR( VC_MEM_IOC_MAGIC, 0, unsigned long )
979 +#define VC_MEM_IOC_MEM_SIZE _IOR( VC_MEM_IOC_MAGIC, 1, unsigned int )
980 +#define VC_MEM_IOC_MEM_BASE _IOR( VC_MEM_IOC_MAGIC, 2, unsigned int )
981 +#define VC_MEM_IOC_MEM_LOAD _IOR( VC_MEM_IOC_MAGIC, 3, unsigned int )
983 +#if defined( __KERNEL__ )
984 +#define VC_MEM_TO_ARM_ADDR_MASK 0x3FFFFFFF
986 +extern unsigned long mm_vc_mem_phys_addr;
987 +extern unsigned int mm_vc_mem_size;
988 +extern int vc_mem_get_current_size( void );
991 +#endif /* _VC_MEM_H */