Skip to content

Commit 340083b

Browse files
Initial commit for ASUS ROG Arion external NVMe SSD enclosure
1 parent 30b12c6 commit 340083b

13 files changed

+331
-88
lines changed

Controllers/ENESMBusController/ENESMBusController.cpp

Lines changed: 95 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static const char* ene_channels[] = /* ENE channel strings
2626
"RGB Header",
2727
"RGB Header 2",
2828
"RGB Header",
29+
"SSD",
2930
"Unknown",
3031
};
3132

@@ -35,40 +36,51 @@ ENESMBusController::ENESMBusController(ENESMBusInterface* interface, ene_dev_id
3536
this->dev = dev;
3637
supports_mode_14 = false;
3738

38-
UpdateDeviceName();
39-
40-
// Read the device configuration table
41-
for (int i = 0; i < 64; i++)
39+
if(interface->GetInterfaceType() != ENE_INTERFACE_TYPE_ROG_ARION)
4240
{
43-
config_table[i] = ENERegisterRead(ENE_REG_CONFIG_TABLE + i);
44-
}
41+
UpdateDeviceName();
42+
43+
// Read the device configuration table
44+
for (int i = 0; i < 64; i++)
45+
{
46+
config_table[i] = ENERegisterRead(ENE_REG_CONFIG_TABLE + i);
47+
}
4548

46-
/*-----------------------------------------------------------------*\
47-
| If this is running with TRACE or higher loglevel then |
48-
| dump the entire Feature list to log |
49-
\*-----------------------------------------------------------------*/
50-
if(LogManager::get()->getLoglevel() >= LL_TRACE)
49+
/*-----------------------------------------------------------------*\
50+
| If this is running with TRACE or higher loglevel then |
51+
| dump the entire Feature list to log |
52+
\*-----------------------------------------------------------------*/
53+
if(LogManager::get()->getLoglevel() >= LL_TRACE)
54+
{
55+
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X:", dev);
56+
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],
57+
config_table[4], config_table[5], config_table[6], config_table[7],
58+
config_table[8], config_table[9], config_table[10], config_table[11],
59+
config_table[12], config_table[13], config_table[14], config_table[15]);
60+
61+
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],
62+
config_table[20], config_table[21], config_table[22], config_table[23],
63+
config_table[24], config_table[25], config_table[26], config_table[27],
64+
config_table[28], config_table[29], config_table[30], config_table[31]);
65+
66+
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],
67+
config_table[36], config_table[37], config_table[38], config_table[39],
68+
config_table[40], config_table[41], config_table[42], config_table[43],
69+
config_table[44], config_table[45], config_table[46], config_table[47]);
70+
71+
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],
72+
config_table[52], config_table[53], config_table[54], config_table[55],
73+
config_table[56], config_table[57], config_table[58], config_table[59],
74+
config_table[60], config_table[61], config_table[62], config_table[63]);
75+
}
76+
}
77+
else
5178
{
52-
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X:", dev);
53-
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],
54-
config_table[4], config_table[5], config_table[6], config_table[7],
55-
config_table[8], config_table[9], config_table[10], config_table[11],
56-
config_table[12], config_table[13], config_table[14], config_table[15]);
57-
58-
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],
59-
config_table[20], config_table[21], config_table[22], config_table[23],
60-
config_table[24], config_table[25], config_table[26], config_table[27],
61-
config_table[28], config_table[29], config_table[30], config_table[31]);
62-
63-
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],
64-
config_table[36], config_table[37], config_table[38], config_table[39],
65-
config_table[40], config_table[41], config_table[42], config_table[43],
66-
config_table[44], config_table[45], config_table[46], config_table[47]);
67-
68-
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],
69-
config_table[52], config_table[53], config_table[54], config_table[55],
70-
config_table[56], config_table[57], config_table[58], config_table[59],
71-
config_table[60], config_table[61], config_table[62], config_table[63]);
79+
LOG_TRACE("[ENE SMBus] ROG STRIX ARION detected, filling in hard coded config table entries.", dev);
80+
memset(config_table, 0, sizeof(config_table));
81+
config_table[ENE_CONFIG_LED_COUNT] = 4;
82+
config_table[0x03] = 4;
83+
strcpy(device_name, "ROG STRIX ARION");
7284
}
7385

