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

Commit a6104efd authored by Ashish Jain's avatar Ashish Jain
Browse files

soc: qcom: Enable wcd glink driver for BG



Enable wcd glink driver for platform with BG support. Also
add support to configure the glink edge which is used
for glink communication between the msm and the target
device.

Change-Id: I1b4a888a40a8f4187bc384494fe3ac97a864756a
Signed-off-by: default avatarAshish Jain <ashishj@codeaurora.org>
parent d96c71eb
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -411,6 +411,9 @@ Required properties:
Required properties:
Required properties:


 - compatible :                            "qcom,wcd-dsp-glink"
 - compatible :                            "qcom,wcd-dsp-glink"
 - qcom,msm-codec-glink-edge:              Name of the glink edge which is used
					    for IPC.
					    If no name is set, it defaults to "wdsp"


Example:
Example:


@@ -689,6 +692,7 @@ Example:


	wcd_dsp_glink {
	wcd_dsp_glink {
		compatible = "qcom,wcd-dsp-glink";
		compatible = "qcom,wcd-dsp-glink";
		qcom,msm-codec-glink-edge = "bg";
	};
	};




+1 −1
Original line number Original line Diff line number Diff line
@@ -932,7 +932,7 @@ config MSM_BG_GLINK
config WCD_DSP_GLINK
config WCD_DSP_GLINK
	tristate "WCD DSP GLINK Driver"
	tristate "WCD DSP GLINK Driver"
	depends on MSM_GLINK
	depends on MSM_GLINK
	default y if SND_SOC_WCD934X=y
	default y if (SND_SOC_WCD934X=y || MSM_BG_GLINK=y)
	help
	help
	   This option enables driver which provides communication interface
	   This option enables driver which provides communication interface
	   between MSM and WCD DSP over glink transport protocol. This driver
	   between MSM and WCD DSP over glink transport protocol. This driver
+22 −5
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@
#include <linux/cdev.h>
#include <linux/cdev.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <linux/vmalloc.h>
#include <linux/vmalloc.h>
#include <linux/of_device.h>
#include <soc/qcom/glink.h>
#include <soc/qcom/glink.h>
#include "sound/wcd-dsp-glink.h"
#include "sound/wcd-dsp-glink.h"


@@ -40,12 +41,14 @@
#define RESP_QUEUE_SIZE 3
#define RESP_QUEUE_SIZE 3
#define QOS_PKT_SIZE 1024
#define QOS_PKT_SIZE 1024
#define TIMEOUT_MS 1000
#define TIMEOUT_MS 1000
#define GLINK_EDGE_MAX 16


struct wdsp_glink_dev {
struct wdsp_glink_dev {
	struct class *cls;
	struct class *cls;
	struct device *dev;
	struct device *dev;
	struct cdev cdev;
	struct cdev cdev;
	dev_t dev_num;
	dev_t dev_num;
	char glink_edge[GLINK_EDGE_MAX];
};
};


