Commit bcac5902 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul
Browse files

soundwire: add Slave sysfs support



Expose MIPI DisCo Slave properties in sysfs.

For Slave properties and Data Port 0, the attributes are managed with
simple devm_ support.

A Slave Device may have more than one Data Port (DPN), and each Data
Port can be sink or source. The attributes are created dynamically
using pre-canned macros, but still use devm_ with a name attribute
group to avoid creating kobjects - as requested by GregKH. In the
_show function, we use container_of() to retrieve port number and
direction required to extract the information.

Audio modes are not supported for now. Depending on the discussions
the SoundWire Device Class, we may add it later as is or follow the
new specification.

Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20200518203551.2053-4-yung-chuan.liao@linux.intel.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent c5778ca4
Loading
Loading
Loading
Loading
+91 −0
Original line number Diff line number Diff line
What:		/sys/bus/soundwire/devices/sdw:.../dev-properties/mipi_revision
		/sys/bus/soundwire/devices/sdw:.../dev-properties/wake_capable
		/sys/bus/soundwire/devices/sdw:.../dev-properties/test_mode_capable
		/sys/bus/soundwire/devices/sdw:.../dev-properties/clk_stop_mode1
		/sys/bus/soundwire/devices/sdw:.../dev-properties/simple_clk_stop_capable
		/sys/bus/soundwire/devices/sdw:.../dev-properties/clk_stop_timeout
		/sys/bus/soundwire/devices/sdw:.../dev-properties/ch_prep_timeout
		/sys/bus/soundwire/devices/sdw:.../dev-properties/reset_behave
		/sys/bus/soundwire/devices/sdw:.../dev-properties/high_PHY_capable
		/sys/bus/soundwire/devices/sdw:.../dev-properties/paging_support
		/sys/bus/soundwire/devices/sdw:.../dev-properties/bank_delay_support
		/sys/bus/soundwire/devices/sdw:.../dev-properties/p15_behave
		/sys/bus/soundwire/devices/sdw:.../dev-properties/master_count
		/sys/bus/soundwire/devices/sdw:.../dev-properties/source_ports
		/sys/bus/soundwire/devices/sdw:.../dev-properties/sink_ports

Date:		May 2020

Contact:	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
		Bard Liao <yung-chuan.liao@linux.intel.com>
		Vinod Koul <vkoul@kernel.org>

Description:	SoundWire Slave DisCo properties.
		These properties are defined by MIPI DisCo Specification
		for SoundWire. They define various properties of the
		SoundWire Slave and are used by the bus to configure
		the Slave


What:		/sys/bus/soundwire/devices/sdw:.../dp0/max_word
		/sys/bus/soundwire/devices/sdw:.../dp0/min_word
		/sys/bus/soundwire/devices/sdw:.../dp0/words
		/sys/bus/soundwire/devices/sdw:.../dp0/BRA_flow_controlled
		/sys/bus/soundwire/devices/sdw:.../dp0/simple_ch_prep_sm
		/sys/bus/soundwire/devices/sdw:.../dp0/imp_def_interrupts

Date:		May 2020

Contact:	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
		Bard Liao <yung-chuan.liao@linux.intel.com>
		Vinod Koul <vkoul@kernel.org>

Description:	SoundWire Slave Data Port-0 DisCo properties.
		These properties are defined by MIPI DisCo Specification
		for the SoundWire. They define various properties of the
		Data port 0 are used by the bus to configure the Data Port 0.


What:		/sys/bus/soundwire/devices/sdw:.../dpN_src/max_word
		/sys/bus/soundwire/devices/sdw:.../dpN_src/min_word
		/sys/bus/soundwire/devices/sdw:.../dpN_src/words
		/sys/bus/soundwire/devices/sdw:.../dpN_src/type
		/sys/bus/soundwire/devices/sdw:.../dpN_src/max_grouping
		/sys/bus/soundwire/devices/sdw:.../dpN_src/simple_ch_prep_sm
		/sys/bus/soundwire/devices/sdw:.../dpN_src/ch_prep_timeout
		/sys/bus/soundwire/devices/sdw:.../dpN_src/imp_def_interrupts
		/sys/bus/soundwire/devices/sdw:.../dpN_src/min_ch
		/sys/bus/soundwire/devices/sdw:.../dpN_src/max_ch
		/sys/bus/soundwire/devices/sdw:.../dpN_src/channels
		/sys/bus/soundwire/devices/sdw:.../dpN_src/ch_combinations
		/sys/bus/soundwire/devices/sdw:.../dpN_src/max_async_buffer
		/sys/bus/soundwire/devices/sdw:.../dpN_src/block_pack_mode
		/sys/bus/soundwire/devices/sdw:.../dpN_src/port_encoding

		/sys/bus/soundwire/devices/sdw:.../dpN_sink/max_word
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/min_word
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/words
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/type
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/max_grouping
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/simple_ch_prep_sm
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/ch_prep_timeout
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/imp_def_interrupts
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/min_ch
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/max_ch
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/channels
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/ch_combinations
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/max_async_buffer
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/block_pack_mode
		/sys/bus/soundwire/devices/sdw:.../dpN_sink/port_encoding

Date:		May 2020

Contact:	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
		Bard Liao <yung-chuan.liao@linux.intel.com>
		Vinod Koul <vkoul@kernel.org>

Description:	SoundWire Slave Data Source/Sink Port-N DisCo properties.
		These properties are defined by MIPI DisCo Specification
		for SoundWire. They define various properties of the
		Source/Sink Data port N and are used by the bus to configure
		the Data Port N.
+2 −1
Original line number Diff line number Diff line
@@ -4,7 +4,8 @@
#

#Bus Objs
soundwire-bus-objs := bus_type.o bus.o master.o slave.o mipi_disco.o stream.o
soundwire-bus-objs := bus_type.o bus.o master.o slave.o mipi_disco.o stream.o  \
			sysfs_slave.o sysfs_slave_dpn.o
obj-$(CONFIG_SOUNDWIRE) += soundwire-bus.o

ifdef CONFIG_DEBUG_FS
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw.h>
#include "bus.h"
#include "sysfs_local.h"

static DEFINE_IDA(sdw_ida);

+1 −0
Original line number Diff line number Diff line
@@ -175,5 +175,6 @@ sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
#define SDW_UNATTACH_REQUEST_MASTER_RESET	BIT(0)

void sdw_clear_slave_status(struct sdw_bus *bus, u32 request);
int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size);

#endif /* __SDW_BUS_H */
+7 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
#include "bus.h"
#include "sysfs_local.h"

/**
 * sdw_get_device_id - find the matching SoundWire device id
@@ -46,8 +47,7 @@ static int sdw_bus_match(struct device *dev, struct device_driver *ddrv)
	return ret;
}

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

@@ -105,6 +105,11 @@ static int sdw_drv_probe(struct device *dev)
	if (slave->ops && slave->ops->read_prop)
		slave->ops->read_prop(slave);

	/* init the sysfs as we have properties now */
	ret = sdw_slave_sysfs_init(slave);
	if (ret < 0)
		dev_warn(dev, "Slave sysfs init failed:%d\n", ret);

	/*
	 * Check for valid clk_stop_timeout, use DisCo worst case value of
	 * 300ms
Loading