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 interrupt handler for the shared memory Bridge channel manager.
76 * Calls the Bridge's chnlsm_isr to determine if this interrupt is ours,
77 * then schedules a DPC to dispatch I/O.
79 * ref_data: Pointer to the channel manager object for this board.
80 * Set in an initial call to ISR_Install().
82 * TRUE if interrupt handled; FALSE otherwise.
84 * Must be in locked memory if executing in kernel mode.
85 * Must only call functions which are in locked memory if Kernel mode.
86 * Must only call asynchronous services.
87 * Interrupts are disabled and EOI for this interrupt has been sent.
90 void io_mbox_msg(u32 msg);
93 * ======== io_request_chnl ========
95 * Request I/O from the DSP. Sets flags in shared memory, then interrupts
98 * hio_mgr: IO manager handle.
99 * pchnl: Ptr to the channel requesting I/O.
100 * io_mode: Mode of channel: {IO_INPUT | IO_OUTPUT}.
106 extern void io_request_chnl(struct io_mgr *io_manager,
107 struct chnl_object *pchnl,
108 u8 io_mode, u16 *mbx_val);
111 * ======== iosm_schedule ========
113 * Schedule DPC for IO.
115 * pio_mgr: Ptr to a I/O manager.
121 extern void iosm_schedule(struct io_mgr *io_manager);
124 * DSP-DMA IO functions
128 * ======== io_ddma_init_chnl_desc ========
130 * Initialize DSP DMA channel descriptor.
132 * hio_mgr: Handle to a I/O manager.
133 * ddma_chnl_id: DDMA channel identifier.
134 * num_desc: Number of buffer descriptors(equals # of IOReqs &
139 * ddma_chnl_id < DDMA_MAXDDMACHNLS
146 extern void io_ddma_init_chnl_desc(struct io_mgr *hio_mgr, u32 ddma_chnl_id,
147 u32 num_desc, void *dsp);
150 * ======== io_ddma_clear_chnl_desc ========
152 * Clear DSP DMA channel descriptor.
154 * hio_mgr: Handle to a I/O manager.
155 * ddma_chnl_id: DDMA channel identifier.
158 * ddma_chnl_id < DDMA_MAXDDMACHNLS
161 extern void io_ddma_clear_chnl_desc(struct io_mgr *hio_mgr, u32 ddma_chnl_id);
164 * ======== io_ddma_request_chnl ========
166 * Request channel DSP-DMA from the DSP. Sets up SM descriptors and
167 * control fields in shared memory.
169 * hio_mgr: Handle to a I/O manager.
170 * pchnl: Ptr to channel object
171 * chnl_packet_obj: Ptr to channel i/o request packet.
175 * pchnl->cio_reqs > 0
176 * chnl_packet_obj != NULL
179 extern void io_ddma_request_chnl(struct io_mgr *hio_mgr,
180 struct chnl_object *pchnl,
181 struct chnl_irp *chnl_packet_obj,
185 * Zero-copy IO functions
189 * ======== io_ddzc_init_chnl_desc ========
191 * Initialize ZCPY channel descriptor.
193 * hio_mgr: Handle to a I/O manager.
194 * zid: zero-copy channel identifier.
197 * ddma_chnl_id < DDMA_MAXZCPYCHNLS
201 extern void io_ddzc_init_chnl_desc(struct io_mgr *hio_mgr, u32 zid);
204 * ======== io_ddzc_clear_chnl_desc ========
206 * Clear DSP ZC channel descriptor.
208 * hio_mgr: Handle to a I/O manager.
209 * ch_id: ZC channel identifier.
213 * ch_id < DDMA_MAXZCPYCHNLS
216 extern void io_ddzc_clear_chnl_desc(struct io_mgr *hio_mgr, u32 ch_id);
219 * ======== io_ddzc_request_chnl ========
221 * Request zero-copy channel transfer. Sets up SM descriptors and
222 * control fields in shared memory.
224 * hio_mgr: Handle to a I/O manager.
225 * pchnl: Ptr to channel object
226 * chnl_packet_obj: Ptr to channel i/o request packet.
230 * pchnl->cio_reqs > 0
231 * chnl_packet_obj != NULL
234 extern void io_ddzc_request_chnl(struct io_mgr *hio_mgr,
235 struct chnl_object *pchnl,
236 struct chnl_irp *chnl_packet_obj,
240 * ======== io_sh_msetting ========
242 * Sets the shared memory setting
244 * hio_mgr: Handle to a I/O manager.
245 * desc: Shared memory type
246 * pargs: Ptr to shm setting
253 extern int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void *pargs);
256 * Misc functions for the CHNL_IO shared memory library:
259 /* Maximum channel bufsize that can be used. */
260 extern u32 io_buf_size(struct io_mgr *hio_mgr);
262 extern u32 io_read_value(struct bridge_dev_context *dev_ctxt, u32 dsp_addr);
264 extern void io_write_value(struct bridge_dev_context *dev_ctxt,
265 u32 dsp_addr, u32 value);
267 extern u32 io_read_value_long(struct bridge_dev_context *dev_ctxt,
270 extern void io_write_value_long(struct bridge_dev_context *dev_ctxt,
271 u32 dsp_addr, u32 value);
273 extern void io_or_set_value(struct bridge_dev_context *dev_ctxt,
274 u32 dsp_addr, u32 value);
276 extern void io_and_set_value(struct bridge_dev_context *dev_ctxt,
277 u32 dsp_addr, u32 value);
279 extern void io_sm_init(void);
281 #ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
283 * ========print_dsp_trace_buffer ========
284 * Print DSP tracebuffer.
286 extern int print_dsp_trace_buffer(struct bridge_dev_context
289 int dump_dsp_stack(struct bridge_dev_context *bridge_context);
291 void dump_dl_modules(struct bridge_dev_context *bridge_context);
294 #if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG)
295 void print_dsp_debug_trace(struct io_mgr *hio_mgr);