sibavar.h revision 183371
1183371Simp/*- 2183371Simp * Copyright (c) 2007 Bruce M. Simpson. 3183371Simp * All rights reserved. 4183371Simp * 5183371Simp * Redistribution and use in source and binary forms, with or without 6183371Simp * modification, are permitted provided that the following conditions 7183371Simp * are met: 8183371Simp * 1. Redistributions of source code must retain the above copyright 9183371Simp * notice, this list of conditions and the following disclaimer. 10183371Simp * 2. Redistributions in binary form must reproduce the above copyright 11183371Simp * notice, this list of conditions and the following disclaimer in the 12183371Simp * documentation and/or other materials provided with the distribution. 13183371Simp * 14183371Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15183371Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16183371Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17183371Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18183371Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19183371Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20183371Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21183371Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22183371Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23183371Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24183371Simp * SUCH DAMAGE. 25183371Simp * 26183371Simp * $FreeBSD: head/sys/dev/siba/sibavar.h 183371 2008-09-26 03:57:23Z imp $ 27183371Simp */ 28183371Simp 29183371Simp#ifndef _SIBA_SIBAVAR_H_ 30183371Simp#define _SIBA_SIBAVAR_H_ 31183371Simp 32183371Simp#include <sys/rman.h> 33183371Simp 34183371Simpstruct siba_softc { 35183371Simp device_t sc_dev; /* Device ID */ 36183371Simp struct resource *sc_mem; /* Memory window on nexus */ 37183371Simp 38183371Simp bus_space_tag_t sc_bt; 39183371Simp bus_space_handle_t sc_bh; 40183371Simp bus_addr_t sc_maddr; 41183371Simp bus_size_t sc_msize; 42183371Simp 43183371Simp uint8_t sc_ncores; 44183371Simp}; 45183371Simp 46183371Simpstruct siba_devinfo { 47183371Simp struct resource_list sdi_rl; 48183371Simp /*devhandle_t sdi_devhandle; XXX*/ 49183371Simp /*struct rman sdi_intr_rman;*/ 50183371Simp 51183371Simp /* Accessors are needed for ivars below. */ 52183371Simp uint16_t sdi_vid; 53183371Simp uint16_t sdi_devid; 54183371Simp uint8_t sdi_rev; 55183371Simp uint8_t sdi_idx; /* core index on bus */ 56183371Simp uint8_t sdi_irq; /* TODO */ 57183371Simp}; 58183371Simp 59183371Simp#define siba_read_2(sc, core, reg) \ 60183371Simp bus_space_read_2((sc)->sc_bt, (sc)->sc_bh, \ 61183371Simp (core * SIBA_CORE_LEN) + (reg)) 62183371Simp 63183371Simp#define siba_read_4(sc, core, reg) \ 64183371Simp bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, \ 65183371Simp (core * SIBA_CORE_LEN) + (reg)) 66183371Simp 67183371Simp#define siba_write_2(sc, core, reg, val) \ 68183371Simp bus_space_write_2((sc)->sc_bt, (sc)->sc_bh, \ 69183371Simp (core * SIBA_CORE_LEN) + (reg), (val)) 70183371Simp 71183371Simp#define siba_write_4(sc, core, reg, val) \ 72183371Simp bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, \ 73183371Simp (core * SIBA_CORE_LEN) + (reg), (val)) 74183371Simp 75183371Simpenum siba_device_ivars { 76183371Simp SIBA_IVAR_VENDOR, 77183371Simp SIBA_IVAR_DEVICE, 78183371Simp SIBA_IVAR_REVID, 79183371Simp SIBA_IVAR_CORE_INDEX 80183371Simp}; 81183371Simp 82183371Simp#define SIBA_ACCESSOR(var, ivar, type) \ 83183371Simp __BUS_ACCESSOR(siba, var, SIBA, ivar, type) 84183371Simp 85183371SimpSIBA_ACCESSOR(vendor, VENDOR, uint16_t) 86183371SimpSIBA_ACCESSOR(device, DEVICE, uint16_t) 87183371SimpSIBA_ACCESSOR(revid, REVID, uint8_t) 88183371SimpSIBA_ACCESSOR(core_index, CORE_INDEX, uint8_t) 89183371Simp 90183371Simp#undef SIBA_ACCESSOR 91183371Simp 92183371Simp#endif /* _SIBA_SIBAVAR_H_ */ 93