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 mutex_lock_interruptible(&open_lock);
47 if (omap_dsp->initialized == 0) {
48 ret = dsp_late_init();
50 mutex_unlock(&open_lock);
53 omap_dsp->initialized = 1;
55 mutex_unlock(&open_lock);
57 switch (iminor(inode)) {
59 file->f_op = &dsp_ctl_fops;
62 file->f_op = &dsp_mem_fops;
65 file->f_op = &dsp_twch_fops;
68 file->f_op = &dsp_err_fops;
73 if (file->f_op && file->f_op->open)
74 return file->f_op->open(inode, file);
78 static struct file_operations dsp_ctl_core_fops = {
80 .open = dsp_ctl_core_open,
83 static const struct dev_list {
88 {CTL_MINOR, "dspctl", S_IRUSR | S_IWUSR},
89 {MEM_MINOR, "dspmem", S_IRUSR | S_IWUSR | S_IRGRP},
90 {TWCH_MINOR, "dsptwch", S_IRUSR | S_IWUSR | S_IRGRP},
91 {ERR_MINOR, "dsperr", S_IRUSR | S_IRGRP},
94 int __init dsp_ctl_core_init(void)
99 retval = register_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl",
103 "omapdsp: failed to register dspctl device: %d\n",
108 dsp_ctl_class = class_create(THIS_MODULE, "dspctl");
109 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
110 class_device_create(dsp_ctl_class, NULL,
111 MKDEV(OMAP_DSP_CTL_MAJOR,
113 NULL, dev_list[i].devname);
119 void dsp_ctl_core_exit(void)
123 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
124 class_device_destroy(dsp_ctl_class,
125 MKDEV(OMAP_DSP_CTL_MAJOR,
128 class_destroy(dsp_ctl_class);
130 unregister_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl");