GitLab has been upgraded to 13.7.4 If you encounter any issues mail code@riscosopen.org

GPIO 54.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
;
; Copyright (c) 2012, RISC OS Open Ltd
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;     * Redistributions of source code must retain the above copyright
;       notice, this list of conditions and the following disclaimer.
;     * Redistributions in binary form must reproduce the above copyright
;       notice, this list of conditions and the following disclaimer in the
;       documentation and/or other materials provided with the distribution.
;     * Neither the name of RISC OS Open Ltd nor the names of its contributors
;       may be used to endorse or promote products derived from this software
;       without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
; POSSIBILITY OF SUCH DAMAGE.
;

        AREA    |ARM$$code|, CODE, READONLY, PIC

        GET     Hdr:ListOpts
        GET     Hdr:Macros
ROOL's avatar
ROOL committed
33
        GET     Hdr:System
34 35 36
        GET     Hdr:Proc
        GET     hdr.BCM2835
        GET     hdr.StaticWS
ROOL's avatar
ROOL committed
37
        GET     hdr.CastleMacros
38 39

        EXPORT  GPIO_InitDevices
40
        EXPORT  HAL_PlatformName
41
        IMPORT  memcpy
ROOL's avatar
ROOL committed
42
        IMPORT  HAL_CounterDelay
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

        MACRO
$class  HALDeviceField $field, $value
        LCLS    myvalue
      [ "$value" = ""
myvalue SETS    "$field"
      |
myvalue SETS    "$value"
      ]
        ASSERT  . - %A0 = HALDevice_$class$field
     [ ?HALDevice_$class$field = 2
        DCW     $myvalue
   ELIF ?HALDevice_$class$field = 4
        DCD     $myvalue
      |
        %       ?HALDevice_$class$field
      ]
        MEND

ROOL's avatar
ROOL committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
        MACRO
        FuncSelectTable $limit
        LCLA    pin
        LCLA    grp
        LCLA    reg
pin     SETA    0
        WHILE pin <= $limit
reg     SETA    pin / 10                ; 10 pins per register
grp     SETA    pin % 10                ; 3 bits per pin
        DCB     grp * 3
        DCB     GPFSel0 + (reg * 4)
pin     SETA    pin + 1
        WEND
        MEND

        GBLA    PinDef_List0
        GBLA    PinDef_List1
        GBLA    PinDef_List2
        GBLA    PinDef_List3
        GBLA    PinDef_List4
        GBLA    PinDef_List5
        GBLA    PinDef_Number
        GBLA    PinDef_List
        GBLA    PinDef_Alts
        ; The BCM2835 has a maximum of 6 alternates
AltGPI  *       2_000
AltGPO  *       2_001
Alt0    *       2_100
Alt1    *       2_101
Alt2    *       2_110
Alt3    *       2_111
Alt4    *       2_011
Alt5    *       2_010

        MACRO
        PinStart $pin, $io
PinDef_Number SETA $pin :AND: &1F
      [ ("$io" = "IO") :LOR: ("$io" = "OI")
PinDef_Number SETA PinDef_Number :OR: GPIOEnumerate_PinFlags_Output :OR: GPIOEnumerate_PinFlags_Input
      ]
      [ "$io" = "I"
PinDef_Number SETA PinDef_Number :OR: GPIOEnumerate_PinFlags_Input
      ]
      [ "$io" = "O"
PinDef_Number SETA PinDef_Number :OR: GPIOEnumerate_PinFlags_Output
      ]
PinDef_List0  SETA GPIOEnumerate_GroupListEnd
PinDef_List1  SETA GPIOEnumerate_GroupListEnd
PinDef_List2  SETA GPIOEnumerate_GroupListEnd
PinDef_List3  SETA GPIOEnumerate_GroupListEnd
PinDef_List4  SETA GPIOEnumerate_GroupListEnd
PinDef_List5  SETA GPIOEnumerate_GroupListEnd
PinDef_List   SETA 0
PinDef_Alts   SETA 0
        MEND

        MACRO
        PinBelongsTo $type, $num, $alt
        ASSERT $alt < 32
        ASSERT $num < 256
        ASSERT $type < 65536
        LCLS var
var     SETS "PinDef_List" :CC: (:STR:PinDef_List:RIGHT:1)
$var    SETA ($num) :OR: ($alt :SHL: 8) :OR: ($type :SHL: 16)
PinDef_List SETA PinDef_List + 1
PinDef_Alts SETA PinDef_Alts :OR (1 :SHL: $alt)
        MEND

        MACRO
        PinEnd
        LCLA count
        LCLS var
count   SETA 0
        ; Private word to make searching easier
        DCD  PinDef_List
        ; Always these words
        DCB  PinDef_Number, 0, 0, 0
        DCD  PinDef_Alts
        ; Then dump up to 6 alternates
        WHILE count < PinDef_List
var     SETS "PinDef_List" :CC: (:STR:count:RIGHT:1)
        DCD $var
count   SETA count + 1
        WEND
        ; Terminator
        DCD  GPIOEnumerate_GroupListEnd
        MEND

; GPIO structures
                  ^ 0
                  # HALDevice_GPIO_Size_1_0
WkspType          # 4                   ; GPIORevision_RaspberryPi type
WkspPullEnable    # 4                   ; Soft copies
WkspPullDirection # 4                   ; Soft copies
WkspCopySB        # 4
Wksp_GPIO_Size    # 0
                  ASSERT ?GPIO0Device = Wksp_GPIO_Size
                  ASSERT ?GPIO1Device = Wksp_GPIO_Size
160 161 162

; Template for GPIO interface

ROOL's avatar
ROOL committed
163
GPIOTemplate
164 165 166 167
0
        HALDeviceField Type,               HALDeviceType_Comms + HALDeviceComms_GPIO
        HALDeviceField ID,                 HALDeviceID_GPIO_BCM2835
        HALDeviceField Location,           HALDeviceBus_Sys + HALDeviceSysBus_AHB ; Guess
ROOL's avatar
ROOL committed
168 169 170
        HALDeviceField Version,            &10000 ; API 1.0
        HALDeviceField Description,        0 ; Filled in at runtime
        HALDeviceField Address,            0 ; Filled in at runtime
171 172 173 174 175 176 177 178 179
        HALDeviceField Reserved1,          0
        HALDeviceField Activate,           GPIO_Activate
        HALDeviceField Deactivate,         GPIO_Deactivate
        HALDeviceField Reset,              GPIO_Reset
        HALDeviceField Sleep,              GPIO_Sleep
        HALDeviceField Device,             -1
        HALDeviceField TestIRQ,            0
        HALDeviceField ClearIRQ,           0
        HALDeviceField Reserved2,          0
ROOL's avatar
ROOL committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
GPIO    HALDeviceField Ports,              GPIOPorts
GPIO    HALDeviceField Number,             0 ; also overwritten for extra ports
GPIO    HALDeviceField Enumerate,          GPIOEnumerate
GPIO    HALDeviceField SetDataBits,        GPIOSetDataBits
GPIO    HALDeviceField ClearDataBits,      GPIOClearDataBits
GPIO    HALDeviceField ToggleDataBits,     GPIOToggleDataBits
GPIO    HALDeviceField ReadDataBits,       GPIOReadDataBits
GPIO    HALDeviceField DataDirection,      GPIODataDirection
GPIO    HALDeviceField ReadMode,           GPIOReadMode
GPIO    HALDeviceField WriteMode,          GPIOWriteMode
GPIO    HALDeviceField PullControl,        GPIOPullControl
GPIO    HALDeviceField PullDirection,      GPIOPullDirection
GPIO    HALDeviceField EdgeControl,        GPIOEdgeControl
GPIO    HALDeviceField EdgePollStatus,     GPIOEdgePollStatus
        ASSERT  . - %A0 = HALDevice_GPIO_Size_1_0

GPIO_Description_0
        = "Raspberry Pi GPIO interface pins 0-31", 0
        ALIGN
GPIO_Description_1
        = "Raspberry Pi GPIO interface pins 32-63", 0
        ALIGN
202

ROOL's avatar
ROOL committed
203 204 205 206 207
                                 ^       0
