1/* 2 * io_sm.h 3 * 4 * DSP-BIOS Bridge driver support functions for TI OMAP processors. 5 * 6 * IO dispatcher for a shared memory channel driver. 7 * Also, includes macros to simulate shm via port io calls. 8 * 9 * Copyright (C) 2005-2006 Texas Instruments, Inc. 10 * 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. 14 * 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. 18 */ 19 20#ifndef IOSM_ 21#define IOSM_ 22 23#include <dspbridge/_chnl_sm.h> 24#include <dspbridge/host_os.h> 25 26#include <dspbridge/iodefs.h> 27 28#define IO_INPUT 0 29#define IO_OUTPUT 1 30#define IO_SERVICE 2 31#define IO_MAXSERVICE IO_SERVICE 32 33#ifdef CONFIG_TIDSPBRIDGE_DVFS 34/* The maximum number of OPPs that are supported */ 35extern s32 dsp_max_opps; 36/* The Vdd1 opp table information */ 37extern u32 vdd1_dsp_freq[6][4]; 38#endif 39 40/* 41 * ======== io_cancel_chnl ======== 42 * Purpose: 43 * Cancel IO on a given channel. 44 * Parameters: 45 * hio_mgr: IO Manager. 46 * chnl: Index of channel to cancel IO on. 47 * Returns: 48 * Requires: 49 * Valid hio_mgr. 50 * Ensures: 51 */ 52extern void io_cancel_chnl(struct io_mgr *hio_mgr, u32 chnl); 53 54/* 55 * ======== io_dpc ======== 56 * Purpose: 57 * Deferred procedure call for shared memory channel driver ISR. Carries 58 * out the dispatch of I/O. 59 * Parameters: 60 * ref_data: Pointer to reference data registered via a call to 61 * DPC_Create(). 62 * Returns: 63 * Requires: 64 * Must not block. 65 * Must not acquire resources. 66 * All data touched must be locked in memory if running in kernel mode. 67 * Ensures: 68 * Non-preemptible (but interruptible). 69 */ 70extern void io_dpc(unsigned long ref_data); 71 72/* 73 * ======== io_mbox_msg ======== 74 * Purpose: 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. 78 * Parameters: 79 * ref_data: Pointer to the channel manager object for this board. 80 * Set in an initial call to ISR_Install(). 81 * Returns: 82 * TRUE if interrupt handled; FALSE otherwise. 83 * Requires: 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. 88 * Ensures: 89 */ 90void io_mbox_msg(u32 msg); 91 92/* 93 * ======== io_request_chnl ======== 94 * Purpose: 95 * Request I/O from the DSP. Sets flags in shared memory, then interrupts 96 * the DSP. 97 * Parameters: 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}. 101 * Returns: 102 * Requires: 103 * pchnl != NULL 104 * Ensures: 105 */ 106extern void io_request_chnl(struct io_mgr *io_manager, 107 struct chnl_object *pchnl, 108 u8 io_mode, u16 *mbx_val); 109 110/* 111 * ======== iosm_schedule ======== 112 * Purpose: 113 * Schedule DPC for IO. 114 * Parameters: 115 * pio_mgr: Ptr to a I/O manager. 116 * Returns: 117 * Requires: 118 * pchnl != NULL 119 * Ensures: 120 */ 121extern void iosm_schedule(struct io_mgr *io_manager); 122 123/* 124 * DSP-DMA IO functions 125 */ 126 127/* 128 * ======== io_ddma_init_chnl_desc ======== 129 * Purpose: 130 * Initialize DSP DMA channel descriptor. 131 * Parameters: 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 & 135 * Chirps) 136 * dsp: Dsp address; 137 * Returns: 138 * Requires: 139 * ddma_chnl_id < DDMA_MAXDDMACHNLS 140 * num_desc > 0 141 * pVa != NULL 142 * pDspPa != NULL 143 * 144 * Ensures: 145 */ 146extern void io_ddma_init_chnl_desc(struct io_mgr *hio_mgr, u32 ddma_chnl_id, 147 u32 num_desc, void *dsp); 148 149/* 150 * ======== io_ddma_clear_chnl_desc ======== 151 * Purpose: 152 * Clear DSP DMA channel descriptor. 153 * Parameters: 154 * hio_mgr: Handle to a I/O manager. 155 * ddma_chnl_id: DDMA channel identifier. 156 * Returns: 157 * Requires: 158 * ddma_chnl_id < DDMA_MAXDDMACHNLS 159 * Ensures: 160 */ 161extern void io_ddma_clear_chnl_desc(struct io_mgr *hio_mgr, u32 ddma_chnl_id); 162 163/* 164 * ======== io_ddma_request_chnl ======== 165 * Purpose: 166 * Request channel DSP-DMA from the DSP. Sets up SM descriptors and 167 * control fields in shared memory. 168 * Parameters: 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. 172 * Returns: 173 * Requires: 174 * pchnl != NULL 175 * pchnl->cio_reqs > 0 176 * chnl_packet_obj != NULL 177 * Ensures: 178 */ 179extern void io_ddma_request_chnl(struct io_mgr *hio_mgr, 180 struct chnl_object *pchnl, 181 struct chnl_irp *chnl_packet_obj, 182 u16 *mbx_val); 183 184/* 185 * Zero-copy IO functions 186 */ 187 188/* 189 * ======== io_ddzc_init_chnl_desc ======== 190 * Purpose: 191 * Initialize ZCPY channel descriptor. 192 * Parameters: 193 * hio_mgr: Handle to a I/O manager. 194 * zid: zero-copy channel identifier. 195 * Returns: 196 * Requires: 197 * ddma_chnl_id < DDMA_MAXZCPYCHNLS 198 * hio_mgr != Null 199 * Ensures: 200 */ 201extern void io_ddzc_init_chnl_desc(struct io_mgr *hio_mgr, u32 zid); 202 203/* 204 * ======== io_ddzc_clear_chnl_desc ======== 205 * Purpose: 206 * Clear DSP ZC channel descriptor. 207 * Parameters: 208 * hio_mgr: Handle to a I/O manager. 209 * ch_id: ZC channel identifier. 210 * Returns: 211 * Requires: 212 * hio_mgr is valid 213 * ch_id < DDMA_MAXZCPYCHNLS 214 * Ensures: 215 */ 216extern void io_ddzc_clear_chnl_desc(struct io_mgr *hio_mgr, u32 ch_id); 217 218/* 219 * ======== io_ddzc_request_chnl ======== 220 * Purpose: 221 * Request zero-copy channel transfer. Sets up SM descriptors and 222 * control fields in shared memory. 223 * Parameters: 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. 227 * Returns: 228 * Requires: 229 * pchnl != NULL 230 * pchnl->cio_reqs > 0 231 * chnl_packet_obj != NULL 232 * Ensures: 233 */ 234extern void io_ddzc_request_chnl(struct io_mgr *hio_mgr, 235 struct chnl_object *pchnl, 236 struct chnl_irp *chnl_packet_obj, 237 u16 *mbx_val); 238 239/* 240 * ======== io_sh_msetting ======== 241 * Purpose: 242 * Sets the shared memory setting 243 * Parameters: 244 * hio_mgr: Handle to a I/O manager. 245 * desc: Shared memory type 246 * pargs: Ptr to shm setting 247 * Returns: 248 * Requires: 249 * hio_mgr != NULL 250 * pargs != NULL 251 * Ensures: 252 */ 253extern int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void *pargs); 254 255/* 256 * Misc functions for the CHNL_IO shared memory library: 257 */ 258 259/* Maximum channel bufsize that can be used. */ 260extern u32 io_buf_size(struct io_mgr *hio_mgr); 261 262extern u32 io_read_value(struct bridge_dev_context *dev_ctxt, u32 dsp_addr); 263 264extern void io_write_value(struct bridge_dev_context *dev_ctxt, 265 u32 dsp_addr, u32 value); 266 267extern u32 io_read_value_long(struct bridge_dev_context *dev_ctxt, 268 u32 dsp_addr); 269 270extern void io_write_value_long(struct bridge_dev_context *dev_ctxt, 271 u32 dsp_addr, u32 value); 272 273extern void io_or_set_value(struct bridge_dev_context *dev_ctxt, 274 u32 dsp_addr, u32 value); 275 276extern void io_and_set_value(struct bridge_dev_context *dev_ctxt, 277 u32 dsp_addr, u32 value); 278 279extern void io_sm_init(void); 280 281#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE 282/* 283 * ========print_dsp_trace_buffer ======== 284 * Print DSP tracebuffer. 285 */ 286extern int print_dsp_trace_buffer(struct bridge_dev_context 287 *hbridge_context); 288 289int dump_dsp_stack(struct bridge_dev_context *bridge_context); 290 291void dump_dl_modules(struct bridge_dev_context *bridge_context); 292 293#endif 294#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG) 295void print_dsp_debug_trace(struct io_mgr *hio_mgr); 296#endif 297 298#endif /* IOSM_ */ 299