Jump to content

Patch for O2 Micro SD card readers


joe82

Recommended Posts

My E7440 has an SD card reader. With some  relative minor patches, I was able to get the Apple AppleSDXC.kext driver to load and work. Here are the details.
 
The SD card reader in my E7440 uses an O2 micro part. Here is the lspci output:

03:00.0 SD Host controller: O2 Micro, Inc. Unknown device 8520 (rev 01)

The driver matches on IOName, which has a default value of pci14e4,16bc.
This needs to change. First I patched the binary driver AppleSDXC with the following perl script.

perl -pi -e 's|pci14e4,16bc|pci1217,8520|g' AppleSDXC

Next you need to modify the following section of Info.plist from:

<key>IONameMatch</key>
<array>
        <string>pci14e4,16bc</string>
</array>

to

<key>IONameMatch</key>
<array>
        <string>pci1217,8520</string>
        <string>pci14e4,16bc</string>
</array>

I added the correct value for the O2 Micro part: pci1217,8520. You most like only need to replace the old line with the new one, but I added it. Lastly I modified the RP05.PXSX device to match the Apple device SDXC. My modified PXSX function now looks like this:

Device (SDXC)
{
        Name (_ADR, Zero)  // _ADR: Address
        Method (_PRW, 0, NotSerialized)  // _PRW: Power Resources for Wake
        {
                Return (GPRW (0x69, 0x04))
        }
        Method (_RMV, 0, NotSerialized)
        {
                Return (0x00)
        }
}

I doubt this last step is necessary, but I like to match the Apple names when possible. After you make the changes, regenerate the cache and reboot.
 
I have tried this change with 10.9.1, 10.9.2, 10.9.3 and 10.9.4 and they all work. I have not had a chance to try 10.9.5, but it should work.
 
I will attach the modified files from 10.9.1 as a reference.
 
Joe

SDXC_10P9P1.tar.gz

  • Like 3
Link to comment
Share on other sites

  • Moderators

I use this patch for E7440/E7240, no need to patch kext anymore

into device label PXSX parent_label RP05 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package (0x08)\n
    {\n
        "AAPL,slot-name",\n 
        "Built-in",\n
        "device_type",\n 
        Buffer (0x11)\n
        {\n
              "Media controller"\n
         },\n

         "model",\n 
        Buffer (0x18)\n
         {\n
             "O2 Micro SD card reader"\n
         },\n
                                
        "compatible",\n
         Buffer (0x0D)\n
        {\n
            "pci14e4,16bc"\n
        }\n
                            
     }, Local0)\n
    DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
    Return (Local0)\n
}\n 
end;
  • Like 1
Link to comment
Share on other sites

  • Moderators

This one works too

#Patch for O2Micro SD Card Reader
into device label PXSX parent_label RP05 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
    If (LEqual (Arg2, Zero)) { Return (Buffer() { 0x03 } ) }\n
    Return (Package()\n
    {\n
        "AAPL,slot-name",\n
        "Built-in",\n
        "device-type", Buffer() { "Media Controller" },\n
        "model", Buffer() { "O2 Micro SD Card Reader" },\n
        "compatible", Buffer() { "pci14e4,16bc" },\n
    })\n
}\n
end;
Link to comment
Share on other sites

  • Administrators

This patch applies to PCIe SD card readers only, not USB readers. It's known to work with several O2 Micro devices but may not work with all of them. It does not appear to work with non-O2 Micro devices (Ricoh or Realtek for instance).
 
To patch your DSDT, use the following process:
 
1) Using IORegistryExplorer, identify your DSDT device (pay good attention to displayed PCI vendor and device ids). The device will differ from one system to another.
2) Open up your DSDT with MacIASL
3) look for your SD card device identified in step #1 (for instance: device PXSX under RP05)
4) paste the following code under the _ADR and _PWR sections:

                   Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method
                   {
                        If (LEqual (Arg2, Zero))
                        {
                            Return (Buffer (One)
                            {
                                 0x03                                           
                            })
                        }
                        Return (Package ()
                        {
                            "AAPL,slot-name",                     // Optional
                            Buffer (0x09)                         // Optional
                            {                                     // Optional
                                "Built-in"                        // Optional
                            },                                    // Optional
                            "device_type",                        // Optional
                            Buffer (0x11)                         // Optional
                            {                                     // Optional
                                "Media Controller"                // Optional
                            },                                    // Optional
                            "model",                              // Optional
                            Buffer ()                             // Optional
                            {                                     // Optional
                                "<specify your model here>"       // Optional
                            },                                    // Optional
                            "compatible", 
                            Buffer (0x0D)
                            {
                                "pci14e4,16bc"
                            }
                        })
                    }

5) Recompile your DSDT and replace your initial table.
 
