xref: /netbsd-src/sys/arch/arm/broadcom/bcm2835_gpioreg.h (revision 229485571bb431865b82c776ddada4c7069b7571)
1 /*	$NetBSD: bcm2835_gpioreg.h,v 1.6 2021/03/08 13:59:29 mlelstv Exp $	*/
2 
3 /*
4  * Copyright (c) 2013 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 _BROADCOM_BCM2835_GPIOREG_H_
30 #define _BROADCOM_BCM2835_GPIOREG_H_
31 
32 #define BCM2835_GPIO_GPFSEL(x)	(0x000 + (x) * sizeof(uint32_t))
33 #define BCM2835_GPIO_GPFSEL_PINS_PER_REGISTER	10
34 #define BCM2835_GPIO_GPFSEL_BITS_PER_PIN	3
35 
36 #define BCM2835_GPIO_GPSET(x)	(0x01C + (x) * sizeof(uint32_t))
37 #define BCM2835_GPIO_GPSET_PINS_PER_REGISTER 32
38 #define BCM2835_GPIO_GPCLR(x)	(0x028 + (x) * sizeof(uint32_t))
39 #define BCM2835_GPIO_GPCLR_PINS_PER_REGISTER BCM2835_GPIO_GPSET_PINS_PER_REGISTER
40 #define BCM2835_GPIO_GPLEV(x)	(0x034 + (x) * sizeof(uint32_t))
41 #define BCM2835_GPIO_GPLEV_PINS_PER_REGISTER 32
42 #define BCM2835_GPIO_GPEDS(x)	(0x040 + (x) * sizeof(uint32_t))
43 #define BCM2835_GPIO_GPREN(x)	(0x04C + (x) * sizeof(uint32_t))
44 #define BCM2835_GPIO_GPFEN(x)	(0x058 + (x) * sizeof(uint32_t))
45 #define BCM2835_GPIO_GPHEN(x)	(0x064 + (x) * sizeof(uint32_t))
46 #define BCM2835_GPIO_GPLEN(x)	(0x070 + (x) * sizeof(uint32_t))
47 #define BCM2835_GPIO_GPAREN(x)	(0x07C + (x) * sizeof(uint32_t))
48 #define BCM2835_GPIO_GPAFEN(x)	(0x088 + (x) * sizeof(uint32_t))
49 
50 #define BCM2835_GPIO_GPPUD	(0x094)
51 
52 /* brcm,pull property */
53 #define  BCM2835_GPIO_GPPUD_PULLOFF	0x0
54 #define  BCM2835_GPIO_GPPUD_PULLDOWN	0x1
55 #define  BCM2835_GPIO_GPPUD_PULLUP	0x2
56 #define BCM2835_GPIO_GPPUDCLK(x)	(0x098 + (x) * sizeof(uint32_t))
57 #define BCM2835_GPIO_GPPUD_PINS_PER_REGISTER 32
58 
59 #define  BCM2838_GPIO_GPPUD_PULLOFF	0x0
60 #define  BCM2838_GPIO_GPPUD_PULLDOWN	0x2
61 #define  BCM2838_GPIO_GPPUD_PULLUP	0x1
62 #define BCM2838_GPIO_GPPUPPDN(x)	(0x0e4 + (x) * sizeof(uint32_t))
63 #define BCM2838_GPIO_GPPUD_REGID(n)	((n) / 16)
64 #define BCM2838_GPIO_GPPUD_MASK(n)	(0x3 << ((n) % 16)*2)
65 
66 /* brcm,function property */
67 #define BCM2835_GPIO_IN		0
68 #define BCM2835_GPIO_OUT	1
69 #define BCM2835_GPIO_ALT5	2
70 #define BCM2835_GPIO_ALT4	3
71 #define BCM2835_GPIO_ALT0	4
72 #define BCM2835_GPIO_ALT1	5
73 #define BCM2835_GPIO_ALT2	6
74 #define BCM2835_GPIO_ALT3	7
75 
76 /* Undocumented register to multiplex emmc2 pins to legacy sdhc */
77 #define BCM2838_GPIO_MUX		0x0d0
78 #define  BCM2838_GPIO_MUX_LEGACY	0x2
79 
80 #endif /* _BROADCOM_BCM2835_GPIOREG_H_ */
81