sdhci: cleanup, no functional changes.
Change-Id: Ie9b85e9a527b125db2f95ef9ee046daea20f7894 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9681 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
f6195731ea
commit
51a2c5498c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2024 Haiku, Inc. All rights reserved.
|
||||
* Copyright 2018-2025 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -35,15 +35,12 @@
|
||||
|
||||
|
||||
#define SDHCI_DEVICE_MODULE_NAME "busses/mmc/sdhci/driver_v1"
|
||||
#define SDHCI_ACPI_MMC_BUS_MODULE_NAME "busses/mmc/sdhci/acpi/device/v1"
|
||||
#define SDHCI_PCI_MMC_BUS_MODULE_NAME "busses/mmc/sdhci/pci/device/v1"
|
||||
|
||||
#define SLOT_NUMBER "device/slot"
|
||||
#define BAR_INDEX "device/bar"
|
||||
|
||||
device_manager_info* gDeviceManager;
|
||||
device_module_info* gMMCBusController;
|
||||
|
||||
|
||||
static int32
|
||||
sdhci_generic_interrupt(void* data)
|
||||
{
|
||||
@@ -617,6 +614,7 @@ SdhciBus::HandleInterrupt()
|
||||
return B_HANDLED_INTERRUPT;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
SdhciBus::_WorkerThread(void* cookie) {
|
||||
SdhciBus* bus = (SdhciBus*)cookie;
|
||||
@@ -638,8 +636,10 @@ SdhciBus::_WorkerThread(void* cookie) {
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
void
|
||||
uninit_bus(void* bus_cookie)
|
||||
{
|
||||
@@ -656,6 +656,7 @@ bus_removed(void* bus_cookie)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
register_child_devices(void* cookie)
|
||||
{
|
||||
@@ -680,6 +681,7 @@ register_child_devices(void* cookie)
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
init_device(device_node* node, void** device_cookie)
|
||||
{
|
||||
@@ -706,6 +708,7 @@ init_device(device_node* node, void** device_cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
uninit_device(void* device_cookie)
|
||||
{
|
||||
@@ -738,6 +741,7 @@ register_device(device_node* parent)
|
||||
attrs, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
static float
|
||||
supports_device(device_node* parent)
|
||||
{
|
||||
@@ -807,6 +811,7 @@ set_bus_width(void* controller, int width)
|
||||
return bus->SetBusWidth(width);
|
||||
}
|
||||
|
||||
|
||||
// Root device that binds to the ACPI or PCI bus. It will register an mmc_bus_interface
|
||||
// node for each SD slot in the device.
|
||||
static driver_module_info sSDHCIDevice = {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright 2018-2024 Haiku, Inc. All rights reserved.
|
||||
* Copyright 2018-2025 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* B Krishnan Iyer, [email protected]
|
||||
* Adrien Destugues, [email protected]
|
||||
* Ron Ben Aroya, [email protected]
|
||||
*/
|
||||
#ifndef _SDHCI_H
|
||||
@@ -11,61 +12,48 @@
|
||||
|
||||
|
||||
#include <device_manager.h>
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
|
||||
#define SDHCI_PCI_SLOT_INFO 0x40
|
||||
#define SDHCI_PCI_SLOTS(x) ((((x) >> 4) & 0x7) + 1)
|
||||
#define SDHCI_PCI_SLOT_INFO_FIRST_BASE_INDEX(x) ((x) & 0x7)
|
||||
|
||||
// Ricoh specific PCI registers
|
||||
// Ricoh devices start in a vendor-specific mode but can be switched
|
||||
// to standard sdhci using these PCI registers
|
||||
#define SDHCI_PCI_RICOH_MODE_KEY 0xf9
|
||||
#define SDHCI_PCI_RICOH_MODE 0x150
|
||||
#define SDHCI_PCI_RICOH_MODE_SD20 0x10
|
||||
|
||||
#define SDHCI_BUS_TYPE_NAME "bus/sdhci/v1"
|
||||
|
||||
|
||||
class SdhciBus {
|
||||
public:
|
||||
SdhciBus(struct registers* registers, uint8_t irq, bool poll);
|
||||
~SdhciBus();
|
||||
SdhciBus(struct registers* registers, uint8_t irq, bool poll);
|
||||
~SdhciBus();
|
||||
|
||||
void EnableInterrupts(uint32_t mask);
|
||||
void DisableInterrupts();
|
||||
status_t ExecuteCommand(uint8_t command, uint32_t argument,
|
||||
uint32_t* response);
|
||||
int32 HandleInterrupt();
|
||||
status_t InitCheck();
|
||||
void Reset();
|
||||
void SetClock(int kilohertz);
|
||||
status_t DoIO(uint8_t command, IOOperation* operation,
|
||||
bool offsetAsSectors);
|
||||
void SetScanSemaphore(sem_id sem);
|
||||
void SetBusWidth(int width);
|
||||
void EnableInterrupts(uint32_t mask);
|
||||
void DisableInterrupts();
|
||||
status_t ExecuteCommand(uint8_t command, uint32_t argument,
|
||||
uint32_t* response);
|
||||
int32 HandleInterrupt();
|
||||
status_t InitCheck();
|
||||
void Reset();
|
||||
void SetClock(int kilohertz);
|
||||
status_t DoIO(uint8_t command, IOOperation* operation,
|
||||
bool offsetAsSectors);
|
||||
void SetScanSemaphore(sem_id sem);
|
||||
void SetBusWidth(int width);
|
||||
|
||||
private:
|
||||
bool PowerOn();
|
||||
void RecoverError();
|
||||
static status_t _WorkerThread(void*);
|
||||
bool PowerOn();
|
||||
void RecoverError();
|
||||
static status_t _WorkerThread(void*);
|
||||
|
||||
private:
|
||||
struct registers* fRegisters;
|
||||
uint32_t fCommandResult;
|
||||
uint8_t fIrq;
|
||||
sem_id fSemaphore;
|
||||
sem_id fScanSemaphore;
|
||||
status_t fStatus;
|
||||
thread_id fWorkerThread;
|
||||
struct registers* fRegisters;
|
||||
uint32_t fCommandResult;
|
||||
uint8_t fIrq;
|
||||
sem_id fSemaphore;
|
||||
sem_id fScanSemaphore;
|
||||
status_t fStatus;
|
||||
thread_id fWorkerThread;
|
||||
};
|
||||
|
||||
|
||||
class SdhciDevice {
|
||||
public:
|
||||
device_node* fNode;
|
||||
uint8_t fRicohOriginalMode;
|
||||
device_node* fNode;
|
||||
uint8_t fRicohOriginalMode;
|
||||
};
|
||||
|
||||
class TransferMode {
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
|
||||
//#define TRACE_SDHCI
|
||||
#ifdef TRACE_SDHCI
|
||||
# define TRACE(x...) dprintf("\33[33msdhci:\33[0m " x)
|
||||
# define TRACE(x...) dprintf("\33[33msdhci_pci:\33[0m " x)
|
||||
#else
|
||||
# define TRACE(x...) ;
|
||||
#endif
|
||||
#define TRACE_ALWAYS(x...) dprintf("\33[33msdhci:\33[0m " x)
|
||||
#define ERROR(x...) dprintf("\33[33msdhci:\33[0m " x)
|
||||
#define TRACE_ALWAYS(x...) dprintf("\33[33msdhci_pci:\33[0m " x)
|
||||
#define ERROR(x...) dprintf("\33[33msdhci_pci:\33[0m " x)
|
||||
#define CALLED(x...) TRACE("CALLED %s\n", __PRETTY_FUNCTION__)
|
||||
|
||||
|
||||
@@ -40,6 +40,18 @@
|
||||
#define SLOT_NUMBER "device/slot"
|
||||
#define BAR_INDEX "device/bar"
|
||||
|
||||
#define SDHCI_PCI_SLOT_INFO 0x40
|
||||
#define SDHCI_PCI_SLOTS(x) ((((x) >> 4) & 0x7) + 1)
|
||||
#define SDHCI_PCI_SLOT_INFO_FIRST_BASE_INDEX(x) ((x) & 0x7)
|
||||
|
||||
// Ricoh specific PCI registers
|
||||
// Ricoh devices start in a vendor-specific mode but can be switched
|
||||
// to standard sdhci using these PCI registers
|
||||
#define SDHCI_PCI_RICOH_MODE_KEY 0xf9
|
||||
#define SDHCI_PCI_RICOH_MODE 0x150
|
||||
#define SDHCI_PCI_RICOH_MODE_SD20 0x10
|
||||
|
||||
|
||||
status_t
|
||||
init_bus_pci(device_node* node, void** bus_cookie)
|
||||
{
|
||||
|
||||
@@ -641,7 +641,7 @@ module_dependency module_dependencies[] = {
|
||||
|
||||
|
||||
// The "block device" associated with the device file. It can be open()
|
||||
// multiple times, eash allocating an mmc_disk_handle. It does not interact
|
||||
// multiple times, each allocating an mmc_disk_handle. It does not interact
|
||||
// with the hardware directly, instead it forwards all IO requests to the
|
||||
// disk driver through the IO scheduler.
|
||||
struct device_module_info sMMCBlockDevice = {
|
||||
|
||||
Reference in New Issue
Block a user