Below is an example for the Latitude E6230 (with original DSDT device "PXSX" renamed to "SDXC"):

 

               Device (SDXC)                    // Renamed from PXSX to SDXC as per Apple convention
               {
                    Name (_ADR, Zero)           // _ADR: Address
                    Name (_PRW, Package (0x02)  // _PRW: Power Resources for Wake
                    {
                        0x09, 
                        0x04
                    })
                    Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method
                    {
                        If (LEqual (Arg2, Zero))
                        {
                            Return (Buffer (One)
                            {
                                 0x03                                           
                            })
                        }

                        Return (Package (0x08)
                        {
                            "AAPL,slot-name", 
                            Buffer (0x09)
                            {
                                "Built-in"
                            }, 
                            "device_type", 
                            Buffer (0x11)
                            {
                                "Media Controller"
                            }, 
                            "model", 
                            Buffer (0x18)
                            {
                                "O2 Micro SD Card Reader"
                            }, 
                            "compatible", 
                            Buffer (0x0D)
                            {
                                "pci14e4,16bc"
                            }
                        })
                    }
                }

                Method (HPME, 0, Serialized)
                {
                    If (PMSX)
                    {
                        Store (0xC8, Local0)
                        While (Local0)
                        {
                            Store (One, PMSX)
                            If (PMSX)
                            {
                                Decrement (Local0)
                            }
                            Else
                            {
                                Store (Zero, Local0)
                            }
                        }
                        Notify (SDXC, 0x02)                    // PXSX renamed to SDXC
                    }
                }

                Method (_PRT, 0, NotSerialized)  // _PRT: PCI Routing Table
                {
                    If (PICM)
                    {
                        Return (AR09 ())
                    }
                    Return (PR09 ())
                }
          }

 

 

Link to comment
Share on other sites

  • Administrators

Last updated: 16 Mar 2019

 

O2 Micro SD card readers known to work with above DSDT patch (non-exhaustive list):

  • 1217:8221 (fitted to Latitude E5x20/E6x20, E5x30/E6x30)
  • 1217:8231 (fitted to Latitude E5x20/E6x20, E5x30/E6x30)
  • 1217:8520 (fitted to Latitude E5x40/E6x40/E7x40, E5x50/E7x50, Precision M6800)
  • 1217:8621 (fitted to Lenovo Y520/Y720/E470/L560)

 

Ricoh SD card readers understood to work with above DSDT patch (non-exhaustive list) - /!\ unconfirmed info /!\:

  • 1180:e822 (fitted to ThinkPad T430, Latitude E6x10)
  • 1180:e823 (fitted to ThinkPad T420/T430)

 

To be updated as more info comes along...

Link to comment
Share on other sites

  • Moderators

No need to patch the kext or DSDT. Add Arbitrary under Devices in Config file. You just need to determine the PCIAddr by looking at the IOReg file under RPxx/PXSX, search for pcidebug.

In this example it's RP01/PXSX@0, pcidebug = 01:00:00

 

sdcard2.png

 

You can also use dspci (app attached below) to find the address

sdCard.png

Change the PCIAddr accordingly

Spoiler

 


     <key>Arbitrary</key>
		<array>
			<dict>
				<key>Comment</key>
				<string>SDXC reader - RP01</string>
				<key>CustomProperties</key>
				<array>
					<dict>
						<key>Disabled</key>
						<false/>
						<key>Key</key>
						<string>device_type</string>
						<key>Value</key>
						<string>Media controller</string>
					</dict>
					<dict>
						<key>Disabled</key>
						<false/>
						<key>Key</key>
						<string>model</string>
						<key>Value</key>
						<string>O2 Micro SD card reader</string>
					</dict>
					<dict>
						<key>Disabled</key>
						<false/>
						<key>Key</key>
						<string>name</string>
						<key>Value</key>
						<string>SD/MMC Card Reader</string>
					</dict>
					<dict>
						<key>Disabled</key>
						<false/>
						<key>Key</key>
						<string>compatible</string>
						<key>Value</key>
						<string>pci14e4,16bc</string>
					</dict>
					<dict>
						<key>Disabled</key>
						<false/>
						<key>Key</key>
						<string>subsystem-vendor-id</string>
						<key>Value</key>
						<data>
						axAAAA==
						</data>
					</dict>
				</array>
				<key>PciAddr</key>
				<string>01:00:00</string>
			</dict>
		</array>

 

 

 

 

If the card reader is not on this list, it might not be supported by this patch

dspci.zip

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

  • Administrators

Modernising this fairly old thread to update it for property injection with our beloved Clover/OpenCore bootloaders. As stated in the posts above, the alternative to DSDT patching (deprecated today), patched SSDT and/or kext patching (totally deprecated today and most difficult since Big Sur) is to simply inject the properties detailed above in the bootloader's config:

  1. identify card reader's location (with say IORegistryExplorer or bootloader's device detection)
  2. inject the compatible property as bare minimum, the rest being entirely optional and cosmetic

Device:

PciRoot(0x0,0x0)/Pci(0x--,0x--)[/Pci(0x--,0x--)] -> 3rd location may not be applicable

Property:

compatible        pci14e4,16bc                    STRING     -> mandatory
AAPL,slot-name    <specify your PCI slot here>    STRING     -> optional/cosmetic
device_type       <specify the device type here>  STRING     -> optional/cosmetic
name              <specify a device name here>    STRING     -> optional/cosmtic
model             <specify the model ref. here>   STRING     -> optional/cosmetic

 

Clover example; under Devices section:

O2_Micro_Property_Injection.jpg

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...