Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions RAMSPDToolkit/SPD/DDR4Accessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public DDR4Accessor(SMBusInterface bus, byte address)
/// <returns>True if DDR4 is available at specified address; false otherwise.</returns>
public static bool IsAvailable(SMBusInterface bus, byte address)
{
//On DDR5 hubs offset 0x02 is the device revision, not the memory type.
//Its value can overlap the DDR4 memory type codes.
if (DDR5Accessor.HasHubDeviceType(bus, address))
{
return false;
}

int value;

//Select first page
Expand Down
25 changes: 23 additions & 2 deletions RAMSPDToolkit/SPD/DDR5Accessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public DDR5Accessor(SMBusInterface bus, byte address)
/// <returns>True if DDR5 is available at specified address; false otherwise.</returns>
public static bool IsAvailable(SMBusInterface bus, byte address)
{
//Check device type before changing the page
if (!HasHubDeviceType(bus, address))
{
return false;
}

//Read current page
int status = RetryReadByteData(bus, address, DDR5Constants.SPD_DDR5_MREG_VIRTUAL_PAGE, SPDConstants.SPD_DATA_RETRIES, out byte page);

Expand Down Expand Up @@ -129,13 +135,28 @@ public static bool IsAvailable(SMBusInterface bus, byte address)
}
}

return true;
}

#endregion

#region Internal

/// <summary>
/// Detects if a DDR5 SPD Hub is available at specified address without changing the page.
/// </summary>
/// <param name="bus">SMBus to check for RAM.</param>
/// <param name="address">Address to check.</param>
/// <returns>True if a DDR5 SPD Hub is available at specified address; false otherwise.</returns>
internal static bool HasHubDeviceType(SMBusInterface bus, byte address)
{
//Try read most significant byte
//Result should be 0x51
var result = RetryReadByteData(bus, address, DDR5Constants.SPD_DDR5_DEVICE_TYPE_MOST, SPDConstants.SPD_DATA_RETRIES, out byte ddr5Magic);

if (result < 0)
{
LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(IsAvailable)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_MOST)} due to error {result}.");
LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(HasHubDeviceType)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_MOST)} due to error {result}.");
}

//Try read least significant byte
Expand All @@ -144,7 +165,7 @@ public static bool IsAvailable(SMBusInterface bus, byte address)

if (result < 0)
{
LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(IsAvailable)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_LEAST)} due to error {result}.");
LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(HasHubDeviceType)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_LEAST)} due to error {result}.");
}

//Is it a DDR5 module ?
Expand Down