Initial commit for ASUS ROG Arion external NVMe SSD enclosure

This commit is contained in:
Adam Honse 2023-09-18 00:24:18 -05:00
parent 30b12c67b2
commit 340083bc33
13 changed files with 340 additions and 97 deletions

View file

@ -26,6 +26,7 @@ static const char* ene_channels[] = /* ENE channel strings
"RGB Header",
"RGB Header 2",
"RGB Header",
"SSD",
"Unknown",
};
@ -35,40 +36,51 @@ ENESMBusController::ENESMBusController(ENESMBusInterface* interface, ene_dev_id
this->dev = dev;
supports_mode_14 = false;
UpdateDeviceName();
// Read the device configuration table
for (int i = 0; i < 64; i++)
if(interface->GetInterfaceType() != ENE_INTERFACE_TYPE_ROG_ARION)
{
config_table[i] = ENERegisterRead(ENE_REG_CONFIG_TABLE + i);
UpdateDeviceName();
// Read the device configuration table
for (int i = 0; i < 64; i++)
{
config_table[i] = ENERegisterRead(ENE_REG_CONFIG_TABLE + i);
}
/*-----------------------------------------------------------------*\
| If this is running with TRACE or higher loglevel then |
| dump the entire Feature list to log |
\*-----------------------------------------------------------------*/
if(LogManager::get()->getLoglevel() >= LL_TRACE)
{
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X:", dev);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[0], config_table[1], config_table[2], config_table[3],
config_table[4], config_table[5], config_table[6], config_table[7],
config_table[8], config_table[9], config_table[10], config_table[11],
config_table[12], config_table[13], config_table[14], config_table[15]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[16], config_table[17], config_table[18], config_table[19],
config_table[20], config_table[21], config_table[22], config_table[23],
config_table[24], config_table[25], config_table[26], config_table[27],
config_table[28], config_table[29], config_table[30], config_table[31]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[32], config_table[33], config_table[34], config_table[35],
config_table[36], config_table[37], config_table[38], config_table[39],
config_table[40], config_table[41], config_table[42], config_table[43],
config_table[44], config_table[45], config_table[46], config_table[47]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[48], config_table[49], config_table[50], config_table[51],
config_table[52], config_table[53], config_table[54], config_table[55],
config_table[56], config_table[57], config_table[58], config_table[59],
config_table[60], config_table[61], config_table[62], config_table[63]);
}
}
/*-----------------------------------------------------------------*\
| If this is running with TRACE or higher loglevel then |
| dump the entire Feature list to log |
\*-----------------------------------------------------------------*/
if(LogManager::get()->getLoglevel() >= LL_TRACE)
else
{
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X:", dev);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[0], config_table[1], config_table[2], config_table[3],
config_table[4], config_table[5], config_table[6], config_table[7],
config_table[8], config_table[9], config_table[10], config_table[11],
config_table[12], config_table[13], config_table[14], config_table[15]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[16], config_table[17], config_table[18], config_table[19],
config_table[20], config_table[21], config_table[22], config_table[23],
config_table[24], config_table[25], config_table[26], config_table[27],
config_table[28], config_table[29], config_table[30], config_table[31]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[32], config_table[33], config_table[34], config_table[35],
config_table[36], config_table[37], config_table[38], config_table[39],
config_table[40], config_table[41], config_table[42], config_table[43],
config_table[44], config_table[45], config_table[46], config_table[47]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[48], config_table[49], config_table[50], config_table[51],
config_table[52], config_table[53], config_table[54], config_table[55],
config_table[56], config_table[57], config_table[58], config_table[59],
config_table[60], config_table[61], config_table[62], config_table[63]);
LOG_TRACE("[ENE SMBus] ROG STRIX ARION detected, filling in hard coded config table entries.", dev);
memset(config_table, 0, sizeof(config_table));
config_table[ENE_CONFIG_LED_COUNT] = 4;
config_table[0x03] = 4;
strcpy(device_name, "ROG STRIX ARION");
}
// Read LED count from configuration table
@ -166,6 +178,15 @@ ENESMBusController::ENESMBusController(ENESMBusInterface* interface, ene_dev_id
// Read LED count from configuration table
led_count = config_table[ENE_CONFIG_LED_COUNT_0107];
}
// ROG ARION - ASUS ROG Arion external SSD enclosure
// This device does not support ENE read, so we fake the device name string
// if the interface is ROG Arion type. It uses second generation registers.
else if(strcmp(device_name, "ROG STRIX ARION") == 0)
{
direct_reg = ENE_REG_COLORS_DIRECT_V2;
effect_reg = ENE_REG_COLORS_EFFECT_V2;
channel_cfg = ENE_CONFIG_CHANNEL_V2;
}
// Assume first generation controller if string does not match
else
{
@ -201,53 +222,60 @@ const char * ENESMBusController::GetChannelName(unsigned int cfg_zone)
{
LOG_TRACE("[%s] Config table for zone %02d: %02d", device_name, cfg_zone, config_table[channel_cfg + cfg_zone]);
switch(config_table[channel_cfg + cfg_zone])
if(interface->GetInterfaceType() == ENE_INTERFACE_TYPE_ROG_ARION)
{
case (unsigned char)ENE_LED_CHANNEL_AUDIO:
return(ene_channels[0]);
break;
case (unsigned char)ENE_LED_CHANNEL_BACKPLATE:
return(ene_channels[1]);
break;
case (unsigned char)ENE_LED_CHANNEL_BACK_IO:
return(ene_channels[2]);
break;
case (unsigned char)ENE_LED_CHANNEL_CENTER:
return(ene_channels[3]);
break;
case (unsigned char)ENE_LED_CHANNEL_CENTER_START:
return(ene_channels[4]);
break;
case (unsigned char)ENE_LED_CHANNEL_DRAM:
case (unsigned char)ENE_LED_CHANNEL_DRAM_2:
case (unsigned char)ENE_LED_CHANNEL_DRAM_3:
return(ene_channels[5]);
break;
case (unsigned char)ENE_LED_CHANNEL_PCIE:
return(ene_channels[6]);
break;
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER:
return(ene_channels[7]);
break;
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_2:
return(ene_channels[8]);
break;
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_3:
return(ene_channels[9]);
break;
default:
return(ene_channels[10]);
break;
}
else
{
switch(config_table[channel_cfg + cfg_zone])
{
case (unsigned char)ENE_LED_CHANNEL_AUDIO:
return(ene_channels[0]);
break;
case (unsigned char)ENE_LED_CHANNEL_BACKPLATE:
return(ene_channels[1]);
break;
case (unsigned char)ENE_LED_CHANNEL_BACK_IO:
return(ene_channels[2]);
break;
case (unsigned char)ENE_LED_CHANNEL_CENTER:
return(ene_channels[3]);
break;
case (unsigned char)ENE_LED_CHANNEL_CENTER_START:
return(ene_channels[4]);
break;
case (unsigned char)ENE_LED_CHANNEL_DRAM:
case (unsigned char)ENE_LED_CHANNEL_DRAM_2:
case (unsigned char)ENE_LED_CHANNEL_DRAM_3:
return(ene_channels[5]);
break;
case (unsigned char)ENE_LED_CHANNEL_PCIE:
return(ene_channels[6]);
break;
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER:
return(ene_channels[7]);
break;
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_2:
return(ene_channels[8]);
break;
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_3:
return(ene_channels[9]);
break;
default:
return(ene_channels[11]);
break;
}
}
}

View file

@ -12,15 +12,27 @@
typedef unsigned short ene_register;
typedef unsigned char ene_dev_id;
typedef unsigned int ene_interface_type;
/*-----------------------------------------*\
| Known interface types |
\*-----------------------------------------*/
enum
{
ENE_INTERFACE_TYPE_I2C_SMBUS,
ENE_INTERFACE_TYPE_SPECTRIX_S40G,
ENE_INTERFACE_TYPE_ROG_ARION,
};
class ENESMBusInterface
{
public:
virtual ~ENESMBusInterface() = default;
virtual ~ENESMBusInterface() = default;
virtual std::string GetLocation() = 0;
virtual int GetMaxBlock() = 0;
virtual unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg) = 0;
virtual void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val) = 0;
virtual void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz) = 0;
virtual ene_interface_type GetInterfaceType() = 0;
virtual std::string GetLocation() = 0;
virtual int GetMaxBlock() = 0;
virtual unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg) = 0;
virtual void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val) = 0;
virtual void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz) = 0;
};

