Skip to content

Commit b592426

Browse files
plbossartvinodkoul
authored andcommitted
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>
1 parent ee9173d commit b592426

5 files changed

Lines changed: 25 additions & 9 deletions

File tree

‎drivers/soundwire/bus_type.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)
2424

2525
for (id = drv->id_table; id && id->mfg_id; id++)
2626
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))
2832
return id;
2933

3034
return NULL;
@@ -47,10 +51,11 @@ static int sdw_bus_match(struct device *dev, struct device_driver *ddrv)
4751

4852
int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size)
4953
{
50-
/* modalias is sdw:m<mfg_id>p<part_id> */
54+
/* modalias is sdw:m<mfg_id>p<part_id>v<version>c<class_id> */
5155

52-
return snprintf(buf, size, "sdw:m%04Xp%04X\n",
53-
slave->id.mfg_id, slave->id.part_id);
56+
return snprintf(buf, size, "sdw:m%04Xp%04Xv%02Xc%02X\n",
57+
slave->id.mfg_id, slave->id.part_id,
58+
slave->id.sdw_version, slave->id.class_id);
5459
}
5560

5661
int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env)

‎include/linux/mod_devicetable.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ struct hda_device_id {
251251
struct sdw_device_id {
252252
__u16 mfg_id;
253253
__u16 part_id;
254+
__u8 sdw_version;
255+
__u8 class_id;
254256
kernel_ulong_t driver_data;
255257
};
256258

‎include/linux/soundwire/sdw.h‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ int sdw_slave_read_prop(struct sdw_slave *slave);
426426
* struct sdw_slave_id - Slave ID
427427
* @mfg_id: MIPI Manufacturer ID
428428
* @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)
431430
* @unique_id: Device unique ID
432431
* @sdw_version: SDW version implemented
433432
*
@@ -659,10 +658,14 @@ struct sdw_driver {
659658
struct device_driver driver;
660659
};
661660

662-
#define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \
663-
{ .mfg_id = (_mfg_id), .part_id = (_part_id), \
661+
#define SDW_SLAVE_ENTRY_EXT(_mfg_id, _part_id, _version, _c_id, _drv_data) \
662+
{ .mfg_id = (_mfg_id), .part_id = (_part_id), \
663+
.sdw_version = (_version), .class_id = (_c_id), \
664664
.driver_data = (unsigned long)(_drv_data) }
665665

666+
#define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \
667+
SDW_SLAVE_ENTRY_EXT((_mfg_id), (_part_id), 0, 0, (_drv_data))
668+
666669
int sdw_handle_slave_status(struct sdw_bus *bus,
667670
enum sdw_slave_status status[]);
668671

‎scripts/mod/devicetable-offsets.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ int main(void)
216216
DEVID(sdw_device_id);
217217
DEVID_FIELD(sdw_device_id, mfg_id);
218218
DEVID_FIELD(sdw_device_id, part_id);
219+
DEVID_FIELD(sdw_device_id, sdw_version);
220+
DEVID_FIELD(sdw_device_id, class_id);
219221

220222
DEVID(fsl_mc_device_id);
221223
DEVID_FIELD(fsl_mc_device_id, vendor);

‎scripts/mod/file2alias.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,15 +1258,19 @@ static int do_hda_entry(const char *filename, void *symval, char *alias)
12581258
return 1;
12591259
}
12601260

1261-
/* Looks like: sdw:mNpN */
1261+
/* Looks like: sdw:mNpNvNcN */
12621262
static int do_sdw_entry(const char *filename, void *symval, char *alias)
12631263
{
12641264
DEF_FIELD(symval, sdw_device_id, mfg_id);
12651265
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);
12661268

12671269
strcpy(alias, "sdw:");
12681270
ADD(alias, "m", mfg_id != 0, mfg_id);
12691271
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);
12701274

12711275
add_wildcard(alias);
12721276
return 1;

0 commit comments

Comments
 (0)