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>
35 static struct class *dsp_ctl_class;
36 extern struct file_operations dsp_ctl_fops,
41 static int dsp_ctl_core_open(struct inode *inode, struct file *file)
43 static DEFINE_MUTEX(open_lock);
46 if (mutex_lock_interruptible(&open_lock))
48 if (omap_dsp->initialized == 0) {
49 ret = dsp_late_init();
51 mutex_unlock(&open_lock);
54 omap_dsp->initialized = 1;
56 mutex_unlock(&open_lock);
58 switch (iminor(inode)) {
60 file->f_op = &dsp_ctl_fops;
63 file->f_op = &dsp_mem_fops;
66 file->f_op = &dsp_twch_fops;
69 file->f_op = &dsp_err_fops;
74 if (file->f_op && file->f_op->open)
75 return file->f_op->open(inode, file);
79 static struct file_operations dsp_ctl_core_fops = {
81 .open = dsp_ctl_core_open,
84 static const struct dev_list {
89 {CTL_MINOR, "dspctl", S_IRUSR | S_IWUSR},
90 {MEM_MINOR, "dspmem", S_IRUSR | S_IWUSR | S_IRGRP},
91 {TWCH_MINOR, "dsptwch", S_IRUSR | S_IWUSR | S_IRGRP},
92 {ERR_MINOR, "dsperr", S_IRUSR | S_IRGRP},
95 int __init dsp_ctl_core_init(void)
100 retval = register_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl",
104 "omapdsp: failed to register dspctl device: %d\n",
109 dsp_ctl_class = class_create(THIS_MODULE, "dspctl");
110 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
111 device_create(dsp_ctl_class, NULL,
112 MKDEV(OMAP_DSP_CTL_MAJOR,
114 dev_list[i].devname);
120 void dsp_ctl_core_exit(void)
124 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
125 device_destroy(dsp_ctl_class,
126 MKDEV(OMAP_DSP_CTL_MAJOR,
129 class_destroy(dsp_ctl_class);
131 unregister_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl");