bcm2835_gpioreg.h revision 1.5 1 1.5 mlelstv /* $NetBSD: bcm2835_gpioreg.h,v 1.5 2019/09/28 07:24:52 mlelstv Exp $ */
2 1.1 jakllsch
3 1.1 jakllsch /*
4 1.1 jakllsch * Copyright (c) 2013 Jonathan A. Kollasch
5 1.1 jakllsch * All rights reserved.
6 1.1 jakllsch *
7 1.1 jakllsch * Redistribution and use in source and binary forms, with or without
8 1.1 jakllsch * modification, are permitted provided that the following conditions
9 1.1 jakllsch * are met:
10 1.1 jakllsch * 1. Redistributions of source code must retain the above copyright
11 1.1 jakllsch * notice, this list of conditions and the following disclaimer.
12 1.1 jakllsch * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jakllsch * notice, this list of conditions and the following disclaimer in the
14 1.1 jakllsch * documentation and/or other materials provided with the distribution.
15 1.1 jakllsch *
16 1.1 jakllsch * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 1.1 jakllsch * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 jakllsch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 jakllsch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 1.1 jakllsch * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 1.1 jakllsch * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 1.1 jakllsch * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 1.1 jakllsch * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 1.1 jakllsch * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 1.1 jakllsch * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 1.1 jakllsch * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.1 jakllsch */
28 1.1 jakllsch
29 1.1 jakllsch #ifndef _BROADCOM_BCM2835_GPIOREG_H_
30 1.1 jakllsch #define _BROADCOM_BCM2835_GPIOREG_H_
31 1.1 jakllsch
32 1.1 jakllsch #define BCM2835_GPIO_GPFSEL(x) (0x000 + (x) * sizeof(uint32_t))
33 1.1 jakllsch #define BCM2835_GPIO_GPFSEL_PINS_PER_REGISTER 10
34 1.2 skrll #define BCM2835_GPIO_GPFSEL_BITS_PER_PIN 3
35 1.1 jakllsch
36 1.3 kardel #define BCM2835_GPIO_GPSET(x) (0x01C + (x) * sizeof(uint32_t))
37 1.3 kardel #define BCM2835_GPIO_GPSET_PINS_PER_REGISTER 32
38 1.3 kardel #define BCM2835_GPIO_GPCLR(x) (0x028 + (x) * sizeof(uint32_t))
39 1.3 kardel #define BCM2835_GPIO_GPCLR_PINS_PER_REGISTER BCM2835_GPIO_GPSET_PINS_PER_REGISTER
40 1.3 kardel #define BCM2835_GPIO_GPLEV(x) (0x034 + (x) * sizeof(uint32_t))
41 1.3 kardel #define BCM2835_GPIO_GPLEV_PINS_PER_REGISTER 32
42 1.3 kardel #define BCM2835_GPIO_GPEDS(x) (0x040 + (x) * sizeof(uint32_t))
43 1.3 kardel #define BCM2835_GPIO_GPREN(x) (0x04C + (x) * sizeof(uint32_t))
44 1.3 kardel #define BCM2835_GPIO_GPFEN(x) (0x058 + (x) * sizeof(uint32_t))
45 1.3 kardel #define BCM2835_GPIO_GPHEN(x) (0x064 + (x) * sizeof(uint32_t))
46 1.3 kardel #define BCM2835_GPIO_GPLEN(x) (0x070 + (x) * sizeof(uint32_t))
47 1.3 kardel #define BCM2835_GPIO_GPAREN(x) (0x07C + (x) * sizeof(uint32_t))
48 1.3 kardel #define BCM2835_GPIO_GPAFEN(x) (0x088 + (x) * sizeof(uint32_t))
49 1.4 skrll
50 1.3 kardel #define BCM2835_GPIO_GPPUD (0x094)
51 1.5 mlelstv
52 1.4 skrll /* brcm,pull property */
53 1.4 skrll #define BCM2835_GPIO_GPPUD_PULLOFF 0x0
54 1.4 skrll #define BCM2835_GPIO_GPPUD_PULLDOWN 0x1
55 1.4 skrll #define BCM2835_GPIO_GPPUD_PULLUP 0x2
56 1.3 kardel #define BCM2835_GPIO_GPPUDCLK(x) (0x098 + (x) * sizeof(uint32_t))
57 1.3 kardel #define BCM2835_GPIO_GPPUD_PINS_PER_REGISTER 32
58 1.3 kardel
59 1.5 mlelstv #define BCM2838_GPIO_GPPUD_PULLOFF 0x0
60 1.5 mlelstv #define BCM2838_GPIO_GPPUD_PULLDOWN 0x2
61 1.5 mlelstv #define BCM2838_GPIO_GPPUD_PULLUP 0x1
62 1.5 mlelstv #define BCM2838_GPIO_GPPUPPDN(x) (0x0e4 + (x) * sizeof(uint32_t))
63 1.5 mlelstv #define BCM2838_GPIO_GPPUD_REGID(n) ((n) / 16)
64 1.5 mlelstv #define BCM2838_GPIO_GPPUD_MASK(n) (0x3 << ((n) % 16)*2)
65 1.5 mlelstv
66 1.4 skrll /* brcm,function property */
67 1.4 skrll #define BCM2835_GPIO_IN 0
68 1.4 skrll #define BCM2835_GPIO_OUT 1
69 1.4 skrll #define BCM2835_GPIO_ALT5 2
70 1.4 skrll #define BCM2835_GPIO_ALT4 3
71 1.4 skrll #define BCM2835_GPIO_ALT0 4
72 1.4 skrll #define BCM2835_GPIO_ALT1 5
73 1.4 skrll #define BCM2835_GPIO_ALT2 6
74 1.4 skrll #define BCM2835_GPIO_ALT3 7
75 1.1 jakllsch
76 1.1 jakllsch #endif /* _BROADCOM_BCM2835_GPIOREG_H_ */
77