Commit df6c5057 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Refactor IIC calls to use RISCOS_IICOpV

Copy changes from OMAP3-0_90 to OMAP4.
Built, but not tested.

Version 0.23. Tagged as 'OMAP4-0_23'
parent 8ef181eb
/* (0.22)
/* (0.23)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.22
#define Module_MajorVersion_CMHG 0.23
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 30 Oct 2013
#define Module_Date_CMHG 01 Nov 2013
#define Module_MajorVersion "0.22"
#define Module_Version 22
#define Module_MajorVersion "0.23"
#define Module_Version 23
#define Module_MinorVersion ""
#define Module_Date "30 Oct 2013"
#define Module_Date "01 Nov 2013"
#define Module_ApplicationDate "30-Oct-13"
#define Module_ApplicationDate "01-Nov-13"
#define Module_ComponentName "OMAP4"
#define Module_ComponentPath "castle/RiscOS/Sources/HAL/OMAP4"
#define Module_FullVersion "0.22"
#define Module_HelpVersion "0.22 (30 Oct 2013)"
#define Module_LibraryVersionInfo "0:22"
#define Module_FullVersion "0.23"
#define Module_HelpVersion "0.23 (01 Nov 2013)"
#define Module_LibraryVersionInfo "0:23"
......@@ -24,10 +24,24 @@
GET hdr.SR44x
GET <Lib$Dir>.USB.hdr.usbhal
GET Hdr:SDHCIDevice
GET Hdr:RTCDevice
GET Hdr:GPIODevice
sb RN 9
MACRO
CallOS $entry, $tailcall
ASSERT $entry <= HighestOSEntry
[ "$tailcall"=""
MOV lr, pc
|
[ "$tailcall"<>"tailcall"
! 0, "Unrecognised parameter to CallOS"
]
]
LDR pc, OSentries + 4*$entry
MEND
; Per-SDHCI workspace
^ 0
......@@ -38,6 +52,13 @@ SDHCISize * :INDEX:@
MaxSDControllers * 2 ; I don't think any platform uses all 3 controllers?
; Per-RTC workspace
^ 0
RTCDevice # HALDevice_RTC_Size ; see Hdr:RTCDevice
RTCDeviceHAL_SB # 4 ; pointer to HAL workspace for HAL calls
RTCSize * :INDEX:@
^ 0,sb
BoardConfig # BoardConfig_Size
; NOTE: Almost all code assumes the board config is at the start. You have been warned!
......@@ -102,6 +123,7 @@ AudioWS # Audio_WorkspaceSize
CPUClkWS # SR44x_WorkspaceSize
GPIOWS # HALDevice_GPIO_Size
NVRAMWS # HALDeviceSize
RTCWS # RTCSize
SDIOWS # SDHCISize * MaxSDControllers
......
......@@ -46,13 +46,6 @@
IMPORT HAL_CounterDelay
IMPORT GPIOx_SetAsOutput
MACRO
CallOS $entry
ASSERT $entry <= HighestOSEntry
MOV lr, pc
LDR pc, OSentries + 4*$entry
MEND
; A brief rundown of OMAP4 HAL audio support:
; Audio in/out is typically provided via the TWL6040 companion chip.
; Two interfaces are used to link the audio subsystem to the OMAP: I2C is used to program the
......
......@@ -72,19 +72,6 @@ UseSR44x SETL {TRUE}
ADD pc, v8, ip
MEND
MACRO
CallOS $entry, $tailcall
ASSERT $entry <= HighestOSEntry
[ "$tailcall"=""
MOV lr, pc
|
[ "$tailcall"<>"tailcall"
! 0, "Unrecognised parameter to CallOS"
]
]
LDR pc, OSentries + 4*$entry
MEND
rom_checkedout_ok
; On entry, v8 -> OS entry table, sb -> board config
; Register the attached RAM
......
......@@ -35,12 +35,7 @@
EXPORT RTC_Init
IMPORT TPSRead
IMPORT TPSWrite
; Note - debug stuff won't work since we don't get passed a HAL workspace pointer!
; IMPORT DebugHALPrint
; IMPORT DebugHALPrintReg
; IMPORT DebugMemDump
; IMPORT DebugHALPrintByte
IMPORT memcpy
; TWL6030 RTC IIC address
TPSRTC_IIC * &48
......@@ -68,27 +63,21 @@ RTC_STATUS_1D_EVENT_M * (1 << 5)
RTC_STATUS_ALARM_M * (1 << 6)
RTC_STATUS_POWER_UP_M * (1 << 7)
MACRO
CallOS $entry, $tailcall
ASSERT $entry <= HighestOSEntry
[ "$tailcall"=""
MOV lr, pc
|
[ "$tailcall"<>"tailcall"
! 0, "Unrecognised parameter to CallOS"
]
]
LDR pc, OSentries + 4*$entry
MEND
RTC_Init
; Just register our HAL Device with the OS
ADRL a1, RTCWS
ADR a2, RTCDeviceTemplate
MOV a3, #RTCSize
Push "lr"
BL memcpy
Pull "lr"
STR sb, [a1, #RTCDeviceHAL_SB]
MOV a1, #0
ADR a2, RTCDevice
CallOS OS_AddDevice, tailcall
RTCDevice
RTCDeviceTemplate
DCW HALDeviceType_SysPeri + HALDeviceSysPeri_RTC
DCW HALDeviceID_RTC_TWL6030
DCD HALDeviceBus_Ser + HALDeviceSerBus_IIC
......@@ -104,13 +93,16 @@ RTCDevice
DCD 0
% 8
DCB RTCTimeFormat_BCD
DCB RTCFormatFlags_BCD_1BasedDay+RTCFormatFlags_BCD_1BasedMonth+RTCFormatFlags_BCD_YearLOIsGood ; todo - add RTCFormatFlags_BCD_NeedsYearHelp once NVRAM is implemented
DCB RTCFormatFlags_BCD_1BasedDay + \
RTCFormatFlags_BCD_1BasedMonth + \
RTCFormatFlags_BCD_YearLOIsGood + \
RTCFormatFlags_BCD_NeedsYearHelp
% 2
DCD RTCReadTime
DCD RTCWriteTime
RTCDesc
DCB "TWL6030-compatible real-time clock",0
DCB "TWL6030-compatible real-time clock",0
ALIGN
......@@ -128,14 +120,12 @@ RTCReadTime
; In:
; a1 = HALDevice ptr
; a2 = RTCTimeStruct ptr
; a3 = IICOp func ptr
; a4 = kernel workspace ptr
; Out:
; a1 = return code
; RTCTimeStruct updated
Push "v1-v3,lr"
MOV v1, a3
MOV v2, a4
Push "v1,v3,sb,lr"
LDR sb, [a1, #RTCDeviceHAL_SB]
LDR v1, OSentries+4*OS_IICOpV ; for TPSRead/TPSWrite
MOV v3, a2
; Reading the time safely involves several transfers:
; 1. Read RTC_STATUS_REG. If bit 1 is clear, the RTC is stopped and we can just
......@@ -158,7 +148,7 @@ RTCReadTime
EOR ip, ip, #RTC_STATUS_RUN_M
TSTEQ ip, #RTC_STATUS_RUN_M
ADDNE sp, sp, #4
Pull "v1-v3,pc", NE
Pull "v1,v3,sb,pc", NE
MOV ip, #(RTC_CTRL_GET_TIME_M + RTC_CTRL_STOP_RTC_M)
STR ip, [a2]
MOV a1, #TPSRTC_IIC*2
......@@ -167,7 +157,7 @@ RTCReadTime
CMP a1, #IICStatus_Completed
MOVNE a1, #RTCRetCode_Error
ADD sp, sp, #4
Pull "v1-v3,pc", NE
Pull "v1,v3,sb,pc", NE
MOV a1, #TPSRTC_IIC*2
; We can read the time directly into the RTCTimeStruct buffer
ASSERT RTCTimeStruct_BCD_Minutes=RTCTimeStruct_BCD_Seconds+1
......@@ -181,32 +171,21 @@ RTCReadTime
BL TPSRead
CMP a1, #IICStatus_Completed
MOVNE a1, #RTCRetCode_Error
Pull "v1-v3,pc", NE
ASSERT IICStatus_Completed = 0
STRB a1, [v3, #RTCTimeStruct_BCD_Centiseconds] ; No centisecond time
; Construct a fakey YearHI by looking at YearLO
; Anything 70 or above is considered 1970+, else 2000+
; This should work OK, since RISC OS clamps the time to 1970 for unix compatability
; (or it does on boot, at least)
LDRB a2, [v3, #RTCTimeStruct_BCD_YearLO]
CMP a2, #&70
MOVGE a3, #&19
MOVLT a3, #&20
STRB a3, [v3, #RTCTimeStruct_BCD_YearHI]
STREQB a1, [v3, #RTCTimeStruct_BCD_Centiseconds] ; No centisecond time
STREQB a1, [v3, #RTCTimeStruct_BCD_YearHI] ; Kernel gives year help
ASSERT RTCRetCode_OK = 0
Pull "v1-v3,pc"
Pull "v1,v3,sb,pc"
RTCWriteTime
; In:
; a1 = HALDevice ptr
; a2 = RTCTimeStruct ptr
; a3 = IICOp func ptr
; a4 = kernel workspace ptr
; Out:
; a1 = return code
Push "v1-v3,lr"
MOV v1, a3
MOV v2, a4
Push "v1,v3,sb,lr"
LDR sb, [a1, #RTCDeviceHAL_SB]
LDR v1, OSentries+4*OS_IICOpV ; for TPSRead/TPSWrite
MOV v3, a2
; Writing the time safely involves several transfers:
; 1. Write 0 to RTC_CTRL_REG to stop the clock (just in case there are any issues with
......@@ -223,7 +202,7 @@ RTCWriteTime
CMP a1, #IICStatus_Completed
MOVNE a1, #RTCRetCode_Error
ADDNE sp, sp, #4
Pull "v1-v3,pc", NE
Pull "v1,v3,sb,pc", NE
MOV a1, #TPSRTC_IIC*2
; We can write the time directly from the RTCTimeStruct buffer
ASSERT RTCTimeStruct_BCD_Minutes=RTCTimeStruct_BCD_Seconds+1
......@@ -249,7 +228,7 @@ RTCWriteTime
CMP a1, #IICStatus_Completed
MOVNE a1, #RTCRetCode_Error
ADDNE sp, sp, #4
Pull "v1-v3,pc", NE
Pull "v1,v3,sb,pc", NE
01
MOV a3, #RTC_CTRL_STOP_RTC_M
STR a3, [sp]
......@@ -261,7 +240,6 @@ RTCWriteTime
ASSERT RTCRetCode_OK = IICStatus_Completed
MOVNE a1, #RTCRetCode_Error
ADD sp, sp, #4
Pull "v1-v3,pc"
Pull "v1,v3,sb,pc"
END
......@@ -41,13 +41,6 @@
IMPORT HAL_FIQClear
IMPORT HAL_CounterDelay
MACRO
CallOS $entry
ASSERT $entry <= HighestOSEntry
MOV lr, pc
LDR pc, OSentries + 4*$entry
MEND
; Flag to enable gobs of debug output
GBLL SDMADebug
SDMADebug SETL {FALSE}
......
......@@ -42,20 +42,6 @@
IMPORT TPSWrite
IMPORT IIC_DoOp_Poll
MACRO
CallOS $entry, $tailcall
ASSERT $entry <= HighestOSEntry
[ "$tailcall"=""
MOV lr, pc
|
[ "$tailcall"<>"tailcall"
! 0, "Unrecognised parameter to CallOS"
]
]
LDR pc, OSentries + 4*$entry
MEND
; some definitions related to TWL630 power control
TWL6030_ADDR_ID0 * (0x12) ; ID0 group (SmartReflex only)
TWL6030_ADDR_ID1 * (0x48 << 1) ; ID1 group
......
......@@ -57,13 +57,6 @@
IMPORT GPIOx_SetAsOutput
IMPORT GPIOx_SetOutput
MACRO
CallOS $entry
ASSERT $entry <= HighestOSEntry
MOV lr, pc
LDR pc, OSentries + 4*$entry
MEND
; A brief rundown of OMAP4430 video output modes:
; The display subsystem (DSS) provides the logic to display a video frame from the
; memory frame buffer on a LCD panel or a TV set.
......
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