aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2019-03-01 13:19:46 +0000
committerSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2019-03-07 12:55:27 +0000
commit18b476620a2478b14f9e0010c43b3fde29dc5b48 (patch)
tree900422b00ff22152ac64414106903f04594aad23
parent3c93e64bb0e8985ea4e4dcd6f74c78fdf0e82ee5 (diff)
soundwire: add device tree support for adding slavestracking-qcomlt-soundwire
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/soundwire/bus.txt51
-rw-r--r--drivers/soundwire/bus.c2
-rw-r--r--drivers/soundwire/bus.h1
-rw-r--r--drivers/soundwire/slave.c54
4 files changed, 107 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/soundwire/bus.txt b/Documentation/devicetree/bindings/soundwire/bus.txt
new file mode 100644
index 000000000000..6e00030acbcf
--- /dev/null
+++ b/Documentation/devicetree/bindings/soundwire/bus.txt
@@ -0,0 +1,51 @@
+Soundwire bus
+
+SoundWire is a 2-pin multi-drop interface with data and clock line.
+It facilitates development of low cost, efficient, high performance systems.
+
+Required property for Soundwire controller node:
+
+Required properties:
+- #address-cells - Should be 1
+- #size-cell - Should be 0
+Rest of the controller bindings are very much specific to vendor.
+
+Child nodes:
+Every Soundwire controller node can contain zero or more child nodes
+representing slave devices on the bus. Every Soundwire slave device is
+uniquely determined by the enumeration address containing 5 fields:
+Soundwire Version, Instance ID, Manufacturer ID, Part ID and Class ID
+for a device.
+
+Required property for SLIMbus child node if it is present:
+- reg - Should be ('Instance ID') from Soundwire
+ Enumeration Address.
+ Instance ID Is for the cases where multiple Devices of the
+ same type or Class are attached to the bus.
+
+- compatible -"swrVER,MFD,PID,CID". The textual representation of
+ Soundwire Version, Manufacturer ID, Part ID, shall be
+ in lower case hexadecimal with leading zeroes suppressed
+ Version number '0x10' represents SoundWire 1.0
+ Version number '0x11' represents SoundWire 1.1
+
+
+Soundwire example for Qualcomm's soundwire controller:
+
+ soundwire@c2d0000 {
+ compatible = "qcom,soundwire-v1.5.0"
+ reg = <0x0c2d0000 0x2000>;
+ ...
+ #address-cells = <1>;
+ #size-cell = <0>;
+
+ wsa8810@0{
+ compatible = "swr10,217,211,0";
+ reg = <0>;
+ };
+
+ wsa8810@1{
+ compatible = "swr10,217,211,0";
+ reg = <1>;
+ };
+ };
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 1cbfedfc20ef..0673f01053eb 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -77,7 +77,7 @@ 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
- ret = -ENOTSUPP; /* No ACPI/DT so error out */
+ ret = sdw_of_find_slaves(bus);
if (ret) {
dev_err(bus->dev, "Finding slaves failed:%d\n", ret);
diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h
index c77de05b8100..2e683042a526 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 ac103bd0c176..724a1f23ec88 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"
@@ -112,3 +113,56 @@ int sdw_acpi_find_slaves(struct sdw_bus *bus)
}
#endif
+
+#if IS_ENABLED(CONFIG_OF)
+/*
+ * 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;
+
+ if (!bus->dev->of_node)
+ return 0;
+
+ for_each_child_of_node(bus->dev->of_node, node) {
+ unsigned long long addr;
+ struct sdw_slave_id id;
+ const char *compat = NULL;
+ int reg, ret;
+ int ver, manf_id, prod_code, class;
+
+ compat = of_get_property(node, "compatible", NULL);
+ if (!compat)
+ continue;
+
+ ret = sscanf(compat, "swr%x,%x,%x,%x", &ver, &manf_id, &prod_code, &class);
+ if (ret != 4) {
+ dev_err(dev, "Manf ID & Product code not found %s\n",
+ compat);
+ continue;
+ }
+
+ ret = of_property_read_u32(node, "reg", &reg);
+ if (ret) {
+ dev_err(dev, "Device and Instance id not found:%d\n",
+ ret);
+ continue;
+ }
+
+ id.sdw_version = ver - 0xF;
+ id.unique_id = reg;
+ id.mfg_id = manf_id;
+ id.part_id = prod_code;
+ id.class_id = class;
+
+ sdw_slave_add(bus, &id, of_fwnode_handle(node));
+ }
+ return 0;
+}
+
+#endif