struct wdsp_glink_rsp_que {
struct wdsp_glink_rsp_que {
@@ -115,6 +118,7 @@ struct wdsp_glink_priv {
	u8 no_of_channels;
	u8 no_of_channels;
	struct work_struct ch_open_cls_wrk;
	struct work_struct ch_open_cls_wrk;
	struct workqueue_struct *work_queue;
	struct workqueue_struct *work_queue;
	const char *glink_edge;


	wait_queue_head_t link_state_wait;
	wait_queue_head_t link_state_wait;


@@ -401,7 +405,7 @@ static int wdsp_glink_open_ch(struct wdsp_glink_ch *ch)
	if (!ch->handle) {
	if (!ch->handle) {
		memset(&open_cfg, 0, sizeof(open_cfg));
		memset(&open_cfg, 0, sizeof(open_cfg));
		open_cfg.options = GLINK_OPT_INITIAL_XPORT;
		open_cfg.options = GLINK_OPT_INITIAL_XPORT;
		open_cfg.edge = WDSP_EDGE;
		open_cfg.edge = wpriv->glink_edge;
		open_cfg.notify_rx = wdsp_glink_notify_rx;
		open_cfg.notify_rx = wdsp_glink_notify_rx;
		open_cfg.notify_tx_done = wdsp_glink_notify_tx_done;
		open_cfg.notify_tx_done = wdsp_glink_notify_tx_done;
		open_cfg.notify_tx_abort = wdsp_glink_notify_tx_abort;
		open_cfg.notify_tx_abort = wdsp_glink_notify_tx_abort;
@@ -511,10 +515,8 @@ static void wdsp_glink_link_state_cb(struct glink_link_state_cb_info *cb_info,


	wpriv = (struct wdsp_glink_priv *)priv;
	wpriv = (struct wdsp_glink_priv *)priv;


	mutex_lock(&wpriv->glink_mutex);
	wpriv->glink_state.link_state = cb_info->link_state;
	wpriv->glink_state.link_state = cb_info->link_state;
	wake_up(&wpriv->link_state_wait);
	wake_up(&wpriv->link_state_wait);
	mutex_unlock(&wpriv->glink_mutex);


	queue_work(wpriv->work_queue, &wpriv->ch_open_cls_wrk);
	queue_work(wpriv->work_queue, &wpriv->ch_open_cls_wrk);
}
}
@@ -631,7 +633,7 @@ static int wdsp_glink_ch_info_init(struct wdsp_glink_priv *wpriv,
	/* Register glink link_state notification */
	/* Register glink link_state notification */
	link_info.glink_link_state_notif_cb = wdsp_glink_link_state_cb;
	link_info.glink_link_state_notif_cb = wdsp_glink_link_state_cb;
	link_info.transport = NULL;
	link_info.transport = NULL;
	link_info.edge = WDSP_EDGE;
	link_info.edge = wpriv->glink_edge;


	wpriv->glink_state.link_state = GLINK_LINK_STATE_DOWN;
	wpriv->glink_state.link_state = GLINK_LINK_STATE_DOWN;
	wpriv->glink_state.handle = glink_register_link_state_cb(&link_info,
	wpriv->glink_state.handle = glink_register_link_state_cb(&link_info,
@@ -971,7 +973,7 @@ static int wdsp_glink_open(struct inode *inode, struct file *file)
		ret = -EINVAL;
		ret = -EINVAL;
		goto err_wq;
		goto err_wq;
	}
	}

	wpriv->glink_edge = wdev->glink_edge;
	wpriv->glink_state.link_state = GLINK_LINK_STATE_DOWN;
	wpriv->glink_state.link_state = GLINK_LINK_STATE_DOWN;
	init_completion(&wpriv->rsp_complete);
	init_completion(&wpriv->rsp_complete);
	init_waitqueue_head(&wpriv->link_state_wait);
	init_waitqueue_head(&wpriv->link_state_wait);
@@ -1087,6 +1089,7 @@ static int wdsp_glink_probe(struct platform_device *pdev)
{
{
	int ret;
	int ret;
	struct wdsp_glink_dev *wdev;
	struct wdsp_glink_dev *wdev;
	const char *str = NULL;


	wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
	wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
	if (!wdev) {
	if (!wdev) {
@@ -1126,6 +1129,20 @@ static int wdsp_glink_probe(struct platform_device *pdev)
			__func__, ret);
			__func__, ret);
		goto err_cdev_add;
		goto err_cdev_add;
	}
	}
	ret = of_property_read_string(pdev->dev.of_node,
				"qcom,msm-codec-glink-edge", &str);
	if (ret < 0) {
		strlcpy(wdev->glink_edge, WDSP_EDGE, GLINK_EDGE_MAX);
		dev_info(&pdev->dev,
			"%s: qcom,msm-codec-glink-edge not set use default %s\n",
			__func__, wdev->glink_edge);
		ret = 0;
	} else {
		strlcpy(wdev->glink_edge, str, GLINK_EDGE_MAX);
		dev_info(&pdev->dev, "%s: glink edge is %s\n", __func__,
					wdev->glink_edge);
	}

	platform_set_drvdata(pdev, wdev);
	platform_set_drvdata(pdev, wdev);
	goto done;
	goto done;