mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:17:42 +00:00
Kernel: Increase SD Data Timeout
Otherwise, reading will sometimes fail on the Raspberry Pi. This is mostly a hack, the spec has some info about how the correct divisor should be calculated and how we can recover from timeouts.
This commit is contained in:
parent
bbe614c6c5
commit
6eb06384b3
1 changed files with 8 additions and 0 deletions
|
@ -47,6 +47,10 @@ constexpr u32 internal_clock_stable = 1 << 1;
|
||||||
constexpr u32 sd_clock_enable = 1 << 2;
|
constexpr u32 sd_clock_enable = 1 << 2;
|
||||||
constexpr u32 sd_clock_divisor_mask = 0x0000ffc0;
|
constexpr u32 sd_clock_divisor_mask = 0x0000ffc0;
|
||||||
|
|
||||||
|
// In sub-register "Timeout Control"
|
||||||
|
constexpr u32 data_timeout_counter_value_mask = 0b1111 << 16;
|
||||||
|
constexpr u32 data_timeout_counter_value_max = 0b1110 << 16;
|
||||||
|
|
||||||
// In sub-register "Software Reset"
|
// In sub-register "Software Reset"
|
||||||
constexpr u32 software_reset_for_all = 0x01000000;
|
constexpr u32 software_reset_for_all = 0x01000000;
|
||||||
|
|
||||||
|
@ -469,6 +473,10 @@ ErrorOr<void> SDHostController::sd_clock_supply(u32 frequency)
|
||||||
return EIO;
|
return EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: With the default timeout value, reading will sometimes fail on the Raspberry Pi.
|
||||||
|
// We should be a bit smarter with choosing the right timeout value and handling errors.
|
||||||
|
m_registers->host_configuration_1 = (m_registers->host_configuration_1 & ~data_timeout_counter_value_mask) | data_timeout_counter_value_max;
|
||||||
|
|
||||||
// 4. Set SD Clock Enable in the Clock Control register to 1
|
// 4. Set SD Clock Enable in the Clock Control register to 1
|
||||||
m_registers->host_configuration_1 = m_registers->host_configuration_1 | sd_clock_enable;
|
m_registers->host_configuration_1 = m_registers->host_configuration_1 | sd_clock_enable;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue