spibusvar.h revision 278957
1278957Simp/*-
2278957Simp * Copyright (c) 2006 M. Warner Losh
3278957Simp * All rights reserved.
4278957Simp *
5278957Simp * Redistribution and use in source and binary forms, with or without
6278957Simp * modification, are permitted provided that the following conditions
7278957Simp * are met:
8278957Simp * 1. Redistributions of source code must retain the above copyright
9278957Simp *    notice, this list of conditions and the following disclaimer.
10278957Simp * 2. Redistributions in binary form must reproduce the above copyright
11278957Simp *    notice, this list of conditions and the following disclaimer in the
12278957Simp *    documentation and/or other materials provided with the distribution.
13278957Simp *
14278957Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15278957Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16278957Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17278957Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18278957Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19278957Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20278957Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21278957Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22278957Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23278957Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24278957Simp * SUCH DAMAGE.
25278957Simp *
26278957Simp * $FreeBSD: head/sys/dev/spibus/spibusvar.h 278957 2015-02-18 14:33:33Z imp $
27278957Simp */
28160370Simp
29160370Simp#define SPIBUS_IVAR(d) (struct spibus_ivar *) device_get_ivars(d)
30160370Simp#define SPIBUS_SOFTC(d) (struct spibus_softc *) device_get_softc(d)
31160370Simp
32160370Simpstruct spibus_softc
33160370Simp{
34160370Simp	device_t	dev;
35160370Simp};
36160370Simp
37160370Simpstruct spibus_ivar
38160370Simp{
39160370Simp	uint32_t	cs;
40160370Simp};
41160370Simp
42160370Simpenum {
43160370Simp	SPIBUS_IVAR_CS		/* chip select that we're on */
44160370Simp};
45160370Simp
46160370Simp#define SPIBUS_ACCESSOR(A, B, T)					\
47228471Sedstatic inline int							\
48160370Simpspibus_get_ ## A(device_t dev, T *t)					\
49160370Simp{									\
50160370Simp	return BUS_READ_IVAR(device_get_parent(dev), dev,		\
51160370Simp	    SPIBUS_IVAR_ ## B, (uintptr_t *) t);			\
52160370Simp}
53160370Simp
54160370SimpSPIBUS_ACCESSOR(cs,		CS,		uint32_t)
55257064Sloos
56257064Sloosextern driver_t spibus_driver;
57257064Sloosextern devclass_t spibus_devclass;
58