Skip to content

Commit

Permalink
soundwire: extend SDW_SLAVE_ENTRY
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
plbossart authored and vinodkoul committed Jun 30, 2020
1 parent ee9173d commit b592426
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
13 changes: 9 additions & 4 deletions drivers/soundwire/bus_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)

for (id = drv->id_table; id && id->mfg_id; id++)
if (slave->id.mfg_id == id->mfg_id &&
slave->id.part_id == id->part_id)
slave->id.part_id == id->part_id &&
(!id->sdw_version ||
slave->id.sdw_version == id->sdw_version) &&
(!id->class_id ||
slave->id.class_id == id->class_id))
return id;

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

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

return snprintf(buf, size, "sdw:m%04Xp%04X\n",
slave->id.mfg_id, slave->id.part_id);
return snprintf(buf, size, "sdw:m%04Xp%04Xv%02Xc%02X\n",
slave->id.mfg_id, slave->id.part_id,
slave->id.sdw_version, slave->id.class_id);
}

int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env)
Expand Down
2 changes: 2 additions & 0 deletions include/linux/mod_devicetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ struct hda_device_id {
struct sdw_device_id {
__u16 mfg_id;
__u16 part_id;
__u8 sdw_version;
__u8 class_id;
kernel_ulong_t driver_data;
};

Expand Down
11 changes: 7 additions & 4 deletions include/linux/soundwire/sdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ int sdw_slave_read_prop(struct sdw_slave *slave);
* struct sdw_slave_id - Slave ID
* @mfg_id: MIPI Manufacturer ID
* @part_id: Device Part ID
* @class_id: MIPI Class ID, unused now.
* Currently a placeholder in MIPI SoundWire Spec
* @class_id: MIPI Class ID (defined starting with SoundWire 1.2 spec)
* @unique_id: Device unique ID
* @sdw_version: SDW version implemented
*
Expand Down Expand Up @@ -659,10 +658,14 @@ struct sdw_driver {
struct device_driver driver;
};

#define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \
{ .mfg_id = (_mfg_id), .part_id = (_part_id), \
#define SDW_SLAVE_ENTRY_EXT(_mfg_id, _part_id, _version, _c_id, _drv_data) \
{ .mfg_id = (_mfg_id), .part_id = (_part_id), \
.sdw_version = (_version), .class_id = (_c_id), \
.driver_data = (unsigned long)(_drv_data) }

#define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \
SDW_SLAVE_ENTRY_EXT((_mfg_id), (_part_id), 0, 0, (_drv_data))

int sdw_handle_slave_status(struct sdw_bus *bus,
enum sdw_slave_status status[]);

Expand Down
2 changes: 2 additions & 0 deletions scripts/mod/devicetable-offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ int main(void)
DEVID(sdw_device_id);
DEVID_FIELD(sdw_device_id, mfg_id);
DEVID_FIELD(sdw_device_id, part_id);
DEVID_FIELD(sdw_device_id, sdw_version);
DEVID_FIELD(sdw_device_id, class_id);

DEVID(fsl_mc_device_id);
DEVID_FIELD(fsl_mc_device_id, vendor);
Expand Down
6 changes: 5 additions & 1 deletion scripts/mod/file2alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,15 +1258,19 @@ static int do_hda_entry(const char *filename, void *symval, char *alias)
return 1;
}

/* Looks like: sdw:mNpN */
/* Looks like: sdw:mNpNvNcN */
static int do_sdw_entry(const char *filename, void *symval, char *alias)
{
DEF_FIELD(symval, sdw_device_id, mfg_id);
DEF_FIELD(symval, sdw_device_id, part_id);
DEF_FIELD(symval, sdw_device_id, sdw_version);
DEF_FIELD(symval, sdw_device_id, class_id);

strcpy(alias, "sdw:");
ADD(alias, "m", mfg_id != 0, mfg_id);
ADD(alias, "p", part_id != 0, part_id);
ADD(alias, "v", sdw_version != 0, sdw_version);
ADD(alias, "c", class_id != 0, class_id);

add_wildcard(alias);
return 1;
Expand Down

0 comments on commit b592426

Please sign in to comment.