root/include/asm-sparc/dma.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. sparc_dma_pause

   1 /* $Id: dma.h,v 1.12 1995/11/25 02:31:34 davem Exp $
   2  * include/asm-sparc/dma.h
   3  *
   4  * Copyright 1995 (C) David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 #ifndef _ASM_SPARC_DMA_H
   8 #define _ASM_SPARC_DMA_H
   9 
  10 #include <linux/kernel.h>
  11 
  12 #include <asm/vac-ops.h>  /* for invalidate's, etc. */
  13 #include <asm/sbus.h>
  14 #include <asm/delay.h>
  15 #include <asm/oplib.h>
  16 
  17 /* These are irrelevant for Sparc DMA, but we leave it in so that
  18  * things can compile.
  19  */
  20 #define MAX_DMA_CHANNELS 8
  21 #define MAX_DMA_ADDRESS  (~0UL)
  22 #define DMA_MODE_READ    1
  23 #define DMA_MODE_WRITE   2
  24 
  25 /* Useful constants */
  26 #define SIZE_16MB      (16*1024*1024)
  27 #define SIZE_64K       (64*1024)
  28 
  29 /* Structure to describe the current status of DMA registers on the Sparc */
  30 struct sparc_dma_registers {
  31   volatile unsigned long cond_reg;   /* DMA condition register */
  32   volatile char * st_addr;           /* Start address of this transfer */
  33   volatile unsigned long cnt;        /* How many bytes to transfer */
  34   volatile unsigned long dma_test;   /* DMA test register */
  35 };
  36 
  37 /* DVMA chip revisions */
  38 enum dvma_rev {
  39         dvmarev0,
  40         dvmaesc1,
  41         dvmarev1,
  42         dvmarev2,
  43         dvmarev3,
  44         dvmarevplus
  45 };
  46 
  47 #define DMA_HASCOUNT(rev)  ((rev)==dvmaesc1)
  48 
  49 /* Linux DMA information structure, filled during probe. */
  50 struct Linux_SBus_DMA {
  51         struct Linux_SBus_DMA *next;
  52         struct linux_sbus_device *SBus_dev;
  53         struct sparc_dma_registers *regs;
  54 
  55         /* Status, misc info */
  56         int node;                /* Prom node for this DMA device */
  57         int running;             /* Are we doing DMA now? */
  58         int allocated;           /* Are we "owned" by anyone yet? */
  59 
  60         /* Transfer information. */
  61         unsigned long addr;      /* Start address of current transfer */
  62         int nbytes;              /* Size of current transfer */
  63         int realbytes;           /* For splitting up large transfers, etc. */
  64 
  65         /* DMA revision */
  66         enum dvma_rev revision;
  67 };
  68 
  69 extern struct Linux_SBus_DMA *dma_chain;
  70 
  71 /* Broken hardware... */
  72 #define DMA_ISBROKEN(dma)    ((dma)->revision == dvmarev1)
  73 #define DMA_ISESC1(dma)      ((dma)->revision == dvmaesc1)
  74 
  75 /* Main routines in dma.c */
  76 extern void dump_dma_regs(struct sparc_dma_registers *);
  77 extern unsigned long dvma_init(struct linux_sbus *, unsigned long);
  78 
  79 /* Fields in the cond_reg register */
  80 /* First, the version identification bits */
  81 #define DMA_DEVICE_ID    0xf0000000        /* Device identification bits */
  82 #define DMA_VERS0        0x00000000        /* Sunray DMA version */
  83 #define DMA_ESCV1        0x40000000        /* DMA ESC Version 1 */
  84 #define DMA_VERS1        0x80000000        /* DMA rev 1 */
  85 #define DMA_VERS2        0xa0000000        /* DMA rev 2 */
  86 #define DMA_VERSPLUS     0x90000000        /* DMA rev 1 PLUS */
  87 
  88 #define DMA_HNDL_INTR    0x00000001        /* An IRQ needs to be handled */
  89 #define DMA_HNDL_ERROR   0x00000002        /* We need to take an error */
  90 #define DMA_FIFO_ISDRAIN 0x0000000c        /* The DMA FIFO is draining */
  91 #define DMA_INT_ENAB     0x00000010        /* Turn on interrupts */
  92 #define DMA_FIFO_INV     0x00000020        /* Invalidate the FIFO */
  93 #define DMA_ACC_SZ_ERR   0x00000040        /* The access size was bad */
  94 #define DMA_FIFO_STDRAIN 0x00000040        /* DMA_VERS1 Drain the FIFO */
  95 #define DMA_RST_SCSI     0x00000080        /* Reset the SCSI controller */
  96 #define DMA_ST_WRITE     0x00000100        /* write from device to memory */
  97 #define DMA_ENABLE       0x00000200        /* Fire up DMA, handle requests */
  98 #define DMA_PEND_READ    0x00000400        /* DMA_VERS1/0/PLUS Pendind Read */
  99 #define DMA_BCNT_ENAB    0x00002000        /* If on, use the byte counter */
 100 #define DMA_TERM_CNTR    0x00004000        /* Terminal counter */
 101 #define DMA_CSR_DISAB    0x00010000        /* No FIFO drains during csr */
 102 #define DMA_SCSI_DISAB   0x00020000        /* No FIFO drains during reg */
 103 #define DMA_ADD_ENABLE   0x00040000        /* Special ESC DVMA optimization */
 104 #define DMA_BRST_SZ      0x000c0000        /* SBUS transfer r/w burst size */
 105 #define DMA_ADDR_DISAB   0x00100000        /* No FIFO drains during addr */
 106 #define DMA_2CLKS        0x00200000        /* Each transfer = 2 clock ticks */
 107 #define DMA_3CLKS        0x00400000        /* Each transfer = 3 clock ticks */
 108 #define DMA_CNTR_DISAB   0x00800000        /* No IRQ when DMA_TERM_CNTR set */
 109 #define DMA_AUTO_NADDR   0x01000000        /* Use "auto nxt addr" feature */
 110 #define DMA_SCSI_ON      0x02000000        /* Enable SCSI dma */
 111 #define DMA_LOADED_ADDR  0x04000000        /* Address has been loaded */
 112 #define DMA_LOADED_NADDR 0x08000000        /* Next address has been loaded */
 113 
 114 /* Values describing the burst-size property from the PROM */
 115 #define DMA_BURST1       0x01
 116 #define DMA_BURST2       0x02
 117 #define DMA_BURST4       0x04
 118 #define DMA_BURST8       0x08
 119 #define DMA_BURST16      0x10
 120 #define DMA_BURST32      0x20
 121 #define DMA_BURST64      0x40
 122 #define DMA_BURSTBITS    0x7f
 123 
 124 /* Determine highest possible final transfer address given a base */
 125 #define DMA_MAXEND(addr) (0x01000000UL-(((unsigned long)(addr))&0x00ffffffUL))
 126 
 127 /* Yes, I hack a lot of elisp in my spare time... */
 128 #define DMA_ERROR_P(regs)  ((((regs)->cond_reg) & DMA_HNDL_ERROR))
 129 #define DMA_IRQ_P(regs)    ((((regs)->cond_reg) & DMA_HNDL_INTR))
 130 #define DMA_WRITE_P(regs)  ((((regs)->cond_reg) & DMA_ST_WRITE))
 131 #define DMA_OFF(regs)      ((((regs)->cond_reg) &= (~DMA_ENABLE)))
 132 #define DMA_INTSOFF(regs)  ((((regs)->cond_reg) &= (~DMA_INT_ENAB)))
 133 #define DMA_INTSON(regs)   ((((regs)->cond_reg) |= (DMA_INT_ENAB)))
 134 #define DMA_PUNTFIFO(regs) ((((regs)->cond_reg) |= DMA_FIFO_INV))
 135 #define DMA_SETSTART(regs, addr)  ((((regs)->st_addr) = (char *) addr))
 136 #define DMA_BEGINDMA_W(regs) \
 137         ((((regs)->cond_reg |= (DMA_ST_WRITE|DMA_ENABLE|DMA_INT_ENAB))))
 138 #define DMA_BEGINDMA_R(regs) \
 139         ((((regs)->cond_reg |= ((DMA_ENABLE|DMA_INT_ENAB)&(~DMA_ST_WRITE)))))
 140 
 141 /* For certain DMA chips, we need to disable ints upon irq entry
 142  * and turn them back on when we are done.  So in any ESP interrupt
 143  * handler you *must* call DMA_IRQ_ENTRY upon entry and DMA_IRQ_EXIT
 144  * when leaving the handler.  You have been warned...
 145  */
 146 #define DMA_IRQ_ENTRY(dma, dregs) do { \
 147         if(DMA_ISBROKEN(dma)) DMA_INTSOFF(dregs); \
 148    } while (0)
 149 
 150 #define DMA_IRQ_EXIT(dma, dregs) do { \
 151         if(DMA_ISBROKEN(dma)) DMA_INTSON(dregs); \
 152    } while(0)
 153 
 154 /* Pause until counter runs out or BIT isn't set in the DMA condition
 155  * register.
 156  */
 157 extern inline void sparc_dma_pause(struct sparc_dma_registers *regs,
     /* [previous][next][first][last][top][bottom][index][help] */
 158                                    unsigned long bit)
 159 {
 160         int ctr = 50000;   /* Let's find some bugs ;) */
 161 
 162         /* Busy wait until the bit is not set any more */
 163         while((regs->cond_reg&bit) && (ctr>0)) {
 164                 ctr--;
 165                 __delay(5);
 166         }
 167 
 168         /* Check for bogus outcome. */
 169         if(!ctr)
 170                 panic("DMA timeout");
 171 }
 172 
 173 /* Reset the friggin' thing... */
 174 #define DMA_RESET(dma) do { \
 175         struct sparc_dma_registers *regs = dma->regs;                      \
 176         /* Let the current FIFO drain itself */                            \
 177         sparc_dma_pause(regs, (DMA_FIFO_ISDRAIN));                         \
 178         /* Reset the logic */                                              \
 179         regs->cond_reg |= (DMA_RST_SCSI);     /* assert */                 \
 180         __delay(400);                         /* let the bits set ;) */    \
 181         regs->cond_reg &= ~(DMA_RST_SCSI);    /* de-assert */              \
 182         sparc_dma_enable_interrupts(regs);    /* Re-enable interrupts */   \
 183         /* Enable FAST transfers if available */                           \
 184         if(dma->revision>dvmarev1) regs->cond_reg |= DMA_3CLKS;            \
 185         dma->running = 0;                                                  \
 186 } while(0)
 187 
 188 #define for_each_dvma(dma) \
 189         for((dma) = dma_chain; (dma); (dma) = (dma)->next)
 190 
 191 extern int get_dma_list(char *);
 192 extern int request_dma(unsigned int, const char *);
 193 extern void free_dma(unsigned int);
 194 
 195 #endif /* !(_ASM_SPARC_DMA_H) */

/* [previous][next][first][last][top][bottom][index][help] */