Commit 4830dcfe authored by Ben Avison's avatar Ben Avison
Browse files

Support the Raspberry Pi model B+

Detail:
  The activity GPIO pin has been reassigned and its sense is inverted,
  compared to earlier boards. More importantly, the SD card detect pin has
  been removed entirely, so we need to signal to the SD stack to use its
  new timeout-based state machine (rather than polling for card presence).
Admin:
  Already in use in RC12a.

Version 0.35. Tagged as 'BCM2835-0_35'
parent d4275b0f
/* (0.34)
/* (0.35)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.34
#define Module_MajorVersion_CMHG 0.35
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 19 Jun 2014
#define Module_Date_CMHG 14 Jul 2014
#define Module_MajorVersion "0.34"
#define Module_Version 34
#define Module_MajorVersion "0.35"
#define Module_Version 35
#define Module_MinorVersion ""
#define Module_Date "19 Jun 2014"
#define Module_Date "14 Jul 2014"
#define Module_ApplicationDate "19-Jun-14"
#define Module_ApplicationDate "14-Jul-14"
#define Module_ComponentName "BCM2835"
#define Module_ComponentPath "mixed/RiscOS/Sources/HAL/BCM2835"
#define Module_FullVersion "0.34"
#define Module_HelpVersion "0.34 (19 Jun 2014)"
#define Module_LibraryVersionInfo "0:34"
#define Module_FullVersion "0.35"
#define Module_HelpVersion "0.35 (14 Jul 2014)"
#define Module_LibraryVersionInfo "0:35"
......@@ -94,8 +94,11 @@ GPIO_Description
MEND
GPIO_BoardTypes
BoardType 0, 2, 3, B_1
BoardType 0, 4, &ffffffff, B_2 ; Only revs 4-6 confirmed so far, but assume anything newer will be compatible so that minor revisions don't trip us up
BoardType 0, &02, &03, B_1
BoardType 0, &04, &06, B_2
BoardType 0, &07, &09, A_2
BoardType 0, &0d, &0f, B_2
BoardType 0, &10, &ffffffff, BPlus ; Assume anything newer will be compatible so that minor revisions don't trip us up
GPIO_BoardTypes_End
; Initialise our HAL devices
......
......@@ -56,18 +56,22 @@ REGISTER_WRITE_PACE * 2
; writes while reprogramming SDCLK
MIN_SDCLK * 400
; Significant board revisions
BoardRevision_BPlus * &10 ; they took away my card detect line!
; Base address of controller as an offset from PeriBase
EMMC_Base * &00300000
; GPIO pin assignments
GPIO_DAT3 * 53
GPIO_DAT2 * 52
GPIO_DAT1 * 51
GPIO_DAT0 * 50
GPIO_CMD * 49 ; needs pull-up iff in ID mode
GPIO_CLK * 48
GPIO_CD * 47 ; needs pull-up; active low
GPIO_STATUS_LED * 16 ; active low
GPIO_DAT3 * 53
GPIO_DAT2 * 52
GPIO_DAT1 * 51
GPIO_DAT0 * 50
GPIO_CMD * 49 ; needs pull-up iff in ID mode
GPIO_CLK * 48
GPIO_CD_AB * 47 ; needs pull-up; active low
GPIO_STATUS_LED_AB * 16 ; active low
GPIO_STATUS_LED_BPlus * 47 ; active high
; GPIO function select bitfields
GPIO_FSEL_INPUT * 0
......@@ -287,7 +291,7 @@ Template
HALDeviceField Description
HALDeviceField Address, 0 ; patched up at initialisation
HALDeviceField Reserved1, 0
HALDeviceField Activate
HALDeviceField Activate, 0 ; patched up at initialisation
HALDeviceField Deactivate
HALDeviceField Reset
HALDeviceField Sleep
......@@ -308,8 +312,8 @@ SDHCI HALDeviceField SetBusWidth, 0
SDHCI HALDeviceField GetMaxCurrent
SDHCI HALDeviceField SetSDCLK
SDHCI HALDeviceField GetTMCLK
SDHCI HALDeviceField SetActivity
SDHCI HALDeviceField GetCardDetect
SDHCI HALDeviceField SetActivity, 0 ; patched up at initialisation
SDHCI HALDeviceField GetCardDetect, 0 ; patched up at initialisation
SDHCI HALDeviceField GetWriteProtect
ASSERT . - %A0 = HALDevice_SDHCISize
......@@ -324,6 +328,14 @@ SDIO_InitDevices ROUT
MOV a3, #HALDevice_SDHCISize
BL memcpy
LDR a3, Board_Revision
CMP a3, #BoardRevision_BPlus
; Activate
ADRCC a1, Activate_AB
ADRCS a1, Activate_BPlus
STR a1, SDHCIDevice + HALDevice_Activate
; Address and SlotInfo_StdRegs
LDR a1, PeriBase
ADD a1, a1, #EMMC_Base
......@@ -336,8 +348,17 @@ SDIO_InitDevices ROUT
; SlotInfo_Flags
MOV a1, #HALDeviceSDHCI_SlotFlag_Bus4Bit
ORRCS a1, a1, #HALDeviceSDHCI_SlotFlag_NoCardDetect
STR a1, SDHCISlotInfo + HALDeviceSDHCI_SlotInfo_Flags
; SetActivity and GetCardDetect
ADRL a1, SetActivity_AB
ADDCS a1, a1, #SetActivity_BPlus - SetActivity_AB
ADRL a2, GetCardDetect_AB
ADDCS a2, a2, #GetCardDetect_BPlus - GetCardDetect_AB
STR a1, SDHCIDevice + HALDevice_SDHCISetActivity
STR a2, SDHCIDevice + HALDevice_SDHCIGetCardDetect
MOV a1, #0 ; flags
ADR a2, SDHCIDevice
Pull "lr"
......@@ -438,7 +459,7 @@ Description DATA
NOPEntry ROUT
MOV pc, lr
Activate ROUT
Activate_AB ROUT
Push "sb,lr"
SUB sb, a1, #:INDEX:SDHCIDevice
......@@ -453,19 +474,43 @@ Activate ROUT
DoMemBarrier a1 ; switch to GPIO peripheral
; Set up pin mux registers and GPIO directions
MOV a1, #GPIO_CD
MOV a1, #GPIO_CD_AB
MOV a2, #GPIO_FSEL_INPUT
BL PinMux_SetFunction
MOV a1, #GPIO_CD
MOV a1, #GPIO_CD_AB
MOV a2, #GPIO_PUD_UP
BL GPIO_SetPull
MOV a1, #GPIO_STATUS_LED
MOV a1, #GPIO_STATUS_LED_AB
MOV a2, #GPIO_FSEL_OUTPUT
BL PinMux_SetFunction
MOV a1, #GPIO_STATUS_LED
MOV a1, #GPIO_STATUS_LED_AB
MOV a2, #GPIO_PUD_OFF
BL GPIO_SetPull
B Activate_Common
Activate_BPlus ROUT
Push "sb,lr"
SUB sb, a1, #:INDEX:SDHCIDevice
MOV lr, #0
STR lr, SDHCILastWriteCount
; SDCLK has to be set up before any register writes are done - it's not
; reasonable to expect SDIODriver to know this requirement
MOV a3, #MIN_SDCLK
BL SetSDCLK
DoMemBarrier a1 ; switch to GPIO peripheral
; Set up pin mux registers and GPIO directions
MOV a1, #GPIO_STATUS_LED_BPlus
MOV a2, #GPIO_FSEL_OUTPUT
BL PinMux_SetFunction
MOV a1, #GPIO_STATUS_LED_BPlus
MOV a2, #GPIO_PUD_OFF
BL GPIO_SetPull
; drop through...
Activate_Common
MOV a1, #GPIO_DAT3
MOV a2, #GPIO_PUD_UP
BL GPIO_SetPull
......@@ -692,7 +737,7 @@ GetTMCLK ROUT
DivRem a1, a2, a3, a4
Pull "sb,pc"
SetActivity ROUT
SetActivity_AB ROUT
Push "sb,lr"
DoMemBarrier lr ; switch to GPIO peripheral
SUB sb, a1, #:INDEX:SDHCIDevice
......@@ -701,18 +746,33 @@ SetActivity ROUT
TEQ a3, #HALDeviceSDHCI_ActivityOff
MOVEQ a2, #1
MOVNE a2, #0
MOV a1, #GPIO_STATUS_LED
MOV a1, #GPIO_STATUS_LED_AB
BL GPIO_Output
DoMemBarrier lr ; back to SDHCI peripheral
Pull "sb,pc"
GetCardDetect ROUT
SetActivity_BPlus ROUT
Push "sb,lr"
DoMemBarrier lr ; switch to GPIO peripheral
SUB sb, a1, #:INDEX:SDHCIDevice
MOV a1, #GPIO_CD
; Line is active high
ASSERT HALDeviceSDHCI_ActivityOff = 0
MOVS a2, a3
MOVNE a2, #1
MOV a1, #GPIO_STATUS_LED_BPlus
BL GPIO_Output
DoMemBarrier lr ; back to SDHCI peripheral
Pull "sb,pc"
GetCardDetect_AB ROUT
Push "sb,lr"
DoMemBarrier lr ; switch to GPIO peripheral
SUB sb, a1, #:INDEX:SDHCIDevice
MOV a1, #GPIO_CD_AB
BL GPIO_Input
; Line is active low, so invert
SUB a1, a1, #1
......@@ -721,6 +781,12 @@ GetCardDetect ROUT
DoMemBarrier lr ; back to SDHCI peripheral
Pull "sb,pc"
GetCardDetect_BPlus ROUT
; CD is not connected. This entry shouldn't be called, but just in case
; (perhaps someone softloaded old SDFSDriver/SDFS?) report card present
MOV a1, #1
MOV pc, lr
GetWriteProtect ROUT
; WP is not connected, so just have to always report unprotected :-(
MOV a1, #0
......
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