@@ -285,6 +285,14 @@ enum as7326_56x_cpld_sysfs_attributes {
285
285
TRANSCEIVER_TXFAULT_ATTR_ID (48 ),
286
286
TRANSCEIVER_TXFAULT_ATTR_ID (57 ),
287
287
TRANSCEIVER_TXFAULT_ATTR_ID (58 ),
288
+ TRANSCEIVER_RESET_ATTR_ID (49 ),
289
+ TRANSCEIVER_RESET_ATTR_ID (50 ),
290
+ TRANSCEIVER_RESET_ATTR_ID (51 ),
291
+ TRANSCEIVER_RESET_ATTR_ID (52 ),
292
+ TRANSCEIVER_RESET_ATTR_ID (53 ),
293
+ TRANSCEIVER_RESET_ATTR_ID (54 ),
294
+ TRANSCEIVER_RESET_ATTR_ID (55 ),
295
+ TRANSCEIVER_RESET_ATTR_ID (56 ),
288
296
};
289
297
290
298
/* sysfs attributes for hwmon
@@ -297,6 +305,8 @@ static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da,
297
305
char * buf );
298
306
static ssize_t set_tx_disable (struct device * dev , struct device_attribute * da ,
299
307
const char * buf , size_t count );
308
+ static ssize_t set_reset (struct device * dev , struct device_attribute * da ,
309
+ const char * buf , size_t count );
300
310
static ssize_t access (struct device * dev , struct device_attribute * da ,
301
311
const char * buf , size_t count );
302
312
static ssize_t show_version (struct device * dev , struct device_attribute * da ,
@@ -437,6 +447,15 @@ DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48);
437
447
DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR (57 );
438
448
DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR (58 );
439
449
450
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (49 );
451
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (50 );
452
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (51 );
453
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (52 );
454
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (53 );
455
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (54 );
456
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (55 );
457
+ DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR (56 );
458
+
440
459
static struct attribute * as7326_56x_cpld3_attributes [] = {
441
460
& sensor_dev_attr_version .dev_attr .attr ,
442
461
& sensor_dev_attr_access .dev_attr .attr ,
@@ -507,7 +526,7 @@ static struct attribute *as7326_56x_cpld2_attributes[] = {
507
526
DECLARE_SFP_TRANSCEIVER_ATTR (22 ),
508
527
DECLARE_SFP_TRANSCEIVER_ATTR (23 ),
509
528
DECLARE_SFP_TRANSCEIVER_ATTR (24 ),
510
- DECLARE_SFP_TRANSCEIVER_ATTR (25 ),
529
+ DECLARE_SFP_TRANSCEIVER_ATTR (25 ),
511
530
DECLARE_SFP_TRANSCEIVER_ATTR (26 ),
512
531
DECLARE_SFP_TRANSCEIVER_ATTR (27 ),
513
532
DECLARE_SFP_TRANSCEIVER_ATTR (28 ),
@@ -574,6 +593,14 @@ static struct attribute *as7326_56x_cpld1_attributes[] = {
574
593
DECLARE_SFP_TRANSCEIVER_ATTR (48 ),
575
594
DECLARE_SFP_TRANSCEIVER_ATTR (57 ),
576
595
DECLARE_SFP_TRANSCEIVER_ATTR (58 ),
596
+ DECLARE_TRANSCEIVER_RESET_ATTR (49 ),
597
+ DECLARE_TRANSCEIVER_RESET_ATTR (50 ),
598
+ DECLARE_TRANSCEIVER_RESET_ATTR (51 ),
599
+ DECLARE_TRANSCEIVER_RESET_ATTR (52 ),
600
+ DECLARE_TRANSCEIVER_RESET_ATTR (53 ),
601
+ DECLARE_TRANSCEIVER_RESET_ATTR (54 ),
602
+ DECLARE_TRANSCEIVER_RESET_ATTR (55 ),
603
+ DECLARE_TRANSCEIVER_RESET_ATTR (56 ),
577
604
NULL
578
605
};
579
606
@@ -724,6 +751,11 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da,
724
751
reg = 0x19 ;
725
752
mask = 0x1 << (( attr -> index - MODULE_RXLOS_57 )+ 2 );
726
753
break ;
754
+ case MODULE_RESET_49 ... MODULE_RESET_56 :
755
+ reg = 0x4 ;
756
+ mask = 0x1 << (attr -> index - MODULE_RESET_49 );
757
+ revert = 1 ;
758
+ break ;
727
759
default :
728
760
return 0 ;
729
761
}
@@ -806,6 +838,59 @@ static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da,
806
838
return status ;
807
839
}
808
840
841
+ static ssize_t set_reset (struct device * dev , struct device_attribute * da ,
842
+ const char * buf , size_t count )
843
+ {
844
+ struct sensor_device_attribute * attr = to_sensor_dev_attr (da );
845
+ struct i2c_client * client = to_i2c_client (dev );
846
+ struct as7326_56x_cpld_data * data = i2c_get_clientdata (client );
847
+ long reset ;
848
+ int status ;
849
+ u8 reg = 0 , mask = 0 ;
850
+
851
+ status = kstrtol (buf , 10 , & reset );
852
+ if (status ) {
853
+ return status ;
854
+ }
855
+
856
+ switch (attr -> index )
857
+ {
858
+ case MODULE_RESET_49 ... MODULE_RESET_56 :
859
+ reg = 0x4 ;
860
+ mask = 0x1 << (attr -> index - MODULE_RESET_49 );
861
+ break ;
862
+ default :
863
+ return 0 ;
864
+ }
865
+
866
+ /* Read current status */
867
+ mutex_lock (& data -> update_lock );
868
+ status = as7326_56x_cpld_read_internal (client , reg );
869
+ if (unlikely (status < 0 )) {
870
+ goto exit ;
871
+ }
872
+
873
+ /* Update reset status */
874
+ if (!reset ) {
875
+ status |= mask ;
876
+ }
877
+ else {
878
+ status &= ~mask ;
879
+ }
880
+
881
+ status = as7326_56x_cpld_write_internal (client , reg , status );
882
+ if (unlikely (status < 0 )) {
883
+ goto exit ;
884
+ }
885
+
886
+ mutex_unlock (& data -> update_lock );
887
+ return count ;
888
+
889
+ exit :
890
+ mutex_unlock (& data -> update_lock );
891
+ return status ;
892
+ }
893
+
809
894
static ssize_t access (struct device * dev , struct device_attribute * da ,
810
895
const char * buf , size_t count )
811
896
{
0 commit comments