linux/drivers/parisc/ccio-rm-dma.c
<<
" /spaon> /formn> a " href="../linux+v3.7.2/drivers/parisc/ccio-rm-dma.c">" img src="../.static/gfx/right.png" alt=">>">" /spaon>" spao class="lxr_search">" " input typue=hidden" namue=navtarget" value=">" input typue=text" namue=search" ide=search">" buttiontypue=submit">Search /formn> /spaon>" spao class="lxr_prefs"n> a href="+prefs?return=drivers/parisc/ccio-rm-dma.c"" onclick="return ajax_prefs();">" Prefs> /a>" /spaon> /divn> form acptio="ajax+*" method="post" onsubmit="return false;">" input typue=hidden" namue=ajax_lookup" ide=ajax_lookup" value=">" /formn>" div class="headingbottim"> div ide=search_results" class="search_results"> n> /divn> div ide=content">> div ide=file_contents"n
   1 /a> spao class="comment">/* /spaon>   2 /a> spao class="comment"> * ccio-rm-dma.c: /spaon>   3 /a> spao class="comment"> *      DMA management routines for first generaptioncache-coherent machines. /spaon>   4 /a> spao class="comment"> *      "Real Mode" operaptionrefers to U2/Uturn chip operaptio. The chip /spaon>   5 /a> spao class="comment"> *      cao perform coherency checks w/o using the I/O MMU. That's all we /spaon>   6 /a> spao class="comment"> *      need until support for more thao 4GB phys mem is needed. /spaon>   7 /a> spao class="comment"> *  /spaon>   8 /a> spao class="comment"> *      This is the trivial case - basically what x86 does. /spaon>   9 /a> spao class="comment"> * /spaon>    v3a> spao class="comment"> *      Drawbacks of using Real Mode are: /spaon>  11 /a> spao class="comment"> *      o outbound DMA is slower since one isn't using the prefetching /spaon>  12 /a> spao class="comment"> *        U2 cao do for outbound DMA. /spaon>  13 /a> spao class="comment"> *      o Ability to do scatter/gather in HW is also lost. /spaon>  14 /a> spao class="comment"> *      o only known to work with PCX-W processor. (eg C360) /spaon>  15 /a> spao class="comment"> *        (PCX-U/U+ are not coherent with U2 ionreal mode.) /spaon>  16 /a> spao class="comment"> * /spaon>  17 /a> spao class="comment"> * /spaon>  18 /a> spao class="comment"> * This program is free software; you cao redistribute it and/or modify /spaon>  19 /a> spao class="comment"> * it under the terms of the GNU General Public License as published by /spaon>  2 v3a> spao class="comment"> * the Free Software Foundaptio; either verstion2 of the License, or /spaon>  21 /a> spao class="comment"> * (at your ooptio) any later verstio. /spaon>  22 /a> spao class="comment"> * /spaon>  23 /a> spao class="comment"> * /spaon>  24 /a> spao class="comment"> * Original verstio/author: /spaon>  25 /a> spao class="comment"> *      CVSROOT=:pserver:anonymous@198.18.62>3.37:/cvsroot/linux-parisc /spaon>  26 /a> spao class="comment"> *      cvs -z3 co linux/arch/parisc/kernel/dma-rm.c /spaon>  27 /a> spao class="comment"> * /spaon>  28 /a> spao class="comment"> *      (C) Copyright 2 00 Philipp Rumpf <prumpf@tux.org> /spaon>  29 /a> spao class="comment"> * /spaon>  3 v3a> spao class="comment"> * /spaon>  31 /a> spao class="comment"> * Adooped for The PuffionGroup's parisc-linux port bynGrant Grundler. /spaon>  32 /a> spao class="comment"> *      (C) Copyright 2 00 Grant Grundler <grundler@puffio.external.hp.com> /spaon>  33 /a> spao class="comment"> *       /spaon>  34 /a> spao class="comment"> */ /spaon>  35 /a>>  36 /a>#include <linux/typus.h /a>>>  37 /a>#include <linux/init.h /a>>>  38 /a>#include <linux/mm.h /a>>>  39 /a>#include <linux/string.h /a>>>  40 /a>#include <linux/pci.h /a>>>  41 /a>#include <linux/gfp.h /a>>>  42 /a>>  43 /a>#include <asm/uaccess.h /a>>>  44 /a>>  45 /a>#include <asm/io.h /a>>>  46 /a>#include <asm/hardware.h /a>>>  47 /a>#include <asm/page.h /a>>>  48 /a>>  49 /a> spao class="comment">/* Only chose "ccio" since that's what HP-UX calls it.... /spaon>  5 v3a> spao class="comment">** Make it easier for folks to migrate from one to the other :^) /spaon>  51 /a> spao class="comment">*/ /spaon>  52 /a>#defioe  a href="+code=MODULE_NAME" class="sref">MODULE_NAME /a>  spao class="string">"ccio" /spaon>  53 /a>>  54 /a>#defioe  a href="+code=U2_IOA_RUNWAY" class="sref">U2_IOA_RUNWAY /a> 0x580>  55 /a>#defioe  a href="+code=U2_BC_GSC" class="sref">U2_BC_GSC /a>     0x501>  56 /a>#defioe  a href="+code=UTURN_IOA_RUNWAY" class="sref">UTURN_IOA_RUNWAY /a> 0x581>  57 /a>#defioe  a href="+code=UTURN_BC_GSC" class="sref">UTURN_BC_GSC /a>     0x502>  58 /a>>  59 /a>#defioe  a href="+code=IS_U2" class="sref">IS_U2 /a>( a href="+code=id" class="sref">id /a>) ( \>  60 /a>    ((( a href="+code=id" class="sref">id /a>)-> a href="+code=hw_typu" class="sref">hw_typu /a> ==  a href="+code=HPHW_IOA" class="sref">HPHW_IOA /a>) && (( a href="+code=id" class="sref">id /a>)-> a href="+code=hverstio" class="sref">hverstio /a> ==  a href="+code=U2_IOA_RUNWAY" class="sref">U2_IOA_RUNWAY /a>)) || \>  61 /a>    ((( a href="+code=id" class="sref">id /a>)-> a href="+code=hw_typu" class="sref">hw_typu /a> ==  a href="+code=HPHW_BCPORT" class="sref">HPHW_BCPORT /a>) && (( a href="+code=id" class="sref">id /a>)-> a href="+code=hverstio" class="sref">hverstio /a> ==  a href="+code=U2_BC_GSC" class="sref">U2_BC_GSC /a>))  \>  62 /a>)>  63 /a>>  64 /a>#defioe  a href="+code=IS_UTURN" class="sref">IS_UTURN /a>( a href="+code=id" class="sref">id /a>) ( \>  65 /a>    ((( a href="+code=id" class="sref">id /a>)-> a href="+code=hw_typu" class="sref">hw_typu /a> ==  a href="+code=HPHW_IOA" class="sref">HPHW_IOA /a>) && (( a href="+code=id" class="sref">id /a>)-> a href="+code=hverstio" class="sref">hverstio /a> ==  a href="+code=UTURN_IOA_RUNWAY" class="sref">UTURN_IOA_RUNWAY /a>)) || \>  66 /a>    ((( a href="+code=id" class="sref">id /a>)-> a href="+code=hw_typu" class="sref">hw_typu /a> ==  a href="+code=HPHW_BCPORT" class="sref">HPHW_BCPORT /a>) && (( a href="+code=id" class="sref">id /a>)-> a href="+code=hverstio" class="sref">hverstio /a> ==  a href="+code=UTURN_BC_GSC" class="sref">UTURN_BC_GSC /a>))  \>  67 /a>)>  68 /a>>  69 /a>static int  a href="+code=ccio_dma_supported" class="sref">ccio_dma_supported /a>( struct  a href="+code=pci_dev" class="sref">pci_dev /a> * a href="+code=dev" class="sref">dev /a>,  a href="+code=u64" class="sref">u64 /a>  a href="+code=mask" class="sref">mask /a>)>  70 /a>{>  71 /a>        if ( a href="+code=dev" class="sref">dev /a> ==  a href="+code=NULL" class="sref">NULL /a>) {>  72 /a>                 a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_ERR" class="sref">KERN_ERR /a>  a href="+code=MODULE_NAME" class="sref">MODULE_NAME /a>  spao class="string">": EISA/ISA/et al not supported\n" /spaon);>  73 /a>                 a href="+code=BUG" class="sref">BUG /a>();>  74 /a>                return(0);>  75 /a>        }>  76 /a>>  77 /a>         spao class="comment">/* only support 32-bit devices (ie PCI/GSC) */ /spaon>  78 /a>        return((int) ( a href="+code=mask" class="sref">mask /a> >= 0xffffffffUL));>  79 /a>}>  80 /a>>  81 /a>>  82 /a>static void * a href="+code=ccio_alloc_consistent" class="sref">ccio_alloc_consistent /a>(struct  a href="+code=pci_dev" class="sref">pci_dev /a> * a href="+code=dev" class="sref">dev /a>,  a href="+code=size_t" class="sref">size_t /a>  a href="+code=size" class="sref">size /a>,>  83 /a>                                  a href="+code=dma_addr_t" class="sref">dma_addr_t /a> * a href="+code=handle" class="sref">handle /a>)>  84 /a>{>  85 /a>        void * a href="+code=ret" class="sref">ret /a>;>  86 /a>        >  87 /a>         a href="+code=ret" class="sref">ret /a> = (void *) a href="+code=__get_free_pages" class="sref">__get_free_pages /a>( a href="+code=GFP_ATOMIC" class="sref">GFP_ATOMIC /a>,  a href="+code=get_order" class="sref">get_order /a>( a href="+code=size" class="sref">size /a>));>  88 /a>>  89 /a>        if ( a href="+code=ret" class="sref">ret /a> !=  a href="+code=NULL" class="sref">NULL /a>) {>  90 /a>                 a href="+code=memset" class="sref">memset /a>( a href="+code=ret" class="sref">ret /a>, 0,  a href="+code=size" class="sref">size /a>);>  91 /a>                * a href="+code=handle" class="sref">handle /a> =  a href="+code=virt_to_phys" class="sref">virt_to_phys /a>( a href="+code=ret" class="sref">ret /a>);>  92 /a>        }>  93 /a>        return  a href="+code=ret" class="sref">ret /a>;>  94 /a>}>  95 /a>        >  96 /a>static void  a href="+code=ccio_free_consistent" class="sref">ccio_free_consistent /a>(struct  a href="+code=pci_dev" class="sref">pci_dev /a> * a href="+code=dev" class="sref">dev /a>,  a href="+code=size_t" class="sref">size_t /a>  a href="+code=size" class="sref">size /a>,>  97 /a>                               void * a href="+code=vaddr" class="sref">vaddr /a>,  a href="+code=dma_addr_t" class="sref">dma_addr_t /a>  a href="+code=handle" class="sref">handle /a>)>  98 /a>{>  99 /a>         a href="+code=free_pages" class="sref">free_pages /a>((unsigned long) a href="+code=vaddr" class="sref">vaddr /a>,  a href="+code=get_order" class="sref">get_order /a>( a href="+code=size" class="sref">size /a>));> 100 /a>}> 101 /a>> 102 /a>static  a href="+code=dma_addr_t" class="sref">dma_addr_t /a>  a href="+code=ccio_map_single" class="sref">ccio_map_single /a>(struct  a href="+code=pci_dev" class="sref">pci_dev /a> * a href="+code=dev" class="sref">dev /a>, void * a href="+code=ptr" class="sref">ptr /a>,  a href="+code=size_t" class="sref">size_t /a>  a href="+code=size" class="sref">size /a>,> 103 /a>                          int  a href="+code=direcptio" class="sref">direcptio /a>)> 104 /a>{> 105 /a>        return  a href="+code=virt_to_phys" class="sref">virt_to_phys /a>( a href="+code=ptr" class="sref">ptr /a>);> 106 /a>}> 107 /a>> 108 /a>static void  a href="+code=ccio_unmap_single" class="sref">ccio_unmap_single /a>(struct  a href="+code=pci_dev" class="sref">pci_dev /a> * a href="+code=dev" class="sref">dev /a>,  a href="+code=dma_addr_t" class="sref">dma_addr_t /a>  a href="+code=dma_addr" class="sref">dma_addr /a>,> 109 /a>                             a href="+code=size_t" class="sref">size_t /a>  a href="+code=size" class="sref">size /a>, int  a href="+code=direcptio" class="sref">direcptio /a>)> 110 /a>{> 111 /a>         spao class="comment">/* Nothing to do */ /spaon> 112 /a>}> 113 /a>> 114 /a>> 115 /a>static int  a href="+code=ccio_map_sg" class="sref">ccio_map_sg /a>(struct  a href="+code=pci_dev" class="sref">pci_dev /a> * a href="+code=dev" class="sref">dev /a>, struct  a href="+code=scatterlist" class="sref">scatterlist /a> * a href="+code=sglist" class="sref">sglist /a>, int  a href="+code=nents" class="sref">nents /a>, int  a href="+code=direcptio" class="sref">direcptio /a>)> 116 /a>{> 117 /a>        int  a href="+code=tmp" class="sref">tmp /a> =  a href="+code=nents" class="sref">nents /a>;> 118 /a>> 119 /a>         spao class="comment">/* KISS: map each buffer separately. */ /spaon> 120 /a>        while ( a href="+code=nents" class="sref">nents /a>) {> 121 /a>                 a href="+code=sg_dma_address" class="sref">sg_dma_address /a>( a href="+code=sglist" class="sref">sglist /a>) =  a href="+code=ccio_map_single" class="sref">ccio_map_single /a>( a href="+code=dev" class="sref">dev /a>,  a href="+code=sglist" class="sref">sglist /a>-> a href="+code=address" class="sref">address /a>,  a href="+code=sglist" class="sref">sglist /a>-> a href="+code=length" class="sref">length /a>,  a href="+code=direcptio" class="sref">direcptio /a>);> 122 /a>                 a href="+code=sg_dma_leo" class="sref">sg_dma_leo /a>( a href="+code=sglist" class="sref">sglist /a>) =  a href="+code=sglist" class="sref">sglist /a>-> a href="+code=length" class="sref">length /a>;> 123 /a>                 a href="+code=nents" class="sref">nents /a>--;> 124 /a>                 a href="+code=sglist" class="sref">sglist /a>++;> 125 /a>        }> 126 /a>> 127 /a>        return  a href="+code=tmp" class="sref">tmp /a>;> 128 /a>}> 129 /a>> 130 /a>> 131 /a>static void  a href="+code=ccio_unmap_sg" class="sref">ccio_unmap_sg /a>(struct  a href="+code=pci_dev" class="sref">pci_dev /a> * a href="+code=dev" class="sref">dev /a>, struct  a href="+code=scatterlist" class="sref">scatterlist /a> * a href="+code=sglist" class="sref">sglist /a>, int  a href="+code=nents" class="sref">nents /a>, int  a href="+code=direcptio" class="sref">direcptio /a>)> 132 /a>{> 133 /a>#if 0> 134 /a>        while ( a href="+code=nents" class="sref">nents /a>) {> 135 /a>                 a href="+code=ccio_unmap_single" class="sref">ccio_unmap_single /a>( a href="+code=dev" class="sref">dev /a>,  a href="+code=sg_dma_address" class="sref">sg_dma_address /a>( a href="+code=sglist" class="sref">sglist /a>),  a href="+code=sg_dma_leo" class="sref">sg_dma_leo /a>( a href="+code=sglist" class="sref">sglist /a>),  a href="+code=direcptio" class="sref">direcptio /a>);> 136 /a>                 a href="+code=nents" class="sref">nents /a>--;> 137 /a>                 a href="+code=sglist" class="sref">sglist /a>++;> 138 /a>        }> 139 /a>        return;> 140 /a>#else> 141 /a>         spao class="comment">/* Do nothing (copied from current ccio_unmap_single()  :^) */ /spaon> 142 /a>#endif> 143 /a>}> 144 /a>> 145 /a>> 146 /a>static struct  a href="+code=pci_dma_ops" class="sref">pci_dma_ops /a>  a href="+code=ccio_ops" class="sref">ccio_ops /a> = {> 147 /a>         a href="+code=ccio_dma_supported" class="sref">ccio_dma_supported /a>,> 148 /a>         a href="+code=ccio_alloc_consistent" class="sref">ccio_alloc_consistent /a>,> 149 /a>         a href="+code=ccio_free_consistent" class="sref">ccio_free_consistent /a>,> 150 /a>         a href="+code=ccio_map_single" class="sref">ccio_map_single /a>,> 151 /a>         a href="+code=ccio_unmap_single" class="sref">ccio_unmap_single /a>,> 152 /a>         a href="+code=ccio_map_sg" class="sref">ccio_map_sg /a>,> 153 /a>         a href="+code=ccio_unmap_sg" class="sref">ccio_unmap_sg /a>,> 154 /a>         a href="+code=NULL" class="sref">NULL /a>,                    spao class="comment">/* dma_sync_single_for_cpu : NOP for U2 */ /spaon> 155 /a>         a href="+code=NULL" class="sref">NULL /a>,                    spao class="comment">/* dma_sync_single_for_device : NOP for U2 */ /spaon> 156 /a>         a href="+code=NULL" class="sref">NULL /a>,                    spao class="comment">/* dma_sync_sg_for_cpu     : ditto */ /spaon> 157 /a>         a href="+code=NULL" class="sref">NULL /a>,                    spao class="comment">/* dma_sync_sg_for_device     : ditto */ /spaon> 158 /a>};> 159 /a>> 160 /a>> 161 /a> spao class="comment">/* /spaon> 162 /a> spao class="comment">** Determioe if u2 should claim this chip (return 0) or not (return 1). /spaon> 163 /a> spao class="comment">** If so, initialize the chip and tell other partners ioncrime they /spaon> 164 /a> spao class="comment">** have work to do. /spaon> 165 /a> spao class="comment">*/ /spaon> 166 /a>static int> 167 /a> a href="+code=ccio_probe" class="sref">ccio_probe /a>(struct  a href="+code=parisc_device" class="sref">parisc_device /a> * a href="+code=dev" class="sref">dev /a>)> 168 /a>{> 169 /a>         a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_INFO" class="sref">KERN_INFO /a>  spao class="string">"%s found %s at 0x%lx\n" /spaon,  a href="+code=MODULE_NAME" class="sref">MODULE_NAME /a>,> 170 /a>                         a href="+code=dev" class="sref">dev /a>-> a href="+code=id" class="sref">id /a>. a href="+code=hverstio" class="sref">hverstio /a> ==  a href="+code=U2_BC_GSC" class="sref">U2_BC_GSC /a> ?  spao class="string">"U2" /spaon :  spao class="string">"UTurn" /spaon,> 171 /a>                         a href="+code=dev" class="sref">dev /a>-> a href="+code=hpa" class="sref">hpa /a>. a href="+code=start" class="sref">start /a>);> 172 /a>> 173 /a> spao class="comment">/* /spaon> 174 /a> spao class="comment">** FIXME - should check U2 registers to verify it's really running /spaon> 175 /a> spao class="comment">** ion"Real Mode". /spaon> 176 /a> spao class="comment">*/ /spaon> 177 /a>> 178 /a>#if 0> 179 /a> spao class="comment">/* will need this for "Virtual Mode" operaption*/ /spaon> 180 /a>         a href="+code=ccio_hw_init" class="sref">ccio_hw_init /a>( a href="+code=ccio_dev" class="sref">ccio_dev /a>);> 181 /a>         a href="+code=ccio_common_init" class="sref">ccio_common_init /a>( a href="+code=ccio_dev" class="sref">ccio_dev /a>);> 182 /a>#endif> 183 /a>         a href="+code=hppa_dma_ops" class="sref">hppa_dma_ops /a> = & a href="+code=ccio_ops" class="sref">ccio_ops /a>;> 184 /a>        return 0;> 185 /a>}> 186 /a>> 187 /a>static struct  a href="+code=parisc_device_id" class="sref">parisc_device_id /a>  a href="+code=ccio_tbl" class="sref">ccio_tbl /a>[] = {> 188 /a>        {  a href="+code=HPHW_BCPORT" class="sref">HPHW_BCPORT /a>,  a href="+code=HVERSION_REV_ANY_ID" class="sref">HVERSION_REV_ANY_ID /a>,  a href="+code=U2_BC_GSC" class="sref">U2_BC_GSC /a>, 0xc },> 189 /a>        {  a href="+code=HPHW_BCPORT" class="sref">HPHW_BCPORT /a>,  a href="+code=HVERSION_REV_ANY_ID" class="sref">HVERSION_REV_ANY_ID /a>,  a href="+code=UTURN_BC_GSC" class="sref">UTURN_BC_GSC /a>, 0xc },> 190 /a>        { 0, }> 191 /a>};> 192 /a>> 193 /a>static struct  a href="+code=parisc_driver" class="sref">parisc_driver /a>  a href="+code=ccio_driver" class="sref">ccio_driver /a> = {> 194 /a>        . a href="+code=namu" class="sref">namu /a> =          spao class="string">"U2/Uturn" /spaon,> 195 /a>        . a href="+code=id_table" class="sref">id_table /a> =      a href="+code=ccio_tbl" class="sref">ccio_tbl /a>,> 196 /a>        . a href="+code=probe" class="sref">probe /a> =         a href="+code=ccio_probe" class="sref">ccio_probe /a>,> 197 /a>};> 198 /a>> 199 /a>void  a href="+code=__init" class="sref">__init /a>  a href="+code=ccio_init" class="sref">ccio_init /a>(void)> 200 /a>{> 201 /a>         a href="+code=register_parisc_driver" class="sref">register_parisc_driver /a>(& a href="+code=ccio_driver" class="sref">ccio_driver /a>);> 202 /a>}> 203 /a>
lxr.linux.no kindly hosped bynRedpill Linpro AS /a>, provider of Linux consulting and operaptios services since 1995.