From 366adce39ee76d3ade9a672fb4bb72b9e108ff09 Mon Sep 17 00:00:00 2001 From: Milan Cermak Date: Sat, 28 Dec 2024 14:17:07 +0100 Subject: [PATCH] Patriot Controllers to use DIMM_DETECTOR --- .../PatriotViperControllerDetect.cpp | 81 +++++++------------ .../PatriotViperSteelControllerDetect.cpp | 81 +++++++------------ SPDAccessor/SPDCommon.h | 3 +- 3 files changed, 56 insertions(+), 109 deletions(-) diff --git a/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp b/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp index 4d88363a..5bcfc90b 100644 --- a/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp +++ b/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp @@ -57,67 +57,40 @@ bool TestForPatriotViperController(i2c_smbus_interface* bus, unsigned char addre * * \******************************************************************************************/ -void DetectPatriotViperControllers(std::vector &busses) +void DetectPatriotViperControllers(i2c_smbus_interface* bus, std::vector &slots) { - for(unsigned int bus = 0; bus < busses.size(); bus++) + unsigned char slots_valid = 0x00; + + // Check for Patriot Viper controller at 0x77 + LOG_DEBUG("[%s] Testing bus %d at address 0x77", PATRIOT_CONTROLLER_NAME, bus->port_id); + + if(TestForPatriotViperController(bus, 0x77)) { - unsigned char slots_valid = 0x00; - - IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) + for(SPDWrapper *slot : slots) { - // Check for Patriot Viper controller at 0x77 - LOG_DEBUG("[%s] Testing bus %d at address 0x77", PATRIOT_CONTROLLER_NAME, bus); - - if(TestForPatriotViperController(busses[bus], 0x77)) + if((slot->manufacturer_data(0x00) == 0x4D) + &&(slot->manufacturer_data(0x01) == 0x49) + &&(slot->manufacturer_data(0x02) == 0x43) + &&(slot->manufacturer_data(0x03) == 0x53) + &&(slot->manufacturer_data(0x04) == 0x59) + &&(slot->manufacturer_data(0x05) == 0x53) + &&(slot->manufacturer_data(0x06) == 0x5f) + &&(slot->manufacturer_data(0x07) == 0x44)) { - for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++) - { - // Test for Patriot Viper RGB SPD at slot_addr - // This test was copied from Viper RGB software - // Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68 - - busses[bus]->i2c_smbus_write_byte_data(0x36, 0x00, 0xFF); - - std::this_thread::sleep_for(1ms); - - int res = busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00); - - LOG_DEBUG("[%s] Trying to read 0x%02X RAM module data at 0x00 expect: 0x23 res: %02X", PATRIOT_CONTROLLER_NAME, slot_addr, res); - if(res == 0x23) - { - busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF); - - std::this_thread::sleep_for(1ms); - - if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0x85) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x02) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x61) == 0x4D) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x62) == 0x49) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x63) == 0x43) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x64) == 0x53) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x65) == 0x59) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x66) == 0x53) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x5f) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x68) == 0x44)) - { - LOG_DEBUG("[%s] The 0x%02X RAM module detected", PATRIOT_CONTROLLER_NAME, slot_addr); - slots_valid |= (1 << (slot_addr - 0x50)); - } - } - - std::this_thread::sleep_for(1ms); - } - - if(slots_valid != 0) - { - PatriotViperController* controller = new PatriotViperController(busses[bus], 0x77, slots_valid); - RGBController_PatriotViper* rgb_controller = new RGBController_PatriotViper(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); - } + LOG_DEBUG("[%s] The RAM module detected in slot %d", PATRIOT_CONTROLLER_NAME, slot->index()); + slots_valid |= (1 << (slot->index())); } } + + if(slots_valid != 0) + { + PatriotViperController* controller = new PatriotViperController(bus, 0x77, slots_valid); + RGBController_PatriotViper* rgb_controller = new RGBController_PatriotViper(controller); + ResourceManager::get()->RegisterRGBController(rgb_controller); + } } } /* DetectPatriotViperControllers() */ -REGISTER_I2C_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperControllers); +REGISTER_I2C_DIMM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperControllers, JEDEC_PATRIOT, SPD_DDR4_SDRAM); + diff --git a/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp b/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp index f0ca26ca..7b0a37f0 100644 --- a/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp +++ b/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp @@ -55,67 +55,40 @@ bool TestForPatriotViperSteelController(i2c_smbus_interface* bus, unsigned char * * \******************************************************************************************/ -void DetectPatriotViperSteelControllers(std::vector &busses) +void DetectPatriotViperSteelControllers(i2c_smbus_interface* bus, std::vector &slots) { - for(unsigned int bus = 0; bus < busses.size(); bus++) + unsigned char slots_valid = 0x00; + + // Check for Patriot Viper controller at 0x77 + LOG_DEBUG("[%s] Testing bus %d at address 0x77", PATRIOT_CONTROLLER_NAME, bus->port_id); + + if(TestForPatriotViperSteelController(bus, 0x77)) { - unsigned char slots_valid = 0x00; - - IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) + for(SPDWrapper *slot : slots) { - // Check for Patriot Viper Steel controller at 0x77 - LOG_DEBUG("[%s] Testing bus %d at address 0x77", PATRIOT_CONTROLLER_NAME, bus); - - if(TestForPatriotViperSteelController(busses[bus], 0x77)) + if((slot->manufacturer_data(0x00) == 0x50) + &&(slot->manufacturer_data(0x01) == 0x44) + &&(slot->manufacturer_data(0x02) == 0x41) + &&(slot->manufacturer_data(0x03) == 0x31) + &&(slot->manufacturer_data(0x04) == 0x00) + &&(slot->manufacturer_data(0x05) == 0x00) + &&(slot->manufacturer_data(0x06) == 0x00) + &&(slot->manufacturer_data(0x07) == 0x00)) { - for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++) - { - // Test for Patriot Viper Steel RGB SPD at slot_addr - // This test was copied from PatriotViperControllerDetect - // Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68 - - busses[bus]->i2c_smbus_write_byte_data(0x36, 0x00, 0xFF); - - std::this_thread::sleep_for(1ms); - - int res = busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00); - - LOG_DEBUG("[%s] Trying to read 0x%02X RAM module data at 0x00 expect: 0x23 res: %02X", PATRIOT_CONTROLLER_NAME, slot_addr, res); - if(res == 0x23) - { - busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF); - - std::this_thread::sleep_for(1ms); - - if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0xFF) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0xFF) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x61) == 0x50) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x62) == 0x44) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x63) == 0x41) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x64) == 0x31) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x65) == 0x00) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x66) == 0x00) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x00) - &&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x68) == 0x00)) - { - LOG_DEBUG("[%s] The 0x%02X RAM module detected", PATRIOT_CONTROLLER_NAME, slot_addr); - slots_valid |= (1 << (slot_addr - 0x50)); - } - } - - std::this_thread::sleep_for(1ms); - } - - if(slots_valid != 0) - { - PatriotViperSteelController* controller = new PatriotViperSteelController(busses[bus], 0x77); - RGBController_PatriotViperSteel* rgb_controller = new RGBController_PatriotViperSteel(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); - } + LOG_DEBUG("[%s] The RAM module detected in slot %d", PATRIOT_CONTROLLER_NAME, slot->index()); + slots_valid |= (1 << (slot->index())); } } + + if(slots_valid != 0) + { + PatriotViperSteelController* controller = new PatriotViperSteelController(bus, 0x77); + RGBController_PatriotViperSteel* rgb_controller = new RGBController_PatriotViperSteel(controller); + ResourceManager::get()->RegisterRGBController(rgb_controller); + } } } /* DetectPatriotViperSteelControllers() */ -REGISTER_I2C_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperSteelControllers); +REGISTER_I2C_DIMM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperSteelControllers, 0xFF7E, SPD_DDR4_SDRAM); + diff --git a/SPDAccessor/SPDCommon.h b/SPDAccessor/SPDCommon.h index 66c14704..cc7fcc63 100644 --- a/SPDAccessor/SPDCommon.h +++ b/SPDAccessor/SPDCommon.h @@ -21,7 +21,8 @@ typedef enum JEDEC_TEAMGROUP = 0x046E, JEDEC_MUSHKIN = 0x8313, JEDEC_GIGABYTE = 0x8971, - JEDEC_THERMALTAKE = 0x8A41 + JEDEC_THERMALTAKE = 0x8A41, + JEDEC_PATRIOT = 0x8501 } JedecIdentifier; typedef enum