4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * IO dispatcher for a shared memory channel driver.
7 * Also, includes macros to simulate shm via port io calls.
9 * Copyright (C) 2005-2006 Texas Instruments, Inc.
11 * This package is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 #include <dspbridge/_chnl_sm.h>
24 #include <dspbridge/host_os.h>
26 #include <dspbridge/iodefs.h>
31 #define IO_MAXSERVICE IO_SERVICE
33 #ifdef CONFIG_TIDSPBRIDGE_DVFS
34 /* The maximum number of OPPs that are supported */
35 extern s32 dsp_max_opps;
36 /* The Vdd1 opp table information */
37 extern u32 vdd1_dsp_freq[6][4];
41 * ======== io_cancel_chnl ========
43 * Cancel IO on a given channel.
45 * hio_mgr: IO Manager.
46 * chnl: Index of channel to cancel IO on.
52 extern void io_cancel_chnl(struct io_mgr *hio_mgr, u32 chnl);
55 * ======== io_dpc ========
57 * Deferred procedure call for shared memory channel driver ISR. Carries
58 * out the dispatch of I/O.
60 * ref_data: Pointer to reference data registered via a call to
65 * Must not acquire resources.
66 * All data touched must be locked in memory if running in kernel mode.
68 * Non-preemptible (but interruptible).
70 extern void io_dpc(unsigned long ref_data);
73 * ======== io_mbox_msg ========
75 * Main message handler for the shared memory Bridge channel manager.
76 * Determine if this message is ours, then schedules a DPC to
79 * self: Pointer to its own notifier_block struct.
80 * len: Length of message.
81 * msg: Message code received.
83 * NOTIFY_OK if handled; NOTIFY_BAD otherwise.
85 int io_mbox_msg(struct notifier_block *self, unsigned long len, void *msg);
88 * ======== io_request_chnl ========
90 * Request I/O from the DSP. Sets flags in shared memory, then interrupts
93 * hio_mgr: IO manager handle.
94 * pchnl: Ptr to the channel requesting I/O.
95 * io_mode: Mode of channel: {IO_INPUT | IO_OUTPUT}.
101 extern void io_request_chnl(struct io_mgr *io_manager,
102 struct chnl_object *pchnl,
103 u8 io_mode, u16 *mbx_val);
106 * ======== iosm_schedule ========
108 * Schedule DPC for IO.
110 * pio_mgr: Ptr to a I/O manager.
116 extern void iosm_schedule(struct io_mgr *io_manager);
119 * DSP-DMA IO functions
123 * ======== io_ddma_init_chnl_desc ========
125 * Initialize DSP DMA channel descriptor.
127 * hio_mgr: Handle to a I/O manager.
128 * ddma_chnl_id: DDMA channel identifier.
129 * num_desc: Number of buffer descriptors(equals # of IOReqs &
134 * ddma_chnl_id < DDMA_MAXDDMACHNLS
141 extern void io_ddma_init_chnl_desc(struct io_mgr *hio_mgr, u32 ddma_chnl_id,
142 u32 num_desc, void *dsp);
145 * ======== io_ddma_clear_chnl_desc ========
147 * Clear DSP DMA channel descriptor.
149 * hio_mgr: Handle to a I/O manager.
150 * ddma_chnl_id: DDMA channel identifier.
153 * ddma_chnl_id < DDMA_MAXDDMACHNLS
156 extern void io_ddma_clear_chnl_desc(struct io_mgr *hio_mgr, u32 ddma_chnl_id);
159 * ======== io_ddma_request_chnl ========
161 * Request channel DSP-DMA from the DSP. Sets up SM descriptors and
162 * control fields in shared memory.
164 * hio_mgr: Handle to a I/O manager.
165 * pchnl: Ptr to channel object
166 * chnl_packet_obj: Ptr to channel i/o request packet.
170 * pchnl->cio_reqs > 0
171 * chnl_packet_obj != NULL
174 extern void io_ddma_request_chnl(struct io_mgr *hio_mgr,
175 struct chnl_object *pchnl,
176 struct chnl_irp *chnl_packet_obj,
180 * Zero-copy IO functions
184 * ======== io_ddzc_init_chnl_desc ========
186 * Initialize ZCPY channel descriptor.
188 * hio_mgr: Handle to a I/O manager.
189 * zid: zero-copy channel identifier.
192 * ddma_chnl_id < DDMA_MAXZCPYCHNLS
196 extern void io_ddzc_init_chnl_desc(struct io_mgr *hio_mgr, u32 zid);
199 * ======== io_ddzc_clear_chnl_desc ========
201 * Clear DSP ZC channel descriptor.
203 * hio_mgr: Handle to a I/O manager.
204 * ch_id: ZC channel identifier.
208 * ch_id < DDMA_MAXZCPYCHNLS
211 extern void io_ddzc_clear_chnl_desc(struct io_mgr *hio_mgr, u32 ch_id);
214 * ======== io_ddzc_request_chnl ========
216 * Request zero-copy channel transfer. Sets up SM descriptors and
217 * control fields in shared memory.
219 * hio_mgr: Handle to a I/O manager.
220 * pchnl: Ptr to channel object
221 * chnl_packet_obj: Ptr to channel i/o request packet.
225 * pchnl->cio_reqs > 0
226 * chnl_packet_obj != NULL
229 extern void io_ddzc_request_chnl(struct io_mgr *hio_mgr,
230 struct chnl_object *pchnl,
231 struct chnl_irp *chnl_packet_obj,
235 * ======== io_sh_msetting ========
237 * Sets the shared memory setting
239 * hio_mgr: Handle to a I/O manager.
240 * desc: Shared memory type
241 * pargs: Ptr to shm setting
248 extern int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void *pargs);
251 * Misc functions for the CHNL_IO shared memory library:
254 /* Maximum channel bufsize that can be used. */
255 extern u32 io_buf_size(struct io_mgr *hio_mgr);
257 extern u32 io_read_value(struct bridge_dev_context *dev_ctxt, u32 dsp_addr);
259 extern void io_write_value(struct bridge_dev_context *dev_ctxt,
260 u32 dsp_addr, u32 value);
262 extern u32 io_read_value_long(struct bridge_dev_context *dev_ctxt,
265 extern void io_write_value_long(struct bridge_dev_context *dev_ctxt,
266 u32 dsp_addr, u32 value);
268 extern void io_or_set_value(struct bridge_dev_context *dev_ctxt,
269 u32 dsp_addr, u32 value);
271 extern void io_and_set_value(struct bridge_dev_context *dev_ctxt,
272 u32 dsp_addr, u32 value);
274 extern void io_sm_init(void);
276 #ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
278 * ========print_dsp_trace_buffer ========
279 * Print DSP tracebuffer.
281 extern int print_dsp_trace_buffer(struct bridge_dev_context
284 int dump_dsp_stack(struct bridge_dev_context *bridge_context);
286 void dump_dl_modules(struct bridge_dev_context *bridge_context);
289 #if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG)
290 void print_dsp_debug_trace(struct io_mgr *hio_mgr);