From d7ed9fea9169d9f5ae1baba56c0e7294862f98a5 Mon Sep 17 00:00:00 2001
From: Jeffrey Lee <jlee@gitlab.riscosopen.org>
Date: Thu, 21 Feb 2013 20:20:02 +0000
Subject: [PATCH] Disable SD card write protect sensing on Pandora

Detail:
  s/SDIO - Disabled SD write protect sensing on Pandora, as hardware faults can result in some units always reporting that cards are protected
Admin:
  Tested briefly on Pandora, write-protected cards can be written to
  Should fix issue reported on forums with unprotected cards being reported as read-only:
  http://www.riscosopen.org/forum/forums/5/topics/166?page=18#posts-19848


Version 0.86. Tagged as 'OMAP3-0_86'
---
 VersionASM | 12 ++++++------
 VersionNum | 20 ++++++++++----------
 s/SDIO     | 15 +++++++++++++++
 3 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/VersionASM b/VersionASM
index 1693b5d..88b9812 100644
--- a/VersionASM
+++ b/VersionASM
@@ -11,13 +11,13 @@
                         GBLS    Module_HelpVersion
                         GBLS    Module_ComponentName
                         GBLS    Module_ComponentPath
-Module_MajorVersion     SETS    "0.85"
-Module_Version          SETA    85
+Module_MajorVersion     SETS    "0.86"
+Module_Version          SETA    86
 Module_MinorVersion     SETS    ""
-Module_Date             SETS    "22 Jan 2013"
-Module_ApplicationDate  SETS    "22-Jan-13"
+Module_Date             SETS    "21 Feb 2013"
+Module_ApplicationDate  SETS    "21-Feb-13"
 Module_ComponentName    SETS    "OMAP3"
 Module_ComponentPath    SETS    "castle/RiscOS/Sources/HAL/OMAP3"
-Module_FullVersion      SETS    "0.85"
-Module_HelpVersion      SETS    "0.85 (22 Jan 2013)"
+Module_FullVersion      SETS    "0.86"
+Module_HelpVersion      SETS    "0.86 (21 Feb 2013)"
                         END
diff --git a/VersionNum b/VersionNum
index 6820462..f9e54b6 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,23 +1,23 @@
-/* (0.85)
+/* (0.86)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  * Last processed by srccommit version: 1.1.
  *
  */
-#define Module_MajorVersion_CMHG        0.85
+#define Module_MajorVersion_CMHG        0.86
 #define Module_MinorVersion_CMHG        
-#define Module_Date_CMHG                22 Jan 2013
+#define Module_Date_CMHG                21 Feb 2013
 
-#define Module_MajorVersion             "0.85"
-#define Module_Version                  85
+#define Module_MajorVersion             "0.86"
+#define Module_Version                  86
 #define Module_MinorVersion             ""
-#define Module_Date                     "22 Jan 2013"
+#define Module_Date                     "21 Feb 2013"
 
-#define Module_ApplicationDate          "22-Jan-13"
+#define Module_ApplicationDate          "21-Feb-13"
 
 #define Module_ComponentName            "OMAP3"
 #define Module_ComponentPath            "castle/RiscOS/Sources/HAL/OMAP3"
 
-#define Module_FullVersion              "0.85"
-#define Module_HelpVersion              "0.85 (22 Jan 2013)"
-#define Module_LibraryVersionInfo       "0:85"
+#define Module_FullVersion              "0.86"
+#define Module_HelpVersion              "0.86 (21 Feb 2013)"
+#define Module_LibraryVersionInfo       "0:86"
diff --git a/s/SDIO b/s/SDIO
index 2bda529..82fb888 100644
--- a/s/SDIO
+++ b/s/SDIO
@@ -41,6 +41,13 @@
         GET     hdr.GPIO
         GET     hdr.StaticWS
 
+        ; The Pandora developers have stated that the write protect circuitry
+        ; isn't very reliable, for this reason it's recommended to ignore it
+        ; (as per the official Linux distro)
+        ; http://www.riscosopen.org/forum/forums/5/topics/166?page=18#posts-19848
+        GBLL    EnablePandoraWriteProtect
+EnablePandoraWriteProtect SETL {FALSE}
+
 sb      RN      9
 
 ; Timings
@@ -437,8 +444,10 @@ InitDevice ROUT
         TEQNE   a2, #GPIORevision_BeagleBoard_C4
         TEQEQ   a1, #GPIOType_OMAP3_BeagleBoard
         ADREQL  lr, GetWriteProtect_BeagleboardRevC
+      [ EnablePandoraWriteProtect
         TEQ     a1, #GPIOType_OMAP3_Pandora
         ADREQL  lr, GetWriteProtect_Pandora_MMC1
+      ]
         STR     lr, [a4, #HALDevice_SDHCIGetWriteProtect]
 
         ; SlotInfo_Flags
@@ -487,7 +496,11 @@ InitDevice ROUT
         STR     lr, [a4, #HALDevice_SDHCIGetCardDetect]
 
         ; GetWriteProtect
+      [ EnablePandoraWriteProtect
         ADRL    lr, GetWriteProtect_Pandora_MMC2
+      |
+        ADRL    lr, GetWriteProtect_Unimplemented
+      ]
         STR     lr, [a4, #HALDevice_SDHCIGetWriteProtect]
 
         ; SlotInfo_Flags
@@ -1171,6 +1184,7 @@ GetWriteProtect_BeagleboardRevC ROUT
         MOVNE   a1, #1
         Pull    "sb,pc"
 
+ [ EnablePandoraWriteProtect
 GetWriteProtect_Pandora_MMC1 ROUT
         Push    "sb,lr"
         LDR     sb, [a1, #SDHCISB]
@@ -1190,6 +1204,7 @@ GetWriteProtect_Pandora_MMC2 ROUT
         TEQ     a1, #0
         MOVNE   a1, #1
         Pull    "sb,pc"
+ ]
 
 GetWriteProtect_Unimplemented ROUT ; because it's a microSD slot
         MOV     a1, #0 ; permit writes
-- 
GitLab