7486
// Read LED count from configuration table
@@ -166,6 +178,15 @@ ENESMBusController::ENESMBusController(ENESMBusInterface* interface, ene_dev_id
166178
// Read LED count from configuration table
167179
led_count = config_table[ENE_CONFIG_LED_COUNT_0107];
168180
}
181+
// ROG ARION - ASUS ROG Arion external SSD enclosure
182+
// This device does not support ENE read, so we fake the device name string
183+
// if the interface is ROG Arion type. It uses second generation registers.
184+
else if(strcmp(device_name, "ROG STRIX ARION") == 0)
185+
{
186+
direct_reg = ENE_REG_COLORS_DIRECT_V2;
187+
effect_reg = ENE_REG_COLORS_EFFECT_V2;
188+
channel_cfg = ENE_CONFIG_CHANNEL_V2;
189+
}
169190
// Assume first generation controller if string does not match
170191
else
171192
{
@@ -201,53 +222,60 @@ const char * ENESMBusController::GetChannelName(unsigned int cfg_zone)
201222
{
202223
LOG_TRACE("[%s] Config table for zone %02d: %02d", device_name, cfg_zone, config_table[channel_cfg + cfg_zone]);
203224

204-
switch(config_table[channel_cfg + cfg_zone])
225+
if(interface->GetInterfaceType() == ENE_INTERFACE_TYPE_ROG_ARION)
226+
{
227+
return(ene_channels[10]);
228+
}
229+
else
205230
{
206-
case (unsigned char)ENE_LED_CHANNEL_AUDIO:
207-
return(ene_channels[0]);
208-
break;
231+
switch(config_table[channel_cfg + cfg_zone])
232+
{
233+
case (unsigned char)ENE_LED_CHANNEL_AUDIO:
234+
return(ene_channels[0]);
235+
break;
209236

210-
case (unsigned char)ENE_LED_CHANNEL_BACKPLATE:
211-
return(ene_channels[1]);
212-
break;
237+
case (unsigned char)ENE_LED_CHANNEL_BACKPLATE:
238+
return(ene_channels[1]);
239+
break;
213240

214-
case (unsigned char)ENE_LED_CHANNEL_BACK_IO:
215-
return(ene_channels[2]);
216-
break;
241+
case (unsigned char)ENE_LED_CHANNEL_BACK_IO:
242+
return(ene_channels[2]);
243+
break;
217244

218-
case (unsigned char)ENE_LED_CHANNEL_CENTER:
219-
return(ene_channels[3]);
220-
break;
245+
case (unsigned char)ENE_LED_CHANNEL_CENTER:
246+
return(ene_channels[3]);
247+
break;
221248

222-
case (unsigned char)ENE_LED_CHANNEL_CENTER_START:
223-
return(ene_channels[4]);
224-
break;
249+
case (unsigned char)ENE_LED_CHANNEL_CENTER_START:
250+
return(ene_channels[4]);
251+
break;
225252

226-
case (unsigned char)ENE_LED_CHANNEL_DRAM:
227-
case (unsigned char)ENE_LED_CHANNEL_DRAM_2:
228-
case (unsigned char)ENE_LED_CHANNEL_DRAM_3:
229-
return(ene_channels[5]);
230-
break;
253+
case (unsigned char)ENE_LED_CHANNEL_DRAM:
254+
case (unsigned char)ENE_LED_CHANNEL_DRAM_2:
255+
case (unsigned char)ENE_LED_CHANNEL_DRAM_3:
256+
return(ene_channels[5]);
257+
break;
231258

232-
case (unsigned char)ENE_LED_CHANNEL_PCIE:
233-
return(ene_channels[6]);
234-
break;
259+
case (unsigned char)ENE_LED_CHANNEL_PCIE:
260+
return(ene_channels[6]);
261+
break;
235262

236-
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER:
237-
return(ene_channels[7]);
238-
break;
263+
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER:
264+
return(ene_channels[7]);
265+
break;
239266

240-
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_2:
241-
return(ene_channels[8]);
242-
break;
267+
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_2:
268+
return(ene_channels[8]);
269+
break;
243270

244-
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_3:
245-
return(ene_channels[9]);
246-
break;
271+
case (unsigned char)ENE_LED_CHANNEL_RGB_HEADER_3:
272+
return(ene_channels[9]);
273+
break;
247274

248-
default:
249-
return(ene_channels[10]);
250-
break;
275+
default:
276+
return(ene_channels[11]);
277+
break;
278+
}
251279
}
252280
}
253281

Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,27 @@
1212

1313
typedef unsigned short ene_register;
1414
typedef unsigned char ene_dev_id;
15+
typedef unsigned int ene_interface_type;
16+
17+
/*-----------------------------------------*\
18+
| Known interface types |
19+
\*-----------------------------------------*/
20+
enum
21+
{
22+
ENE_INTERFACE_TYPE_I2C_SMBUS,
23+
ENE_INTERFACE_TYPE_SPECTRIX_S40G,
24+
ENE_INTERFACE_TYPE_ROG_ARION,
25+
};
1526

1627
class ENESMBusInterface
1728
{
1829
public:
19-
virtual ~ENESMBusInterface() = default;
30+
virtual ~ENESMBusInterface() = default;
2031

21-
virtual std::string GetLocation() = 0;
22-
virtual int GetMaxBlock() = 0;
23-
virtual unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg) = 0;
24-
virtual void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val) = 0;
25-
virtual void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz) = 0;
32+
virtual ene_interface_type GetInterfaceType() = 0;
33+
virtual std::string GetLocation() = 0;
34+
virtual int GetMaxBlock() = 0;
35+
virtual unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg) = 0;
36+
virtual void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val) = 0;
37+
virtual void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz) = 0;
2638
};
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*-----------------------------------------*\
2+
| ENESMBusInterface_ROGArion.cpp |
3+
| |
4+
| Code for ENE ASUS ROG Arion interface |
5+
| |
6+
| Adam Honse (CalcProgrammer1) 9/17/2023 |
7+
\*-----------------------------------------*/
8+
9+
#include "ENESMBusInterface_ROGArion.h"
10+
11+
ENESMBusInterface_ROGArion::ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path)
12+
{
13+
scsi_dev = dev_handle;
14+
path = dev_path;
15+
}
16+
17+
ENESMBusInterface_ROGArion::~ENESMBusInterface_ROGArion()
18+
{
19+
20+
}
21+
22+
ene_interface_type ENESMBusInterface_ROGArion::GetInterfaceType()
23+
{
24+
return(ENE_INTERFACE_TYPE_ROG_ARION);
25+
}
26+
27+
std::string ENESMBusInterface_ROGArion::GetLocation()
28+
{
29+
std::string str(path.begin(), path.end());
30+
return("SCSI: " + str);
31+
}
32+
33+
int ENESMBusInterface_ROGArion::GetMaxBlock()
34+
{
35+
return(24);
36+
}
37+
38+
unsigned char ENESMBusInterface_ROGArion::ENERegisterRead(ene_dev_id dev, ene_register reg)
39+
{
40+
/*-----------------------------------------------------------------------------*\
41+
| This interface does not support reading |
42+
\*-----------------------------------------------------------------------------*/
43+
return( 0 );
44+
}
45+
46+
void ENESMBusInterface_ROGArion::ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val)
47+
{
48+
SendPacket(reg, &val, sizeof(unsigned char));
49+
}
50+
51+
void ENESMBusInterface_ROGArion::ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz)
52+
{
53+
SendPacket(reg, data, sz);
54+
}
55+
56+
void ENESMBusInterface_ROGArion::SendPacket
57+
(
58+
ene_register reg,
59+
unsigned char * packet,
60+
unsigned char packet_sz
61+
)
62+
{
63+
/*-----------------------------------------------------------------------------*\
64+
| Create buffer to hold CDB |
65+
\*-----------------------------------------------------------------------------*/
66+
unsigned char cdb[16] = {0};
67+
cdb[0] = 0xEC;
68+
cdb[1] = 0x41;
69+
cdb[2] = 0x53;
70+
cdb[3] = ((reg >> 8) & 0x00FF);
71+
cdb[4] = ( reg & 0x00FF );
72+
cdb[5] = 0x00;
73+
cdb[6] = 0x00;
74+
cdb[7] = 0x00;
75+
cdb[8] = 0x00;
76+
cdb[9] = 0x00;
77+
cdb[10] = 0x00;
78+
cdb[11] = 0x00;
79+
cdb[12] = 0x00;
80+
cdb[13] = packet_sz;
81+
cdb[14] = 0x00;
82+
cdb[15] = 0x00;
83+
84+
/*-----------------------------------------------------------------------------*\
85+
| Create buffer to hold sense data |
86+
\*-----------------------------------------------------------------------------*/
87+
unsigned char sense[32] = {0};
88+
89+
/*-----------------------------------------------------------------------------*\
90+
| Write SCSI packet |
91+
\*-----------------------------------------------------------------------------*/
92+
scsi_write(scsi_dev, packet, packet_sz, cdb, 16, sense, 32);
93+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*-----------------------------------------*\
2+
| ENESMBusInterface_ROGArion.h |
3+
| |
4+
| Definitions and types for ENE ASUS ROG |
5+
| Arion interface |
6+
| |
7+
| Adam Honse (CalcProgrammer1) 9/17/2023 |
8+
\*-----------------------------------------*/
9+
10+
#pragma once
11+
12+
#include "ENESMBusInterface.h"
13+
#include "scsiapi.h"
14+
15+
class ENESMBusInterface_ROGArion : public ENESMBusInterface
16+
{
17+
public:
18+
ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path);
19+
~ENESMBusInterface_ROGArion();
20+
21+
ene_interface_type GetInterfaceType();
22+
std::string GetLocation();
23+
int GetMaxBlock();
24+
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
25+
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
26+
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
27+
28+
private:
29+
scsi_device* scsi_dev;
30+
std::string path;
31+
32+
void SendPacket
33+
(
34+
ene_register reg,
35+
unsigned char * packet,
36+
unsigned char packet_sz
37+
);
38+
};

Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ ENESMBusInterface_SpectrixS40G::~ENESMBusInterface_SpectrixS40G()
110110

111111
}
112112

113+
ene_interface_type ENESMBusInterface_SpectrixS40G::GetInterfaceType()
114+
{
115+
return(ENE_INTERFACE_TYPE_SPECTRIX_S40G);
116+
}
117+
113118
std::string ENESMBusInterface_SpectrixS40G::GetLocation()
114119
{
115120
return("NVMe: " + path);

0 commit comments

Comments
 (0)