1 1.10 skrll /* $NetBSD: footbridge_com_io.c,v 1.10 2021/08/13 11:40:43 skrll Exp $ */ 2 1.1 chris 3 1.1 chris /* 4 1.1 chris * Copyright (c) 1997 Mark Brinicombe. 5 1.1 chris * Copyright (c) 1997 Causality Limited. 6 1.1 chris * All rights reserved. 7 1.1 chris * 8 1.1 chris * Redistribution and use in source and binary forms, with or without 9 1.1 chris * modification, are permitted provided that the following conditions 10 1.1 chris * are met: 11 1.1 chris * 1. Redistributions of source code must retain the above copyright 12 1.1 chris * notice, this list of conditions and the following disclaimer. 13 1.1 chris * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 chris * notice, this list of conditions and the following disclaimer in the 15 1.1 chris * documentation and/or other materials provided with the distribution. 16 1.1 chris * 3. All advertising materials mentioning features or use of this software 17 1.1 chris * must display the following acknowledgement: 18 1.1 chris * This product includes software developed by Mark Brinicombe 19 1.1 chris * for the NetBSD Project. 20 1.1 chris * 4. The name of the company nor the name of the author may be used to 21 1.1 chris * endorse or promote products derived from this software without specific 22 1.1 chris * prior written permission. 23 1.1 chris * 24 1.1 chris * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 1.1 chris * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 1.1 chris * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 1.1 chris * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 1.1 chris * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 1.1 chris * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 1.1 chris * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 1.1 chris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 1.1 chris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 1.1 chris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 1.1 chris * SUCH DAMAGE. 35 1.1 chris */ 36 1.1 chris 37 1.1 chris /* 38 1.1 chris * This file provides the bus space tag for the footbridge serial console 39 1.1 chris */ 40 1.1 chris 41 1.1 chris /* 42 1.1 chris * bus_space I/O functions for mainbus 43 1.1 chris */ 44 1.5 chris 45 1.5 chris #include <sys/cdefs.h> 46 1.10 skrll __KERNEL_RCSID(0, "$NetBSD: footbridge_com_io.c,v 1.10 2021/08/13 11:40:43 skrll Exp $"); 47 1.1 chris 48 1.1 chris #include <sys/param.h> 49 1.1 chris #include <sys/systm.h> 50 1.7 dyoung #include <sys/bus.h> 51 1.1 chris 52 1.1 chris /* Proto types for all the bus_space structure functions */ 53 1.1 chris 54 1.1 chris bs_protos(fcomcons); 55 1.3 thorpej bs_protos(generic); 56 1.1 chris bs_protos(bs_notimpl); 57 1.1 chris 58 1.1 chris /* Declare the fcomcons bus space tag */ 59 1.1 chris 60 1.1 chris struct bus_space fcomcons_bs_tag = { 61 1.1 chris /* cookie */ 62 1.9 ryo .bs_cookie = NULL, 63 1.1 chris 64 1.1 chris /* mapping/unmapping */ 65 1.9 ryo .bs_map = fcomcons_bs_map, 66 1.9 ryo .bs_unmap = fcomcons_bs_unmap, 67 1.9 ryo .bs_subregion = fcomcons_bs_subregion, 68 1.1 chris 69 1.1 chris /* allocation/deallocation */ 70 1.9 ryo .bs_alloc = fcomcons_bs_alloc, 71 1.9 ryo .bs_free = fcomcons_bs_free, 72 1.1 chris 73 1.1 chris /* get kernel virtual address */ 74 1.9 ryo .bs_vaddr = 0, /* never used */ 75 1.2 chris 76 1.2 chris /* Mmap bus space for user */ 77 1.9 ryo .bs_mmap = bs_notimpl_bs_mmap, 78 1.1 chris 79 1.1 chris /* barrier */ 80 1.9 ryo .bs_barrier = fcomcons_bs_barrier, 81 1.1 chris 82 1.1 chris /* read (single) */ 83 1.9 ryo .bs_r_1 = bs_notimpl_bs_r_1, 84 1.9 ryo .bs_r_2 = bs_notimpl_bs_r_2, 85 1.9 ryo .bs_r_4 = generic_bs_r_4, 86 1.9 ryo .bs_r_8 = bs_notimpl_bs_r_8, 87 1.1 chris 88 1.1 chris /* read multiple */ 89 1.9 ryo .bs_rm_1 = bs_notimpl_bs_rm_1, 90 1.9 ryo .bs_rm_2 = bs_notimpl_bs_rm_2, 91 1.9 ryo .bs_rm_4 = bs_notimpl_bs_rm_4, 92 1.9 ryo .bs_rm_8 = bs_notimpl_bs_rm_8, 93 1.1 chris 94 1.1 chris /* read region */ 95 1.9 ryo .bs_rr_1 = bs_notimpl_bs_rr_1, 96 1.9 ryo .bs_rr_2 = bs_notimpl_bs_rr_2, 97 1.9 ryo .bs_rr_4 = bs_notimpl_bs_rr_4, 98 1.9 ryo .bs_rr_8 = bs_notimpl_bs_rr_8, 99 1.1 chris 100 1.1 chris /* write (single) */ 101 1.9 ryo .bs_w_1 = bs_notimpl_bs_w_1, 102 1.9 ryo .bs_w_2 = bs_notimpl_bs_w_2, 103 1.9 ryo .bs_w_4 = generic_bs_w_4, 104 1.9 ryo .bs_w_8 = bs_notimpl_bs_w_8, 105 1.1 chris 106 1.1 chris /* write multiple */ 107 1.9 ryo .bs_wm_1 = bs_notimpl_bs_wm_1, 108 1.9 ryo .bs_wm_2 = bs_notimpl_bs_wm_2, 109 1.9 ryo .bs_wm_4 = bs_notimpl_bs_wm_4, 110 1.9 ryo .bs_wm_8 = bs_notimpl_bs_wm_8, 111 1.1 chris 112 1.1 chris /* write region */ 113 1.9 ryo .bs_wr_1 = bs_notimpl_bs_wr_1, 114 1.9 ryo .bs_wr_2 = bs_notimpl_bs_wr_2, 115 1.9 ryo .bs_wr_4 = bs_notimpl_bs_wr_4, 116 1.9 ryo .bs_wr_8 = bs_notimpl_bs_wr_8, 117 1.9 ryo 118 1.9 ryo .bs_sm_1 = bs_notimpl_bs_sm_1, 119 1.9 ryo .bs_sm_2 = bs_notimpl_bs_sm_2, 120 1.9 ryo .bs_sm_4 = bs_notimpl_bs_sm_4, 121 1.9 ryo .bs_sm_8 = bs_notimpl_bs_sm_8, 122 1.1 chris 123 1.1 chris /* set region */ 124 1.9 ryo .bs_sr_1 = bs_notimpl_bs_sr_1, 125 1.9 ryo .bs_sr_2 = bs_notimpl_bs_sr_2, 126 1.9 ryo .bs_sr_4 = bs_notimpl_bs_sr_4, 127 1.9 ryo .bs_sr_8 = bs_notimpl_bs_sr_8, 128 1.1 chris 129 1.1 chris /* copy */ 130 1.9 ryo .bs_c_1 = bs_notimpl_bs_c_1, 131 1.9 ryo .bs_c_2 = bs_notimpl_bs_c_2, 132 1.9 ryo .bs_c_4 = bs_notimpl_bs_c_4, 133 1.9 ryo .bs_c_8 = bs_notimpl_bs_c_8, 134 1.1 chris }; 135 1.1 chris 136 1.1 chris /* bus space functions */ 137 1.1 chris 138 1.1 chris int 139 1.6 dsl fcomcons_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int cacheable, bus_space_handle_t *bshp) 140 1.1 chris { 141 1.1 chris /* 142 1.1 chris * Temporary implementation as all I/O is already mapped etc. 143 1.1 chris * 144 1.1 chris * Eventually this function will do the mapping check for multiple maps 145 1.1 chris */ 146 1.1 chris *bshp = bpa; 147 1.1 chris return(0); 148 1.1 chris } 149 1.1 chris 150 1.1 chris int 151 1.8 matt fcomcons_bs_alloc( 152 1.8 matt void *t, 153 1.8 matt bus_addr_t rstart, 154 1.8 matt bus_addr_t rend, 155 1.8 matt bus_size_t size, 156 1.8 matt bus_size_t alignment, 157 1.8 matt bus_size_t boundary, 158 1.8 matt int cacheable, 159 1.8 matt bus_addr_t *bpap, 160 1.8 matt bus_space_handle_t *bshp) 161 1.1 chris { 162 1.4 provos panic("fcomcons_alloc(): Help!"); 163 1.1 chris } 164 1.1 chris 165 1.1 chris 166 1.1 chris void 167 1.6 dsl fcomcons_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) 168 1.1 chris { 169 1.1 chris /* 170 1.1 chris * Temporary implementation 171 1.1 chris */ 172 1.1 chris } 173 1.1 chris 174 1.10 skrll void 175 1.6 dsl fcomcons_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) 176 1.1 chris { 177 1.1 chris 178 1.4 provos panic("fcomcons_free(): Help!"); 179 1.1 chris /* fcomcons_unmap() does all that we need to do. */ 180 1.1 chris /* fcomcons_unmap(t, bsh, size);*/ 181 1.1 chris } 182 1.1 chris 183 1.1 chris int 184 1.6 dsl fcomcons_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp) 185 1.1 chris { 186 1.1 chris 187 1.1 chris *nbshp = bsh + offset; 188 1.1 chris return (0); 189 1.1 chris } 190 1.1 chris 191 1.1 chris void 192 1.6 dsl fcomcons_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset, bus_size_t len, int flags) 193 1.1 chris { 194 1.10 skrll } 195 1.1 chris 196 1.1 chris /* End of footbridge_com_io.c */ 197