Skip to content

Commit

Permalink
soundwire: Add MIPI DisCo property helpers
Browse files Browse the repository at this point in the history
MIPI Discovery And Configuration (DisCo) Specification for SoundWire
specifies properties to be implemented for SoundWire Masters and
Slaves. The DisCo spec doesn't mandate these properties. However,
SDW bus cannot work without knowing these values.

The helper functions read the Master and Slave properties.
Implementers of Master or Slave drivers can use any of the below
three mechanisms:
   a) Use these APIs here as .read_prop() callback for Master
      and Slave
   b) Implement own methods and set those as .read_prop(), but invoke
      APIs in this file for generic read and override the values with
      platform specific data
   c) Implement ones own methods which do not use anything provided
      here

Signed-off-by: Sanyog Kale <sanyog.r.kale@intel.com>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Acked-By: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Vinod Koul authored and gregkh committed Dec 19, 2017
1 parent 7c3cd18 commit 56d4fe3
Show file tree
Hide file tree
Showing 5 changed files with 706 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/soundwire/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#

#Bus Objs
soundwire-bus-objs := bus_type.o bus.o slave.o
soundwire-bus-objs := bus_type.o bus.o slave.o mipi_disco.o
obj-$(CONFIG_SOUNDWIRE_BUS) += soundwire-bus.o
8 changes: 8 additions & 0 deletions drivers/soundwire/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ int sdw_add_bus_master(struct sdw_bus *bus)
mutex_init(&bus->bus_lock);
INIT_LIST_HEAD(&bus->slaves);

if (bus->ops->read_prop) {
ret = bus->ops->read_prop(bus);
if (ret < 0) {
dev_err(bus->dev, "Bus read properties failed:%d", ret);
return ret;
}
}

/*
* Device numbers in SoundWire are 0 thru 15. Enumeration device
* number (0), Broadcast device number (15), Group numbers (12 and
Expand Down
23 changes: 22 additions & 1 deletion drivers/soundwire/bus_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ static int sdw_drv_probe(struct device *dev)
if (!id)
return -ENODEV;

slave->ops = drv->ops;

/*
* attach to power domain but don't turn on (last arg)
*/
Expand All @@ -89,7 +91,26 @@ static int sdw_drv_probe(struct device *dev)
}
}

return ret;
if (ret)
return ret;

/* device is probed so let's read the properties now */
if (slave->ops && slave->ops->read_prop)
slave->ops->read_prop(slave);

/*
* Check for valid clk_stop_timeout, use DisCo worst case value of
* 300ms
*
* TODO: check the timeouts and driver removal case
*/
if (slave->prop.clk_stop_timeout == 0)
slave->prop.clk_stop_timeout = 300;

slave->bus->clk_stop_timeout = max_t(u32, slave->bus->clk_stop_timeout,
slave->prop.clk_stop_timeout);

return 0;
}

static int sdw_drv_remove(struct device *dev)
Expand Down

0 comments on commit 56d4fe3

Please sign in to comment.