GPIORevision_RaspberryPi_B_1     #       1 ; Model B Rev 1.0
GPIORevision_RaspberryPi_B_2     #       1 ; Model B Rev 2.0
GPIORevision_RaspberryPi_A_2     #       1 ; Model A Rev 2.0
GPIORevision_RaspberryPi_BPlus   #       1 ; Model B+
Robert Sprowson's avatar
Robert Sprowson committed
208 209
GPIORevision_RaspberryPi_C_1     #       1 ; Model CM1
GPIORevision_RaspberryPi_C_3     #       1 ; Model CM3
ROOL's avatar
ROOL committed
210
GPIORevision_RaspberryPi_APlus   #       1 ; Model A+
Robert Sprowson's avatar
Robert Sprowson committed
211
GPIORevision_RaspberryPi_Mk2_B   #       1 ; Model Pi 2 B
ROOL's avatar
ROOL committed
212
GPIORevision_RaspberryPi_Zero    #       1 ; Model Zero
Robert Sprowson's avatar
Robert Sprowson committed
213 214 215
GPIORevision_RaspberryPi_ZeroW   #       1 ; Model ZeroW
GPIORevision_RaspberryPi_Mk3_B   #       1 ; Model Pi 3 B
GPIORevision_RaspberryPi_Mk3_BPlus #     1 ; Model Pi 3 B+
Ben Avison's avatar
Ben Avison committed
216
GPIORevision_RaspberryPi_Mk3_APlus #     1 ; Model Pi 3 A+
217
GPIORevision_RaspberryPi_C_3Plus #       1 ; Model CM3+
Ben Avison's avatar
Ben Avison committed
218
GPIORevision_RaspberryPi_Mk4_B   #       1 ; Model Pi 4 B
Ben Avison's avatar
Ben Avison committed
219 220
GPIORevision_RaspberryPi_400     #       1 ; Raspberry Pi 400
GPIORevision_RaspberryPi_C_4     #       1 ; Model CM4
ROOL's avatar
ROOL committed
221
GPIORevision_RaspberryPi_Max     #       0
222

223 224 225
Name_B_1 = "Raspberry Pi B PCB 1.0", 0
Name_B_2 = "Raspberry Pi B PCB 2.0", 0
Name_A_2 = "Raspberry Pi A", 0
ROOL's avatar
ROOL committed
226
Name_BPlus = "Raspberry Pi B+", 0
Robert Sprowson's avatar
Robert Sprowson committed
227 228
Name_C_1 = "Raspberry Pi Compute Module 1", 0
Name_C_3 = "Raspberry Pi Compute Module 3", 0
229
Name_APlus = "Raspberry Pi A+", 0
Robert Sprowson's avatar
Robert Sprowson committed
230
Name_Mk2_B = "Raspberry Pi 2 Model B", 0
231
Name_Zero = "Raspberry Pi Zero", 0
Robert Sprowson's avatar
Robert Sprowson committed
232 233 234
Name_ZeroW = "Raspberry Pi Zero W", 0
Name_Mk3_B = "Raspberry Pi 3 Model B", 0
Name_Mk3_BPlus = "Raspberry Pi 3 Model B+", 0
Ben Avison's avatar
Ben Avison committed
235
Name_Mk3_APlus = "Raspberry Pi 3 Model A+", 0
236
Name_C_3Plus = "Raspberry Pi Compute Module 3+", 0
Ben Avison's avatar
Ben Avison committed
237
Name_B_4 = "Raspberry Pi 4 Model B", 0
Ben Avison's avatar
Ben Avison committed
238 239
Name_400 = "Raspberry Pi 400", 0
Name_C_4 = "Raspberry Pi Compute Module 4", 0
240
Name_Unknown = "Raspberry Pi Unknown", 0
241 242
        ALIGN

ROOL's avatar
ROOL committed
243 244 245 246 247 248
GPIO_Board_Names_Table ; same order as GPIORevision_RaspberryPi types
        DCD     Name_B_1
        DCD     Name_B_2
        DCD     Name_A_2
        DCD     Name_BPlus
        DCD     Name_C_1
Robert Sprowson's avatar
Robert Sprowson committed
249
        DCD     Name_C_3
ROOL's avatar
ROOL committed
250
        DCD     Name_APlus
Robert Sprowson's avatar
Robert Sprowson committed
251
        DCD     Name_Mk2_B
ROOL's avatar
ROOL committed
252
        DCD     Name_Zero
Robert Sprowson's avatar
Robert Sprowson committed
253 254 255
        DCD     Name_ZeroW
        DCD     Name_Mk3_B
        DCD     Name_Mk3_BPlus
Ben Avison's avatar
Ben Avison committed
256
        DCD     Name_Mk3_APlus
257
        DCD     Name_C_3Plus
Ben Avison's avatar
Ben Avison committed
258
        DCD     Name_B_4
Ben Avison's avatar
Ben Avison committed
259 260
        DCD     Name_400
        DCD     Name_C_4
ROOL's avatar
ROOL committed
261 262 263 264
        ASSERT  (.-GPIO_Board_Names_Table) :SHR: 2 = GPIORevision_RaspberryPi_Max

; Lookup table to determine board type (old style)
; Ref: http://elinux.org/RPi_HardwareHistory#Board_Revision_History
265
        MACRO
Robert Sprowson's avatar
Robert Sprowson committed
266
        BoardType $minrev, $maxrev, $type
267 268 269 270 271 272
        DCD $minrev
        DCD $maxrev
        DCD GPIORevision_RaspberryPi_$type
        MEND

GPIO_BoardTypes
Robert Sprowson's avatar
Robert Sprowson committed
273 274 275 276 277 278 279 280 281 282
        BoardType &02, &03, B_1
        BoardType &04, &06, B_2
        BoardType &07, &09, A_2
        BoardType &0d, &0f, B_2
        BoardType &10, &10, BPlus
        BoardType &11, &11, C_1
        BoardType &12, &12, APlus
        BoardType &13, &13, BPlus
        BoardType &14, &14, C_1
        BoardType &15, &15, APlus
283 284
GPIO_BoardTypes_End

