soundwire: Add support to use group id for slave devices
Devices with the same group id or broadcast command can be configured simultaneously. This will help improve the latency during device configuration. Add support to use group id for slave device configuration. Change-Id: I5e86e61a0b5223de6c6471f3f342fe1f387d81ef Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
This commit is contained in:
parent
f95641a7b7
commit
7b9c5205f5
2 changed files with 56 additions and 0 deletions
|
@ -476,6 +476,15 @@ int swr_bulk_write(struct swr_device *dev, u8 dev_num, void *reg,
|
|||
return -EINVAL;
|
||||
|
||||
master = dev->master;
|
||||
if (dev->group_id) {
|
||||
if (master->gr_sid != dev_num) {
|
||||
if (!master->gr_sid)
|
||||
master->gr_sid = dev_num;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
dev_num = dev->group_id;
|
||||
}
|
||||
if (master->bulk_write)
|
||||
return master->bulk_write(master, dev_num, reg, buf, len);
|
||||
|
||||
|
@ -499,6 +508,16 @@ int swr_write(struct swr_device *dev, u8 dev_num, u16 reg_addr,
|
|||
struct swr_master *master = dev->master;
|
||||
if (!master)
|
||||
return -EINVAL;
|
||||
|
||||
if (dev->group_id) {
|
||||
if (master->gr_sid != dev_num) {
|
||||
if (!master->gr_sid)
|
||||
master->gr_sid = dev_num;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
dev_num = dev->group_id;
|
||||
}
|
||||
return master->write(master, dev_num, reg_addr, buf);
|
||||
}
|
||||
EXPORT_SYMBOL(swr_write);
|
||||
|
@ -588,6 +607,29 @@ int swr_reset_device(struct swr_device *swr_dev)
|
|||
}
|
||||
EXPORT_SYMBOL(swr_reset_device);
|
||||
|
||||
/**
|
||||
* swr_set_device_group - Assign group id to the slave devices
|
||||
* @swr_dev: pointer to soundwire slave device
|
||||
* @id: group id to be assigned to slave device
|
||||
* Context: can sleep
|
||||
*
|
||||
* This API will be called either from soundwire master or slave
|
||||
* device to assign group id.
|
||||
*/
|
||||
int swr_set_device_group(struct swr_device *swr_dev, u8 id)
|
||||
{
|
||||
struct swr_master *master = swr_dev->master;
|
||||
|
||||
if (!swr_dev)
|
||||
return -EINVAL;
|
||||
swr_dev->group_id = id;
|
||||
if (!id && master)
|
||||
master->gr_sid = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(swr_set_device_group);
|
||||
|
||||
static int swr_drv_probe(struct device *dev)
|
||||
{
|
||||
const struct swr_driver *sdrv = to_swr_driver(dev->driver);
|
||||
|
|
|
@ -29,6 +29,14 @@ extern struct bus_type soundwire_type;
|
|||
*/
|
||||
#define SWR_MAX_MSTR_PORT_NUM (SWR_MAX_DEV_NUM * SWR_MAX_DEV_PORT_NUM)
|
||||
|
||||
/* Indicates soundwire devices group information */
|
||||
enum {
|
||||
SWR_GROUP_NONE = 0,
|
||||
SWR_GROUP_12 = 12,
|
||||
SWR_GROUP_13 = 13,
|
||||
SWR_BROADCAST = 15,
|
||||
};
|
||||
|
||||
/*
|
||||
* struct swr_port_info - represent soundwire frame shape
|
||||
* @dev_id: logical device number of the soundwire slave device
|
||||
|
@ -112,6 +120,7 @@ struct swr_reg {
|
|||
* @last_tid: size of table port_txn (can't grow beyond 256 since
|
||||
* tid is 8 bits)
|
||||
* @num_port: number of active ports on soundwire master
|
||||
* @gr_sid: slave id used by the group for write operations
|
||||
* @connect_port: callback for configuration of soundwire port(s)
|
||||
* @disconnect_port: callback for disable of soundwire port(s)
|
||||
* @read: callback for soundwire slave register read
|
||||
|
@ -131,6 +140,7 @@ struct swr_master {
|
|||
u8 last_tid;
|
||||
u8 num_port;
|
||||
u8 num_dev;
|
||||
u8 gr_sid;
|
||||
int (*connect_port)(struct swr_master *mstr, struct swr_params *txn);
|
||||
int (*disconnect_port)(struct swr_master *mstr, struct swr_params *txn);
|
||||
int (*read)(struct swr_master *mstr, u8 dev_num, u16 reg_addr,
|
||||
|
@ -159,6 +169,7 @@ static inline struct swr_master *to_swr_master(struct device *dev)
|
|||
* @dev: driver model representation of the device
|
||||
* @addr: represents "ea-addr" which is unique-id of soundwire slave
|
||||
* device
|
||||
* @group_id: group id supported by the slave device
|
||||
*/
|
||||
struct swr_device {
|
||||
char name[SOUNDWIRE_NAME_SIZE];
|
||||
|
@ -168,6 +179,7 @@ struct swr_device {
|
|||
u8 dev_num;
|
||||
struct device dev;
|
||||
unsigned long addr;
|
||||
u8 group_id;
|
||||
};
|
||||
|
||||
static inline struct swr_device *to_swr_device(struct device *dev)
|
||||
|
@ -270,6 +282,8 @@ extern int swr_connect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
|
|||
extern int swr_disconnect_port(struct swr_device *dev,
|
||||
u8 *port_id, u8 num_port);
|
||||
|
||||
extern int swr_set_device_group(struct swr_device *swr_dev, u8 id);
|
||||
|
||||
extern int swr_driver_register(struct swr_driver *drv);
|
||||
|
||||
extern void swr_driver_unregister(struct swr_driver *drv);
|
||||
|
|
Loading…
Add table
Reference in a new issue