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

Commit bc05b7ea authored by Sudheer Papothi's avatar Sudheer Papothi Committed by Matt Wagantall
Browse files

soundwire: Add support to get notifications from WCD9935



WCD9335 is parent device node to soundwire master controller.
soundwire master controller will get notifications such as
port configuration, device up and down from WCD9335. Add
support to get notifications from WCD9335 to soundwire master.

Change-Id: I5d7e2b49aa3ad540bf279f3c7d3d5946f8e877c4
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent e8b5c848
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/soundwire/soundwire.h>
#include <linux/soundwire/swr-wcd.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/clk.h>
@@ -109,6 +110,61 @@ enum {
	SWR_RESERVED,
};

static int swrm_set_ch_map(struct swr_mstr_ctrl *swrm, void *data)
{
	struct swr_mstr_port *pinfo = (struct swr_mstr_port *)data;

	swrm->mstr_port = kzalloc(sizeof(struct swr_mstr_port), GFP_KERNEL);
	if (swrm->mstr_port == NULL)
		return -ENOMEM;
	swrm->mstr_port->num_port = pinfo->num_port;
	swrm->mstr_port->port = kzalloc((pinfo->num_port * sizeof(u8)),
					GFP_KERNEL);
	if (!swrm->mstr_port->port)
		return -ENOMEM;

	memcpy(swrm->mstr_port->port, pinfo->port, pinfo->num_port);
	return 0;
}

int swrm_notify(struct platform_device *pdev, u32 id, void *data)
{
	struct swr_mstr_ctrl *swrm;
	int ret = 0;

	if (!pdev) {
		pr_err("%s: pdev is NULL\n", __func__);
		return -EINVAL;
	}
	swrm = platform_get_drvdata(pdev);
	if (!swrm) {
		dev_err(&pdev->dev, "%s: swrm is NULL\n", __func__);
		return -EINVAL;
	}
	switch (id) {
	case SWR_CH_MAP:
		if (!data) {
			dev_err(swrm->dev, "%s: data is NULL\n", __func__);
			ret = -EINVAL;
		} else {
			ret = swrm_set_ch_map(swrm, data);
		}
		break;
	case SWR_DEVICE_DOWN:
		dev_dbg(swrm->dev, "%s: swr master down called\n", __func__);
		break;
	case SWR_DEVICE_UP:
		dev_dbg(swrm->dev, "%s: swr master up called\n", __func__);
		break;
	default:
		dev_err(swrm->dev, "%s: swr master unknow id %d\n",
			__func__, id);
		break;
	}
	return ret;
}
EXPORT_SYMBOL(swrm_notify);

static int swrm_get_port_config(struct swr_master *master)
{
	u32 ch_rate = 0;
@@ -151,6 +207,7 @@ static int swrm_get_port_config(struct swr_master *master)
static int swrm_get_master_port(u8 *mstr_port_id, u8 slv_port_id)
{
	int i;

	for (i = 0; i < SWR_MSTR_PORT_LEN; i++) {
		if (mstr_ports[i] == slv_port_id) {
			*mstr_port_id = i;
@@ -780,6 +837,10 @@ static int swrm_remove(struct platform_device *pdev)

	swrm->reg_irq(swrm->handle, swr_mstr_interrupt,
			swrm, SWR_IRQ_FREE);
	if (swrm->mstr_port) {
		kfree(swrm->mstr_port->port);
		kfree(swrm->mstr_port);
	}
	swr_unregister_master(&swrm->master);
	mutex_destroy(&swrm->mlock);
	kfree(swrm);
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#ifndef _SWR_WCD_CTRL_H
#define _SWR_WCD_CTRL_H
#include <linux/module.h>
#include <linux/soundwire/swr-wcd.h>

#define SWR_MAX_ROW		48
#define SWR_MAX_COL		16
@@ -65,6 +66,7 @@ struct swr_mstr_ctrl {
	int irq;
	int num_enum_slaves;
	int slave_status;
	struct swr_mstr_port *mstr_port;
};

#endif /* _SWR_WCD_CTRL_H */
+34 −0
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _LINUX_SWR_WCD_H
#define _LINUX_SWR_WCD_H
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/device.h>
#include <linux/bitops.h>

enum {
	SWR_CH_MAP,
	SWR_DEVICE_DOWN,
	SWR_DEVICE_UP,
	SWR_SUBSYS_RESTART
};

struct swr_mstr_port {
	int num_port;
	u8 *port;
};

extern int swrm_notify(struct platform_device *pdev, u32 id, void *data);

#endif /* _LINUX_SWR_WCD_H */