Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
Vinod, the question was not for dp0 and dpN, it's fine to have subdirectories there, but rather why we need separate devices for the master and slave properties. Slave does not have a separate device. IIRC the properties for Slave are in /sys/bus/soundwire/device//... I am not sure this is correct ACPI defines the slaves devices under /sys/bus/acpi/PRP0001, e.g. Yes the bus will create 'soundwire slave' device type (In acpi case created from ACPI walk) and we do link the ACPI as the firmware node. This is 'not' created for properties but for soundwire representation of slave devices. This is the one code driver attaches to. /sys/bus/acpi/devices/PRP1:00/device:17# ls Yes this would the companion ACPI device I see, I must admit I missed this part. I guess it's not technically broken but was is really necessary though to use this notion of companion ACPI device? For the controller it makes sense, that's how to match ACPI and PCI, but since Soundwire slaves are not fully enumerable, precisely why we need all these _DSD properties, couldn't we just use ACPI devices directly?
Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
On 07-05-19, 08:54, Pierre-Louis Bossart wrote: > On 5/7/19 12:19 AM, Vinod Koul wrote: > > On 06-05-19, 11:46, Pierre-Louis Bossart wrote: > > > On 5/6/19 11:22 AM, Vinod Koul wrote: > > > > On 06-05-19, 17:19, Greg KH wrote: > > > > > On Mon, May 06, 2019 at 09:42:35AM -0500, Pierre-Louis Bossart wrote: > > > > > > > > + > > > > > > > > +int sdw_sysfs_slave_init(struct sdw_slave *slave) > > > > > > > > +{ > > > > > > > > + struct sdw_slave_sysfs *sysfs; > > > > > > > > + unsigned int src_dpns, sink_dpns, i, j; > > > > > > > > + int err; > > > > > > > > + > > > > > > > > + if (slave->sysfs) { > > > > > > > > + dev_err(&slave->dev, "SDW Slave sysfs is > > > > > > > > already initialized\n"); > > > > > > > > + err = -EIO; > > > > > > > > + goto err_ret; > > > > > > > > + } > > > > > > > > + > > > > > > > > + sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL); > > > > > > > > > > > > > > Same question as patch 1, why a new device? > > > > > > > > > > > > yes it's the same open. In this case, the slave devices are defined > > > > > > at a > > > > > > different level so it's also confusing to create a device to > > > > > > represent the > > > > > > slave properties. The code works but I am not sure the initial > > > > > > directions > > > > > > are correct. > > > > > > > > > > You can just make a subdir for your attributes by using the attribute > > > > > group name, if a subdirectory is needed just to keep things a bit more > > > > > organized. > > > > > > > > The key here is 'a subdir' which is not the case here. We did discuss > > > > this in the initial patches for SoundWire which had sysfs :) > > > > > > > > The way MIPI disco spec organized properties, we have dp0 and dpN > > > > properties each of them requires to have a subdir of their own and that > > > > was the reason why I coded it to be creating a device. > > > > > > Vinod, the question was not for dp0 and dpN, it's fine to have > > > subdirectories there, but rather why we need separate devices for the > > > master > > > and slave properties. > > > > Slave does not have a separate device. IIRC the properties for Slave are > > in /sys/bus/soundwire/device//... > > I am not sure this is correct > > ACPI defines the slaves devices under > /sys/bus/acpi/PRP0001, e.g. Yes the bus will create 'soundwire slave' device type (In acpi case created from ACPI walk) and we do link the ACPI as the firmware node. This is 'not' created for properties but for soundwire representation of slave devices. This is the one code driver attaches to. > /sys/bus/acpi/devices/PRP1:00/device:17# ls Yes this would the companion ACPI device > adr mipi-sdw-dp-5-sink-subproperties > intel-endpoint-descriptor-0 mipi-sdw-dp-6-source-subproperties > intel-endpoint-descriptor-1 mipi-sdw-dp-7-sink-subproperties > mipi-sdw-dp-0-subproperties mipi-sdw-dp-8-source-subproperties > mipi-sdw-dp-1-sink-subpropertiespath > mipi-sdw-dp-1-source-subproperties physical_node > mipi-sdw-dp-2-sink-subpropertiespower > mipi-sdw-dp-2-source-subproperties subsystem > mipi-sdw-dp-3-sink-subpropertiesuevent > mipi-sdw-dp-4-source-subproperties > > but the sysfs for slaves is shown as > /sys/bus/acpi/devices/PRP1:00/int-sdw.0/sdw:0:25d:700:0:0# ls > bank_delay_support master_count sink_ports > ch_prep_timeout mipi_revisionsource_ports > clk_stop_mode1 modalias src-dp2 > clk_stop_timeoutp15_behave src-dp4 > dp0 paging_support subsystem > driver powertest_mode_capable > firmware_node reset_behave uevent > hda_reg simple_clk_stop_capable wake_capable > high_PHY_capablesink-dp1 > index_reg sink-dp3 > > and in sys/bus/soundwire/devices/sdw:0:25d:700:0:0# ls I think both are same nodes. Since the SoundWire slave is a child of master it appears under int-sdw.0 as well > bank_delay_support master_count sink_ports > ch_prep_timeout mipi_revisionsource_ports > clk_stop_mode1 modalias src-dp2 > clk_stop_timeoutp15_behave src-dp4 > dp0 paging_support subsystem > driver powertest_mode_capable > firmware_node reset_behave uevent > hda_reg simple_clk_stop_capable wake_capable > high_PHY_capablesink-dp1 > index_reg sink-dp3 > > So I would think we *do* create a new device for each slave instead of using > the one that's already exposed by ACPI. > > > > > For master yes we can skip the device creation, it was done for > > consistency sake of having these properties ties into sys/bus/soundwire/ > > > > I don't mind if they are shown up in respective device node (PCI/platform > > etc) /sys/bus/foo/device/<> > >
Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
On 5/7/19 12:19 AM, Vinod Koul wrote: On 06-05-19, 11:46, Pierre-Louis Bossart wrote: On 5/6/19 11:22 AM, Vinod Koul wrote: On 06-05-19, 17:19, Greg KH wrote: On Mon, May 06, 2019 at 09:42:35AM -0500, Pierre-Louis Bossart wrote: + +int sdw_sysfs_slave_init(struct sdw_slave *slave) +{ + struct sdw_slave_sysfs *sysfs; + unsigned int src_dpns, sink_dpns, i, j; + int err; + + if (slave->sysfs) { + dev_err(&slave->dev, "SDW Slave sysfs is already initialized\n"); + err = -EIO; + goto err_ret; + } + + sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL); Same question as patch 1, why a new device? yes it's the same open. In this case, the slave devices are defined at a different level so it's also confusing to create a device to represent the slave properties. The code works but I am not sure the initial directions are correct. You can just make a subdir for your attributes by using the attribute group name, if a subdirectory is needed just to keep things a bit more organized. The key here is 'a subdir' which is not the case here. We did discuss this in the initial patches for SoundWire which had sysfs :) The way MIPI disco spec organized properties, we have dp0 and dpN properties each of them requires to have a subdir of their own and that was the reason why I coded it to be creating a device. Vinod, the question was not for dp0 and dpN, it's fine to have subdirectories there, but rather why we need separate devices for the master and slave properties. Slave does not have a separate device. IIRC the properties for Slave are in /sys/bus/soundwire/device//... I am not sure this is correct ACPI defines the slaves devices under /sys/bus/acpi/PRP0001, e.g. /sys/bus/acpi/devices/PRP1:00/device:17# ls adr mipi-sdw-dp-5-sink-subproperties intel-endpoint-descriptor-0 mipi-sdw-dp-6-source-subproperties intel-endpoint-descriptor-1 mipi-sdw-dp-7-sink-subproperties mipi-sdw-dp-0-subproperties mipi-sdw-dp-8-source-subproperties mipi-sdw-dp-1-sink-subpropertiespath mipi-sdw-dp-1-source-subproperties physical_node mipi-sdw-dp-2-sink-subpropertiespower mipi-sdw-dp-2-source-subproperties subsystem mipi-sdw-dp-3-sink-subpropertiesuevent mipi-sdw-dp-4-source-subproperties but the sysfs for slaves is shown as /sys/bus/acpi/devices/PRP1:00/int-sdw.0/sdw:0:25d:700:0:0# ls bank_delay_support master_count sink_ports ch_prep_timeout mipi_revisionsource_ports clk_stop_mode1 modalias src-dp2 clk_stop_timeoutp15_behave src-dp4 dp0 paging_support subsystem driver powertest_mode_capable firmware_node reset_behave uevent hda_reg simple_clk_stop_capable wake_capable high_PHY_capablesink-dp1 index_reg sink-dp3 and in sys/bus/soundwire/devices/sdw:0:25d:700:0:0# ls bank_delay_support master_count sink_ports ch_prep_timeout mipi_revisionsource_ports clk_stop_mode1 modalias src-dp2 clk_stop_timeoutp15_behave src-dp4 dp0 paging_support subsystem driver powertest_mode_capable firmware_node reset_behave uevent hda_reg simple_clk_stop_capable wake_capable high_PHY_capablesink-dp1 index_reg sink-dp3 So I would think we *do* create a new device for each slave instead of using the one that's already exposed by ACPI. For master yes we can skip the device creation, it was done for consistency sake of having these properties ties into sys/bus/soundwire/ I don't mind if they are shown up in respective device node (PCI/platform etc) /sys/bus/foo/device/<> But for creating subdirectories you would need the new dpX devices. yes, that's agreed.
Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
On 06-05-19, 11:46, Pierre-Louis Bossart wrote: > On 5/6/19 11:22 AM, Vinod Koul wrote: > > On 06-05-19, 17:19, Greg KH wrote: > > > On Mon, May 06, 2019 at 09:42:35AM -0500, Pierre-Louis Bossart wrote: > > > > > > + > > > > > > +int sdw_sysfs_slave_init(struct sdw_slave *slave) > > > > > > +{ > > > > > > + struct sdw_slave_sysfs *sysfs; > > > > > > + unsigned int src_dpns, sink_dpns, i, j; > > > > > > + int err; > > > > > > + > > > > > > + if (slave->sysfs) { > > > > > > + dev_err(&slave->dev, "SDW Slave sysfs is already > > > > > > initialized\n"); > > > > > > + err = -EIO; > > > > > > + goto err_ret; > > > > > > + } > > > > > > + > > > > > > + sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL); > > > > > > > > > > Same question as patch 1, why a new device? > > > > > > > > yes it's the same open. In this case, the slave devices are defined at a > > > > different level so it's also confusing to create a device to represent > > > > the > > > > slave properties. The code works but I am not sure the initial > > > > directions > > > > are correct. > > > > > > You can just make a subdir for your attributes by using the attribute > > > group name, if a subdirectory is needed just to keep things a bit more > > > organized. > > > > The key here is 'a subdir' which is not the case here. We did discuss > > this in the initial patches for SoundWire which had sysfs :) > > > > The way MIPI disco spec organized properties, we have dp0 and dpN > > properties each of them requires to have a subdir of their own and that > > was the reason why I coded it to be creating a device. > > Vinod, the question was not for dp0 and dpN, it's fine to have > subdirectories there, but rather why we need separate devices for the master > and slave properties. Slave does not have a separate device. IIRC the properties for Slave are in /sys/bus/soundwire/device//... For master yes we can skip the device creation, it was done for consistency sake of having these properties ties into sys/bus/soundwire/ I don't mind if they are shown up in respective device node (PCI/platform etc) /sys/bus/foo/device/<> But for creating subdirectories you would need the new dpX devices. HTH > > > > > Do we have a better way to handle this? > > > > > Otherwise, you need to mess with having multiple "types" of struct > > > device all associated with the same bus. It is possible, and not that > > > hard, but I don't think you are doing that here. > > > > > > thnaks, > > > > > > greg k-h > > -- ~Vinod
Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
On 5/6/19 11:22 AM, Vinod Koul wrote: On 06-05-19, 17:19, Greg KH wrote: On Mon, May 06, 2019 at 09:42:35AM -0500, Pierre-Louis Bossart wrote: + +int sdw_sysfs_slave_init(struct sdw_slave *slave) +{ + struct sdw_slave_sysfs *sysfs; + unsigned int src_dpns, sink_dpns, i, j; + int err; + + if (slave->sysfs) { + dev_err(&slave->dev, "SDW Slave sysfs is already initialized\n"); + err = -EIO; + goto err_ret; + } + + sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL); Same question as patch 1, why a new device? yes it's the same open. In this case, the slave devices are defined at a different level so it's also confusing to create a device to represent the slave properties. The code works but I am not sure the initial directions are correct. You can just make a subdir for your attributes by using the attribute group name, if a subdirectory is needed just to keep things a bit more organized. The key here is 'a subdir' which is not the case here. We did discuss this in the initial patches for SoundWire which had sysfs :) The way MIPI disco spec organized properties, we have dp0 and dpN properties each of them requires to have a subdir of their own and that was the reason why I coded it to be creating a device. Vinod, the question was not for dp0 and dpN, it's fine to have subdirectories there, but rather why we need separate devices for the master and slave properties. Do we have a better way to handle this? Otherwise, you need to mess with having multiple "types" of struct device all associated with the same bus. It is possible, and not that hard, but I don't think you are doing that here. thnaks, greg k-h
Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
On 06-05-19, 17:19, Greg KH wrote: > On Mon, May 06, 2019 at 09:42:35AM -0500, Pierre-Louis Bossart wrote: > > > > + > > > > +int sdw_sysfs_slave_init(struct sdw_slave *slave) > > > > +{ > > > > + struct sdw_slave_sysfs *sysfs; > > > > + unsigned int src_dpns, sink_dpns, i, j; > > > > + int err; > > > > + > > > > + if (slave->sysfs) { > > > > + dev_err(&slave->dev, "SDW Slave sysfs is already > > > > initialized\n"); > > > > + err = -EIO; > > > > + goto err_ret; > > > > + } > > > > + > > > > + sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL); > > > > > > Same question as patch 1, why a new device? > > > > yes it's the same open. In this case, the slave devices are defined at a > > different level so it's also confusing to create a device to represent the > > slave properties. The code works but I am not sure the initial directions > > are correct. > > You can just make a subdir for your attributes by using the attribute > group name, if a subdirectory is needed just to keep things a bit more > organized. The key here is 'a subdir' which is not the case here. We did discuss this in the initial patches for SoundWire which had sysfs :) The way MIPI disco spec organized properties, we have dp0 and dpN properties each of them requires to have a subdir of their own and that was the reason why I coded it to be creating a device. Do we have a better way to handle this? > Otherwise, you need to mess with having multiple "types" of struct > device all associated with the same bus. It is possible, and not that > hard, but I don't think you are doing that here. > > thnaks, > > greg k-h -- ~Vinod
Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
On Mon, May 06, 2019 at 09:42:35AM -0500, Pierre-Louis Bossart wrote: > > > + > > > +int sdw_sysfs_slave_init(struct sdw_slave *slave) > > > +{ > > > + struct sdw_slave_sysfs *sysfs; > > > + unsigned int src_dpns, sink_dpns, i, j; > > > + int err; > > > + > > > + if (slave->sysfs) { > > > + dev_err(&slave->dev, "SDW Slave sysfs is already > > > initialized\n"); > > > + err = -EIO; > > > + goto err_ret; > > > + } > > > + > > > + sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL); > > > > Same question as patch 1, why a new device? > > yes it's the same open. In this case, the slave devices are defined at a > different level so it's also confusing to create a device to represent the > slave properties. The code works but I am not sure the initial directions > are correct. You can just make a subdir for your attributes by using the attribute group name, if a subdirectory is needed just to keep things a bit more organized. Otherwise, you need to mess with having multiple "types" of struct device all associated with the same bus. It is possible, and not that hard, but I don't think you are doing that here. thnaks, greg k-h
Re: [alsa-devel] [RFC PATCH 2/7] soundwire: add Slave sysfs support
+static struct attribute_group sdw_slave_dev_attr_group = { + .attrs = slave_dev_attrs, +}; + +const struct attribute_group *sdw_slave_dev_attr_groups[] = { + &sdw_slave_dev_attr_group, + NULL +}; ATTRIBUTE_GROUP()? yes. + +int sdw_sysfs_slave_init(struct sdw_slave *slave) +{ + struct sdw_slave_sysfs *sysfs; + unsigned int src_dpns, sink_dpns, i, j; + int err; + + if (slave->sysfs) { + dev_err(&slave->dev, "SDW Slave sysfs is already initialized\n"); + err = -EIO; + goto err_ret; + } + + sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL); Same question as patch 1, why a new device? yes it's the same open. In this case, the slave devices are defined at a different level so it's also confusing to create a device to represent the slave properties. The code works but I am not sure the initial directions are correct.
Re: [RFC PATCH 2/7] soundwire: add Slave sysfs support
On Fri, May 03, 2019 at 08:00:25PM -0500, Pierre-Louis Bossart wrote: > Add DisCo Slave properties as device attributes. > Add a device for Data Port 0 which adds Dp0 properties as attributes. > Add devices for Source and Sink Data Ports, and add Dp-N > properties as attributes. > > The Slave, DP0 and DPn cases are intentionally handled in separate > files to avoid conflicts with attributes having the same names at > different levels. > > 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. > > Credits: this patch is based on an earlier internal contribution by > Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah > > Signed-off-by: Pierre-Louis Bossart > --- > drivers/soundwire/Makefile | 2 +- > drivers/soundwire/bus.c | 2 + > drivers/soundwire/bus.h | 2 + > drivers/soundwire/bus_type.c| 5 + > drivers/soundwire/slave.c | 1 + > drivers/soundwire/sysfs.c | 213 > drivers/soundwire/sysfs_local.h | 42 ++ > drivers/soundwire/sysfs_slave_dp0.c | 112 +++ > drivers/soundwire/sysfs_slave_dpn.c | 168 ++ > include/linux/soundwire/sdw.h | 5 + > 10 files changed, 551 insertions(+), 1 deletion(-) > create mode 100644 drivers/soundwire/sysfs_local.h > create mode 100644 drivers/soundwire/sysfs_slave_dp0.c > create mode 100644 drivers/soundwire/sysfs_slave_dpn.c > > diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile > index 787f1cbf342c..a72a29731a28 100644 > --- a/drivers/soundwire/Makefile > +++ b/drivers/soundwire/Makefile > @@ -4,7 +4,7 @@ > > #Bus Objs > soundwire-bus-objs := bus_type.o bus.o slave.o mipi_disco.o stream.o \ > - sysfs.o > + sysfs.o sysfs_slave_dp0.o sysfs_slave_dpn.o > obj-$(CONFIG_SOUNDWIRE_BUS) += soundwire-bus.o > > #Cadence Objs > diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c > index 38de7071e135..dd9181693554 100644 > --- a/drivers/soundwire/bus.c > +++ b/drivers/soundwire/bus.c > @@ -113,6 +113,8 @@ static int sdw_delete_slave(struct device *dev, void > *data) > struct sdw_slave *slave = dev_to_sdw_dev(dev); > struct sdw_bus *bus = slave->bus; > > + sdw_sysfs_slave_exit(slave); > + > mutex_lock(&bus->bus_lock); > > if (slave->dev_num) /* clear dev_num if assigned */ > diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h > index 3048ca153f22..0707e68a8d21 100644 > --- a/drivers/soundwire/bus.h > +++ b/drivers/soundwire/bus.h > @@ -18,6 +18,8 @@ static inline int sdw_acpi_find_slaves(struct sdw_bus *bus) > void sdw_extract_slave_id(struct sdw_bus *bus, > u64 addr, struct sdw_slave_id *id); > > +extern const struct attribute_group *sdw_slave_dev_attr_groups[]; > + > enum { > SDW_MSG_FLAG_READ = 0, > SDW_MSG_FLAG_WRITE, > diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c > index 2655602f0cfb..f68fe45c1037 100644 > --- a/drivers/soundwire/bus_type.c > +++ b/drivers/soundwire/bus_type.c > @@ -97,6 +97,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_sysfs_slave_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 > diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c > index f39a5815e25d..bad73a267fdd 100644 > --- a/drivers/soundwire/slave.c > +++ b/drivers/soundwire/slave.c > @@ -34,6 +34,7 @@ static int sdw_slave_add(struct sdw_bus *bus, >id->class_id, id->unique_id); > > slave->dev.release = sdw_slave_release; > + slave->dev.groups = sdw_slave_dev_attr_groups; > slave->dev.bus = &sdw_bus_type; > slave->bus = bus; > slave->status = SDW_SLAVE_UNATTACHED; > diff --git a/drivers/soundwire/sysfs.c b/drivers/soundwire/sysfs.c > index 7b6c3826a73a..734e2c8bc5cd 100644 > --- a/drivers/soundwire/sysfs.c > +++ b/drivers/soundwire/sysfs.c > @@ -8,6 +8,7 @@ > #include > #include > #include "bus.h" > +#include "sysfs_local.h" > > struct sdw_master_sysfs { > struct device dev; > @@ -160,3 +161,215 @@ void sdw_sysfs_bus_exit(struct sdw_bus *bus) > put_device(&master->dev); > bus->sysfs = NULL; > } > + > +/* > + * Slave sysfs > + */ > + > +/* > + * The sysfs for Slave reflects the MIPI description as given > + * in the MIPI DisCo spec > + * > + * Base file is device > + * | mipi_revision > + * | wake_capable > + * | test_mode_capable > + * | simple_clk_stop_capable > + * | clk_stop_timeout > + * | ch_prep_timeo
[RFC PATCH 2/7] soundwire: add Slave sysfs support
Add DisCo Slave properties as device attributes. Add a device for Data Port 0 which adds Dp0 properties as attributes. Add devices for Source and Sink Data Ports, and add Dp-N properties as attributes. The Slave, DP0 and DPn cases are intentionally handled in separate files to avoid conflicts with attributes having the same names at different levels. 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. Credits: this patch is based on an earlier internal contribution by Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus.c | 2 + drivers/soundwire/bus.h | 2 + drivers/soundwire/bus_type.c| 5 + drivers/soundwire/slave.c | 1 + drivers/soundwire/sysfs.c | 213 drivers/soundwire/sysfs_local.h | 42 ++ drivers/soundwire/sysfs_slave_dp0.c | 112 +++ drivers/soundwire/sysfs_slave_dpn.c | 168 ++ include/linux/soundwire/sdw.h | 5 + 10 files changed, 551 insertions(+), 1 deletion(-) create mode 100644 drivers/soundwire/sysfs_local.h create mode 100644 drivers/soundwire/sysfs_slave_dp0.c create mode 100644 drivers/soundwire/sysfs_slave_dpn.c diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile index 787f1cbf342c..a72a29731a28 100644 --- a/drivers/soundwire/Makefile +++ b/drivers/soundwire/Makefile @@ -4,7 +4,7 @@ #Bus Objs soundwire-bus-objs := bus_type.o bus.o slave.o mipi_disco.o stream.o \ - sysfs.o + sysfs.o sysfs_slave_dp0.o sysfs_slave_dpn.o obj-$(CONFIG_SOUNDWIRE_BUS) += soundwire-bus.o #Cadence Objs diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 38de7071e135..dd9181693554 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -113,6 +113,8 @@ static int sdw_delete_slave(struct device *dev, void *data) struct sdw_slave *slave = dev_to_sdw_dev(dev); struct sdw_bus *bus = slave->bus; + sdw_sysfs_slave_exit(slave); + mutex_lock(&bus->bus_lock); if (slave->dev_num) /* clear dev_num if assigned */ diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h index 3048ca153f22..0707e68a8d21 100644 --- a/drivers/soundwire/bus.h +++ b/drivers/soundwire/bus.h @@ -18,6 +18,8 @@ static inline int sdw_acpi_find_slaves(struct sdw_bus *bus) void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id); +extern const struct attribute_group *sdw_slave_dev_attr_groups[]; + enum { SDW_MSG_FLAG_READ = 0, SDW_MSG_FLAG_WRITE, diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c index 2655602f0cfb..f68fe45c1037 100644 --- a/drivers/soundwire/bus_type.c +++ b/drivers/soundwire/bus_type.c @@ -97,6 +97,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_sysfs_slave_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 diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c index f39a5815e25d..bad73a267fdd 100644 --- a/drivers/soundwire/slave.c +++ b/drivers/soundwire/slave.c @@ -34,6 +34,7 @@ static int sdw_slave_add(struct sdw_bus *bus, id->class_id, id->unique_id); slave->dev.release = sdw_slave_release; + slave->dev.groups = sdw_slave_dev_attr_groups; slave->dev.bus = &sdw_bus_type; slave->bus = bus; slave->status = SDW_SLAVE_UNATTACHED; diff --git a/drivers/soundwire/sysfs.c b/drivers/soundwire/sysfs.c index 7b6c3826a73a..734e2c8bc5cd 100644 --- a/drivers/soundwire/sysfs.c +++ b/drivers/soundwire/sysfs.c @@ -8,6 +8,7 @@ #include #include #include "bus.h" +#include "sysfs_local.h" struct sdw_master_sysfs { struct device dev; @@ -160,3 +161,215 @@ void sdw_sysfs_bus_exit(struct sdw_bus *bus) put_device(&master->dev); bus->sysfs = NULL; } + +/* + * Slave sysfs + */ + +/* + * The sysfs for Slave reflects the MIPI description as given + * in the MIPI DisCo spec + * + * Base file is device + * | mipi_revision + * | wake_capable + * | test_mode_capable + * | simple_clk_stop_capable + * | clk_stop_timeout + * | ch_prep_timeout + * | reset_behave + * | high_PHY_capable + * | paging_support + * | bank_delay_support + * | p15_behave + * | master_count + * | source_ports + * | sink_ports + * | dp0 + * | ma