1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #define S905_GPIOX_PINS    22
8 #define S905_GPIOY_PINS    17
9 #define S905_GPIOZ_PINS    16
10 #define S905_GPIODV_PINS   30
11 #define S905_GPIOH_PINS    4
12 #define S905_GPIOCLK_PINS  2
13 #define S905_GPIOBOOT_PINS 18
14 #define S905_GPIOCARD_PINS 7
15 #define S905_GPIOAO_PINS   14
16 
17 #define S905_GPIOX_START       (0 * 32)
18 #define S905_GPIOY_START       (1 * 32)
19 #define S905_GPIOZ_START       (2 * 32)
20 #define S905_GPIODV_START      (3 * 32)
21 #define S905_GPIOH_START       (4 * 32)
22 #define S905_GPIOCLK_START     (5 * 32)
23 #define S905_GPIOBOOT_START    (6 * 32)
24 #define S905_GPIOCARD_START    (7 * 32)
25 #define S905_GPIOAO_START      (8 * 32)
26 
27 #define S905_GPIOX(n)      (S905_GPIOX_START + n)
28 #define S905_GPIOY(n)      (S905_GPIOY_START + n)
29 #define S905_GPIOZ(n)      (S905_GPIOZ_START + n)
30 #define S905_GPIODV(n)     (S905_GPIODV_START + n)
31 #define S905_GPIOH(n)      (S905_GPIOH_START + n)
32 #define S905_GPIOCLK(n)    (S905_GPIOCLK_START + n)
33 #define S905_GPIOBOOT(n)   (S905_GPIOBOOT_START + n)
34 #define S905_GPIOCARD(n)   (S905_GPIOCARD_START + n)
35 #define S905_GPIOAO(n)     (S905_GPIOAO_START + n)
36 
37 #define S905_GPIOX_0EN     0x18
38 #define S905_GPIOX_OUT     0x19
39 #define S905_GPIOX_IN      0x1a
40 #define S905_GPIOY_0EN     0x0f
41 #define S905_GPIOY_OUT     0x10
42 #define S905_GPIOY_IN      0x11
43 #define S905_GPIOZ_0EN     0x0c
44 #define S905_GPIOZ_OUT     0x0d
45 #define S905_GPIOZ_IN      0x0e
46 #define S905_GPIODV_0EN    0x0c
47 #define S905_GPIODV_OUT    0x0d
48 #define S905_GPIODV_IN     0x0e
49 #define S905_GPIOH_0EN     0x0f
50 #define S905_GPIOH_OUT     0x10
51 #define S905_GPIOH_IN      0x11
52 #define S905_GPIOBOOT_0EN  0x12
53 #define S905_GPIOBOOT_OUT  0x13
54 #define S905_GPIOBOOT_IN   0x14
55 #define S905_GPIOCARD_0EN  0x12
56 #define S905_GPIOCARD_OUT  0x13
57 #define S905_GPIOCARD_IN   0x14
58 #define S905_GPIOCLK_0EN   0x15
59 #define S905_GPIOCLK_OUT   0x16
60 #define S905_GPIOCLK_IN    0x17
61 
62 #define S905_PERIPHS_PIN_MUX_0 0x2C
63 #define S905_PERIPHS_PIN_MUX_1 0x2D
64 #define S905_PERIPHS_PIN_MUX_2 0x2E
65 #define S905_PERIPHS_PIN_MUX_3 0x2F
66 #define S905_PERIPHS_PIN_MUX_4 0x30
67 #define S905_PERIPHS_PIN_MUX_5 0x31
68 #define S905_PERIPHS_PIN_MUX_6 0x32
69 #define S905_PERIPHS_PIN_MUX_7 0x33
70 #define S905_PERIPHS_PIN_MUX_8 0x34
71 #define S905_PERIPHS_PIN_MUX_9 0x35
72 
73 // GPIO AO registers live in a separate register bank.
74 #define S905_AO_RTI_PIN_MUX_REG  0x05
75 #define S905_AO_RTI_PIN_MUX_REG2 0x06
76 #define S905_AO_GPIO_OEN_OUT     0x09   // OEN: [13:0], OUT: [25:16]
77 #define S905_AO_GPIO_IN          0x0a
78 
79 #define S905_PULL_UP_REG0   0x3A
80 #define S905_PULL_UP_REG1   0x3B
81 #define S905_PULL_UP_REG2   0x3C
82 #define S905_PULL_UP_REG3   0x3D
83 #define S905_PULL_UP_REG4   0x3E
84 #define S905_PULL_UP_REG_AO 0x0b
85 
86 #define S905_PULL_UP_EN_REG0   0x48
87 #define S905_PULL_UP_EN_REG1   0x49
88 #define S905_PULL_UP_EN_REG2   0x4A
89 #define S905_PULL_UP_EN_REG3   0x4B
90 #define S905_PULL_UP_EN_REG4   0x4C
91 #define S905_PULL_UP_EN_REGAO  0x0b
92 
93 // These are relative to base address 0xc1100000 and in sizeof(uint32_t)
94 #define S905_GPIO_INT_STATUS            0x2618
95 #define S905_GPIO_INT_CLEAR             0x2619
96 #define S905_GPIO_INT_MASK              0x261A
97 #define S905_GPIO_INT_EDGE_POLARITY     0x2620
98 #define S905_GPIO_0_3_PIN_SELECT        0x2621
99 #define S905_GPIO_4_7_PIN_SELECT        0x2622
100 #define S905_GPIO_FILTER_SELECT         0x2623
101 
102 #define S905_GPIOA0_PIN_START      0
103 #define S905_GPIOZ_PIN_START       14
104 #define S905_GPIOH_PIN_START       30
105 #define S905_GPIOBOOT_PIN_START    34
106 #define S905_GPIOCARD_PIN_START    52
107 #define S905_GPIODV_PIN_START      59
108 #define S905_GPIOY_PIN_START       89
109 #define S905_GPIOX_PIN_START       106
110 #define S905_GPIOCLK_PIN_START     129
111