Check for Micron string when detecting Aura and Crucial DRAM to ensure right controller gets used

This commit is contained in:
Adam Honse 2021-10-12 21:42:01 -05:00
parent 3786047f90
commit f37b39e45e
4 changed files with 87 additions and 6 deletions

View file

@ -20,6 +20,7 @@ typedef unsigned short aura_register;
enum
{
AURA_REG_DEVICE_NAME = 0x1000, /* Device String 16 bytes */
AURA_REG_MICRON_CHECK = 0x1030, /* If "Micron" appears here, skip */
AURA_REG_CONFIG_TABLE = 0x1C00, /* Start of LED configuration bytes */
AURA_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
AURA_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */

View file

@ -59,6 +59,25 @@ static const unsigned char aura_mobo_addresses[] =
0x4F
};
/******************************************************************************************\
* *
* AuraRegisterRead *
* *
* A standalone version of the AuraSMBusController::AuraRegisterRead function for *
* access to Aura devices without instancing the AuraSMBusController class or reading *
* the config table from the device. *
* *
\******************************************************************************************/
unsigned char AuraRegisterRead(i2c_smbus_interface* bus, aura_dev_id dev, aura_register reg)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Read Aura value
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
}
/******************************************************************************************\
* *
* AuraRegisterWrite *
@ -116,7 +135,23 @@ bool TestForAsusAuraSMBusController(i2c_smbus_interface* bus, unsigned char addr
if(pass)
{
LOG_VERBOSE("[Aura SMBus] Detection successful, address %02X", address);
LOG_DEBUG("[Aura SMBus] Checking for Micron string");
char buf[16];
for(int i = 0; i < 16; i++)
{
buf[i] = AuraRegisterRead(bus, address, AURA_REG_MICRON_CHECK + i);
}
if(strcmp(buf, "Micron") == 0)
{
LOG_DEBUG("[Aura SMBus] Device %02X is a Micron device, skipping", address);
pass = false;
}
else
{
LOG_VERBOSE("[Aura SMBus] Detection successful, address %02X", address);
}
}
}

View file

@ -16,6 +16,11 @@
typedef unsigned char crucial_dev_id;
typedef unsigned short crucial_register;
enum
{
CRUCIAL_REG_MICRON_CHECK = 0x1030 /* "Micron" string should be here */
};
enum
{
CRUCIAL_MODE_UNKNOWN = 0x00, /* We don't know what the mode is */

View file

@ -14,7 +14,7 @@ using namespace std::chrono_literals;
/*----------------------------------------------------------------------*\
| This list contains the available SMBus addresses for Crucial RAM |
\*----------------------------------------------------------------------*/
#define CRUCIAL_ADDRESS_COUNT 4
#define CRUCIAL_ADDRESS_COUNT 8
static const unsigned char crucial_addresses[] =
{
@ -24,10 +24,10 @@ static const unsigned char crucial_addresses[] =
| the same, Aura RAM will be detected as Crucial. |
| We need to improve the Crucial detection scheme. |
\*-----------------------------------------------------*/
// 0x39,
// 0x3A,
// 0x3B,
// 0x3C,
0x39,
0x3A,
0x3B,
0x3C,
0x20,
0x21,
0x22,
@ -46,6 +46,25 @@ std::string concatHexArray(const unsigned char array[], int count, const char sp
}
#define TESTING_ADDRESSES concatHexArray(crucial_addresses, CRUCIAL_ADDRESS_COUNT, "|").c_str()
/******************************************************************************************\
* *
* CrucialRegisterRead *
* *
* A standalone version of the AuraSMBusController::AuraRegisterRead function for *
* access to Aura devices without instancing the AuraSMBusController class or reading *
* the config table from the device. *
* *
\******************************************************************************************/
unsigned char CrucialRegisterRead(i2c_smbus_interface* bus, crucial_dev_id dev, crucial_register reg)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Read Aura value
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
}
/******************************************************************************************\
* *
* TestForCrucialController *
@ -79,6 +98,27 @@ bool TestForCrucialController(i2c_smbus_interface* bus, unsigned char address)
pass = false;
}
}
if(pass)
{
LOG_DEBUG("[%s] Checking for Micron string", CRUCIAL_CONTROLLER_NAME);
char buf[16];
for(int i = 0; i < 16; i++)
{
buf[i] = CrucialRegisterRead(bus, address, CRUCIAL_REG_MICRON_CHECK + i);
}
if(strcmp(buf, "Micron") == 0)
{
LOG_DEBUG("[%s] Device %02X is a Micron device, continuing", CRUCIAL_CONTROLLER_NAME, address);
}
else
{
LOG_DEBUG("[%s] Device %02X is not a Micron device, skipping", CRUCIAL_CONTROLLER_NAME, address);
pass = false;
}
}
}
return(pass);