Skip to content

Commit 85926f8

Browse files
jpirkodavem330
authored andcommitted
mlxsw: reg: Add definition of temperature management registers
Add definition of MTCAP and MTMP registers which provide access to temperature sensors. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3a66ee3 commit 85926f8

File tree

1 file changed

+111
-0
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+111
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,113 @@ static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id)
20872087
mlxsw_reg_hpkt_ctrl_set(payload, MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT);
20882088
}
20892089

2090+
/* MTCAP - Management Temperature Capabilities
2091+
* -------------------------------------------
2092+
* This register exposes the capabilities of the device and
2093+
* system temperature sensing.
2094+
*/
2095+
#define MLXSW_REG_MTCAP_ID 0x9009
2096+
#define MLXSW_REG_MTCAP_LEN 0x08
2097+
2098+
static const struct mlxsw_reg_info mlxsw_reg_mtcap = {
2099+
.id = MLXSW_REG_MTCAP_ID,
2100+
.len = MLXSW_REG_MTCAP_LEN,
2101+
};
2102+
2103+
/* reg_mtcap_sensor_count
2104+
* Number of sensors supported by the device.
2105+
* This includes the QSFP module sensors (if exists in the QSFP module).
2106+
* Access: RO
2107+
*/
2108+
MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
2109+
2110+
/* MTMP - Management Temperature
2111+
* -----------------------------
2112+
* This register controls the settings of the temperature measurements
2113+
* and enables reading the temperature measurements. Note that temperature
2114+
* is in 0.125 degrees Celsius.
2115+
*/
2116+
#define MLXSW_REG_MTMP_ID 0x900A
2117+
#define MLXSW_REG_MTMP_LEN 0x20
2118+
2119+
static const struct mlxsw_reg_info mlxsw_reg_mtmp = {
2120+
.id = MLXSW_REG_MTMP_ID,
2121+
.len = MLXSW_REG_MTMP_LEN,
2122+
};
2123+
2124+
/* reg_mtmp_sensor_index
2125+
* Sensors index to access.
2126+
* 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
2127+
* (module 0 is mapped to sensor_index 64).
2128+
* Access: Index
2129+
*/
2130+
MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
2131+
2132+
/* Convert to milli degrees Celsius */
2133+
#define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
2134+
2135+
/* reg_mtmp_temperature
2136+
* Temperature reading from the sensor. Reading is in 0.125 Celsius
2137+
* degrees units.
2138+
* Access: RO
2139+
*/
2140+
MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
2141+
2142+
/* reg_mtmp_mte
2143+
* Max Temperature Enable - enables measuring the max temperature on a sensor.
2144+
* Access: RW
2145+
*/
2146+
MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
2147+
2148+
/* reg_mtmp_mtr
2149+
* Max Temperature Reset - clears the value of the max temperature register.
2150+
* Access: WO
2151+
*/
2152+
MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
2153+
2154+
/* reg_mtmp_max_temperature
2155+
* The highest measured temperature from the sensor.
2156+
* When the bit mte is cleared, the field max_temperature is reserved.
2157+
* Access: RO
2158+
*/
2159+
MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
2160+
2161+
#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
2162+
2163+
/* reg_mtmp_sensor_name
2164+
* Sensor Name
2165+
* Access: RO
2166+
*/
2167+
MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
2168+
2169+
static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
2170+
bool max_temp_enable,
2171+
bool max_temp_reset)
2172+
{
2173+
MLXSW_REG_ZERO(mtmp, payload);
2174+
mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
2175+
mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
2176+
mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
2177+
}
2178+
2179+
static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
2180+
unsigned int *p_max_temp,
2181+
char *sensor_name)
2182+
{
2183+
u16 temp;
2184+
2185+
if (p_temp) {
2186+
temp = mlxsw_reg_mtmp_temperature_get(payload);
2187+
*p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
2188+
}
2189+
if (p_max_temp) {
2190+
temp = mlxsw_reg_mtmp_temperature_get(payload);
2191+
*p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
2192+
}
2193+
if (sensor_name)
2194+
mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
2195+
}
2196+
20902197
/* MLCR - Management LED Control Register
20912198
* --------------------------------------
20922199
* Controls the system LEDs.
@@ -2449,6 +2556,10 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
24492556
return "HTGT";
24502557
case MLXSW_REG_HPKT_ID:
24512558
return "HPKT";
2559+
case MLXSW_REG_MTCAP_ID:
2560+
return "MTCAP";
2561+
case MLXSW_REG_MTMP_ID:
2562+
return "MTMP";
24522563
case MLXSW_REG_MLCR_ID:
24532564
return "MLCR";
24542565
case MLXSW_REG_SBPR_ID:

0 commit comments

Comments
 (0)