2 * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
4 * Copyright (C) 2004-2006 Nokia Corporation. All rights reserved.
6 * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <linux/major.h>
26 #include <linux/device.h>
27 #include <linux/init.h>
36 static struct class *dsp_ctl_class;
37 extern struct file_operations dsp_ctl_fops,
42 static int dsp_ctl_core_open(struct inode *inode, struct file *file)
44 static DEFINE_MUTEX(open_lock);
47 if (mutex_lock_interruptible(&open_lock))
49 if (omap_dsp->initialized == 0) {
50 ret = dsp_late_init();
52 mutex_unlock(&open_lock);
55 omap_dsp->initialized = 1;
57 mutex_unlock(&open_lock);
59 switch (iminor(inode)) {
61 file->f_op = &dsp_ctl_fops;
64 file->f_op = &dsp_mem_fops;
67 file->f_op = &dsp_twch_fops;
70 file->f_op = &dsp_err_fops;
75 if (file->f_op && file->f_op->open)
76 return file->f_op->open(inode, file);
80 static struct file_operations dsp_ctl_core_fops = {
82 .open = dsp_ctl_core_open,
85 static const struct dev_list {
90 {CTL_MINOR, "dspctl", S_IRUSR | S_IWUSR},
91 {MEM_MINOR, "dspmem", S_IRUSR | S_IWUSR | S_IRGRP},
92 {TWCH_MINOR, "dsptwch", S_IRUSR | S_IWUSR | S_IRGRP},
93 {ERR_MINOR, "dsperr", S_IRUSR | S_IRGRP},
96 int __init dsp_ctl_core_init(void)
101 retval = register_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl",
105 "omapdsp: failed to register dspctl device: %d\n",
110 dsp_ctl_class = class_create(THIS_MODULE, "dspctl");
111 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
112 device_create(dsp_ctl_class, NULL,
113 MKDEV(OMAP_DSP_CTL_MAJOR,
115 dev_list[i].devname);
121 void dsp_ctl_core_exit(void)
125 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
126 device_destroy(dsp_ctl_class,
127 MKDEV(OMAP_DSP_CTL_MAJOR,
130 class_destroy(dsp_ctl_class);
132 unregister_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl");