]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-n800-dsp.c
ARM: OMAP: Merge board specific files from N800 tree
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-n800-dsp.c
1 /*
2  * linux/arch/arm/mach-omap2/board-n800-dsp.c
3  *
4  * Copyright (C) 2006 Nokia Corporation.
5  *
6  * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
7  *
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.
11  *
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.
16  *
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
20  * 02110-1301 USA
21  *
22  */
23
24 #include <linux/kernel.h>
25 #include <linux/device.h>
26 #include <linux/list.h>
27 #include <linux/err.h>
28 #include <linux/clk.h>
29
30 #include <asm/io.h>
31 #include <asm/arch/clock.h>
32
33 #include "../plat-omap/dsp/dsp_common.h"
34
35 extern int n800_audio_enable(struct dsp_kfunc_device *kdev, int stage);
36 extern int n800_audio_disable(struct dsp_kfunc_device *kdev, int stage);
37
38 #if     defined(CONFIG_OMAP_DSP)
39
40 /*
41  * dsp peripheral device: AUDIO
42  */
43 static struct dsp_kfunc_device n800_audio_device = {
44         .name    = "audio",
45         .type    = DSP_KFUNC_DEV_TYPE_AUDIO,
46         .enable  = n800_audio_enable,
47         .disable = n800_audio_disable,
48 };
49
50 /*
51  * dsp peripheral device: TIMER
52  */
53 static int dsp_timer_probe(struct dsp_kfunc_device *kdev)
54 {
55         char clockname[20];
56
57         strcpy(clockname, kdev->name);
58         strcat(clockname, "_fck");
59
60         kdev->fck = clk_get(NULL, clockname);
61         if (IS_ERR(kdev->fck)) {
62                 printk(KERN_ERR "couldn't acquire %s\n", clockname);
63                 return PTR_ERR(kdev->fck);
64         }
65         pr_debug("%s probed successfully\n", clockname);
66
67         strcpy(clockname, kdev->name);
68         strcat(clockname, "_ick");
69         kdev->ick = clk_get(NULL, clockname);
70         if (IS_ERR(kdev->ick)) {
71                 printk(KERN_ERR "couldn't acquire %s\n", clockname);
72                 goto fail;
73         }
74         pr_debug("%s probed successfully\n", clockname);
75
76         return 0;
77  fail:
78         clk_put(kdev->fck);
79
80         return PTR_ERR(kdev->ick);
81 }
82
83 static int dsp_timer_remove(struct dsp_kfunc_device *kdev)
84 {
85         clk_put(kdev->ick);
86         clk_put(kdev->fck);
87         pr_debug("%s removed successfully\n", kdev->name);
88         return 0;
89 }
90
91 static int dsp_timer_enable(struct dsp_kfunc_device *kdev, int stage)
92 {
93         pr_debug("%s enabled(%d)\n", kdev->name, stage);
94
95         mutex_lock(&kdev->lock);
96
97         if (kdev->enabled)
98                 goto out;
99         kdev->enabled = 1;
100
101         clk_enable(kdev->fck);
102         clk_enable(kdev->ick);
103  out:
104         mutex_unlock(&kdev->lock);
105
106         return 0;
107 }
108
109 static int dsp_timer_disable(struct dsp_kfunc_device *kdev, int stage)
110 {
111         pr_debug("%s disabled(%d)\n", kdev->name, stage);
112
113         mutex_lock(&kdev->lock);
114
115         if (kdev->enabled == 0)
116                 goto out;
117         kdev->enabled = 0;
118
119         clk_disable(kdev->ick);
120         clk_disable(kdev->fck);
121  out:
122         mutex_unlock(&kdev->lock);
123
124         return 0;
125 }
126
127 static struct dsp_kfunc_device n800_timer_device = {
128         .name    = "gpt5",
129         .type    = DSP_KFUNC_DEV_TYPE_COMMON,
130         .probe   = dsp_timer_probe,
131         .remove  = dsp_timer_remove,
132         .enable  = dsp_timer_enable,
133         .disable = dsp_timer_disable,
134 };
135
136 static struct dsp_kfunc_device *n800_kfunc_dev[] = {
137         &n800_audio_device,
138         &n800_timer_device,
139 };
140
141 void __init n800_dsp_init(void)
142 {
143         int i, ret;
144         struct dsp_kfunc_device **p = n800_kfunc_dev;
145
146         for (i = 0; i < ARRAY_SIZE(n800_kfunc_dev); i++) {
147                 ret = dsp_kfunc_device_register(p[i]);
148                 if (ret) {
149                         printk(KERN_ERR
150                                "KFUNC device registration failed: %s\n",
151                                p[i]->name);
152                 }
153         }
154 }
155
156 #else
157 void __init n800_dsp_init(void) { }
158 #endif  /* CONFIG_OMAP_DSP */