@@ -219,6 +219,21 @@ struct dvfs_set {
219
219
u8 index ;
220
220
} __packed ;
221
221
222
+ struct sensor_capabilities {
223
+ __le16 sensors ;
224
+ } __packed ;
225
+
226
+ struct _scpi_sensor_info {
227
+ __le16 sensor_id ;
228
+ u8 class ;
229
+ u8 trigger_type ;
230
+ char name [20 ];
231
+ };
232
+
233
+ struct sensor_value {
234
+ __le32 val ;
235
+ } __packed ;
236
+
222
237
static struct scpi_drvinfo * scpi_info ;
223
238
224
239
static int scpi_linux_errmap [SCPI_ERR_MAX ] = {
@@ -481,6 +496,48 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)
481
496
return info ;
482
497
}
483
498
499
+ static int scpi_sensor_get_capability (u16 * sensors )
500
+ {
501
+ struct sensor_capabilities cap_buf ;
502
+ int ret ;
503
+
504
+ ret = scpi_send_message (SCPI_CMD_SENSOR_CAPABILITIES , NULL , 0 , & cap_buf ,
505
+ sizeof (cap_buf ));
506
+ if (!ret )
507
+ * sensors = le16_to_cpu (cap_buf .sensors );
508
+
509
+ return ret ;
510
+ }
511
+
512
+ static int scpi_sensor_get_info (u16 sensor_id , struct scpi_sensor_info * info )
513
+ {
514
+ __le16 id = cpu_to_le16 (sensor_id );
515
+ struct _scpi_sensor_info _info ;
516
+ int ret ;
517
+
518
+ ret = scpi_send_message (SCPI_CMD_SENSOR_INFO , & id , sizeof (id ),
519
+ & _info , sizeof (_info ));
520
+ if (!ret ) {
521
+ memcpy (info , & _info , sizeof (* info ));
522
+ info -> sensor_id = le16_to_cpu (_info .sensor_id );
523
+ }
524
+
525
+ return ret ;
526
+ }
527
+
528
+ int scpi_sensor_get_value (u16 sensor , u32 * val )
529
+ {
530
+ struct sensor_value buf ;
531
+ int ret ;
532
+
533
+ ret = scpi_send_message (SCPI_CMD_SENSOR_VALUE , & sensor , sizeof (sensor ),
534
+ & buf , sizeof (buf ));
535
+ if (!ret )
536
+ * val = le32_to_cpu (buf .val );
537
+
538
+ return ret ;
539
+ }
540
+
484
541
static struct scpi_ops scpi_ops = {
485
542
.get_version = scpi_get_version ,
486
543
.clk_get_range = scpi_clk_get_range ,
@@ -489,6 +546,9 @@ static struct scpi_ops scpi_ops = {
489
546
.dvfs_get_idx = scpi_dvfs_get_idx ,
490
547
.dvfs_set_idx = scpi_dvfs_set_idx ,
491
548
.dvfs_get_info = scpi_dvfs_get_info ,
549
+ .sensor_get_capability = scpi_sensor_get_capability ,
550
+ .sensor_get_info = scpi_sensor_get_info ,
551
+ .sensor_get_value = scpi_sensor_get_value ,
492
552
};
493
553
494
554
struct scpi_ops * get_scpi_ops (void )
0 commit comments