public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	broonie@kernel.org, robh+dt@kernel.org, vkoul@kernel.org
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	bgoswami@codeaurora.org, spapothi@codeaurora.org,
	lgirdwood@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [alsa-devel] [RESEND PATCH v4 2/4] soundwire: core: add device tree support for slave devices
Date: Fri, 23 Aug 2019 10:44:30 -0500	[thread overview]
Message-ID: <2f1b5e2e-4699-1d06-e28e-708d5ed99b6a@linux.intel.com> (raw)
In-Reply-To: <20190822233759.12663-3-srinivas.kandagatla@linaro.org>



On 8/22/19 6:37 PM, Srinivas Kandagatla wrote:
> This patch adds support to parsing device tree based
> SoundWire slave devices.
> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>   drivers/soundwire/bus.c   |  2 ++
>   drivers/soundwire/bus.h   |  1 +
>   drivers/soundwire/slave.c | 52 +++++++++++++++++++++++++++++++++++++++
>   3 files changed, 55 insertions(+)
> 
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index 49f64b2115b9..c2eaeb5c38ed 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -77,6 +77,8 @@ int sdw_add_bus_master(struct sdw_bus *bus)
>   	 */
>   	if (IS_ENABLED(CONFIG_ACPI) && ACPI_HANDLE(bus->dev))
>   		ret = sdw_acpi_find_slaves(bus);
> +	else if (IS_ENABLED(CONFIG_OF) && bus->dev->of_node)
> +		ret = sdw_of_find_slaves(bus);
>   	else
>   		ret = -ENOTSUPP; /* No ACPI/DT so error out */
>   
> diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h
> index 3048ca153f22..ee46befedbd1 100644
> --- a/drivers/soundwire/bus.h
> +++ b/drivers/soundwire/bus.h
> @@ -15,6 +15,7 @@ static inline int sdw_acpi_find_slaves(struct sdw_bus *bus)
>   }
>   #endif
>   
> +int sdw_of_find_slaves(struct sdw_bus *bus);
>   void sdw_extract_slave_id(struct sdw_bus *bus,
>   			  u64 addr, struct sdw_slave_id *id);
>   
> diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
> index f39a5815e25d..3ef265d2ee89 100644
> --- a/drivers/soundwire/slave.c
> +++ b/drivers/soundwire/slave.c
> @@ -2,6 +2,7 @@
>   // Copyright(c) 2015-17 Intel Corporation.
>   
>   #include <linux/acpi.h>
> +#include <linux/of.h>
>   #include <linux/soundwire/sdw.h>
>   #include <linux/soundwire/sdw_type.h>
>   #include "bus.h"
> @@ -35,6 +36,7 @@ static int sdw_slave_add(struct sdw_bus *bus,
>   
>   	slave->dev.release = sdw_slave_release;
>   	slave->dev.bus = &sdw_bus_type;
> +	slave->dev.of_node = of_node_get(to_of_node(fwnode));
>   	slave->bus = bus;
>   	slave->status = SDW_SLAVE_UNATTACHED;
>   	slave->dev_num = 0;
> @@ -112,3 +114,53 @@ int sdw_acpi_find_slaves(struct sdw_bus *bus)
>   }
>   
>   #endif
> +
> +/*
> + * sdw_of_find_slaves() - Find Slave devices in master device tree node
> + * @bus: SDW bus instance
> + *
> + * Scans Master DT node for SDW child Slave devices and registers it.
> + */
> +int sdw_of_find_slaves(struct sdw_bus *bus)
> +{
> +	struct device *dev = bus->dev;
> +	struct device_node *node;
> +
> +	for_each_child_of_node(bus->dev->of_node, node) {
> +		int link_id, sdw_version, ret, len;
> +		const char *compat = NULL;
> +		struct sdw_slave_id id;
> +		const __be32 *addr;
> +
> +		compat = of_get_property(node, "compatible", NULL);
> +		if (!compat)
> +			continue;
> +
> +		ret = sscanf(compat, "sdw%01x%04hx%04hx%02hhx", &sdw_version,
> +			     &id.mfg_id, &id.part_id, &id.class_id);
> +
> +		if (ret != 4) {
> +			dev_err(dev, "Invalid compatible string found %s\n",
> +				compat);
> +			continue;
> +		}
> +
> +		addr = of_get_property(node, "reg", &len);
> +		if (!addr || (len < 2 * sizeof(u32))) {
> +			dev_err(dev, "Invalid Instance and Link ID\n");
> +			continue;
> +		}
> +
> +		id.unique_id = be32_to_cpup(addr++);
> +		link_id = be32_to_cpup(addr);

So here the link ID is obviously not in the address, so you are not 
using the MIPI spec as we discussed initially?

> +		id.sdw_version = sdw_version;
> +
> +		/* Check for link_id match */
> +		if (link_id != bus->link_id)
> +			continue;
> +
> +		sdw_slave_add(bus, &id, of_fwnode_handle(node));
> +	}
> +
> +	return 0;
> +}
> 

  reply	other threads:[~2019-08-23 15:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 23:37 [RESEND PATCH v4 0/4] ASoC: codecs: Add WSA881x Smart Speaker amplifier support Srinivas Kandagatla
2019-08-22 23:37 ` [RESEND PATCH v4 1/4] dt-bindings: soundwire: add slave bindings Srinivas Kandagatla
2019-08-23  6:53   ` Vinod Koul
2019-08-27 20:20     ` Rob Herring
2019-08-27 20:28       ` Srinivas Kandagatla
2019-08-23 15:41   ` [alsa-devel] " Pierre-Louis Bossart
2019-08-23 15:57     ` Srinivas Kandagatla
2019-08-23 16:44       ` Pierre-Louis Bossart
2019-08-24  9:28         ` Srinivas Kandagatla
2019-08-26 16:22           ` Pierre-Louis Bossart
2019-08-27 21:21             ` Srinivas Kandagatla
2019-08-22 23:37 ` [RESEND PATCH v4 2/4] soundwire: core: add device tree support for slave devices Srinivas Kandagatla
2019-08-23 15:44   ` Pierre-Louis Bossart [this message]
2019-08-23 15:47     ` [alsa-devel] " Srinivas Kandagatla
2019-08-22 23:37 ` [RESEND PATCH v4 3/4] dt-bindings: ASoC: Add WSA881x bindings Srinivas Kandagatla
2019-08-27 12:20   ` Rob Herring
2019-08-27 20:25     ` Srinivas Kandagatla
2019-08-22 23:37 ` [RESEND PATCH v4 4/4] ASoC: codecs: add wsa881x amplifier support Srinivas Kandagatla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f1b5e2e-4699-1d06-e28e-708d5ed99b6a@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=spapothi@codeaurora.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox