]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/dsp/dsp_common.h
ARM: OMAP: DSPGW: Use device model
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / dsp / dsp_common.h
1 /*
2  * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
3  *
4  * Copyright (C) 2002-2006 Nokia Corporation. All rights reserved.
5  *
6  * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@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 #ifndef DRIVER_DSP_COMMON_H
25 #define DRIVER_DSP_COMMON_H
26
27 #include "hardware_dsp.h"
28
29 #define DSPSPACE_SIZE   0x1000000
30
31 #define omap_set_bit_regw(b,r) \
32         do { omap_writew(omap_readw(r) | (b), (r)); } while(0)
33 #define omap_clr_bit_regw(b,r) \
34         do { omap_writew(omap_readw(r) & ~(b), (r)); } while(0)
35 #define omap_set_bit_regl(b,r) \
36         do { omap_writel(omap_readl(r) | (b), (r)); } while(0)
37 #define omap_clr_bit_regl(b,r) \
38         do { omap_writel(omap_readl(r) & ~(b), (r)); } while(0)
39 #define omap_set_bits_regl(val,mask,r) \
40         do { omap_writel((omap_readl(r) & ~(mask)) | (val), (r)); } while(0)
41
42 #define dspword_to_virt(dw)     ((void *)(dspmem_base + ((dw) << 1)))
43 #define dspbyte_to_virt(db)     ((void *)(dspmem_base + (db)))
44 #define virt_to_dspword(va) \
45         ((dsp_long_t)(((unsigned long)(va) - dspmem_base) >> 1))
46 #define virt_to_dspbyte(va) \
47         ((dsp_long_t)((unsigned long)(va) - dspmem_base))
48 #define is_dsp_internal_mem(va) \
49         (((unsigned long)(va) >= dspmem_base) &&  \
50          ((unsigned long)(va) < dspmem_base + dspmem_size))
51 #define is_dspbyte_internal_mem(db)     ((db) < dspmem_size)
52 #define is_dspword_internal_mem(dw)     (((dw) << 1) < dspmem_size)
53
54 #ifdef CONFIG_ARCH_OMAP1
55 /*
56  * MPUI byteswap/wordswap on/off
57  *   default setting: wordswap = all, byteswap = APIMEM only
58  */
59 #define mpui_wordswap_on() \
60         omap_set_bits_regl(MPUI_CTRL_WORDSWAP_ALL, MPUI_CTRL_WORDSWAP_MASK, \
61                            MPUI_CTRL)
62
63 #define mpui_wordswap_off() \
64         omap_set_bits_regl(MPUI_CTRL_WORDSWAP_NONE, MPUI_CTRL_WORDSWAP_MASK, \
65                            MPUI_CTRL)
66
67 #define mpui_byteswap_on() \
68         omap_set_bits_regl(MPUI_CTRL_BYTESWAP_API, MPUI_CTRL_BYTESWAP_MASK, \
69                            MPUI_CTRL)
70
71 #define mpui_byteswap_off() \
72         omap_set_bits_regl(MPUI_CTRL_BYTESWAP_NONE, MPUI_CTRL_BYTESWAP_MASK, \
73                            MPUI_CTRL)
74
75 /*
76  * TC wordswap on / off
77  */
78 #define tc_wordswap() \
79         do { \
80                 omap_writel(TC_ENDIANISM_SWAP_WORD | TC_ENDIANISM_EN, \
81                             TC_ENDIANISM); \
82         } while(0)
83
84 #define tc_noswap()     omap_clr_bit_regl(TC_ENDIANISM_EN, TC_ENDIANISM)
85
86 /*
87  * enable priority registers, EMIF, MPUI control logic
88  */
89 #define __dsp_enable()  omap_set_bit_regw(ARM_RSTCT1_DSP_RST, ARM_RSTCT1)
90 #define __dsp_disable() omap_clr_bit_regw(ARM_RSTCT1_DSP_RST, ARM_RSTCT1)
91 #define __dsp_run()     omap_set_bit_regw(ARM_RSTCT1_DSP_EN, ARM_RSTCT1)
92 #define __dsp_reset()   omap_clr_bit_regw(ARM_RSTCT1_DSP_EN, ARM_RSTCT1)
93 #endif /* CONFIG_ARCH_OMAP1 */
94
95 #ifdef CONFIG_ARCH_OMAP2
96 /*
97  * PRCM / IPI control logic
98  */
99 #define RSTCTRL_RST1_DSP        0x00000001
100 #define RSTCTRL_RST2_DSP        0x00000002
101 #define __dsp_core_enable() \
102         do { RM_RSTCTRL_DSP &= ~RSTCTRL_RST1_DSP; } while (0)
103 #define __dsp_core_disable() \
104         do { RM_RSTCTRL_DSP |= RSTCTRL_RST1_DSP; } while (0)
105 #define __dsp_per_enable() \
106         do { RM_RSTCTRL_DSP &= ~RSTCTRL_RST2_DSP; } while (0)
107 #define __dsp_per_disable() \
108         do { RM_RSTCTRL_DSP |= RSTCTRL_RST2_DSP; } while (0)
109 #endif /* CONFIG_ARCH_OMAP2 */
110
111 typedef u32 dsp_long_t; /* must have ability to carry TADD_ABORTADR */
112
113 #if defined(CONFIG_ARCH_OMAP1)
114 extern struct clk *dsp_ck_handle;
115 extern struct clk *api_ck_handle;
116 #elif defined(CONFIG_ARCH_OMAP2)
117 extern struct clk *dsp_fck_handle;
118 extern struct clk *dsp_ick_handle;
119 #endif
120 extern dsp_long_t dspmem_base, dspmem_size,
121                   daram_base, daram_size,
122                   saram_base, saram_size;
123
124 enum cpustat_e {
125         CPUSTAT_RESET = 0,
126 #ifdef CONFIG_ARCH_OMAP1
127         CPUSTAT_GBL_IDLE,
128         CPUSTAT_CPU_IDLE,
129 #endif
130         CPUSTAT_RUN,
131         CPUSTAT_MAX
132 };
133
134 int dsp_set_rstvect(dsp_long_t adr);
135 dsp_long_t dsp_get_rstvect(void);
136 #ifdef CONFIG_ARCH_OMAP1
137 void dsp_set_idle_boot_base(dsp_long_t adr, size_t size);
138 void dsp_reset_idle_boot_base(void);
139 #endif
140 void dsp_cpustat_request(enum cpustat_e req);
141 enum cpustat_e dsp_cpustat_get_stat(void);
142 u16 dsp_cpustat_get_icrmask(void);
143 void dsp_cpustat_set_icrmask(u16 mask);
144 #ifdef CONFIG_ARCH_OMAP1
145 void dsp_register_mem_cb(int (*req_cb)(void), void (*rel_cb)(void));
146 void dsp_unregister_mem_cb(void);
147 #endif
148
149 #if defined(CONFIG_ARCH_OMAP1)
150 static inline void dsp_clk_autoidle(void) {}
151 #elif defined(CONFIG_ARCH_OMAP2)
152 static inline void dsp_clk_autoidle(void)
153 {
154         /*XXX should be handled in mach-omap[1,2] XXX*/
155         PM_PWSTCTRL_DSP = (1 << 18) | (1 << 0);
156         CM_AUTOIDLE_DSP |= (1 << 1);
157         CM_CLKSTCTRL_DSP |= (1 << 0);
158 }
159 #endif
160
161 extern int dsp_mmu_irq;
162
163 #endif /* DRIVER_DSP_COMMON_H */