1239674Srwatson/*-
2239674Srwatson * Copyright (c) 2012 Robert N. M. Watson
3239674Srwatson * All rights reserved.
4239674Srwatson *
5239674Srwatson * This software was developed by SRI International and the University of
6239674Srwatson * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7239674Srwatson * ("CTSRD"), as part of the DARPA CRASH research programme.
8239674Srwatson *
9239674Srwatson * Redistribution and use in source and binary forms, with or without
10239674Srwatson * modification, are permitted provided that the following conditions
11239674Srwatson * are met:
12239674Srwatson * 1. Redistributions of source code must retain the above copyright
13239674Srwatson *    notice, this list of conditions and the following disclaimer.
14239674Srwatson * 2. Redistributions in binary form must reproduce the above copyright
15239674Srwatson *    notice, this list of conditions and the following disclaimer in the
16239674Srwatson *    documentation and/or other materials provided with the distribution.
17239674Srwatson *
18239674Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19239674Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20239674Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21239674Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22239674Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23239674Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24239674Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25239674Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26239674Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27239674Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28239674Srwatson * SUCH DAMAGE.
29239674Srwatson *
30239674Srwatson * $FreeBSD: releng/10.3/sys/dev/altera/avgen/altera_avgen.h 245380 2013-01-13 16:57:11Z rwatson $
31239674Srwatson */
32239674Srwatson
33239674Srwatson#ifndef _DEV_ALTERA_AVALON_H_
34239674Srwatson#define	_DEV_ALTERA_AVALON_H_
35239674Srwatson
36239674Srwatsonstruct altera_avgen_softc {
37239674Srwatson	/*
38239674Srwatson	 * Bus-related fields.
39239674Srwatson	 */
40239674Srwatson	device_t	 avg_dev;
41239674Srwatson	int		 avg_unit;
42239674Srwatson
43239674Srwatson	/*
44239674Srwatson	 * The device node and memory-mapped I/O region.
45239674Srwatson	 */
46239674Srwatson	struct cdev	*avg_cdev;
47239674Srwatson	struct resource	*avg_res;
48239674Srwatson	int		 avg_rid;
49239674Srwatson
50239674Srwatson	/*
51239674Srwatson	 * Access properties configured by device.hints.
52239674Srwatson	 */
53239674Srwatson	u_int		 avg_flags;
54239674Srwatson	u_int		 avg_width;
55239674Srwatson};
56239674Srwatson
57239674Srwatson/*
58239674Srwatson * Various flags extracted from device.hints to configure operations on the
59239674Srwatson * device.
60239674Srwatson */
61239674Srwatson#define	ALTERA_AVALON_FLAG_READ			0x01
62239674Srwatson#define	ALTERA_AVALON_FLAG_WRITE		0x02
63239674Srwatson#define	ALTERA_AVALON_FLAG_MMAP_READ		0x04
64239674Srwatson#define	ALTERA_AVALON_FLAG_MMAP_WRITE		0x08
65239674Srwatson#define	ALTERA_AVALON_FLAG_MMAP_EXEC		0x10
66239674Srwatson
67239674Srwatson#define	ALTERA_AVALON_CHAR_READ			'r'
68239674Srwatson#define	ALTERA_AVALON_CHAR_WRITE		'w'
69239674Srwatson#define	ALTERA_AVALON_CHAR_EXEC			'x'
70239674Srwatson
71239674Srwatson#define	ALTERA_AVALON_STR_WIDTH			"width"
72239674Srwatson#define	ALTERA_AVALON_STR_FILEIO		"fileio"
73239674Srwatson#define	ALTERA_AVALON_STR_MMAPIO		"mmapio"
74239674Srwatson#define ALTERA_AVALON_STR_DEVNAME		"devname"
75239674Srwatson#define	ALTERA_AVALON_STR_DEVUNIT		"devunit"
76239674Srwatson
77239674Srwatson/*
78239674Srwatson * Driver setup routines from the bus attachment/teardown.
79239674Srwatson */
80245376Srwatsonint	altera_avgen_attach(struct altera_avgen_softc *sc,
81245376Srwatson	    const char *str_fileio, const char *str_mmapio,
82245376Srwatson	    const char *str_devname, int devunit);
83239674Srwatsonvoid	altera_avgen_detach(struct altera_avgen_softc *sc);
84239674Srwatson
85245380Srwatsonextern devclass_t	altera_avgen_devclass;
86245380Srwatson
87239674Srwatson#endif /* _DEV_ALTERA_AVALON_H_ */
88