@@ -50,6 +50,7 @@ struct mlxsw_hwmon_dev {
50
50
unsigned int attrs_count ;
51
51
u8 sensor_count ;
52
52
u8 module_sensor_max ;
53
+ u8 slot_index ;
53
54
};
54
55
55
56
struct mlxsw_hwmon {
@@ -72,7 +73,8 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
72
73
73
74
index = mlxsw_hwmon_get_attr_index (mlxsw_hwmon_attr -> type_index ,
74
75
mlxsw_hwmon_dev -> module_sensor_max );
75
- mlxsw_reg_mtmp_pack (mtmp_pl , 0 , index , false, false);
76
+ mlxsw_reg_mtmp_pack (mtmp_pl , mlxsw_hwmon_dev -> slot_index , index , false,
77
+ false);
76
78
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mtmp ), mtmp_pl );
77
79
if (err ) {
78
80
dev_err (mlxsw_hwmon -> bus_info -> dev , "Failed to query temp sensor\n" );
@@ -96,7 +98,8 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
96
98
97
99
index = mlxsw_hwmon_get_attr_index (mlxsw_hwmon_attr -> type_index ,
98
100
mlxsw_hwmon_dev -> module_sensor_max );
99
- mlxsw_reg_mtmp_pack (mtmp_pl , 0 , index , false, false);
101
+ mlxsw_reg_mtmp_pack (mtmp_pl , mlxsw_hwmon_dev -> slot_index , index , false,
102
+ false);
100
103
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mtmp ), mtmp_pl );
101
104
if (err ) {
102
105
dev_err (mlxsw_hwmon -> bus_info -> dev , "Failed to query temp sensor\n" );
@@ -128,6 +131,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
128
131
index = mlxsw_hwmon_get_attr_index (mlxsw_hwmon_attr -> type_index ,
129
132
mlxsw_hwmon_dev -> module_sensor_max );
130
133
134
+ mlxsw_reg_mtmp_slot_index_set (mtmp_pl , mlxsw_hwmon_dev -> slot_index );
131
135
mlxsw_reg_mtmp_sensor_index_set (mtmp_pl , index );
132
136
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mtmp ), mtmp_pl );
133
137
if (err )
@@ -245,7 +249,7 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
245
249
int err ;
246
250
247
251
module = mlxsw_hwmon_attr -> type_index - mlxsw_hwmon_dev -> sensor_count ;
248
- mlxsw_reg_mtmp_pack (mtmp_pl , 0 ,
252
+ mlxsw_reg_mtmp_pack (mtmp_pl , mlxsw_hwmon_dev -> slot_index ,
249
253
MLXSW_REG_MTMP_MODULE_INDEX_MIN + module , false,
250
254
false);
251
255
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mtmp ), mtmp_pl );
@@ -285,8 +289,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
285
289
int err ;
286
290
287
291
module = mlxsw_hwmon_attr -> type_index - mlxsw_hwmon_dev -> sensor_count ;
288
- mlxsw_reg_mtbr_pack (mtbr_pl , 0 , MLXSW_REG_MTBR_BASE_MODULE_INDEX + module ,
289
- 1 );
292
+ mlxsw_reg_mtbr_pack (mtbr_pl , mlxsw_hwmon_dev -> slot_index ,
293
+ MLXSW_REG_MTBR_BASE_MODULE_INDEX + module , 1 );
290
294
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mtbr ), mtbr_pl );
291
295
if (err ) {
292
296
dev_err (dev , "Failed to query module temperature sensor\n" );
@@ -326,7 +330,8 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev,
326
330
int err ;
327
331
328
332
module = mlxsw_hwmon_attr -> type_index - mlxsw_hwmon_dev -> sensor_count ;
329
- err = mlxsw_env_module_temp_thresholds_get (mlxsw_hwmon -> core , 0 ,
333
+ err = mlxsw_env_module_temp_thresholds_get (mlxsw_hwmon -> core ,
334
+ mlxsw_hwmon_dev -> slot_index ,
330
335
module , SFP_TEMP_HIGH_WARN ,
331
336
p_temp );
332
337
if (err ) {
@@ -362,7 +367,8 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev,
362
367
int err ;
363
368
364
369
module = mlxsw_hwmon_attr -> type_index - mlxsw_hwmon_dev -> sensor_count ;
365
- err = mlxsw_env_module_temp_thresholds_get (mlxsw_hwmon -> core , 0 ,
370
+ err = mlxsw_env_module_temp_thresholds_get (mlxsw_hwmon -> core ,
371
+ mlxsw_hwmon_dev -> slot_index ,
366
372
module , SFP_TEMP_HIGH_ALARM ,
367
373
p_temp );
368
374
if (err ) {
@@ -609,6 +615,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
609
615
for (i = 0 ; i < mlxsw_hwmon_dev -> sensor_count ; i ++ ) {
610
616
char mtmp_pl [MLXSW_REG_MTMP_LEN ] = {0 };
611
617
618
+ mlxsw_reg_mtmp_slot_index_set (mtmp_pl ,
619
+ mlxsw_hwmon_dev -> slot_index );
612
620
mlxsw_reg_mtmp_sensor_index_set (mtmp_pl , i );
613
621
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mtmp ),
614
622
mtmp_pl );
@@ -678,7 +686,7 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
678
686
u8 module_sensor_max ;
679
687
int i , err ;
680
688
681
- mlxsw_reg_mgpir_pack (mgpir_pl , 0 );
689
+ mlxsw_reg_mgpir_pack (mgpir_pl , mlxsw_hwmon_dev -> slot_index );
682
690
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mgpir ), mgpir_pl );
683
691
if (err )
684
692
return err ;
@@ -730,7 +738,7 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
730
738
u8 gbox_num ;
731
739
int err ;
732
740
733
- mlxsw_reg_mgpir_pack (mgpir_pl , 0 );
741
+ mlxsw_reg_mgpir_pack (mgpir_pl , mlxsw_hwmon_dev -> slot_index );
734
742
err = mlxsw_reg_query (mlxsw_hwmon -> core , MLXSW_REG (mgpir ), mgpir_pl );
735
743
if (err )
736
744
return err ;
@@ -746,7 +754,8 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
746
754
while (index < max_index ) {
747
755
sensor_index = index % mlxsw_hwmon_dev -> module_sensor_max +
748
756
MLXSW_REG_MTMP_GBOX_INDEX_MIN ;
749
- mlxsw_reg_mtmp_pack (mtmp_pl , 0 , sensor_index , true, true);
757
+ mlxsw_reg_mtmp_pack (mtmp_pl , mlxsw_hwmon_dev -> slot_index ,
758
+ sensor_index , true, true);
750
759
err = mlxsw_reg_write (mlxsw_hwmon -> core ,
751
760
MLXSW_REG (mtmp ), mtmp_pl );
752
761
if (err ) {
@@ -797,6 +806,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
797
806
mlxsw_hwmon -> core = mlxsw_core ;
798
807
mlxsw_hwmon -> bus_info = mlxsw_bus_info ;
799
808
mlxsw_hwmon -> line_cards [0 ].hwmon = mlxsw_hwmon ;
809
+ mlxsw_hwmon -> line_cards [0 ].slot_index = 0 ;
800
810
801
811
err = mlxsw_hwmon_temp_init (& mlxsw_hwmon -> line_cards [0 ]);
802
812
if (err )
0 commit comments