@@ -366,6 +366,44 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
366
366
return 0 ;
367
367
}
368
368
369
+ /*
370
+ * In MIPI DisCo spec for SoundWire, lane mapping for a slave device is done with
371
+ * mipi-sdw-lane-x-mapping properties, where x is 1..7, and the values for those
372
+ * properties are mipi-sdw-manager-lane-x or mipi-sdw-peripheral-link-y, where x
373
+ * is an integer between 1 to 7 if the lane is connected to a manager lane, y is a
374
+ * character between A to E if the lane is connected to another peripheral lane.
375
+ */
376
+ int sdw_slave_read_lane_mapping (struct sdw_slave * slave )
377
+ {
378
+ struct sdw_slave_prop * prop = & slave -> prop ;
379
+ struct device * dev = & slave -> dev ;
380
+ char prop_name [30 ];
381
+ const char * prop_val ;
382
+ size_t len ;
383
+ int ret , i ;
384
+ u8 lane ;
385
+
386
+ for (i = 0 ; i < SDW_MAX_LANES ; i ++ ) {
387
+ snprintf (prop_name , sizeof (prop_name ), "mipi-sdw-lane-%d-mapping" , i );
388
+ ret = device_property_read_string (dev , prop_name , & prop_val );
389
+ if (ret )
390
+ continue ;
391
+
392
+ len = strlen (prop_val );
393
+ if (len < 1 )
394
+ return - EINVAL ;
395
+
396
+ /* The last character is enough to identify the connection */
397
+ ret = kstrtou8 (& prop_val [len - 1 ], 10 , & lane );
398
+ if (ret )
399
+ return ret ;
400
+ if (in_range (lane , 1 , SDW_MAX_LANES - 1 ))
401
+ prop -> lane_maps [i ] = lane ;
402
+ }
403
+ return 0 ;
404
+ }
405
+ EXPORT_SYMBOL (sdw_slave_read_lane_mapping );
406
+
369
407
/**
370
408
* sdw_slave_read_prop() - Read Slave properties
371
409
* @slave: SDW Slave
@@ -486,6 +524,6 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
486
524
sdw_slave_read_dpn (slave , prop -> sink_dpn_prop , nval ,
487
525
prop -> sink_ports , "sink" );
488
526
489
- return 0 ;
527
+ return sdw_slave_read_lane_mapping ( slave ) ;
490
528
}
491
529
EXPORT_SYMBOL (sdw_slave_read_prop );
0 commit comments