pxa_space.c (227293) | pxa_space.c (277460) |
---|---|
1/* $NetBSD: obio_space.c,v 1.6 2003/07/15 00:25:05 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 8 * --- 26 unchanged lines hidden (view full) --- 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38/* 39 * bus_space functions for PXA devices 40 */ 41 42#include <sys/cdefs.h> | 1/* $NetBSD: obio_space.c,v 1.6 2003/07/15 00:25:05 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 8 * --- 26 unchanged lines hidden (view full) --- 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38/* 39 * bus_space functions for PXA devices 40 */ 41 42#include <sys/cdefs.h> |
43__FBSDID("$FreeBSD: head/sys/arm/xscale/pxa/pxa_space.c 227293 2011-11-07 06:44:47Z ed $"); | 43__FBSDID("$FreeBSD: head/sys/arm/xscale/pxa/pxa_space.c 277460 2015-01-21 01:06:08Z ian $"); |
44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/bus.h> 48#include <sys/kernel.h> 49#include <sys/malloc.h> 50 51#include <machine/bus.h> --- 88 unchanged lines hidden (view full) --- 140bus_space_tag_t base_tag = &_base_tag; 141bus_space_tag_t obio_tag = NULL; 142 143void 144pxa_obio_tag_init() 145{ 146 147 bcopy(&_base_tag, &_obio_tag, sizeof(struct bus_space)); | 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/bus.h> 48#include <sys/kernel.h> 49#include <sys/malloc.h> 50 51#include <machine/bus.h> --- 88 unchanged lines hidden (view full) --- 140bus_space_tag_t base_tag = &_base_tag; 141bus_space_tag_t obio_tag = NULL; 142 143void 144pxa_obio_tag_init() 145{ 146 147 bcopy(&_base_tag, &_obio_tag, sizeof(struct bus_space)); |
148 _obio_tag.bs_cookie = (void *)PXA2X0_PERIPH_OFFSET; | 148 _obio_tag.bs_privdata = (void *)PXA2X0_PERIPH_OFFSET; |
149 obio_tag = &_obio_tag; 150} 151 152bus_space_tag_t 153pxa_bus_tag_alloc(bus_addr_t offset) 154{ 155 struct bus_space *tag; 156 157 tag = (struct bus_space *)malloc(sizeof(struct bus_space), M_PXATAG, 158 M_WAITOK); 159 if (tag == NULL) { 160 return (NULL); 161 } 162 163 bcopy(&_base_tag, tag, sizeof(struct bus_space)); | 149 obio_tag = &_obio_tag; 150} 151 152bus_space_tag_t 153pxa_bus_tag_alloc(bus_addr_t offset) 154{ 155 struct bus_space *tag; 156 157 tag = (struct bus_space *)malloc(sizeof(struct bus_space), M_PXATAG, 158 M_WAITOK); 159 if (tag == NULL) { 160 return (NULL); 161 } 162 163 bcopy(&_base_tag, tag, sizeof(struct bus_space)); |
164 tag->bs_cookie = (void *)offset; | 164 tag->bs_privdata = (void *)offset; |
165 166 return ((bus_space_tag_t)tag); 167} 168 169 170#define READ_SINGLE(type, proto, base) \ 171 type \ | 165 166 return ((bus_space_tag_t)tag); 167} 168 169 170#define READ_SINGLE(type, proto, base) \ 171 type \ |
172 proto(void *cookie, bus_space_handle_t bsh, bus_size_t offset) \ | 172 proto(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t offset) \ |
173 { \ 174 bus_addr_t tag_offset; \ 175 type value; \ | 173 { \ 174 bus_addr_t tag_offset; \ 175 type value; \ |
176 tag_offset = (bus_addr_t)cookie; \ | 176 tag_offset = (bus_addr_t)tag->bs_privdata; \ |
177 value = base(NULL, bsh + tag_offset, offset); \ 178 return (value); \ 179 } 180 181READ_SINGLE(u_int8_t, pxa_bs_r_1, generic_bs_r_1) 182READ_SINGLE(u_int16_t, pxa_bs_r_2, generic_armv4_bs_r_2) 183READ_SINGLE(u_int32_t, pxa_bs_r_4, generic_bs_r_4) 184 185#undef READ_SINGLE 186 187#define WRITE_SINGLE(type, proto, base) \ 188 void \ | 177 value = base(NULL, bsh + tag_offset, offset); \ 178 return (value); \ 179 } 180 181READ_SINGLE(u_int8_t, pxa_bs_r_1, generic_bs_r_1) 182READ_SINGLE(u_int16_t, pxa_bs_r_2, generic_armv4_bs_r_2) 183READ_SINGLE(u_int32_t, pxa_bs_r_4, generic_bs_r_4) 184 185#undef READ_SINGLE 186 187#define WRITE_SINGLE(type, proto, base) \ 188 void \ |
189 proto(void *cookie, bus_space_handle_t bsh, bus_size_t offset, \ | 189 proto(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t offset, \ |
190 type value) \ 191 { \ 192 bus_addr_t tag_offset; \ | 190 type value) \ 191 { \ 192 bus_addr_t tag_offset; \ |
193 tag_offset = (bus_addr_t)cookie; \ | 193 tag_offset = (bus_addr_t)tag->bs_privdata; \ |
194 base(NULL, bsh + tag_offset, offset, value); \ 195 } 196 197WRITE_SINGLE(u_int8_t, pxa_bs_w_1, generic_bs_w_1) 198WRITE_SINGLE(u_int16_t, pxa_bs_w_2, generic_armv4_bs_w_2) 199WRITE_SINGLE(u_int32_t, pxa_bs_w_4, generic_bs_w_4) 200 201#undef WRITE_SINGLE 202 203#define READ_MULTI(type, proto, base) \ 204 void \ | 194 base(NULL, bsh + tag_offset, offset, value); \ 195 } 196 197WRITE_SINGLE(u_int8_t, pxa_bs_w_1, generic_bs_w_1) 198WRITE_SINGLE(u_int16_t, pxa_bs_w_2, generic_armv4_bs_w_2) 199WRITE_SINGLE(u_int32_t, pxa_bs_w_4, generic_bs_w_4) 200 201#undef WRITE_SINGLE 202 203#define READ_MULTI(type, proto, base) \ 204 void \ |
205 proto(void *cookie, bus_space_handle_t bsh, bus_size_t offset, \ | 205 proto(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t offset, \ |
206 type *dest, bus_size_t count) \ 207 { \ 208 bus_addr_t tag_offset; \ | 206 type *dest, bus_size_t count) \ 207 { \ 208 bus_addr_t tag_offset; \ |
209 tag_offset = (bus_addr_t)cookie; \ | 209 tag_offset = (bus_addr_t)tag->bs_privdata; \ |
210 base(NULL, bsh + tag_offset, offset, dest, count); \ 211 } 212 213READ_MULTI(u_int8_t, pxa_bs_rm_1, generic_bs_rm_1) 214READ_MULTI(u_int16_t, pxa_bs_rm_2, generic_armv4_bs_rm_2) 215 216READ_MULTI(u_int8_t, pxa_bs_rr_1, generic_bs_rr_1) 217 218#undef READ_MULTI 219 220#define WRITE_MULTI(type, proto, base) \ 221 void \ | 210 base(NULL, bsh + tag_offset, offset, dest, count); \ 211 } 212 213READ_MULTI(u_int8_t, pxa_bs_rm_1, generic_bs_rm_1) 214READ_MULTI(u_int16_t, pxa_bs_rm_2, generic_armv4_bs_rm_2) 215 216READ_MULTI(u_int8_t, pxa_bs_rr_1, generic_bs_rr_1) 217 218#undef READ_MULTI 219 220#define WRITE_MULTI(type, proto, base) \ 221 void \ |
222 proto(void *cookie, bus_space_handle_t bsh, bus_size_t offset, \ | 222 proto(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t offset, \ |
223 const type *src, bus_size_t count) \ 224 { \ 225 bus_addr_t tag_offset; \ | 223 const type *src, bus_size_t count) \ 224 { \ 225 bus_addr_t tag_offset; \ |
226 tag_offset = (bus_addr_t)cookie; \ | 226 tag_offset = (bus_addr_t)tag->bs_privdata; \ |
227 base(NULL, bsh + tag_offset, offset, src, count); \ 228 } 229 230WRITE_MULTI(u_int8_t, pxa_bs_wm_1, generic_bs_wm_1) 231WRITE_MULTI(u_int16_t, pxa_bs_wm_2, generic_armv4_bs_wm_2) 232 233#undef WRITE_MULTI | 227 base(NULL, bsh + tag_offset, offset, src, count); \ 228 } 229 230WRITE_MULTI(u_int8_t, pxa_bs_wm_1, generic_bs_wm_1) 231WRITE_MULTI(u_int16_t, pxa_bs_wm_2, generic_armv4_bs_wm_2) 232 233#undef WRITE_MULTI |