xref: /freebsd/sys/dev/altera/avgen/altera_avgen.h (revision b364a5252ea51c0c1a259d0c54c2bdb60d9a9924)
1cf824886SRobert Watson /*-
2cf824886SRobert Watson  * Copyright (c) 2012 Robert N. M. Watson
3cf824886SRobert Watson  * All rights reserved.
4cf824886SRobert Watson  *
5cf824886SRobert Watson  * This software was developed by SRI International and the University of
6cf824886SRobert Watson  * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7cf824886SRobert Watson  * ("CTSRD"), as part of the DARPA CRASH research programme.
8cf824886SRobert Watson  *
9cf824886SRobert Watson  * Redistribution and use in source and binary forms, with or without
10cf824886SRobert Watson  * modification, are permitted provided that the following conditions
11cf824886SRobert Watson  * are met:
12cf824886SRobert Watson  * 1. Redistributions of source code must retain the above copyright
13cf824886SRobert Watson  *    notice, this list of conditions and the following disclaimer.
14cf824886SRobert Watson  * 2. Redistributions in binary form must reproduce the above copyright
15cf824886SRobert Watson  *    notice, this list of conditions and the following disclaimer in the
16cf824886SRobert Watson  *    documentation and/or other materials provided with the distribution.
17cf824886SRobert Watson  *
18cf824886SRobert Watson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19cf824886SRobert Watson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20cf824886SRobert Watson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21cf824886SRobert Watson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22cf824886SRobert Watson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23cf824886SRobert Watson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24cf824886SRobert Watson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25cf824886SRobert Watson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26cf824886SRobert Watson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27cf824886SRobert Watson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28cf824886SRobert Watson  * SUCH DAMAGE.
29cf824886SRobert Watson  *
30cf824886SRobert Watson  * $FreeBSD$
31cf824886SRobert Watson  */
32cf824886SRobert Watson 
33cf824886SRobert Watson #ifndef _DEV_ALTERA_AVALON_H_
34cf824886SRobert Watson #define	_DEV_ALTERA_AVALON_H_
35cf824886SRobert Watson 
36cf824886SRobert Watson struct altera_avgen_softc {
37cf824886SRobert Watson 	/*
38cf824886SRobert Watson 	 * Bus-related fields.
39cf824886SRobert Watson 	 */
40cf824886SRobert Watson 	device_t	 avg_dev;
41cf824886SRobert Watson 	int		 avg_unit;
42cf824886SRobert Watson 
43cf824886SRobert Watson 	/*
44cf824886SRobert Watson 	 * The device node and memory-mapped I/O region.
45cf824886SRobert Watson 	 */
46cf824886SRobert Watson 	struct cdev	*avg_cdev;
47cf824886SRobert Watson 	struct resource	*avg_res;
48cf824886SRobert Watson 	int		 avg_rid;
49cf824886SRobert Watson 
50cf824886SRobert Watson 	/*
51cf824886SRobert Watson 	 * Access properties configured by device.hints.
52cf824886SRobert Watson 	 */
53cf824886SRobert Watson 	u_int		 avg_flags;
54cf824886SRobert Watson 	u_int		 avg_width;
55cf824886SRobert Watson };
56cf824886SRobert Watson 
57cf824886SRobert Watson /*
58cf824886SRobert Watson  * Various flags extracted from device.hints to configure operations on the
59cf824886SRobert Watson  * device.
60cf824886SRobert Watson  */
61cf824886SRobert Watson #define	ALTERA_AVALON_FLAG_READ			0x01
62cf824886SRobert Watson #define	ALTERA_AVALON_FLAG_WRITE		0x02
63cf824886SRobert Watson #define	ALTERA_AVALON_FLAG_MMAP_READ		0x04
64cf824886SRobert Watson #define	ALTERA_AVALON_FLAG_MMAP_WRITE		0x08
65cf824886SRobert Watson #define	ALTERA_AVALON_FLAG_MMAP_EXEC		0x10
66cf824886SRobert Watson 
67cf824886SRobert Watson #define	ALTERA_AVALON_CHAR_READ			'r'
68cf824886SRobert Watson #define	ALTERA_AVALON_CHAR_WRITE		'w'
69cf824886SRobert Watson #define	ALTERA_AVALON_CHAR_EXEC			'x'
70cf824886SRobert Watson 
71cf824886SRobert Watson #define	ALTERA_AVALON_STR_WIDTH			"width"
72cf824886SRobert Watson #define	ALTERA_AVALON_STR_FILEIO		"fileio"
73cf824886SRobert Watson #define	ALTERA_AVALON_STR_MMAPIO		"mmapio"
74cf824886SRobert Watson #define ALTERA_AVALON_STR_DEVNAME		"devname"
75cf824886SRobert Watson #define	ALTERA_AVALON_STR_DEVUNIT		"devunit"
76cf824886SRobert Watson 
77cf824886SRobert Watson /*
78cf824886SRobert Watson  * Driver setup routines from the bus attachment/teardown.
79cf824886SRobert Watson  */
80*b364a525SRobert Watson int	altera_avgen_attach(struct altera_avgen_softc *sc,
81*b364a525SRobert Watson 	    const char *str_fileio, const char *str_mmapio,
82*b364a525SRobert Watson 	    const char *str_devname, int devunit);
83cf824886SRobert Watson void	altera_avgen_detach(struct altera_avgen_softc *sc);
84cf824886SRobert Watson 
85cf824886SRobert Watson #endif /* _DEV_ALTERA_AVALON_H_ */
86