View file

@ -0,0 +1,93 @@
/*-----------------------------------------*\
| ENESMBusInterface_ROGArion.cpp |
| |
| Code for ENE ASUS ROG Arion interface |
| |
| Adam Honse (CalcProgrammer1) 9/17/2023 |
\*-----------------------------------------*/
#include "ENESMBusInterface_ROGArion.h"
ENESMBusInterface_ROGArion::ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path)
{
scsi_dev = dev_handle;
path = dev_path;
}
ENESMBusInterface_ROGArion::~ENESMBusInterface_ROGArion()
{
}
ene_interface_type ENESMBusInterface_ROGArion::GetInterfaceType()
{
return(ENE_INTERFACE_TYPE_ROG_ARION);
}
std::string ENESMBusInterface_ROGArion::GetLocation()
{
std::string str(path.begin(), path.end());
return("SCSI: " + str);
}
int ENESMBusInterface_ROGArion::GetMaxBlock()
{
return(24);
}
unsigned char ENESMBusInterface_ROGArion::ENERegisterRead(ene_dev_id dev, ene_register reg)
{
/*-----------------------------------------------------------------------------*\
| This interface does not support reading |
\*-----------------------------------------------------------------------------*/
return( 0 );
}
void ENESMBusInterface_ROGArion::ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val)
{
SendPacket(reg, &val, sizeof(unsigned char));
}
void ENESMBusInterface_ROGArion::ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz)
{
SendPacket(reg, data, sz);
}
void ENESMBusInterface_ROGArion::SendPacket
(
ene_register reg,
unsigned char * packet,
unsigned char packet_sz
)
{
/*-----------------------------------------------------------------------------*\
| Create buffer to hold CDB |
\*-----------------------------------------------------------------------------*/
unsigned char cdb[16] = {0};
cdb[0] = 0xEC;
cdb[1] = 0x41;
cdb[2] = 0x53;
cdb[3] = ((reg >> 8) & 0x00FF);
cdb[4] = ( reg & 0x00FF );
cdb[5] = 0x00;
cdb[6] = 0x00;
cdb[7] = 0x00;
cdb[8] = 0x00;
cdb[9] = 0x00;
cdb[10] = 0x00;
cdb[11] = 0x00;
cdb[12] = 0x00;
cdb[13] = packet_sz;
cdb[14] = 0x00;
cdb[15] = 0x00;
/*-----------------------------------------------------------------------------*\
| Create buffer to hold sense data |
\*-----------------------------------------------------------------------------*/
unsigned char sense[32] = {0};
/*-----------------------------------------------------------------------------*\
| Write SCSI packet |
\*-----------------------------------------------------------------------------*/
scsi_write(scsi_dev, packet, packet_sz, cdb, 16, sense, 32);
}

