/* $Header: /korea/src/ccd_utilities/device_driver/Solaris/Rev1/RCS/astro_impl.h,v 1.3 1998/05/08 18:07:18 lopez Exp $ */ /* astro_impl.h Private implementation details Warning: Not for general consumption. */ #ifndef __astro_impl_h__ #define __astro_impl_h__ #include /* This is the ID string stored in the FCode PROM */ /* At bootup/autoconfigure, the '|' causes problems */ /* so has been replaced in newer PROMS with ',' */ /* The identify routine should accept either one */ const char prom_id_string_one[] = "SDSU|astr"; const char prom_id_string_two[] = "astr"; const char prom_id_string_three[] = "SDSUastro"; /* Interface card device registers as they appear on the SBus */ /* register set #0 */ struct astro_regs { volatile long csr; /* control/status register */ volatile long ar; /* address register */ volatile long bcr; /* byte count register */ volatile long unused; /* actually used as a transmission register */ volatile long extra1; volatile long extra2; volatile long extra3; volatile long ww; /* word width register */ }; static ddi_device_acc_attr_t access_attr = { DDI_DEVICE_ATTR_V0, DDI_STRUCTURE_BE_ACC, DDI_STRICTORDER_ACC }; static ddi_dma_attr_t dma_attrs = { DMA_ATTR_V0, /* version number, Solaris default */ (unsigned long long)0x0, /* low address */ (unsigned long long)0xffffffff, /* high address */ (unsigned long long)0xffffff, /* byte counter max */ (unsigned long long)0x04, /* alignment 4b */ 0x17, /* burst size of 1,2,4,16 */ 0x1, /* min transfer size */ (unsigned long long)0x1fffffe0, /* max transfer size 512Mb */ (unsigned long long)0xffffff, /* address counter max */ -1, /* scatter/gather list lgth*/ 16, /* granularity 16b */ 0 /* flags, Solaris default */ }; /* register set #1 */ struct Dchan_regs { volatile u_long dr[256]; }; /* register set #2 */ struct Echan_regs { volatile u_short er[1024]; }; /* LSI DMAC+ (L64853A) control/status register (csr) bits (in all cases: true = 1, false = 0) 0: ro interrupt pending 1: ro error pending 2: ro draining 3: ro draining 4: rw interrupt enable 5: wo flush buffer 6: rw slave error 7: rw reset dma 8: rw memory read/write 9: rw enable dma 10--12: ro unused == 0 13: rw enable counter 14: ro terminal count 15: rw reserved (always write 0 to this bit) 16--19: ro unused == 0 20: rw address latch enable/address strobe 21: ro lance error 22: rw faster 23: rw tc interrupt disable 24: rw enable next 25: ro dma on 26: ro address loaded 27: ro next address loaded 28--31: ro device id == 1001 (ro = read only, rw = read or write, wo = write only) */ const u_long dmac_int_pend = 0x00000001; const u_long dmac_err_pend = 0x00000002; const u_long dmac_draining = 0x0000000c; const u_long dmac_int_en = 0x00000010; const u_long dmac_flush = 0x00000020; const u_long dmac_slave_err = 0x00000040; const u_long dmac_reset = 0x00000080; const u_long dmac_write = 0x00000100; const u_long dmac_en_dma = 0x00000200; const u_long dmac_en_cnt = 0x00002000; const u_long dmac_tc = 0x00004000; const u_long dmac_ale_as = 0x00100000; const u_long dmac_faster = 0x00400000; const u_long dmac_tci_dis = 0x00800000; const u_long dmac_en_next = 0x01000000; const u_long dmac_dma_on = 0x02000000; const u_long dmac_a_loaded = 0x04000000; const u_long dmac_na_loaded = 0x08000000; /* Image buffer */ struct image_buf { caddr_t address; int operation; u_int size; u_int length; u_int state; u_int det_state; ddi_dma_cookie_t buf_cookie; ddi_dma_handle_t buf_handle; ddi_acc_handle_t data_access_handle; }; /* Driver state structure. All state variables related to the state of the driver are kept in here. */ struct astro_state { dev_info_t *dip; /* pointer to devices dev_info node */ struct astro_regs *regp; /* register set #0 */ struct Dchan_regs *dchan; struct Echan_regs *echan; volatile int open; /* flag set when driver opened */ volatile int busy; /* set when transfers in progress */ volatile int want; /* set when waiting threads want signal */ /* interrupt control `cookie's */ ddi_iblock_cookie_t iblock_cookie; ddi_idevice_cookie_t idevice_cookie; /* dma buffers */ struct buf *bp; ddi_dma_handle_t handle; struct image_buf image_buf[3]; int buf_numbusy; int buf_numwaiting; int buf_done; int buf_ready; int buf_busy; int buf_waiting; /* thread locking and synchronization */ kmutex_t mu; /* mutual exclusion lock */ kcondvar_t cv; /* synchronization condition variable */ kcondvar_t bufcv; /* image_buf synchronization condition variable */ unsigned int ddic; /* critical region cookie */ int byteremain; /* size of transfer remaining to be transfered */ ddi_acc_handle_t reg_access_handle; /* register access handle */ int timeout; /* not used at this time */ }; /* dma engine limitations */ static ddi_dma_lim_t dma_limits = { 0x00000000, /* low address */ 0xffffffff, /* high address */ 0x00ffffff, /* maximum counter value */ 0x17, /* burst sizes 1, 2, 4, 16 */ 0x1, /* minimum effective transfer size */ 0, /* ? */ /* average speed KBytes/s */ }; const int astro_max_dma = 0xffffff; /* Time out a transfer if no dma interrupt occurrs within this time. */ /* Must be at least long enough to transfer minphys bytes. The timer */ /* is restarted for each new block during a large transfer. */ const int dma_read_timeout_usec = 60000000; /* 60.0 secs */ const int image_buf_size = 64512; const int image_buf_error = 0; const int image_buf_done = 1; const int image_buf_ready = 2; const int image_buf_busy = 3; const int image_buf_waiting = 4; /* Definitions of the errors occurred during the data transfer */ #define DEVICE_NOT_BUSY 5 #define DATA_TRANS_ERROR 6 #define IMAGE_BUF_NOT_BUSY 7 #define TIMED_OUT 8 #define BAD_INTERRUPT 9 #define TDL_SIZE 8 volatile u_long readback; #endif /* !__astro_impl_h__ */ /*--------------------8-->----cut--here----<--8--------------------*/ /* * $Log: astro_impl.h,v $ * Revision 1.3 1998/05/08 18:07:18 lopez * Removed some useless #define's, CAPITALIZED some constant names, and * added a $Header$ and a $Log$. * */