[BACK]Return to sa11x0_space.c CVS log [TXT][DIR] Up to [local] / sys / arch / arm / sa11x0

Annotation of sys/arch/arm/sa11x0/sa11x0_space.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: sa11x0_space.c,v 1.3 2005/07/18 02:43:24 fgsch Exp $ */
                      2: /*     $NetBSD: sa11x0_space.c,v 1.5 2004/06/07 19:45:22 nathanw Exp $ */
                      3:
                      4: /*
                      5:  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed for the NetBSD Project by
                     21:  *     Wasabi Systems, Inc.
                     22:  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
                     23:  *    or promote products derived from this software without specific prior
                     24:  *    written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
                     30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     36:  * POSSIBILITY OF SUCH DAMAGE.
                     37:  */
                     38: /*
                     39:  * Copyright (c) 1997 Mark Brinicombe.
                     40:  * Copyright (c) 1997 Causality Limited.
                     41:  * All rights reserved.
                     42:  *
                     43:  * This code is derived from software contributed to The NetBSD Foundation
                     44:  * by Ichiro FUKUHARA.
                     45:  *
                     46:  * Redistribution and use in source and binary forms, with or without
                     47:  * modification, are permitted provided that the following conditions
                     48:  * are met:
                     49:  * 1. Redistributions of source code must retain the above copyright
                     50:  *    notice, this list of conditions and the following disclaimer.
                     51:  * 2. Redistributions in binary form must reproduce the above copyright
                     52:  *    notice, this list of conditions and the following disclaimer in the
                     53:  *    documentation and/or other materials provided with the distribution.
                     54:  * 3. All advertising materials mentioning features or use of this software
                     55:  *    must display the following acknowledgement:
                     56:  *     This product includes software developed by Mark Brinicombe.
                     57:  * 4. The name of the company nor the name of the author may be used to
                     58:  *    endorse or promote products derived from this software without specific
                     59:  *    prior written permission.
                     60:  *
                     61:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
                     62:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
                     63:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     64:  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
                     65:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     66:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     67:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     68:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     69:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     70:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     71:  * SUCH DAMAGE.
                     72:  */
                     73:
                     74: /*
                     75:  * bus_space functions for Intel PXA2[51]0 application processor.
                     76:  * Derived from i80321_space.c.
                     77:  */
                     78:
                     79: #include <sys/cdefs.h>
                     80: /*
                     81: __KERNEL_RCSID(0, "$NetBSD: sa11x0_space.c,v 1.5 2004/06/07 19:45:22 nathanw Exp $");
                     82: */
                     83:
                     84: #include <sys/param.h>
                     85: #include <sys/systm.h>
                     86:
                     87: #include <uvm/uvm_extern.h>
                     88:
                     89: #include <machine/bus.h>
                     90:
                     91: /* Prototypes for all the bus_space structure functions */
                     92: bs_protos(sa11x0);
                     93: bs_protos(generic);
                     94: bs_protos(generic_armv4);
                     95: bs_protos(bs_notimpl);
                     96:
                     97: struct bus_space sa11x0_bs_tag = {
                     98:        /* cookie */
                     99:        (void *) 0,
                    100:
                    101:        /* mapping/unmapping */
                    102:        sa11x0_bs_map,
                    103:        sa11x0_bs_unmap,
                    104:        sa11x0_bs_subregion,
                    105:
                    106:        /* allocation/deallocation */
                    107:        sa11x0_bs_alloc,        /* not implemented */
                    108:        sa11x0_bs_free,         /* not implemented */
                    109:
                    110:        /* get kernel virtual address */
                    111:        sa11x0_bs_vaddr,
                    112:
                    113:        /* mmap */
                    114:        bs_notimpl_bs_mmap,
                    115:
                    116:        /* barrier */
                    117:        sa11x0_bs_barrier,
                    118:
                    119:        /* read (single) */
                    120:        bs_notimpl_bs_r_1,
                    121:        bs_notimpl_bs_r_2,
                    122:        generic_bs_r_4,
                    123:        bs_notimpl_bs_r_8,
                    124:
                    125:        /* read multiple */
                    126:        bs_notimpl_bs_rm_1,
                    127:        bs_notimpl_bs_rm_2,
                    128:        generic_bs_rm_4,
                    129:        bs_notimpl_bs_rm_8,
                    130:
                    131:        /* read region */
                    132:        /* XXX only word-wide transactions on APB */
                    133:        generic_bs_rr_1,
                    134:        generic_armv4_bs_rr_2,
                    135:        generic_bs_rr_4,
                    136:        bs_notimpl_bs_rr_8,
                    137:
                    138:        /* write (single) */
                    139:        bs_notimpl_bs_w_1,
                    140:        bs_notimpl_bs_w_2,
                    141:        generic_bs_w_4,
                    142:        bs_notimpl_bs_w_8,
                    143:
                    144:        /* write multiple */
                    145:        bs_notimpl_bs_wm_1,
                    146:        bs_notimpl_bs_wm_2,
                    147:        generic_bs_wm_4,
                    148:        bs_notimpl_bs_wm_8,
                    149:
                    150:        /* write region */
                    151:        /* XXX only word-wide transactions on APB */
                    152:        generic_bs_wr_1,
                    153:        generic_armv4_bs_wr_2,
                    154:        generic_bs_wr_4,
                    155:        bs_notimpl_bs_wr_8,
                    156:
                    157:        /* set multiple */
                    158:        bs_notimpl_bs_sm_1,
                    159:        bs_notimpl_bs_sm_2,
                    160:        bs_notimpl_bs_sm_4,
                    161:        bs_notimpl_bs_sm_8,
                    162:
                    163:        /* set region */
                    164:        generic_bs_sr_1,
                    165:        generic_armv4_bs_sr_2,
                    166:        bs_notimpl_bs_sr_4,
                    167:        bs_notimpl_bs_sr_8,
                    168:
                    169:        /* copy */
                    170:        bs_notimpl_bs_c_1,
                    171:        generic_armv4_bs_c_2,
                    172:        bs_notimpl_bs_c_4,
                    173:        bs_notimpl_bs_c_8,
                    174: };
                    175:
                    176: int
                    177: sa11x0_bs_map(void *t, bus_addr_t bpa, bus_size_t size,
                    178:              int flag, bus_space_handle_t *bshp)
                    179: {
                    180:        u_long startpa, endpa, pa;
                    181:        vaddr_t va;
                    182:        pt_entry_t *pte;
                    183:
                    184:        if ((u_long)bpa > (u_long)KERNEL_BASE) {
                    185:                /* Some IO registers (ex. UART ports for console)
                    186:                   are mapped to fixed address by board specific
                    187:                   routine. */
                    188:                *bshp = bpa;
                    189:                return(0);
                    190:        }
                    191:
                    192:        startpa = trunc_page(bpa);
                    193:        endpa = round_page(bpa + size);
                    194:
                    195:        /* XXX use extent manager to check duplicate mapping */
                    196:
                    197:        va = uvm_km_valloc(kernel_map, endpa - startpa);
                    198:        if (! va)
                    199:                return(ENOMEM);
                    200:
                    201:        *bshp = (bus_space_handle_t)(va + (bpa - startpa));
                    202:
                    203:        for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
                    204:                pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
                    205:                if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) {
                    206:                        pte = vtopte(va);
                    207:                        *pte &= ~L2_S_CACHE_MASK;
                    208:                        PTE_SYNC(pte);
                    209:                        /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of
                    210:                         *      waste.
                    211:                         */
                    212:                }
                    213:        }
                    214:        pmap_update(pmap_kernel());
                    215:
                    216:        return(0);
                    217: }
                    218:
                    219: void
                    220: sa11x0_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
                    221: {
                    222:
                    223:        if (bsh > (u_long)KERNEL_BASE)
                    224:                return;
                    225:
                    226:        uvm_km_free(kernel_map, bsh, size);
                    227: }
                    228:
                    229:
                    230: int
                    231: sa11x0_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
                    232:     bus_size_t size, bus_space_handle_t *nbshp)
                    233: {
                    234:
                    235:        *nbshp = bsh + offset;
                    236:        return (0);
                    237: }
                    238:
                    239: void
                    240: sa11x0_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
                    241:     bus_size_t len, int flags)
                    242: {
                    243:
                    244:        /* Nothing to do. */
                    245: }
                    246:
                    247: void *
                    248: sa11x0_bs_vaddr(void *t, bus_space_handle_t bsh)
                    249: {
                    250:
                    251:        return ((void *)bsh);
                    252: }
                    253:
                    254:
                    255: int
                    256: sa11x0_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
                    257:     bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
                    258:     bus_addr_t *bpap, bus_space_handle_t *bshp)
                    259: {
                    260:
                    261:        panic("sa11x0_io_bs_alloc(): not implemented");
                    262: }
                    263:
                    264: void
                    265: sa11x0_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
                    266: {
                    267:
                    268:        panic("sa11x0_io_bs_free(): not implemented");
                    269: }
                    270:

CVSweb