Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5e3b87e authored by Chris Lew's avatar Chris Lew
Browse files

neuron: ch_haven: Add support for svm device tree format



The secondary vm device tree will have a different format than the
primary vm. Try parsing the node as a secondary vm node if the
shared-buffer region does not exist.

Change-Id: Id794a1b21507329f4e16f1335a17a2262ecabd5a
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 66af98dc
Loading
Loading
Loading
Loading
+36 −2
Original line number Diff line number Diff line
@@ -372,6 +372,37 @@ static int channel_hh_rm_cb(struct notifier_block *nb, unsigned long cmd,
	return NOTIFY_DONE;
}

static struct device_node *
channel_hh_svm_of_parse(struct neuron_mq_data_priv *priv, struct device *dev)
{
	const char *compat = "qcom,neuron-channel-haven-shmem-gen";
	struct device_node *np = NULL;
	struct device_node *shm_np;
	u32 label;
	int ret;

	while ((np = of_find_compatible_node(np, NULL, compat))) {
		ret = of_property_read_u32(np, "qcom,label", &label);
		if (ret) {
			of_node_put(np);
			continue;
		}
		if (label == priv->haven_label)
			break;

		of_node_put(np);
	}
	if (!np)
		return NULL;

	shm_np = of_parse_phandle(np, "memory-region", 0);
	if (!shm_np)
		dev_err(dev, "cant parse svm shared mem node!\n");

	of_node_put(np);
	return shm_np;
}

static int channel_hh_map_memory(struct neuron_mq_data_priv *priv,
				 struct device *dev)
{
@@ -382,9 +413,12 @@ static int channel_hh_map_memory(struct neuron_mq_data_priv *priv,

	np = of_parse_phandle(dev->of_node, "shared-buffer", 0);
	if (!np) {
		dev_err(dev, "shared-buffer node missing!\n");
		np = channel_hh_svm_of_parse(priv, dev);
		if (!np) {
			dev_err(dev, "cant parse shared mem node!\n");
			return -EINVAL;
		}
	}

	ret = of_address_to_resource(np, 0, &priv->buffer);
	of_node_put(np);
+36 −2
Original line number Diff line number Diff line
@@ -355,6 +355,37 @@ static int channel_hh_rm_cb(struct notifier_block *nb, unsigned long cmd,
	return NOTIFY_DONE;
}

static struct device_node *
channel_hh_svm_of_parse(struct neuron_mq_data_priv *priv, struct device *dev)
{
	const char *compat = "qcom,neuron-channel-haven-shmem-gen";
	struct device_node *np = NULL;
	struct device_node *shm_np;
	u32 label;
	int ret;

	while ((np = of_find_compatible_node(np, NULL, compat))) {
		ret = of_property_read_u32(np, "qcom,label", &label);
		if (ret) {
			of_node_put(np);
			continue;
		}
		if (label == priv->haven_label)
			break;

		of_node_put(np);
	}
	if (!np)
		return NULL;

	shm_np = of_parse_phandle(np, "memory-region", 0);
	if (!shm_np)
		dev_err(dev, "cant parse svm shared mem node!\n");

	of_node_put(np);
	return shm_np;
}

static int channel_hh_map_memory(struct neuron_mq_data_priv *priv,
				 struct device *dev)
{
@@ -365,9 +396,12 @@ static int channel_hh_map_memory(struct neuron_mq_data_priv *priv,

	np = of_parse_phandle(dev->of_node, "shared-buffer", 0);
	if (!np) {
		dev_err(dev, "shared-buffer node missing!\n");
		np = channel_hh_svm_of_parse(priv, dev);
		if (!np) {
			dev_err(dev, "cant parse shared mem node!\n");
			return -EINVAL;
		}
	}

	ret = of_address_to_resource(np, 0, &priv->buffer);
	of_node_put(np);