Commit 3e87de33 authored by Jeffrey Lee's avatar Jeffrey Lee

Fix SD card activity LED on Pi 3B

Detail:
  hdr/BCM2835 - Remove mailbox definitions - use the ones exported by BCMSupport to avoid needless duplication
  hdr/StaticWS, s/Messaging, s/Top - Use the mailbox property interface to request & map in the virtual GPIO buffer (if present)
  s/SDIO - On the Pi 3B, the GPIO that was used for the SD activity GPIO is now used for a different purpose. To control the activity LED we need to go via an I2C attached GPIO extender, which itself is exposed to the ARM via the new "virtual GPIO" buffer
  s/VCHIQ - Update to use BCMSupport mailbox definitions
Admin:
  Tested on Pi 1B, 3B


Version 0.54. Tagged as 'BCM2835-0_54'
parent be0775b6
/* (0.53)
/* (0.54)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.53
#define Module_MajorVersion_CMHG 0.54
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 26 Mar 2016
#define Module_MajorVersion "0.53"
#define Module_Version 53
#define Module_MajorVersion "0.54"
#define Module_Version 54
#define Module_MinorVersion ""
#define Module_Date "26 Mar 2016"
......@@ -18,6 +18,6 @@
#define Module_ComponentName "BCM2835"
#define Module_ComponentPath "mixed/RiscOS/Sources/HAL/BCM2835"
#define Module_FullVersion "0.53"
#define Module_HelpVersion "0.53 (26 Mar 2016)"
#define Module_LibraryVersionInfo "0:53"
#define Module_FullVersion "0.54"
#define Module_HelpVersion "0.54 (26 Mar 2016)"
#define Module_LibraryVersionInfo "0:54"
......@@ -201,78 +201,6 @@ MB_Cnf_OpIrq * &00000040 ; mailbox Opp irq pending
MB_Cnf_ErNone * &00000100 ; none read error
MB_Cnf_ErWFull * &00000200 ; Write to full mailbox
MB_Cnf_ErREmty * &00000400 ; read from empty mailbox
;
; mailbox channel numbers
MB_Chan_Pwr * 0 ; Power channel
MB_Chan_FB * 1 ; Frame Buffer channel
MB_Chan_VUart * 2 ; Virtual UART channel
MB_Chan_VCHIQ * 3 ; VCHIQ channel
MB_Chan_LEDS * 4 ; LEDS channel
MB_Chan_Btn * 5 ; Buttons channel
MB_Chan_TSc * 6 ; TouchScreen channel
MB_Chan_ARM2VC * 8 ; ARM -> VC property channel
MB_Chan_VC2ARM * 9 ; VC -> ARM property channel
; far end replies on the same channel when command done.. e.g.
; command c0000001 gets 00000001 (ie channel1) reply
; Power channel bits
MB_Pwr_SDCard * 0
MB_Pwr_UART * 1
MB_Pwr_MiniUART * 2
MB_Pwr_USB * 3
MB_Pwr_I2C0 * 4
MB_Pwr_I2C1_MASK * 5
MB_Pwr_I2C2_MASK * 6
MB_Pwr_SPI_MASK * 7
MB_Pwr_CCP2TX_MASK * 8
; ARM2VC tags
; see https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
ARM2VC_Tag_End * &00000000 ; End of tag list
ARM2VC_Tag_GetFirmwareVersion * &00000001 ; return 4 byte firmware version
ARM2VC_Tag_GetBoardModel * &00010001 ; return 4 byte model
ARM2VC_Tag_GetBoardRevision * &00010002 ; return 4 byte revision
ARM2VC_Tag_GetBoardMAC * &00010003 ; return 6 byte MAC
ARM2VC_Tag_GetBoardSerial * &00010004 ; return 8 byte serial
ARM2VC_Tag_GetARMMemory * &00010005 ; return ARM mem base + size
ARM2VC_Tag_GetVCMemory * &00010006 ; return VC mem base + size
ARM2VC_Tag_GetClocks * &00010007 ; return clock tree
ARM2VC_Tag_GetConfig * &00050001 ; get kernel boot args string
ARM2VC_Tag_GetDMAChannels * &00060001 ; get mask of DMA channels usable by ARM
ARM2VC_Tag_GetPowerState * &00020001 ; get power state of specified MB_Pwr_ device
ARM2VC_Tag_GetPowerTiming * &00020002 ; get microsecond delay required after power on for indicated device
ARM2VC_Tag_SetPowerState * &00028001 ; set power state of device
ARM2VC_Tag_GetClockState * &00030001 ; get power state of clock
ARM2VC_Tag_SetClockState * &00038001 ; set power state of clock
ARM2VC_Tag_GetClockRate * &00030002 ; get rate of clock
ARM2VC_Tag_SetClockRate * &00038002 ; set rate of clock
ARM2VC_Tag_FBAlloc * &00040001 ; alloc framebuffer at given alignment
ARM2VC_Tag_FBRelease * &00048001 ; release framebuffer
ARM2VC_Tag_FBBlank * &00040002 ; blank screen
ARM2VC_Tag_FBGetPhysDimension * &00040003 ; get physical display width/height
ARM2VC_Tag_FBTestPhysDimension * &00044003 ; test physical display w/h
ARM2VC_Tag_FBSetPhysDimension * &00048003 ; set physical display w/h
ARM2VC_Tag_FBGetVirtDimension * &00040004 ; get virtual display w/h
ARM2VC_Tag_FBTestVirtDimension * &00044004 ; test virtual display w/h
ARM2VC_Tag_FBSetVirtDimension * &00048004 ; set virtual display w/h
ARM2VC_Tag_FBGetDepth * &00040005 ; get display BPP
ARM2VC_Tag_FBTestDepth * &00044005 ; test display BPP
ARM2VC_Tag_FBSetDepth * &00048005 ; set display BPP
ARM2VC_Tag_FBGetPixelOrder * &00040006 ; get RGB/BGR order
ARM2VC_Tag_FBTestPixelOrder * &00044006 ; test RGB/BGR order
ARM2VC_Tag_FBSetPixelOrder * &00048006 ; set RGB/BGR order
ARM2VC_Tag_FBGetAlphaMode * &00040007 ; get alpha mode
ARM2VC_Tag_FBTestAlphaMode * &00044007 ; test alpha mode
ARM2VC_Tag_FBSetAlphaMode * &00048007 ; set alpha mode
ARM2VC_Tag_FBGetPitch * &00040008 ; get row pitch
ARM2VC_Tag_FBGetVirtOffset * &00040009 ; get X/Y offset of virtual display
ARM2VC_Tag_FBTestVirtOffset * &00044009 ; test X/Y offset
ARM2VC_Tag_FBSetVirtOffset * &00048009 ; set X/Y offset
ARM2VC_Tag_FBGetOverscan * &0004000a ; get overscan values
ARM2VC_Tag_FBTestOverscan * &0004400a ; test overscan values
ARM2VC_Tag_FBSetOverscan * &0004800a ; set overscan values
ARM2VC_Tag_FBGetPalette * &0004000b ; get full palette table
ARM2VC_Tag_FBTestPalette * &0004400b ; test ranged update of table
ARM2VC_Tag_FBSetPalette * &0004800b ; do ranged update of table
ARM2VC_Tag_FBGetTouchBuf * &0004000f ; get address of FT5406 register bank softcopy
; mem barrier operation; ensures all explicit mem operations completed before
; instruction exits.
......
......@@ -123,6 +123,7 @@ Board_Model # 4
Board_Revision # 4
ARM_DMAChannels # 4
TouchBuf # 4
VirtGPIOBuf # 4
; align to 16 byte boundary NB this isnt aligned once hal initialised
# (((:INDEX:@)+15):AND::NOT:15)-(:INDEX:@)
......
......@@ -31,7 +31,12 @@
AREA |ARM$$code|, CODE, READONLY, PIC
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:Proc
GET Hdr:System
GET Hdr:FSNumbers
GET Hdr:NewErrors
GET Hdr:BCMSupport
GET hdr.BCM2835
GET hdr.StaticWS
......@@ -138,6 +143,8 @@ lp1 ldr r3, [r0], #4 ; copy to workspace buffer
CMP r2, #0
MOVEQ r2, #1<<4
STR r2, ARM_DMAChannels
LDR r0, [r5, #virtgpio-tagb]
STR r0, VirtGPIOBuf
; copy out and construct machine ID from MAC address
ADRL r0, tagbuffer
......@@ -260,6 +267,11 @@ touchbuf DCD 0
DCD 2
DCD 3000000 ; Reset PL011 UART clock to default (Pi 3 has this set to 48MHz for BT, but currently we want to use it for plain serial)
DCD 0
DCD ARM2VC_Tag_GetVirtGPIOBuf
DCD 4
DCD 0
virtgpio DCD 0
DCD ARM2VC_Tag_End
tagslen * . - tagb
ASSERT tagslen <= ?tagbuffer
......
......@@ -73,6 +73,7 @@ BoardRevision_Manuf_Embest2 * 4 :SHL: 16
BoardRevision_Manuf_Mask * 15 :SHL: 16
BoardRevision_Proc_2835 * 0 :SHL: 12
BoardRevision_Proc_2836 * 1 :SHL: 12
BoardRevision_Proc_2837 * 2 :SHL: 12
BoardRevision_Proc_Mask * 15 :SHL: 12
BoardRevision_Model_A * 0 :SHL: 4
BoardRevision_Model_B * 1 :SHL: 4
......@@ -80,6 +81,8 @@ BoardRevision_Model_APlus * 2 :SHL: 4
BoardRevision_Model_BPlus * 3 :SHL: 4
BoardRevision_Model_B2 * 4 :SHL: 4
BoardRevision_Model_Compute * 6 :SHL: 4
BoardRevision_Model_B3 * 8 :SHL: 4
BoardRevision_Model_Zero * 9 :SHL: 4
BoardRevision_Model_Mask * 255 :SHL: 4
BoardRevision_Rev_Mask * 15 :SHL: 0
......@@ -396,6 +399,8 @@ SDIO_InitDevices ROUT
ADDEQ a1, a1, #SetActivity_Compute - SetActivity_AB
ADRL a2, GetCardDetect_AB
ADDHS a2, a2, #GetCardDetect_BPlus_Compute - GetCardDetect_AB
TEQ a3, #BoardRevision_Model_B3
ADREQL a1, SetActivity_B3
STR a1, SDHCIDevice + HALDevice_SDHCISetActivity
STR a2, SDHCIDevice + HALDevice_SDHCIGetCardDetect
......@@ -837,6 +842,31 @@ SetActivity_Compute ROUT
; No standard way of wiring up the activity LED on Compute
MOV pc, lr
SetActivity_B3 ROUT
Push "sb,lr"
SUB sb, a1, #:INDEX:SDHCIDevice
LDR a1, VirtGPIOBuf
CMP a1, #0
Pull "sb,pc",EQ
; The virtual GPIO buffer uses some funny counter system to track enable/disable state changes. If we don't follow its rules, it won't work.
LDR a2, [a1]
SXTH a4, a2, ROR #16 ; Enable count
SXTH a2, a2 ; Disable count
TEQ a3, #HALDeviceSDHCI_ActivityOff
BEQ %FT50
CMP a4, a2
Pull "sb,pc", GT ; Don't update if already on
ADD a4, a4, #1
B %FT90
50
CMP a4, a2
Pull "sb,pc", LE ; Don't update if already off
ADD a2, a2, #1
90
PKHBT a2, a2, a4, LSL #16
STR a2, [a1]
Pull "sb,pc"
GetCardDetect_AB ROUT
Push "sb,lr"
DoMemBarrier lr ; switch to GPIO peripheral
......
......@@ -37,6 +37,10 @@
GET Hdr:System
GET Hdr:Machine.<Machine>
GET Hdr:HALSize.<HALSize>
GET Hdr:FSNumbers
GET Hdr:NewErrors
GET Hdr:BCMSupport
$GetMEMM
GET Hdr:HALEntries
......@@ -585,9 +589,11 @@ HAL_Init
ADRL sb, workspace ; where we remembered it is
LDR a1, FB_CacheMode ; GPU cache mode
LDR a2, TouchBuf
LDR a3, VirtGPIOBuf
mov sb, a4
STR a1, FB_CacheMode
STR a2, TouchBuf
STR a3, VirtGPIOBuf
ADRL sb, workspace ; where we remembered it is
LDR a3, VC_Size
LDR a2, VC_Base
......@@ -624,6 +630,17 @@ HAL_Init
ORR a1, a1, a3
STR a1, NCNBPhysAddr
; Map in virtual GPIO buffer if present
LDR a2, VirtGPIOBuf
BICS a2, a2, #&C0000000
STREQ a2, VirtGPIOBuf
BEQ %FT10
MOV a1, #1:SHL:L1_TEXShift ; VMSA Normal, non-cacheable
MOV a3, #4096
CallOS OS_MapInIO
STR a1, VirtGPIOBuf
10
BL Interrupt_Init ; initialise our interrupts
BL Timer_Init
BL IIC_Init
......
......@@ -31,6 +31,10 @@
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:Proc
GET Hdr:System
GET Hdr:FSNumbers
GET Hdr:NewErrors
GET Hdr:BCMSupport
GET hdr.BCM2835
GET hdr.StaticWS
......
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