xref: /netbsd-src/sys/dev/ic/pl061var.h (revision 84f5ea6117c76c8ac2e40fed70f95d89ef203ab8)
1 /* $NetBSD: pl061var.h,v 1.2 2018/10/21 18:31:14 jmcneill Exp $ */
2 
3 /*
4  * Copyright (c) 2018 Jonathan A. Kollasch
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _PL061VAR_H
30 #define _PL061VAR_H
31 
32 struct plgpio_softc {
33 	device_t		sc_dev;
34 	bus_space_tag_t		sc_bst;
35 	bus_space_handle_t	sc_bsh;
36 
37 	struct gpio_chipset_tag	sc_gc;
38 	gpio_pin_t		sc_pins[8];
39 
40 	uint32_t		sc_reserved_mask;
41 };
42 
43 void	plgpio_attach(struct plgpio_softc *);
44 
45 int	plgpio_pin_read(void *, int);
46 void	plgpio_pin_write(void *, int, int);
47 void	plgpio_pin_ctl(void *, int, int);
48 
49 #define PLGPIO_WRITE(sc, reg, val) \
50 	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
51 #define PLGPIO_READ(sc, reg) \
52 	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
53 
54 #endif /* !_PL061VAR_H */
55