mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-14 11:53:21 +00:00
Kernel: Make the PresentState register a bitfield in the SDHC driver
This commit is contained in:
parent
6391480b80
commit
b90a20aee6
|
@ -42,7 +42,34 @@ struct HostControlRegisterMap {
|
|||
u32 response_2;
|
||||
u32 response_3;
|
||||
u32 buffer_data_port;
|
||||
u32 present_state;
|
||||
union PresentState {
|
||||
struct { // SDHC 2.2.9 Present State Register (Cat.C Offset 024h)
|
||||
u32 command_inhibit_cmd : 1;
|
||||
u32 command_inhibit_dat : 1;
|
||||
u32 dat_line_active : 1;
|
||||
u32 re_tuning_request : 1;
|
||||
u32 dat_7_4_line_signal_level : 4;
|
||||
u32 write_transfer_active : 1;
|
||||
u32 read_transfer_active : 1;
|
||||
u32 buffer_write_enable : 1;
|
||||
u32 buffer_read_enable : 1;
|
||||
u32 : 4;
|
||||
u32 card_inserted : 1;
|
||||
u32 card_state_stable : 1;
|
||||
u32 card_detect_pin_level : 1;
|
||||
u32 write_protect_switch_pin_level : 1;
|
||||
u32 dat_3_0_line_signal_level : 4;
|
||||
u32 cmd_line_signal_level : 1;
|
||||
u32 host_regulator_voltage_stable : 1;
|
||||
u32 : 1;
|
||||
u32 command_not_issued_by_error : 1;
|
||||
u32 sub_command_status : 1;
|
||||
u32 in_dormant_state : 1;
|
||||
u32 lane_synchronization : 1;
|
||||
u32 uhs_2_if_detection : 1;
|
||||
};
|
||||
u32 raw;
|
||||
} present_state;
|
||||
u32 host_configuration_0;
|
||||
u32 host_configuration_1;
|
||||
union InterruptStatus {
|
||||
|
|
|
@ -270,14 +270,12 @@ bool SDHostController::retry_with_timeout(Function<bool()> f, i64 delay_between_
|
|||
ErrorOr<void> SDHostController::issue_command(SD::Command const& cmd, u32 argument)
|
||||
{
|
||||
// SDHC 3.7.1: "Transaction Control without Data Transfer Using DAT Line"
|
||||
constexpr u32 command_inhibit = 1 << 1;
|
||||
|
||||
// 1. Check Command Inhibit (CMD) in the Present State register.
|
||||
// Repeat this step until Command Inhibit (CMD) is 0.
|
||||
// That is, when Command Inhibit (CMD) is 1, the Host Driver
|
||||
// shall not issue an SD Command.
|
||||
if (!retry_with_timeout(
|
||||
[&]() { return !(m_registers->present_state & command_inhibit); })) {
|
||||
if (!retry_with_timeout([&]() { return !m_registers->present_state.command_inhibit_cmd; })) {
|
||||
return EIO;
|
||||
}
|
||||
|
||||
|
@ -290,8 +288,7 @@ ErrorOr<void> SDHostController::issue_command(SD::Command const& cmd, u32 argume
|
|||
|
||||
// 4. Check Command Inhibit (DAT) in the Present State register. Repeat
|
||||
// this step until Command Inhibit (DAT) is set to 0.
|
||||
constexpr u32 data_inhibit = 1 << 2;
|
||||
if (!retry_with_timeout([&]() { return !(m_registers->present_state & data_inhibit); })) {
|
||||
if (!retry_with_timeout([&]() { return !m_registers->present_state.command_inhibit_dat; })) {
|
||||
return EIO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ private:
|
|||
|
||||
bool is_card_inserted() const
|
||||
{
|
||||
constexpr u32 card_inserted = 1 << 16;
|
||||
return m_registers->present_state & card_inserted;
|
||||
return m_registers->present_state.card_inserted;
|
||||
}
|
||||
|
||||
SD::HostVersion host_version() { return m_registers->slot_interrupt_status_and_version.specification_version_number; }
|
||||
|
|
Loading…
Reference in a new issue