Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: extend SDW_SLAVE_ENTRY

The SoundWire 1.2 specification adds new capabilities that were not
present in previous version, such as the class ID.

To enable support for class drivers, and well as drivers that address
a specific version, all fields of the sdw_device_id structure need to
be exposed. For SoundWire 1.0 and 1.1 devices, a wildcard is used so
class and version information are ignored.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20200608205436.2402-4-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Vinod Koul
b5924268 ee9173db

+25 -9
+9 -4
drivers/soundwire/bus_type.c
··· 24 24 25 25 for (id = drv->id_table; id && id->mfg_id; id++) 26 26 if (slave->id.mfg_id == id->mfg_id && 27 - slave->id.part_id == id->part_id) 27 + slave->id.part_id == id->part_id && 28 + (!id->sdw_version || 29 + slave->id.sdw_version == id->sdw_version) && 30 + (!id->class_id || 31 + slave->id.class_id == id->class_id)) 28 32 return id; 29 33 30 34 return NULL; ··· 51 47 52 48 int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) 53 49 { 54 - /* modalias is sdw:m<mfg_id>p<part_id> */ 50 + /* modalias is sdw:m<mfg_id>p<part_id>v<version>c<class_id> */ 55 51 56 - return snprintf(buf, size, "sdw:m%04Xp%04X\n", 57 - slave->id.mfg_id, slave->id.part_id); 52 + return snprintf(buf, size, "sdw:m%04Xp%04Xv%02Xc%02X\n", 53 + slave->id.mfg_id, slave->id.part_id, 54 + slave->id.sdw_version, slave->id.class_id); 58 55 } 59 56 60 57 int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env)
+2
include/linux/mod_devicetable.h
··· 251 251 struct sdw_device_id { 252 252 __u16 mfg_id; 253 253 __u16 part_id; 254 + __u8 sdw_version; 255 + __u8 class_id; 254 256 kernel_ulong_t driver_data; 255 257 }; 256 258
+7 -4
include/linux/soundwire/sdw.h
··· 426 426 * struct sdw_slave_id - Slave ID 427 427 * @mfg_id: MIPI Manufacturer ID 428 428 * @part_id: Device Part ID 429 - * @class_id: MIPI Class ID, unused now. 430 - * Currently a placeholder in MIPI SoundWire Spec 429 + * @class_id: MIPI Class ID (defined starting with SoundWire 1.2 spec) 431 430 * @unique_id: Device unique ID 432 431 * @sdw_version: SDW version implemented 433 432 * ··· 658 659 struct device_driver driver; 659 660 }; 660 661 661 - #define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \ 662 - { .mfg_id = (_mfg_id), .part_id = (_part_id), \ 662 + #define SDW_SLAVE_ENTRY_EXT(_mfg_id, _part_id, _version, _c_id, _drv_data) \ 663 + { .mfg_id = (_mfg_id), .part_id = (_part_id), \ 664 + .sdw_version = (_version), .class_id = (_c_id), \ 663 665 .driver_data = (unsigned long)(_drv_data) } 666 + 667 + #define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \ 668 + SDW_SLAVE_ENTRY_EXT((_mfg_id), (_part_id), 0, 0, (_drv_data)) 664 669 665 670 int sdw_handle_slave_status(struct sdw_bus *bus, 666 671 enum sdw_slave_status status[]);
+2
scripts/mod/devicetable-offsets.c
··· 216 216 DEVID(sdw_device_id); 217 217 DEVID_FIELD(sdw_device_id, mfg_id); 218 218 DEVID_FIELD(sdw_device_id, part_id); 219 + DEVID_FIELD(sdw_device_id, sdw_version); 220 + DEVID_FIELD(sdw_device_id, class_id); 219 221 220 222 DEVID(fsl_mc_device_id); 221 223 DEVID_FIELD(fsl_mc_device_id, vendor);
+5 -1
scripts/mod/file2alias.c
··· 1258 1258 return 1; 1259 1259 } 1260 1260 1261 - /* Looks like: sdw:mNpN */ 1261 + /* Looks like: sdw:mNpNvNcN */ 1262 1262 static int do_sdw_entry(const char *filename, void *symval, char *alias) 1263 1263 { 1264 1264 DEF_FIELD(symval, sdw_device_id, mfg_id); 1265 1265 DEF_FIELD(symval, sdw_device_id, part_id); 1266 + DEF_FIELD(symval, sdw_device_id, sdw_version); 1267 + DEF_FIELD(symval, sdw_device_id, class_id); 1266 1268 1267 1269 strcpy(alias, "sdw:"); 1268 1270 ADD(alias, "m", mfg_id != 0, mfg_id); 1269 1271 ADD(alias, "p", part_id != 0, part_id); 1272 + ADD(alias, "v", sdw_version != 0, sdw_version); 1273 + ADD(alias, "c", class_id != 0, class_id); 1270 1274 1271 1275 add_wildcard(alias); 1272 1276 return 1;