Skip to content

Commit

Permalink
Add support for ACPI based SDIO controllers (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zormeister authored Jan 17, 2024
1 parent de0d4b0 commit 7a05350
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
17 changes: 9 additions & 8 deletions EmeraldSDHC/EmeraldSDHC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ bool EmeraldSDHC::start(IOService *provider) {

do {
//
// Get IOPCIDevice provider.
// Get IOPCIDevice or IOACPIPlatformDevice provider.
//
_pciDevice = OSDynamicCast(IOPCIDevice, provider);
if (_pciDevice == nullptr) {
EMSYSLOG("Provider is not IOPCIDevice");
if (!OSDynamicCast(IOACPIPlatformDevice, provider) && !OSDynamicCast(IOPCIDevice, provider)) {
EMSYSLOG("Provider is not IOPCIDevice or IOACPIPlatformDevice");
break;
}
_pciDevice->retain();
_device = provider;
_device->retain();

//
// Create work loop and interrupt source.
Expand Down Expand Up @@ -81,7 +81,8 @@ void EmeraldSDHC::stop(IOService *provider) {
}

OSSafeReleaseNULL(_workLoop);
OSSafeReleaseNULL(_pciDevice);
IOPCIDevice *pciDevice = OSDynamicCast(IOPCIDevice, _device);
OSSafeReleaseNULL(pciDevice);
}

IOWorkLoop* EmeraldSDHC::getWorkLoop() const {
Expand All @@ -106,7 +107,7 @@ bool EmeraldSDHC::probeCardSlots() {
// Get number of active card slots.
// Each card slot will have exactly one BAR on the PCI device, for a maximum of 6.
//
_cardSlotCount = _pciDevice->getDeviceMemoryCount();
_cardSlotCount = _device->getDeviceMemoryCount();
if (_cardSlotCount > kSDHCMaximumSlotCount) {
EMSYSLOG("More than %u card slots are present, limiting to %u", kSDHCMaximumSlotCount, kSDHCMaximumSlotCount);
_cardSlotCount = kSDHCMaximumSlotCount;
Expand All @@ -132,7 +133,7 @@ bool EmeraldSDHC::probeCardSlots() {
//
// Map memory for card slot.
//
_cardSlotMemoryMaps[slot] = _pciDevice->mapDeviceMemoryWithIndex(slot);
_cardSlotMemoryMaps[slot] = _device->mapDeviceMemoryWithIndex(slot);
if (_cardSlotMemoryMaps[slot] == nullptr) {
EMSYSLOG("Failed to get memory map for card slot %u", slot + 1);
return false;
Expand Down
3 changes: 2 additions & 1 deletion EmeraldSDHC/EmeraldSDHC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <IOKit/IOInterruptEventSource.h>
#include <IOKit/IOService.h>
#include <IOKit/pci/IOPCIDevice.h>
#include <IOKit/acpi/IOACPIPlatformDevice.h>

#include "SDMisc.hpp"
#include "SDRegs.hpp"
Expand All @@ -25,7 +26,7 @@ class EmeraldSDHC : public IOService {
typedef IOService super;

private:
IOPCIDevice *_pciDevice = nullptr;
IOService *_device = nullptr;
IOWorkLoop *_workLoop = nullptr;
IOInterruptEventSource *_intEventSource = nullptr;

Expand Down
22 changes: 22 additions & 0 deletions EmeraldSDHC/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,35 @@
<key>IOProviderClass</key>
<string>EmeraldSDHCSlot</string>
</dict>
<key>EmeraldSDHC ACPI</key>
<dict>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>IOClass</key>
<string>EmeraldSDHC</string>
<key>IONameMatch</key>
<string>PNP0D40</string>
<key>IOProbeScore</key>
<integer>1000</integer>
<key>IOProviderClass</key>
<string>IOACPIPlatformDevice</string>
<key>Protocol Characteristics</key>
<dict>
<key>Physical Interconnect</key>
<string>Secure Digital</string>
<key>Physical Interconnect Location</key>
<string>Internal</string>
</dict>
</dict>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021-2023 Goldfish64. All rights reserved.</string>
<key>OSBundleCompatibleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>OSBundleLibraries</key>
<dict>
<key>com.apple.iokit.IOACPIFamily</key>
<string>1.0</string>
<key>com.apple.iokit.IOPCIFamily</key>
<string>1.0</string>
<key>com.apple.iokit.IOStorageFamily</key>
Expand Down

0 comments on commit 7a05350

Please sign in to comment.