ROOL's avatar
ROOL committed
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
; Lookup table to determine board type (new style)
; Only the memory amount, model, and revision are significant in this table.
GPIO_Board_Conversion_Table
        DCD     BoardRevision_Mem_256M+BoardRevision_Model_B+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_B_1
        DCD     BoardRevision_Mem_256M+BoardRevision_Model_B+(2:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_B_2
        DCD     BoardRevision_Mem_256M+BoardRevision_Model_A+(2:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_A_2
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_B+(2:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_BPlus
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_Compute+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_C_1
        DCD     BoardRevision_Mem_256M+BoardRevision_Model_APlus+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_APlus
300 301 302 303
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_APlus+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_APlus
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_BPlus+(2:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_BPlus
304 305
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_B2+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk2_B
ROOL's avatar
ROOL committed
306
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_B2+(1:SHL:BoardRevision_Rev_Shift)
Robert Sprowson's avatar
Robert Sprowson committed
307
        DCD     GPIORevision_RaspberryPi_Mk2_B
ROOL's avatar
ROOL committed
308
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_B2+(2:SHL:BoardRevision_Rev_Shift)
Robert Sprowson's avatar
Robert Sprowson committed
309
        DCD     GPIORevision_RaspberryPi_Mk2_B
ROOL's avatar
ROOL committed
310 311 312 313 314
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_Zero+(2:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Zero
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_Zero+(3:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Zero
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_B3+(2:SHL:BoardRevision_Rev_Shift)
Robert Sprowson's avatar
Robert Sprowson committed
315
        DCD     GPIORevision_RaspberryPi_Mk3_B
316 317
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_B3+(3:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk3_B
ROOL's avatar
ROOL committed
318
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_Compute3+(0:SHL:BoardRevision_Rev_Shift)
Robert Sprowson's avatar
Robert Sprowson committed
319 320 321 322 323
        DCD     GPIORevision_RaspberryPi_C_3
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_ZeroW+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_ZeroW
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_B3Plus+(3:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk3_BPlus
Ben Avison's avatar
Ben Avison committed
324 325
        DCD     BoardRevision_Mem_512M+BoardRevision_Model_A3Plus+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk3_APlus
326 327
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_Compute3Plus+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_C_3Plus
Ben Avison's avatar
Ben Avison committed
328 329
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_B4+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk4_B
330 331
        DCD     BoardRevision_Mem_2G+BoardRevision_Model_B4+(2:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk4_B
Ben Avison's avatar
Ben Avison committed
332 333 334 335
        DCD     BoardRevision_Mem_2G+BoardRevision_Model_B4+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk4_B
        DCD     BoardRevision_Mem_4G+BoardRevision_Model_B4+(1:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk4_B
336 337
        DCD     BoardRevision_Mem_4G+BoardRevision_Model_B4+(2:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk4_B
David Pitt's avatar
David Pitt committed
338 339
        DCD     BoardRevision_Mem_8G+BoardRevision_Model_B4+(4:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_Mk4_B
Ben Avison's avatar
Ben Avison committed
340 341 342 343 344 345 346 347 348 349
        DCD     BoardRevision_Mem_4G+BoardRevision_Model_400+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_400
        DCD     BoardRevision_Mem_1G+BoardRevision_Model_Compute4+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_C_4
        DCD     BoardRevision_Mem_2G+BoardRevision_Model_Compute4+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_C_4
        DCD     BoardRevision_Mem_4G+BoardRevision_Model_Compute4+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_C_4
        DCD     BoardRevision_Mem_8G+BoardRevision_Model_Compute4+(0:SHL:BoardRevision_Rev_Shift)
        DCD     GPIORevision_RaspberryPi_C_4
ROOL's avatar
ROOL committed
350 351
        DCD     &FF

352
        ; Initialise our HAL devices
ROOL's avatar
ROOL committed
353 354 355 356 357
GPIO_InitDevices
        Entry   "v1"

        ; Copy dev struct to WS & fill in the non template items
        ADRL    a1, GPIO0Device
Ben Avison's avatar
Ben Avison committed
358
        ADRL    a2, GPIOTemplate
ROOL's avatar
ROOL committed
359
        MOV     a3, #HALDevice_GPIO_Size_1_0
360
        BL      memcpy
ROOL's avatar
ROOL committed
361

362 363 364 365
        ;               3         2         1         0
        ;              10987654321098765432109876543210
        LDR     a2, =2_11001111111111111111111111111111
        LDR     a3, =2_00000000000000000000000111111111
ROOL's avatar
ROOL committed
366
        STR     a2, [a1, #WkspPullEnable]
367
        STR     a3, [a1, #WkspPullDirection]
ROOL's avatar
ROOL committed
368 369 370 371 372 373 374 375 376 377 378 379
        STR     sb, [a1, #WkspCopySB]

        ADRL    a2, GPIO_Description_0
        STR     a2, [a1, #HALDevice_Description]
        LDR     a4, PeriBase
        ADD     a4, a4, #GPIO_Base
        STR     a4, [a1, #HALDevice_Address]
        MOV     a2, #0
        STR     a2, [a1, #HALDevice_GPIONumber]

        ; Copy dev struct to WS & fill in the non template items
        ADRL    a1, GPIO1Device
380
        ADRL    a2, GPIOTemplate
ROOL's avatar
ROOL committed
381 382 383
        MOV     a3, #HALDevice_GPIO_Size_1_0
        BL      memcpy

384 385 386 387
        ;                 6         5         4       3
        ;              32109876543210987654321098765432
        LDR     a2, =2_00000011111111111100111111111111
        LDR     a3, =2_00000011111111111100000000011100
ROOL's avatar
ROOL committed
388
        STR     a2, [a1, #WkspPullEnable]
389
        STR     a3, [a1, #WkspPullDirection]
ROOL's avatar
ROOL committed
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
        STR     sb, [a1, #WkspCopySB]

        ADRL    a2, GPIO_Description_1
        STR     a2, [a1, #HALDevice_Description]
        LDR     a4, PeriBase
        ADD     a4, a4, #GPIO_Base
        STR     a4, [a1, #HALDevice_Address]
        MOV     a2, #1
        STR     a2, [a1, #HALDevice_GPIONumber]

        ; Only register if it's a model known to us
        BL      GPIO_Get_Platform
        CMP     a1, #-1
        EXIT    EQ
        MOV     v1, a1

        ; Found a match, add devices to list
        MOV     a1, #0
        ADRL    a2, GPIO0Device
        STR     v1, [a2, #WkspType]
Jeffrey Lee's avatar
Jeffrey Lee committed
410
      [ :LNOT: JTAG ; Play it safe, we don't want software messing with the JTAG GPIOs
ROOL's avatar
ROOL committed
411 412 413
        CallOS  OS_AddDevice            ; register device0
      ]

414
        MOV     a1, #0
ROOL's avatar
ROOL committed
415 416 417 418
        ADRL    a2, GPIO1Device
        STR     v1, [a2, #WkspType]
      [ :LNOT: JTAG ; Play it safe, we don't want software messing with the JTAG GPIOs
        CallOS  OS_AddDevice            ; register device1
Jeffrey Lee's avatar
Jeffrey Lee committed
419
      ]
420
        EXIT
421
        LTORG
422 423 424 425 426 427 428 429 430 431 432

GPIO_Activate
        MOV     a1, #1
GPIO_Deactivate
GPIO_Reset
        MOV     pc, lr

GPIO_Sleep
        MOV     a1, #0
        MOV     pc, lr

ROOL's avatar
ROOL committed
433 434
; Name the platform for debug dumps and similar
; Return a1 = zero terminated string
435
HAL_PlatformName
ROOL's avatar
ROOL committed
436 437 438 439 440 441 442 443 444 445 446 447
        Entry
        BL      GPIO_Get_Platform
        CMP     a1, #-1
        ADREQL  a1, Name_Unknown
        ADRNE   a2, GPIO_Board_Names_Table
        LDRNE   a1, [a2, a1, LSL #2]
        EXIT

; Determine which platform this is
; Return a1 = enumerated platform number (GPIORevision_RaspberryPi type)
;             or -1 if unknown
GPIO_Get_Platform
Robert Sprowson's avatar
Robert Sprowson committed
448
        Entry   "v1-v2"
449
        ADR     v1, GPIO_BoardTypes
Robert Sprowson's avatar
Robert Sprowson committed
450
        LDR     v2, Board_Revision
451
        ADR     ip, GPIO_BoardTypes_End
ROOL's avatar
ROOL committed
452

Robert Sprowson's avatar
Robert Sprowson committed
453
        TST     v2, #BoardRevision_NewScheme
ROOL's avatar
ROOL committed
454
        BNE     %FT20                   ; new decode
455 456
10
        CMP     v1, ip
ROOL's avatar
ROOL committed
457 458
        MOVHS   a1, #-1
        EXIT    HS                      ; unknown model, exit
Robert Sprowson's avatar
Robert Sprowson committed
459 460 461
        LDMIA   v1!, {a2-a4}
        CMP     a2, v2
        CMPLS   v2, a3                  ; revision within range?
ROOL's avatar
ROOL committed
462 463 464 465 466 467
        MOVLS   a1, a4
        EXIT    LS                      ; match a1 = GPIORevision_RaspberryPi type
        B       %BT10
20
        ADR     a2, GPIO_Board_Conversion_Table
        LDR     a3, =BoardRevision_Model_Mask+BoardRevision_Mem_Mask+BoardRevision_Rev_Mask
Robert Sprowson's avatar
Robert Sprowson committed
468
        AND     a1, v2, a3
ROOL's avatar
ROOL committed
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
30
        LDR     a4, [a2], #4
        CMP     a4, #&FF
        MOVEQ   a1, #-1
        EXIT    EQ                      ; unknown model, exit
        CMP     a4, a1
        LDREQ   a1, [a2]
        ADDNE   a2, a2, #4
        EXIT    EQ                      ; match a1 = GPIORevision_RaspberryPi type
        B       %BT30

; int GPIOSetDataBits(struct gpiodevice *, int bits)
; Enter with a1 = device struct pointer
;            a2 = any bit set will cause that pin to be set
; Return     a1 = previous value
GPIOSetDataBits
        MOV     a3, #GPSet0
        B       GPIO_Data_Common        ; tail call

; int GPIOClearDataBits(struct gpiodevice *, int bits)
; Enter with a1 = device struct pointer
Robert Sprowson's avatar
Robert Sprowson committed
490
;            a2 = any bit set will cause that pin to be cleared
ROOL's avatar
ROOL committed
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
; Return     a1 = previous value
GPIOClearDataBits
        MOV     a3, #GPClr0
        B       GPIO_Data_Common        ; tail call

; int GPIOReadDataBits(struct gpiodevice *)
; Enter with a1 = device struct pointer
; Return     a1 = previous value
GPIOReadDataBits
        MOV     a3, #GPLev0
        B       GPIO_Data_Common        ; tail call

; void GPIOToggleDataBits(struct gpiodevice *, int bits)
; Enter with a1 = device struct pointer
;            a2 = any bit set will cause that pin to be toggled from its current value
GPIOToggleDataBits
        Entry   "v1-v4"
        MOVS    v2, a2
        EXIT    EQ                      ; nothing to do
        MOV     v1, a1

        PHPSEI  v4                      ; go atomic

        BL      GPIOReadDataBits
        MOV     v3, a1

        ANDS    a2, v2, v3              ; only our bits
        MOVNE   a1, v1
        BLNE    GPIOClearDataBits

        MVN     v3, v3                  ; invert bits
        ANDS    a2, v2, v3              ; only our bits
        MOVNE   a1, v1
        BLNE    GPIOSetDataBits

        PLP     v4                      ; restore interrupt state
        EXIT

; int GPIODataDirection(struct gpiodevice *, int pins, int dir)
; Enter with a1 = device struct pointer
;            a2 = bits to change
;            a3 = direction to set the bits to (1=input 0=output)
; Return     a1 = previous data direction bits (or current if pins=0)
GPIODataDirection
        Entry   "v1-v5"

        ; On the Pi the data direction is scattered across multiple
        ; registers, and changing direction also needs a mode change.
        ; They are, however, individually controllable (groups of 1 pin).
        MOV     v1, a1
        MOV     v2, a2
        MOV     v3, a3

        MOV     v4, #0                  ; pin to change
        MOV     v5, #0                  ; old direction bits
10
        MOV     v5, v5, LSR #1
        MOVS    v2, v2, LSR #1
        MOVCC   a3, #-1
        BCC     %FT20                   ; leave alone

        TST     v3, #1
        MOVNE   a3, #AltGPI             ; input
        MOVEQ   a3, #AltGPO             ; output
20
        MOV     a2, v4
        MOV     a1, v1
        BL      GPIO_Mode_Common
        TEQ     a1, #AltGPI             ; previously input?
        ORREQ   v5, v5, #1:SHL:31
        MOV     v3, v3, LSR #1
        ADD     v4, v4, #1
        CMP     v4, #32
        BNE     %BT10

        MOV     a1, v5
567 568
        EXIT

ROOL's avatar
ROOL committed
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
; struct onepin *GPIOEnumerate(struct gpiodevice *, int *carryon)
; Enter with a1 = device struct pointer
;            a2 = pointer to continuation value (0 to start)
; Return     a1 = pointer to pin info for one more pin
;            continuation value updated (-1 if no more)
GPIOEnumerate
        Entry   "v1-v3"
        LDR     v1, [a1, #WkspType]
        LDR     a1, [a1, #HALDevice_GPIONumber]
        ADRL    a4, GPIOFreeToUse
        MOV     ip, #GPIOPorts * 4
        MLA     a4, v1, ip, a4          ; address of GPIOFreeToUse for this type
        LDR     v1, [a4, a1, LSL #2]    ; mask of valid on this port for this target

        LDR     a3, [a2]                ; just use the continuation value as a bit position
        CMP     a3, #32
        BCS     %FT60                   ; invalid always

        CMP     a3, #0
        BNE     %FT20                   ; not the start condition

        MOVS    ip, v1
        BEQ     %FT60                   ; no valid pins
10
        ; find first set
        MOVS    ip, ip, LSR #1
        ADDCC   a3, a3, #1
        BCC     %BT10
20
        MOV     ip, #1
        TST     v1, ip, LSL a3
        BEQ     %FT60                   ; invalid on this target

602 603 604
        CPUDetect v2
        ADRLSL  v2, GPIOPortTables
        ADRHIL  v2, GPIOPortTables_BCM2838
ROOL's avatar
ROOL committed
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
        LDR     v2, [v2, a1, LSL #2]    ; start of pin data
        MOV     v3, #0
30
        LDR     ip, [v2], #4            ; fetch & skip private word
        CMP     ip, #-1
        BEQ     %FT60                   ; no more

        TEQ     v3, a3
        MOVEQ   a1, v2
        BEQ     %FT40

        ADD     v2, v2, #GPIOEnumerate_GroupList ; account for fixed items
        ADD     ip, ip, #1              ; account for list terminator
        ASSERT  GPIOGroupList_Size = 4
        ADD     v2, v2, ip, LSL #2      ; account for list entries
        ADD     v3, v3, #1
        B       %BT30
40
        ; find next set
        ADD     v3, v3, #1
        CMP     v3, #32
        MOVNES  v1, v1, LSR v3
        BEQ     %FT70
50
        MOVS    v1, v1, LSR #1
        ADDCC   v3, v3, #1
        BCC     %BT50

        STR     v3, [a2]
        EXIT
60
        MOV     a1, #0                  ; nothing
70
        MOV     ip, #-1                 ; no more
        STR     ip, [a2]
        EXIT

; enum HAL_GPIOReadMode(struct gpiodevice *, int pin)
; Enter with a1 = device struct pointer
;            a2 = pin (singular) to change
; Return     a1 = current mode
GPIOReadMode
        MOV     a3, #-1
        B       GPIO_Mode_Common        ; tail call

; enum GPIOWriteMode(struct gpiodevice *, int pin, enum useage)
; Enter with a1 = device struct pointer
;            a2 = pin (singular) to change
;            a3 = new mode (opaque value from Enumerate)
; Return     a1 = previous mode
GPIOWriteMode
        B       GPIO_Mode_Common        ; tail call

; int GPIOPullControl(struct gpiodevice *, int pins, int enable)
; Enter with a1 = device struct pointer
;            a2 = bits to change
;            a3 = pull resistor enables for those pins
; Return     a1 = previous pull enable bits (or current if pins=0)
GPIOPullControl
        Entry   "v1"
        LDR     v1, [a1, #WkspPullEnable]
        AND     a3, a3, a2              ; discard spurious set bits
        BIC     a2, v1, a2
        ORR     a2, a3, a2              ; new soft copy
        STR     a2, [a1, #WkspPullEnable]
        TEQ     v1, a2
        MOVEQ   a1, v1                  ; no enables changed
        EXIT    EQ

        LDR     a3, [a1, #WkspPullDirection]
        BL      GPIO_Pull_Common
        MOV     a1, v1
        EXIT

; int GPIOPullDirection(struct gpiodevice *, int pins, int up)
; Enter with a1 = device struct pointer
;            a2 = bits to change
;            a3 = bits to set as pull up else pull down
; Return     a1 = previous pull direction bits (or current if pins=0)
GPIOPullDirection
        Entry   "v1"
        LDR     v1, [a1, #WkspPullDirection]
        AND     a3, a3, a2              ; discard spurious set bits
        BIC     a2, v1, a2
        ORR     a2, a3, a2              ; new soft copy
        STR     a2, [a1, #WkspPullDirection]
        LDR     a4, [a1, #WkspPullEnable]
692
        AND     ip, a2, a4
ROOL's avatar
ROOL committed
693
        AND     a3, v1, a4
694
        TEQ     ip, a3
ROOL's avatar
ROOL committed
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841
        MOVEQ   a1, v1                  ; no enabled sense change
        EXIT    EQ

        MOV     a3, a2
        MOV     a2, a4
        BL      GPIO_Pull_Common
        MOV     a1, v1
        EXIT

; void GPIOEdgeControl(struct gpiodevice *, int pins, int *enable, int *edge, int *risehigh)
; Enter with a1 = device struct pointer
;            a2 = bits to change
;            a3 = pointer to bits to enable detection on
;            a4 = pointer to bits set for edge mode (else level)
;        [sp+0] = pointer to bits set to detect on rising/high (else falling/low)
GPIOEdgeControl
        LDR     ip, [sp, #0]

        Entry   "v1-v5"
        Push    "a3-a4, ip"

        LDR     v1, [a1, #HALDevice_Address]
        LDR     a1, [a1, #HALDevice_GPIONumber]
        ASSERT  GPREDE0 + 4 = GPREDE1
        ASSERT  GPFEDE0 + 4 = GPFEDE1
        ASSERT  GPHIDE0 + 4 = GPHIDE1
        ASSERT  GPLODE0 + 4 = GPLODE1
        ADD     v1, v1, a1, LSL #2

        LDR     a3, [a3]                ; pick up new values
        LDR     a4, [a4]
        LDR     ip, [ip]

        PHPSEI  v2                      ; go atomic

        LDR     v3, [v1, #GPREDE0]
        LDR     a1, [v1, #GPFEDE0]
        MOV     v5, v3                  ; rising = rising
        ORR     v4, v3, a1              ; OR(rising,falling) = edge
        ORR     v3, v3, a1              ; OR(rising,falling) = edge enable
        LDR     lr, [v1, #GPHIDE0]
        LDR     a1, [v1, #GPLODE0]
        ORR     v5, v5, lr              ; OR(rising,high) = rising/high
        ORR     a1, a1, lr
        ORR     v3, v3, a1              ; OR(edge enable,OR(high,low)) = enable
        TEQ     a2, #0
        BEQ     %FT10

        LDR     a1, [v1, #GPREDE0]
        BIC     a1, a1, a2              ; disable by default
        AND     lr, a3, a4
        AND     lr, lr, ip
        ORR     a1, a1, lr              ; AND(enable,edge,rising) = rising
        STR     a1, [v1, #GPREDE0]

        LDR     a1, [v1, #GPFEDE0]
        BIC     a1, a1, a2              ; disable by default
        AND     lr, a3, a4
        BIC     lr, lr, ip
        ORR     a1, a1, lr              ; AND(enable,edge,NOT(rising)) = falling
        STR     a1, [v1, #GPFEDE0]

        LDR     a1, [v1, #GPHIDE0]
        BIC     a1, a1, a2              ; disable by default
        BIC     lr, a3, a4
        AND     lr, lr, ip
        ORR     a1, a1, lr              ; AND(enable,NOT(edge),rising) = high
        STR     a1, [v1, #GPHIDE0]

        LDR     a1, [v1, #GPLODE0]
        BIC     a1, a1, a2              ; disable by default
        BIC     lr, a3, a4
        BIC     lr, lr, ip
        ORR     a1, a1, lr              ; AND(enable,NOT(edge),NOT(rising)) = low
        STR     a1, [v1, #GPLODE0]
10
        PLP     v2                      ; restore interrupt state

        Pull    "a3-a4, ip"
        STR     v3, [a3]                ; write out previous values
        STR     v4, [a4]
        STR     v5, [ip]
        EXIT

; int GPIOEdgePollStatus(struct gpiodevice *, int collect)
; Enter with a1 = device struct pointer
;            a2 = clear these bits having polled the status
; Return     a1 = states latched in edge/level since last poll
GPIOEdgePollStatus
        MOV     a3, #GPPEDS0
        B       GPIO_Data_Common        ; tail call

; Pin function selection
; Enter with a1 = device pointer
;            a2 = pin (0-31)
;            a3 = mode to set to (or -1 to just read)
; Return     a1 = previous mode, or -1 if invalid request
GPIO_Mode_Common
        Entry   "v1-v5"
        LDR     v2, [a1, #HALDevice_Address]
        LDR     v1, [a1, #WkspType]
        LDR     a1, [a1, #HALDevice_GPIONumber]
        ADR     a4, GPIOFreeToUse
        MOV     ip, #GPIOPorts * 4
        MLA     a4, v1, ip, a4          ; address of GPIOFreeToUse for this type
        LDR     v1, [a4, a1, LSL #2]    ; mask of valid on this port for this target

        MOV     a4, #1
        MOV     a4, a4, LSL a2
        TST     a4, v1
        MOVEQ   a1, #-1
        EXIT    EQ                      ; not a valid pin to change

        MOV     v3, #2_111
        ADD     v4, a2, a1, LSL #5      ; flatten port and pin to 0-63

        ADR     a4, GPIO_FuncSelect_Table
        ADD     a4, a4, v4, LSL #1
        LDRH    a4, [a4]                ; reg/grp pair
        AND     v4, a4, #255            ; grp
        MOV     lr, #2_111              ; mode mask

        PHPSEI  ip                      ; go atomic

        LDR     a2, [v2, a4, LSR #8]
        CMP     a3, #-1                 ; just reading?
        BICNE   a1, a2, lr, LSL v4
        ORRNE   a1, a1, a3, LSL v4
        DataSyncBarrier a3, NE          ; resync before/after peripheral
        STRNE   a1, [v2, a4, LSR #8]

        PLP     ip

        MOV     a1, a2, LSR v4
        AND     a1, a1, #2_111

        EXIT

; Port wide pull resistor modifier
; Enter with a1 = device pointer
;            a2 = enables
;            a3 = sense
GPIO_Pull_Common
        Entry   "v1-v4, sb"
        LDR     v1, [a1, #HALDevice_Address]
        LDR     sb, [a1, #WkspCopySB]
        LDR     a1, [a1, #HALDevice_GPIONumber]
842 843 844
        CPUDetect v2
        BHI     %FT20

ROOL's avatar
ROOL committed
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865
        ASSERT  GPPUDCK0 + 4 = GPPUDCK1
        MOV     a4, #GPPUDCK0
        ADD     v4, a4, a1, LSL #2
        MOV     v2, a2
        MOV     v3, a3

        MOV     a1, #2_00               ; disable pullup/down
        MVNS    a2, v2                  ; NOT(enable) = disable
        BLNE    %FT10

        MOV     a1, #2_01               ; pull down
        MVN     a2, v3
        ANDS    a2, a2, v2              ; AND(NOT(sense),enable) = pull downs
        BLNE    %FT10

        MOV     a1, #2_10               ; pull up
        ANDS    a2, v3, v2              ; AND(sense,enable) = pull ups
        BLNE    %FT10

        MOV     a1, #0                  ; rest
        STR     a1, [v1, #GPPUPDEN]
866
        STR     a1, [v1, v4]
ROOL's avatar
ROOL committed
867 868 869 870 871 872 873
        EXIT
10
        Push    "a2, lr"
        STR     a1, [v1, #GPPUPDEN]
        MOV     a1, #50                 ; guess
        BL      HAL_CounterDelay
        Pull    "a2, lr"
874
        STR     a2, [v1, v4]
ROOL's avatar
ROOL committed
875 876
        MOV     a1, #50                 ; guess
        B       HAL_CounterDelay
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
20
        ; BCM2838 has different pull control registers
        ASSERT  GPPUDCT0 + 4 = GPPUDCT1
        ASSERT  GPPUDCT1 + 4 = GPPUDCT2
        ASSERT  GPPUDCT2 + 4 = GPPUDCT3
        MOV     a4, #GPPUDCT0
        ADD     v4, a4, a1, LSL #3      ; offset of pair of control registers for this port
        MOV     a1, #1                  ; src bit mask
30
        MOV     a4, #0                  ; dst bit number
        MOV     v2, #0                  ; dst
40
        TEQ     a1, #0
        EXIT    EQ
        MOV     ip, #2_00               ; disabled
        TST     a2, a1
        ORRNE   ip, ip, #2_10           ; pull down
        TSTNE   a3, a1
        EORNE   ip, ip, #2_11           ; convert down to up
        ORR     v2, v2, ip, LSL a4
        ADD     a4, a4, #2
        MOV     a1, a1, LSL #1
        TST     a4, #&1F
        BNE     %BT40

        DataSyncBarrier ip
        STR     v2, [v1, v4]            ; dump to hardware
        ADD     v4, v4, #4              ; offset for next 16 bits
        DataSyncBarrier ip
        B       %BT30
ROOL's avatar
ROOL committed
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957

; Port wide pin modifier
; Enter with a1 = device pointer
;            a2 = bit set of pins
;            a3 = GPIO peripheral register offset (or GPLev0 to just read)
; Return     a1 = previous value
GPIO_Data_Common
        Entry   "v1-v2"
        LDR     v2, [a1, #HALDevice_Address]
        LDR     a1, [a1, #HALDevice_GPIONumber]
        ASSERT  GPSet0  + 4 = GPSet1
        ASSERT  GPClr0  + 4 = GPClr1
        ASSERT  GPLev0  + 4 = GPLev1
        ASSERT  GPPEDS0 + 4 = GPPEDS1
        ADD     a4, a3, a1, LSL #2
        ADR     v1, GPIOPORT
        LDR     v1, [v1, a1, LSL #2]    ; mask of invalid

        CMP     a3, #GPLev0
        DataSyncBarrier ip              ; resync before/after peripheral
        LDR     a1, [v2, a4]
        AND     a1, a1, v1
        ANDNE   a2, a2, v1
        STRNE   a2, [v2, a4]
        DataSyncBarrier ip, NE          ; resync before/after peripheral

        EXIT

; Available pins in the GPIO peripheral
GPIOPORT
        DCD     2_11111111111111111111111111111111      ; 31-0
        DCD     2_00000000001111111111111111111111      ; 53-32
GPIOPORTEND
GPIOPorts       *       (GPIOPORTEND-GPIOPORT):SHR:2

; Function Select register offset/bits lookup table
GPIO_FuncSelect_Table
        FuncSelectTable 53
        ALIGN

; Available pins per target board
; Ref: http://elinux.org/RPi_BCM2835_GPIOs
GPIOFreeToUse
        DCD     2_00000011111001101100111110010011      ; B rev 1
        DCD     2_00000000000000000000000000000000
        DCD     2_00001011110001101100111110011100      ; B rev 2
        DCD     2_00000000000000000000000000000000
        DCD     2_00001011110001101100111110011100      ; A rev 2
        DCD     2_00000000000000000000000000000000
        DCD     2_00001111111111111111111111111111      ; B+
        DCD     2_00000000000000000000000000000000
Robert Sprowson's avatar
Robert Sprowson committed
958 959 960 961
        DCD     2_11111111111111111111111111111111      ; Compute CM1
        DCD     2_00000000000000000111111111111111
        DCD     2_11111111111111111111111111111111      ; Compute CM3
        DCD     2_00000000000000000011111111111111
ROOL's avatar
ROOL committed
962 963 964 965
        DCD     2_00001111111111111111111111111111      ; A+
        DCD     2_00000000000000000000000000000000
        DCD     2_00001111111111111111111111111111      ; 2B
        DCD     2_00000000000000000000000000000000
Robert Sprowson's avatar
Robert Sprowson committed
966 967 968
        DCD     2_00001111111111111111111111111111      ; Zero
        DCD     2_00000000000000000000000000000000
        DCD     2_00001111111111111111111111111111      ; ZeroW
ROOL's avatar
ROOL committed
969 970 971
        DCD     2_00000000000000000000000000000000
        DCD     2_00001111111111111111111111111111      ; 3B
        DCD     2_00000000000000000000000000000000
Robert Sprowson's avatar
Robert Sprowson committed
972 973
        DCD     2_00001111111111111111111111111111      ; 3B+
        DCD     2_00000000000000000000000000000000
Robert Sprowson's avatar
Robert Sprowson committed
974 975
        DCD     2_00001111111111111111111111111111      ; 3A+
        DCD     2_00000000000000000000000000000000
976 977
        DCD     2_11111111111111111111111111111111      ; Compute CM3+
        DCD     2_00000000000000000011111111111111
Ben Avison's avatar
Ben Avison committed
978 979
        DCD     2_00001111111111111111111111111111      ; 4B
        DCD     2_00000000000000000000000000000000
Ben Avison's avatar
Ben Avison committed
980 981 982 983
        DCD     2_00001111111111111111111111111111      ; 400
        DCD     2_00000000000000000000000000000000
        DCD     2_00001111111111111111111111111100      ; Compute CM4
        DCD     2_00000000000000000000000000000000
Robert Sprowson's avatar
Robert Sprowson committed
984
        ASSERT  (.-GPIOFreeToUse) :SHR: 3 = GPIORevision_RaspberryPi_Max
ROOL's avatar
ROOL committed
985 986 987

; Pin enumerations
GPIO_Port0_Table
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134
        PinStart     0, IO
        PinBelongsTo GPIOType_GPIO, 0, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SDA
        PinEnd
        PinStart     1, IO
        PinBelongsTo GPIOType_GPIO, 1, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SCL
        PinEnd
        PinStart     2, IO
        PinBelongsTo GPIOType_GPIO, 2, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 1, Alt0      ; I2C1 SDA
        PinEnd
        PinStart     3, IO
        PinBelongsTo GPIOType_GPIO, 3, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 1, Alt0      ; I2C1 SCL
        PinEnd
        PinStart     4, IO
        PinBelongsTo GPIOType_GPIO, 4, AltGPI   ; GPIO
        PinBelongsTo GPIOType_GPCLK, 0, Alt0    ; GPCLK0
        PinEnd
        PinStart     5, IO
        PinBelongsTo GPIOType_GPIO, 5, AltGPI   ; GPIO
        PinBelongsTo GPIOType_GPCLK, 1, Alt0    ; GPCLK1
        PinEnd
        PinStart     6, IO
        PinBelongsTo GPIOType_GPIO, 6, AltGPI   ; GPIO
        PinBelongsTo GPIOType_GPCLK, 2, Alt0    ; GPCLK2
        PinEnd
        PinStart     7, IO
        PinBelongsTo GPIOType_GPIO, 7, AltGPI   ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 CE1
        PinEnd
        PinStart     8, IO
        PinBelongsTo GPIOType_GPIO, 8, AltGPI   ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 CE0
        PinEnd
        PinStart     9, IO
        PinBelongsTo GPIOType_GPIO, 9, AltGPI   ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 MISO
        PinEnd
        PinStart     10, IO
        PinBelongsTo GPIOType_GPIO, 10, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 MOSI
        PinEnd
        PinStart     11, IO
        PinBelongsTo GPIOType_GPIO, 11, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 SCLK
        PinEnd
        PinStart     12, IO
        PinBelongsTo GPIOType_GPIO, 12, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PWM, 0, Alt0      ; PWM0
        PinEnd
        PinStart     13, IO
        PinBelongsTo GPIOType_GPIO, 13, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PWM, 1, Alt0      ; PWM1
        PinEnd
        PinStart     14, IO
        PinBelongsTo GPIOType_GPIO, 14, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 TXD
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 TXD
        PinEnd
        PinStart     15, IO
        PinBelongsTo GPIOType_GPIO, 15, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 RXD
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 RXD
        PinEnd
        PinStart     16, IO
        PinBelongsTo GPIOType_GPIO, 16, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 CTS
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 CE2
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 CTS
        PinEnd
        PinStart     17, IO
        PinBelongsTo GPIOType_GPIO, 17, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 RTS
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 CE1
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 RTS
        PinEnd
        PinStart     18, IO
        PinBelongsTo GPIOType_GPIO, 18, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 CLK
        PinBelongsTo GPIOType_BSC, 0, Alt3      ; BSC0 SDA/MOSI
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 CE0
        PinBelongsTo GPIOType_PWM, 0, Alt5      ; PWM0
        PinEnd
        PinStart     19, IO
        PinBelongsTo GPIOType_GPIO, 19, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 FS
        PinBelongsTo GPIOType_BSC, 0, Alt3      ; BSC0 SCL/SCLK
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 MISO
        PinBelongsTo GPIOType_PWM, 1, Alt5      ; PWM1
        PinEnd
        PinStart     20, IO
        PinBelongsTo GPIOType_GPIO, 20, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 DIN
        PinBelongsTo GPIOType_BSC, 0, Alt3      ; BSC0 MISO
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 MOSI
        PinBelongsTo GPIOType_GPCLK, 0, Alt5    ; GPCLK0
        PinEnd
        PinStart     21, IO
        PinBelongsTo GPIOType_GPIO, 21, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 DOUT
        PinBelongsTo GPIOType_BSC, 0, Alt3      ; BSC0 CE
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 SCLK
        PinBelongsTo GPIOType_GPCLK, 0, Alt5    ; GPCLK1
        PinEnd
        PinStart     22, IO
        PinBelongsTo GPIOType_GPIO, 22, AltGPI  ; GPIO
        PinEnd
        PinStart     23, IO
        PinBelongsTo GPIOType_GPIO, 23, AltGPI  ; GPIO
        PinEnd
        PinStart     24, IO
        PinBelongsTo GPIOType_GPIO, 24, AltGPI  ; GPIO
        PinEnd
        PinStart     25, IO
        PinBelongsTo GPIOType_GPIO, 25, AltGPI  ; GPIO
        PinEnd
        PinStart     26, IO
        PinBelongsTo GPIOType_GPIO, 26, AltGPI  ; GPIO
        PinEnd
        PinStart     27, IO
        PinBelongsTo GPIOType_GPIO, 27, AltGPI  ; GPIO
        PinEnd
        PinStart     28, IO
        PinBelongsTo GPIOType_GPIO, 28, AltGPI  ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SDA
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 CLK
        PinEnd
        PinStart     29, IO
        PinBelongsTo GPIOType_GPIO, 29, AltGPI  ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SCL
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 FS
        PinEnd
        PinStart     30, IO
        PinBelongsTo GPIOType_GPIO, 30, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 DIN
        PinEnd
        PinStart     31, IO
        PinBelongsTo GPIOType_GPIO, 31, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 DOUT
        PinEnd

        ; Table ends
        DCD     -1

GPIO_Port0_Table_BCM2838
ROOL's avatar
ROOL committed
1135 1136 1137
        PinStart     0, IO
        PinBelongsTo GPIOType_GPIO, 0, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SDA
Ben Avison's avatar
Ben Avison committed
1138 1139 1140
        PinBelongsTo GPIOType_SPI, 3, Alt3      ; SPI3 CE0
        PinBelongsTo GPIOType_UART, 2, Alt4     ; UART2 TXD
        PinBelongsTo GPIOType_I2C, 6, Alt5      ; I2C6 SDA
ROOL's avatar
ROOL committed
1141 1142 1143 1144
        PinEnd
        PinStart     1, IO
        PinBelongsTo GPIOType_GPIO, 1, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SCL
Ben Avison's avatar
Ben Avison committed
1145 1146 1147
        PinBelongsTo GPIOType_SPI, 3, Alt3      ; SPI3 MISO
        PinBelongsTo GPIOType_UART, 2, Alt4     ; UART2 RXD
        PinBelongsTo GPIOType_I2C, 6, Alt5      ; I2C6 SCL
ROOL's avatar
ROOL committed
1148 1149 1150 1151
        PinEnd
        PinStart     2, IO
        PinBelongsTo GPIOType_GPIO, 2, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 1, Alt0      ; I2C1 SDA
Ben Avison's avatar
Ben Avison committed
1152 1153 1154
        PinBelongsTo GPIOType_SPI, 3, Alt3      ; SPI3 MOSI
        PinBelongsTo GPIOType_UART, 2, Alt4     ; UART2 CTS
        PinBelongsTo GPIOType_I2C, 3, Alt5      ; I2C3 SDA
ROOL's avatar
ROOL committed
1155 1156 1157 1158
        PinEnd
        PinStart     3, IO
        PinBelongsTo GPIOType_GPIO, 3, AltGPI   ; GPIO
        PinBelongsTo GPIOType_I2C, 1, Alt0      ; I2C1 SCL
Ben Avison's avatar
Ben Avison committed
1159 1160 1161
        PinBelongsTo GPIOType_SPI, 3, Alt3      ; SPI3 SCLK
        PinBelongsTo GPIOType_UART, 2, Alt4     ; UART2 RTS
        PinBelongsTo GPIOType_I2C, 3, Alt5      ; I2C3 SCL
ROOL's avatar
ROOL committed
1162 1163 1164 1165
        PinEnd
        PinStart     4, IO
        PinBelongsTo GPIOType_GPIO, 4, AltGPI   ; GPIO
        PinBelongsTo GPIOType_GPCLK, 0, Alt0    ; GPCLK0
Ben Avison's avatar
Ben Avison committed
1166 1167 1168
        PinBelongsTo GPIOType_SPI, 4, Alt3      ; SPI4 CE0
        PinBelongsTo GPIOType_UART, 3, Alt4     ; UART3 TXD
        PinBelongsTo GPIOType_I2C, 3, Alt5      ; I2C3 SDA
ROOL's avatar
ROOL committed
1169 1170 1171 1172
        PinEnd
        PinStart     5, IO
        PinBelongsTo GPIOType_GPIO, 5, AltGPI   ; GPIO
        PinBelongsTo GPIOType_GPCLK, 1, Alt0    ; GPCLK1
Ben Avison's avatar
Ben Avison committed
1173 1174 1175
        PinBelongsTo GPIOType_SPI, 4, Alt3      ; SPI4 MISO
        PinBelongsTo GPIOType_UART, 3, Alt4     ; UART3 RXD
        PinBelongsTo GPIOType_I2C, 3, Alt5      ; I2C3 SCL
ROOL's avatar
ROOL committed
1176 1177 1178 1179
        PinEnd
        PinStart     6, IO
        PinBelongsTo GPIOType_GPIO, 6, AltGPI   ; GPIO
        PinBelongsTo GPIOType_GPCLK, 2, Alt0    ; GPCLK2
Ben Avison's avatar
Ben Avison committed
1180 1181 1182
        PinBelongsTo GPIOType_SPI, 4, Alt3      ; SPI4 MOSI
        PinBelongsTo GPIOType_UART, 3, Alt4     ; UART3 CTS
        PinBelongsTo GPIOType_I2C, 4, Alt5      ; I2C4 SDA
ROOL's avatar
ROOL committed
1183 1184 1185 1186
        PinEnd
        PinStart     7, IO
        PinBelongsTo GPIOType_GPIO, 7, AltGPI   ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 CE1
Ben Avison's avatar
Ben Avison committed
1187 1188 1189
        PinBelongsTo GPIOType_SPI, 4, Alt3      ; SPI4 SCLK
        PinBelongsTo GPIOType_UART, 3, Alt4     ; UART3 RTS
        PinBelongsTo GPIOType_I2C, 4, Alt5      ; I2C4 SCL
ROOL's avatar
ROOL committed
1190 1191 1192 1193
        PinEnd
        PinStart     8, IO
        PinBelongsTo GPIOType_GPIO, 8, AltGPI   ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 CE0
Ben Avison's avatar
Ben Avison committed
1194 1195
        PinBelongsTo GPIOType_UART, 4, Alt4     ; UART4 TXD
        PinBelongsTo GPIOType_I2C, 4, Alt5      ; I2C4 SDA
ROOL's avatar
ROOL committed
1196 1197 1198 1199
        PinEnd
        PinStart     9, IO
        PinBelongsTo GPIOType_GPIO, 9, AltGPI   ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 MISO
Ben Avison's avatar
Ben Avison committed
1200 1201
        PinBelongsTo GPIOType_UART, 4, Alt4     ; UART4 RXD
        PinBelongsTo GPIOType_I2C, 4, Alt5      ; I2C4 SCL
ROOL's avatar
ROOL committed
1202 1203 1204 1205
        PinEnd
        PinStart     10, IO
        PinBelongsTo GPIOType_GPIO, 10, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 MOSI
Ben Avison's avatar
Ben Avison committed
1206 1207
        PinBelongsTo GPIOType_UART, 4, Alt4     ; UART4 CTS
        PinBelongsTo GPIOType_I2C, 5, Alt5      ; I2C5 SDA
ROOL's avatar
ROOL committed
1208 1209 1210 1211
        PinEnd
        PinStart     11, IO
        PinBelongsTo GPIOType_GPIO, 11, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 SCLK
Ben Avison's avatar
Ben Avison committed
1212 1213
        PinBelongsTo GPIOType_UART, 4, Alt4     ; UART4 RTS
        PinBelongsTo GPIOType_I2C, 5, Alt5      ; I2C5 SCL
ROOL's avatar
ROOL committed
1214 1215 1216 1217
        PinEnd
        PinStart     12, IO
        PinBelongsTo GPIOType_GPIO, 12, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PWM, 0, Alt0      ; PWM0
Ben Avison's avatar
Ben Avison committed
1218 1219 1220
        PinBelongsTo GPIOType_SPI, 5, Alt3      ; SPI5 CE0
        PinBelongsTo GPIOType_UART, 5, Alt4     ; UART5 TXD
        PinBelongsTo GPIOType_I2C, 5, Alt5      ; I2C5 SDA
ROOL's avatar
ROOL committed
1221 1222 1223 1224
        PinEnd
        PinStart     13, IO
        PinBelongsTo GPIOType_GPIO, 13, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PWM, 1, Alt0      ; PWM1
Ben Avison's avatar
Ben Avison committed
1225 1226 1227
        PinBelongsTo GPIOType_SPI, 5, Alt3      ; SPI5 MISO
        PinBelongsTo GPIOType_UART, 5, Alt4     ; UART5 RXD
        PinBelongsTo GPIOType_I2C, 5, Alt5      ; I2C5 SCL
ROOL's avatar
ROOL committed
1228 1229 1230 1231
        PinEnd
        PinStart     14, IO
        PinBelongsTo GPIOType_GPIO, 14, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 TXD
Ben Avison's avatar
Ben Avison committed
1232 1233
        PinBelongsTo GPIOType_SPI, 5, Alt3      ; SPI5 MOSI
        PinBelongsTo GPIOType_UART, 5, Alt4     ; UART5 CTS
ROOL's avatar
ROOL committed
1234 1235 1236 1237 1238
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 TXD
        PinEnd
        PinStart     15, IO
        PinBelongsTo GPIOType_GPIO, 15, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 RXD
Ben Avison's avatar
Ben Avison committed
1239 1240
        PinBelongsTo GPIOType_SPI, 5, Alt3      ; SPI5 SCLK
        PinBelongsTo GPIOType_UART, 5, Alt4     ; UART5 RTS
ROOL's avatar
ROOL committed
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 RXD
        PinEnd
        PinStart     16, IO
        PinBelongsTo GPIOType_GPIO, 16, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 CTS
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 CE2
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 CTS
        PinEnd
        PinStart     17, IO
        PinBelongsTo GPIOType_GPIO, 17, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt0     ; UART0 RTS
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 CE1
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 RTS
        PinEnd
        PinStart     18, IO
        PinBelongsTo GPIOType_GPIO, 18, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 CLK
1258
        PinBelongsTo GPIOType_SPI, 6, Alt3      ; SPI6 CE0
ROOL's avatar
ROOL committed
1259 1260 1261 1262 1263 1264
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 CE0
        PinBelongsTo GPIOType_PWM, 0, Alt5      ; PWM0
        PinEnd
        PinStart     19, IO
        PinBelongsTo GPIOType_GPIO, 19, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 FS
1265
        PinBelongsTo GPIOType_SPI, 5, Alt3      ; SPI5 MISO
ROOL's avatar
ROOL committed
1266 1267 1268 1269 1270 1271
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 MISO
        PinBelongsTo GPIOType_PWM, 1, Alt5      ; PWM1
        PinEnd
        PinStart     20, IO
        PinBelongsTo GPIOType_GPIO, 20, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 DIN
1272
        PinBelongsTo GPIOType_SPI, 5, Alt3      ; SPI5 MOSI
ROOL's avatar
ROOL committed
1273 1274 1275 1276 1277 1278
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 MOSI
        PinBelongsTo GPIOType_GPCLK, 0, Alt5    ; GPCLK0
        PinEnd
        PinStart     21, IO
        PinBelongsTo GPIOType_GPIO, 21, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt0      ; PCM0 DOUT
1279
        PinBelongsTo GPIOType_SPI, 5, Alt3      ; SPI5 SCLK
ROOL's avatar
ROOL committed
1280 1281 1282 1283 1284
        PinBelongsTo GPIOType_SPI, 1, Alt4      ; SPI1 SCLK
        PinBelongsTo GPIOType_GPCLK, 0, Alt5    ; GPCLK1
        PinEnd
        PinStart     22, IO
        PinBelongsTo GPIOType_GPIO, 22, AltGPI  ; GPIO
Ben Avison's avatar
Ben Avison committed
1285
        PinBelongsTo GPIOType_I2C, 6, Alt5      ; I2C6 SDA
ROOL's avatar
ROOL committed
1286 1287 1288
        PinEnd
        PinStart     23, IO
        PinBelongsTo GPIOType_GPIO, 23, AltGPI  ; GPIO
Ben Avison's avatar
Ben Avison committed
1289
        PinBelongsTo GPIOType_I2C, 6, Alt5      ; I2C6 SCL
ROOL's avatar
ROOL committed
1290 1291 1292
        PinEnd
        PinStart     24, IO
        PinBelongsTo GPIOType_GPIO, 24, AltGPI  ; GPIO
Ben Avison's avatar
Ben Avison committed
1293
        PinBelongsTo GPIOType_SPI, 3, Alt5      ; SPI3 CE1
ROOL's avatar
ROOL committed
1294 1295 1296
        PinEnd
        PinStart     25, IO
        PinBelongsTo GPIOType_GPIO, 25, AltGPI  ; GPIO
Ben Avison's avatar
Ben Avison committed
1297
        PinBelongsTo GPIOType_SPI, 4, Alt5      ; SPI4 CE1
ROOL's avatar
ROOL committed
1298 1299 1300
        PinEnd
        PinStart     26, IO
        PinBelongsTo GPIOType_GPIO, 26, AltGPI  ; GPIO
Ben Avison's avatar
Ben Avison committed
1301
        PinBelongsTo GPIOType_SPI, 5, Alt5      ; SPI5 CE1
ROOL's avatar
ROOL committed
1302 1303 1304
        PinEnd
        PinStart     27, IO
        PinBelongsTo GPIOType_GPIO, 27, AltGPI  ; GPIO
Ben Avison's avatar
Ben Avison committed
1305
        PinBelongsTo GPIOType_SPI, 6, Alt5      ; SPI6 CE1
ROOL's avatar
ROOL committed
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
        PinEnd
        PinStart     28, IO
        PinBelongsTo GPIOType_GPIO, 28, AltGPI  ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SDA
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 CLK
        PinEnd
        PinStart     29, IO
        PinBelongsTo GPIOType_GPIO, 29, AltGPI  ; GPIO
        PinBelongsTo GPIOType_I2C, 0, Alt0      ; I2C0 SCL
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 FS
        PinEnd
        PinStart     30, IO
        PinBelongsTo GPIOType_GPIO, 30, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 DIN
        PinEnd
        PinStart     31, IO
        PinBelongsTo GPIOType_GPIO, 31, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PCM, 0, Alt2      ; PCM0 DOUT
        PinEnd

        ; Table ends
        DCD     -1

GPIO_Port1_Table
        PinStart     32, IO
        PinBelongsTo GPIOType_GPIO, 32, AltGPI  ; GPIO
        PinBelongsTo GPIOType_GPCLK, 0, Alt0    ; GPCLK0
        PinBelongsTo GPIOType_UART, 0, Alt3     ; UART0 TXD
        PinBelongsTo GPIOType_UART, 0, Alt5     ; UART1 TXD
        PinEnd
        PinStart     33, IO
        PinBelongsTo GPIOType_GPIO, 33, AltGPI  ; GPIO
        PinBelongsTo GPIOType_UART, 0, Alt3     ; UART0 RXD
        PinBelongsTo GPIOType_UART, 0, Alt5     ; UART1 RXD
        PinEnd
        PinStart     34, IO
        PinBelongsTo GPIOType_GPIO, 34, AltGPI  ; GPIO
        PinBelongsTo GPIOType_GPCLK, 0, Alt0    ; GPCLK0
        PinEnd
        PinStart     35, IO
        PinBelongsTo GPIOType_GPIO, 35, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 CE1
        PinEnd
        PinStart     36, IO
        PinBelongsTo GPIOType_GPIO, 36, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 CE0
        PinBelongsTo GPIOType_UART, 0, Alt2     ; UART0 TXD
        PinEnd
        PinStart     37, IO
        PinBelongsTo GPIOType_GPIO, 37, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 MISO
        PinBelongsTo GPIOType_UART, 0, Alt2     ; UART0 RXD
        PinEnd
        PinStart     38, IO
        PinBelongsTo GPIOType_GPIO, 38, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 MOSI
        PinBelongsTo GPIOType_UART, 0, Alt2     ; UART0 RTS
        PinEnd
        PinStart     39, IO
        PinBelongsTo GPIOType_GPIO, 39, AltGPI  ; GPIO
        PinBelongsTo GPIOType_SPI, 0, Alt0      ; SPI0 SCLK
        PinBelongsTo GPIOType_UART, 0, Alt2     ; UART0 CTS
        PinEnd
        PinStart     40, IO
        PinBelongsTo GPIOType_GPIO, 40, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PWM, 0, Alt0      ; PWM0
        PinBelongsTo GPIOType_SPI, 2, Alt4      ; SPI2 MISO
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 TXD
        PinEnd
        PinStart     41, IO
        PinBelongsTo GPIOType_GPIO, 41, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PWM, 1, Alt0      ; PWM1
        PinBelongsTo GPIOType_SPI, 2, Alt4      ; SPI2 MOSI
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 RXD
        PinEnd
        PinStart     42, IO
        PinBelongsTo GPIOType_GPIO, 42, AltGPI  ; GPIO
        PinBelongsTo GPIOType_GPCLK, 1, Alt0    ; GPCLK1
        PinBelongsTo GPIOType_SPI, 2, Alt4      ; SPI2 SCLK
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 RTS
        PinEnd
        PinStart     43, IO
        PinBelongsTo GPIOType_GPIO, 43, AltGPI  ; GPIO
        PinBelongsTo GPIOType_GPCLK, 2, Alt0    ; GPCLK2
        PinBelongsTo GPIOType_SPI, 2, Alt4      ; SPI2 CE0
        PinBelongsTo GPIOType_UART, 1, Alt5     ; UART1 CTS
        PinEnd
        PinStart     44, IO
        PinBelongsTo GPIOType_GPIO, 44, AltGPI  ; GPIO
        PinBelongsTo GPIOType_GPCLK, 1, Alt0    ; GPCLK1
        PinBelongsTo GPIOType_I2C, 0, Alt1      ; I2C0 SDA
        PinBelongsTo GPIOType_I2C, 1, Alt2      ; I2C1 SDA
        PinBelongsTo GPIOType_SPI, 2, Alt4      ; SPI2 CE1
        PinEnd
        PinStart     45, IO
        PinBelongsTo GPIOType_GPIO, 45, AltGPI  ; GPIO
        PinBelongsTo GPIOType_PWM, 1, Alt0      ; PWM1
        PinBelongsTo GPIOType_I2C, 0, Alt1      ; I2C0 SCL
        PinBelongsTo GPIOType_I2C, 1, Alt2      ; I2C1 SCL
        PinBelongsTo GPIOType_SPI, 2, Alt4      ; SPI2 CE2
        PinEnd
        PinStart     46, IO
        PinBelongsTo GPIOType_GPIO, 46, AltGPI  ; GPIO
        PinEnd
        PinStart     47, IO
        PinBelongsTo GPIOType_GPIO, 47, AltGPI  ; GPIO
        PinEnd
        PinStart     48, IO
        PinBelongsTo GPIOType_GPIO, 48, AltGPI  ; GPIO
        PinEnd
        PinStart     49, IO
        PinBelongsTo GPIOType_GPIO, 49, AltGPI  ; GPIO
        PinEnd
        PinStart     50, IO
        PinBelongsTo GPIOType_GPIO, 50, AltGPI  ; GPIO
        PinEnd
        PinStart     51, IO
        PinBelongsTo GPIOType_GPIO, 51, AltGPI  ; GPIO
        PinEnd
        PinStart     52, IO
        PinBelongsTo GPIOType_GPIO, 52, AltGPI  ; GPIO
        PinEnd
        PinStart     53, IO
        PinBelongsTo GPIOType_GPIO, 53, AltGPI  ; GPIO
        PinEnd

        ; Table ends
        DCD     -1

GPIOPortTables
        DCD     GPIO_Port0_Table
        DCD     GPIO_Port1_Table

1439 1440 1441 1442
GPIOPortTables_BCM2838
        DCD     GPIO_Port0_Table_BCM2838
        DCD     GPIO_Port1_Table

1443
        END