Commit 3b36df75 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Add GPIO & VCHIQ HAL devices. Fix FlushDataCache macro to perform a clean &...

Add GPIO & VCHIQ HAL devices. Fix FlushDataCache macro to perform a clean & invalidate instead of just an invalidate.

Detail:
  s/GPIO - Basic implementation of the GPIO HAL device to allow the GPIO module to detect the board type
  s/VCHIQ, hdr/StaticWS - New VCHIQ HAL device which exposes the functionality required by the work-in-progress VCHIQ driver.
  Makefile, s/Top - Hook up the new files/devices
  hdr/BCM2835 - Make the FlushDataCache macro perform a clean & invalidate, to match the behaviour of FlushDataCacheRange
Admin:
  Tested on Raspberry Pi with high processor vectors


Version 0.17. Tagged as 'BCM2835-0_17'
parent e3299240
......@@ -17,7 +17,7 @@
COMPONENT = BCM2835 HAL
TARGET = BCM2835
OBJS = Top CLib CMOS Debug Display Interrupts SDIO Stubs Timers UART USB Video DMA Messaging
OBJS = Top CLib CMOS Debug Display Interrupts SDIO Stubs Timers UART USB Video DMA Messaging GPIO VCHIQ
HDRS =
CMHGFILE =
......
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "0.16"
Module_Version SETA 16
Module_MajorVersion SETS "0.17"
Module_Version SETA 17
Module_MinorVersion SETS ""
Module_Date SETS "24 Jul 2012"
Module_ApplicationDate SETS "24-Jul-12"
Module_Date SETS "02 Aug 2012"
Module_ApplicationDate SETS "02-Aug-12"
Module_ComponentName SETS "BCM2835"
Module_ComponentPath SETS "mixed/RiscOS/Sources/HAL/BCM2835"
Module_FullVersion SETS "0.16"
Module_HelpVersion SETS "0.16 (24 Jul 2012)"
Module_FullVersion SETS "0.17"
Module_HelpVersion SETS "0.17 (02 Aug 2012)"
END
/* (0.16)
/* (0.17)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.16
#define Module_MajorVersion_CMHG 0.17
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 24 Jul 2012
#define Module_Date_CMHG 02 Aug 2012
#define Module_MajorVersion "0.16"
#define Module_Version 16
#define Module_MajorVersion "0.17"
#define Module_Version 17
#define Module_MinorVersion ""
#define Module_Date "24 Jul 2012"
#define Module_Date "02 Aug 2012"
#define Module_ApplicationDate "24-Jul-12"
#define Module_ApplicationDate "02-Aug-12"
#define Module_ComponentName "BCM2835"
#define Module_ComponentPath "mixed/RiscOS/Sources/HAL/BCM2835"
#define Module_FullVersion "0.16"
#define Module_HelpVersion "0.16 (24 Jul 2012)"
#define Module_LibraryVersionInfo "0:16"
#define Module_FullVersion "0.17"
#define Module_HelpVersion "0.17 (02 Aug 2012)"
#define Module_LibraryVersionInfo "0:17"
......@@ -178,6 +178,10 @@ NumTimers SETA NumTimers + 1
; There are two mailboxes; we write to mailbox 1 and read from mailbox 0
;
MB_Base * &0000b800 ; offset from IO space start
MB_DBell0 * &40 ; doorbell 0 (VCHIQ VC -> ARM)
MB_DBell1 * &44 ; doorbell 1
MB_DBell2 * &48 ; doorbell 2 (VCHIQ ARM -> VC)
MB_DBell3 * &4c ; doorbell 3
MB_ChRd * &80 ; normal read - offset from MB_Base
MB_ChWr * &a0 ; normal write
MB_ChRWTop * &8c ; 4 word read or write
......@@ -304,9 +308,9 @@ $label MOV$cond $r, #0
$label FlushDataCache $r, $cond
$label MOV$cond $r, #0
[ {UAL}
MCR$cond p15, #0, $r, c7, c6, #0
MCR$cond p15, #0, $r, c7, c14, #0
|
MCR$cond p15, 0, $r, c7, c6,0
MCR$cond p15, 0, $r, c7, c14,0
]
MEND
MACRO
......
......@@ -59,6 +59,15 @@ DMACCBOffset # 4 ; Address offset to convert DMA CB addr to ARM CB add
DMACDesc # 32 ; Buffer for description string
DMAC_DeviceSize * :INDEX: @
; VCHIQ HAL device layout
^ 0
# HALDeviceSize
HALDevice_VCHIQARMToVCOffset # 4
HALDevice_VCHIQVCDoorbell # 4 ; Doorbell to interrupt VC
HALDevice_VCHIQARMDoorbell # 4 ; Doorbell to interrupt us
HALDevice_VCHIQInitVC # 4
HALDevice_VCHIQ_Size * :INDEX: @
; Main workspace layout
......@@ -159,6 +168,8 @@ DMAChannels # DMAC_DeviceSize*DMA_CH_Count ; List of channel devices (
CurUnder # 32*4*32
CurShape # 32/4*32
VCHIQDevice # HALDevice_VCHIQ_Size
HAL_WsSize * :INDEX:@
sizeof_workspace * :INDEX:@
......
;
; 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
GET Hdr:Proc
GET Hdr:GPIODevice
GET hdr.BCM2835
GET hdr.StaticWS
EXPORT GPIO_InitDevices
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
; Template for GPIO interface
GPIO_Dev
0
HALDeviceField Type, HALDeviceType_Comms + HALDeviceComms_GPIO
HALDeviceField ID, HALDeviceID_GPIO_BCM2835
HALDeviceField Location, HALDeviceBus_Sys + HALDeviceSysBus_AHB ; Guess
HALDeviceField Version, 0
HALDeviceField Description, GPIO_Description
HALDeviceField Address, 0
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
GPIO HALDeviceField Type, GPIOType_BCM2835_RaspberryPi
GPIO HALDeviceField Revision, GPIORevision_RaspberryPi_Unknown
ASSERT . - %A0 = HALDevice_GPIO_Size
GPIO_Description
= "BCM2835 GPIO interface", 0
ALIGN
; Initialise our HAL devices
GPIO_InitDevices ROUT
Entry
MOV a1, #0
ADR a2, GPIO_Dev
MOV lr, pc
LDR pc, OSentries+4*OS_AddDevice
EXIT
GPIO_Activate
MOV a1, #1
GPIO_Deactivate
GPIO_Reset
MOV pc, lr
GPIO_Sleep
MOV a1, #0
MOV pc, lr
END
......@@ -145,6 +145,10 @@
IMPORT DMA_InitDevices
IMPORT GPIO_InitDevices
IMPORT VCHIQ_InitDevices
IMPORT HAL_SendHostMessage
IMPORT HAL_QueryPlatform
......@@ -843,6 +847,8 @@ HAL_InitDevices
STR lr, [sp, #-4]!
BL SDIO_InitDevices
BL DMA_InitDevices
BL GPIO_InitDevices
BL VCHIQ_InitDevices
LDR pc, [sp], #4
......
;
; 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
GET Hdr:Proc
GET Hdr:GPIODevice
GET hdr.BCM2835
GET hdr.StaticWS
EXPORT VCHIQ_InitDevices
IMPORT HAL_SendHostMessage
IMPORT memcpy
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
; Template for VCHIQ device
VCHIQ_Dev
0
HALDeviceField Type, HALDeviceType_Comms + HALDeviceComms_InterProc
HALDeviceField ID, HALDeviceID_InterProc_VCHIQ
HALDeviceField Location, HALDeviceBus_Sys + HALDeviceSysBus_AHB ; Guess
HALDeviceField Version, 0
HALDeviceField Description, VCHIQ_Description
HALDeviceField Address, 0
HALDeviceField Reserved1, 0
HALDeviceField Activate, VCHIQ_Activate
HALDeviceField Deactivate, VCHIQ_Deactivate
HALDeviceField Reset, VCHIQ_Reset
HALDeviceField Sleep, VCHIQ_Sleep
HALDeviceField Device, iDev_ARM_DBell0
HALDeviceField TestIRQ, 0
HALDeviceField ClearIRQ, 0
HALDeviceField Reserved2, 0
VCHIQ HALDeviceField ARMToVCOffset, 0 ; filled in later
VCHIQ HALDeviceField VCDoorbell, VCHIQ_VCDoorbell
VCHIQ HALDeviceField ARMDoorbell, VCHIQ_ARMDoorbell
VCHIQ HALDeviceField InitVC, VCHIQ_InitVC
ASSERT . - %A0 = HALDevice_VCHIQ_Size
VCHIQ_Description
= "VCHIQ", 0
ALIGN
; Initialise our HAL devices
VCHIQ_InitDevices ROUT
Entry
ADRL a1, VCHIQDevice
ADR a2, VCHIQ_Dev
MOV a3, #HALDevice_VCHIQ_Size
BL memcpy
ADRL a2, VCHIQDevice
LDR a1, FB_CacheMode
STR a1, [a2, #HALDevice_VCHIQARMToVCOffset]
MOV a1, #0
MOV lr, pc
LDR pc, OSentries+4*OS_AddDevice
EXIT
VCHIQ_Activate
MOV a1, #1
VCHIQ_Deactivate
VCHIQ_Reset
MOV pc, lr
VCHIQ_Sleep
MOV a1, #0
MOV pc, lr
VCHIQ_VCDoorbell
DoMemBarrier a2
LDR a2, =:INDEX:PeriBase - :INDEX:VCHIQDevice
LDR a1, [a1, a2]
MOV a2, #0
ADD a1, a1, #MB_Base
STR a2, [a1, #MB_DBell2]
DoMemBarrier a2
MOV pc, lr
VCHIQ_ARMDoorbell
DoMemBarrier a2
LDR a2, =:INDEX:PeriBase - :INDEX:VCHIQDevice
LDR a1, [a1, a2]
ADD a1, a1, #MB_Base
LDR a1, [a1, #MB_DBell0]
DoMemBarrier a2
MOV pc, lr
VCHIQ_InitVC
; in: a1 = HAL device ptr
; a2 = ARM phys addr of VCHIQ buffer
; Write to the VCHIQ mailbox channel to let the VC know about the buffer
Entry "sb"
LDR a3, =:INDEX: VCHIQDevice
SUB sb, a1, a3
LDR a1, FB_CacheMode
ADD a1, a1, a2
ADD a1, a1, #MB_Chan_VCHIQ
; VCHIQ message doesn't generate a response through the mailbox system, so just fire and forget
DoMemBarrier r3
LDR r3, PeriBase
ADD r3, r3, #MB_Base
; check we can send a message
001 LDR r2,[r3, #MB_Sta]
TST r2, #MB_Sta_Full
BNE %BT001 ; write channel full
; send message
STR a1,[r3, #MB_ChWr]
DoMemBarrier r3
EXIT
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment