sdhci: detect Ricoh SDHCI controllers

They don't advertise themselves as standard SDHCI, but are mostly
compatible. Only check for the one in my machine for now.

Also improve tracing in the probe function.

Change-Id: Ia47238fb25b783790fa8caaedf2a71aeb6e29d89
Reviewed-on: https://review.haiku-os.org/c/haiku/+/806
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Adrien Destugues 2018-12-23 11:33:10 +01:00 committed by waddlesplash
parent 62eaf4c0e1
commit 47bf2e3878
2 changed files with 36 additions and 7 deletions

View File

@ -616,22 +616,45 @@ supports_device(device_node* parent)
const char* bus;
uint16 type, subType;
uint8 pciSubDeviceId;
uint16 vendorId, deviceId;
// make sure parent is a PCI SDHCI device node
if (gDeviceManager->get_attr_string(parent, B_DEVICE_BUS, &bus, false)
!= B_OK || gDeviceManager->get_attr_uint16(parent, B_DEVICE_SUB_TYPE,
&subType, false) < B_OK || gDeviceManager->get_attr_uint16(parent,
B_DEVICE_TYPE, &type, false) < B_OK) {
ERROR("Could not find required attribute device/bus\n");
!= B_OK) {
TRACE("Could not find required attribute device/bus\n");
return -1;
}
if (strcmp(bus, "pci") != 0)
return 0.0f;
if (gDeviceManager->get_attr_uint16(parent, B_DEVICE_VENDOR_ID, &vendorId,
false) != B_OK
|| gDeviceManager->get_attr_uint16(parent, B_DEVICE_ID, &deviceId,
false) != B_OK) {
TRACE("No vendor or device id attribute\n");
return 0.0f;
}
TRACE("Probe device %p (%04x:%04x)\n", parent, vendorId, deviceId);
if (gDeviceManager->get_attr_uint16(parent, B_DEVICE_SUB_TYPE, &subType,
false) < B_OK
|| gDeviceManager->get_attr_uint16(parent, B_DEVICE_TYPE, &type,
false) < B_OK) {
TRACE("Could not find type/subtype attributes\n");
return -1;
}
if (type == PCI_base_peripheral) {
if (subType != PCI_sd_host)
return 0.0f;
if (subType != PCI_sd_host) {
// Also accept some compliant devices that do not advertise
// themselves as such.
if (vendorId != 0x1180 && deviceId != 0xe823) {
TRACE("Not the right subclass, and not a Ricoh device\n");
return 0.0f;
}
}
pci_device_module_info* pci;
pci_device* device;

View File

@ -1661,6 +1661,10 @@ device_node::_GetNextDriverPath(void*& cookie, KPath& _path)
case PCI_sd_host:
_AddPath(*stack, "busses", "mmc");
break;
case PCI_system_peripheral_other:
_AddPath(*stack, "busses", "mmc");
_AddPath(*stack, "drivers");
break;
default:
_AddPath(*stack, "drivers");
break;
@ -1964,7 +1968,9 @@ device_node::Probe(const char* devicePath, uint32 updateCycle)
// TODO: maybe make this extendible via settings file?
if (!strcmp(devicePath, "disk")) {
matches = type == PCI_mass_storage
|| (type == PCI_base_peripheral && subType == PCI_sd_host);
|| (type == PCI_base_peripheral
&& (subType == PCI_sd_host
|| subType == PCI_system_peripheral_other));
} else if (!strcmp(devicePath, "audio")) {
matches = type == PCI_multimedia
&& (subType == PCI_audio || subType == PCI_hd_audio);