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