View file

@ -0,0 +1,38 @@
/*-----------------------------------------*\
| ENESMBusInterface_ROGArion.h |
| |
| Definitions and types for ENE ASUS ROG |
| Arion interface |
| |
| Adam Honse (CalcProgrammer1) 9/17/2023 |
\*-----------------------------------------*/
#pragma once
#include "ENESMBusInterface.h"
#include "scsiapi.h"
class ENESMBusInterface_ROGArion : public ENESMBusInterface
{
public:
ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path);
~ENESMBusInterface_ROGArion();
ene_interface_type GetInterfaceType();
std::string GetLocation();
int GetMaxBlock();
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
private:
scsi_device* scsi_dev;
std::string path;
void SendPacket
(
ene_register reg,
unsigned char * packet,
unsigned char packet_sz
);
};

View file

@ -110,6 +110,11 @@ ENESMBusInterface_SpectrixS40G::~ENESMBusInterface_SpectrixS40G()
}
ene_interface_type ENESMBusInterface_SpectrixS40G::GetInterfaceType()
{
return(ENE_INTERFACE_TYPE_SPECTRIX_S40G);
}
std::string ENESMBusInterface_SpectrixS40G::GetLocation()
{
return("NVMe: " + path);

View file

@ -17,11 +17,12 @@ public:
ENESMBusInterface_SpectrixS40G(int fd, char* path);
~ENESMBusInterface_SpectrixS40G();
std::string GetLocation();
int GetMaxBlock();
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
ene_interface_type GetInterfaceType();
std::string GetLocation();
int GetMaxBlock();
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
private:
int nvme_fd;

View file

@ -25,6 +25,11 @@ ENESMBusInterface_SpectrixS40G::~ENESMBusInterface_SpectrixS40G()
}
ene_interface_type ENESMBusInterface_SpectrixS40G::GetInterfaceType()
{
return(ENE_INTERFACE_TYPE_SPECTRIX_S40G);
}
std::string ENESMBusInterface_SpectrixS40G::GetLocation()
{
std::string str(path.begin(), path.end());

View file

@ -19,11 +19,12 @@ public:
ENESMBusInterface_SpectrixS40G(HANDLE fd, wchar_t* path);
~ENESMBusInterface_SpectrixS40G();
std::string GetLocation();
int GetMaxBlock();
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
ene_interface_type GetInterfaceType();
std::string GetLocation();
int GetMaxBlock();
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
private:
HANDLE nvme_fd;

View file

@ -18,6 +18,11 @@ ENESMBusInterface_i2c_smbus::~ENESMBusInterface_i2c_smbus()
}
ene_interface_type ENESMBusInterface_i2c_smbus::GetInterfaceType()
{
return(ENE_INTERFACE_TYPE_I2C_SMBUS);
}
std::string ENESMBusInterface_i2c_smbus::GetLocation()
{
std::string return_string(bus->device_name);

View file

@ -18,11 +18,12 @@ public:
ENESMBusInterface_i2c_smbus(i2c_smbus_interface* bus);
~ENESMBusInterface_i2c_smbus();
std::string GetLocation();
int GetMaxBlock();
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
ene_interface_type GetInterfaceType();
std::string GetLocation();
int GetMaxBlock();
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
private:
i2c_smbus_interface * bus;

View file

@ -56,6 +56,12 @@ RGBController_ENESMBus::RGBController_ENESMBus(ENESMBusController * controller_p
name = "ENE DRAM";
vendor = "ENE";
}
else if(version.find("ROG STRIX ARION") != std::string::npos)
{
type = DEVICE_TYPE_STORAGE;
name = "ASUS ROG Strix Arion";
vendor = "ASUS";
}
else
{
type = DEVICE_TYPE_MOTHERBOARD;

View file

@ -0,0 +1,45 @@
#include "Detector.h"
#include "ENESMBusController.h"
#include "ENESMBusInterface_ROGArion.h"
#include "LogManager.h"
#include "RGBController.h"
#include "RGBController_ENESMBus.h"
#include <vector>
#include "scsiapi.h"
/******************************************************************************************\
* *
* DetectROGArionControllers *
* *
* Detects ENE SMBus controllers on ASUS ROG Arion devices *
* *
\******************************************************************************************/
void DetectROGArionControllers()
{
scsi_device_info * info = scsi_enumerate(NULL, NULL);
while(info)
{
if(strncmp(info->vendor, "ROG", 3) == 0 && strncmp(info->product, "ESD-S1C", 7) == 0)
{
scsi_device * dev = scsi_open_path(info->path);
if(dev)
{
ENESMBusInterface_ROGArion* interface = new ENESMBusInterface_ROGArion(dev, info->path);
ENESMBusController* controller = new ENESMBusController(interface, 0x67);
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
info = info->next;
}
scsi_free_enumeration(info);
} /* DetectROGArionControllers() */
REGISTER_DETECTOR("ASUS ROG Arion", DetectROGArionControllers);

View file

@ -475,6 +475,7 @@ HEADERS +=
Controllers/ENESMBusController/RGBController_ENESMBus.h \
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface.h \
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_i2c_smbus.h \
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_ROGArion.h \
Controllers/EpomakerController/EpomakerController.h \
Controllers/EpomakerController/RGBController_EpomakerController.h \
Controllers/EspurnaController/EspurnaController.h \
@ -1110,8 +1111,10 @@ SOURCES +=
Controllers/ElgatoKeyLightController/RGBController_ElgatoKeyLight.cpp \
Controllers/ENESMBusController/ENESMBusController.cpp \
Controllers/ENESMBusController/ENESMBusControllerDetect.cpp \
Controllers/ENESMBusController/ROGArionDetect.cpp \
Controllers/ENESMBusController/RGBController_ENESMBus.cpp \
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_i2c_smbus.cpp \
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_ROGArion.cpp \
Controllers/EpomakerController/EpomakerController.cpp \
Controllers/EpomakerController/EpomakerControllerDetect.cpp \
Controllers/EpomakerController/RGBController_EpomakerController.cpp \