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

Commit 14682078 authored by Gustavo Solaira's avatar Gustavo Solaira
Browse files

diag: Enable diagfwd via USB even when MHI is available



Some devices need diag via USB even when MHI is used
for rmnet and qmi tethering. This is because of lack
of support for diagfwd for mhi_dev in Linux.

Change-Id: Ie0ec19ee109d49aa409d1df3ad5ca24b75de7102
Signed-off-by: default avatarGustavo Solaira <gustavos@codeaurora.org>
parent 2bd67028
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
QTI Diag Forward USB Driver

Required properties:
-compatible : should be "qcom,diagfwd-usb".

Example:
	qcom,diag {
		compatible = "qcom,diagfwd-usb";
	};
+36 −2
Original line number Diff line number Diff line
@@ -1160,7 +1160,7 @@ static void diag_remote_exit(void)
	return;
}

int diagfwd_bridge_init(void)
int diagfwd_bridge_init(bool use_mhi)
{
	return 0;
}
@@ -3743,7 +3743,7 @@ static int diag_mhi_probe(struct platform_device *pdev)
		diag_remote_exit();
		return ret;
	}
	ret = diagfwd_bridge_init();
	ret = diagfwd_bridge_init(true);
	if (ret) {
		diagfwd_bridge_exit();
		return ret;
@@ -3766,6 +3766,39 @@ static struct platform_driver diag_mhi_driver = {
	},
};

static int diagfwd_usb_probe(struct platform_device *pdev)
{
	int ret;

	driver->pdev = pdev;
	ret = diag_remote_init();
	if (ret) {
		diag_remote_exit();
		return ret;
	}
	ret = diagfwd_bridge_init(false);
	if (ret) {
		diagfwd_bridge_exit();
		return ret;
	}
	pr_debug("diag: usb device is ready\n");
	return 0;
}

static const struct of_device_id diagfwd_usb_table[] = {
	{.compatible = "qcom,diagfwd-usb"},
	{},
};

static struct platform_driver diagfwd_usb_driver = {
	.probe = diagfwd_usb_probe,
	.driver = {
		.name = "DIAGFWD USB Platform",
		.owner = THIS_MODULE,
		.of_match_table = diagfwd_usb_table,
	},
};

static int __init diagchar_init(void)
{
	dev_t dev;
@@ -3892,6 +3925,7 @@ static int __init diagchar_init(void)

	pr_debug("diagchar initialized now");
	platform_driver_register(&diag_mhi_driver);
	platform_driver_register(&diagfwd_usb_driver);
	return 0;

fail:
+18 −7
Original line number Diff line number Diff line
@@ -20,16 +20,24 @@
#include <linux/platform_device.h>
#include "diag_mux.h"
#include "diagfwd_bridge.h"
#ifdef USB_QCOM_DIAG_BRIDGE
#ifdef CONFIG_USB_QCOM_DIAG_BRIDGE
#include "diagfwd_hsic.h"
#endif
#include "diagfwd_mhi.h"
#include "diag_dci.h"

#ifdef CONFIG_MSM_MHI
#define diag_mdm_init		diag_mhi_init
#else
#define diag_mdm_init		diag_hsic_init
#ifndef CONFIG_USB_QCOM_DIAG_BRIDGE
static int diag_hsic_init(void)
{
	return -EINVAL;
}
#endif

#ifndef CONFIG_MSM_MHI
static int diag_mhi_init(void)
{
	return -EINVAL;
}
#endif

#define BRIDGE_TO_MUX(x)	(x + DIAG_MUX_BRIDGE_BASE)
@@ -261,11 +269,14 @@ int diag_remote_dev_write_done(int id, unsigned char *buf, int len, int ctxt)
	return err;
}

int diagfwd_bridge_init()
int diagfwd_bridge_init(bool use_mhi)
{
	int err = 0;

	err = diag_mdm_init();
	if (use_mhi)
		err = diag_mhi_init();
	else
		err = diag_hsic_init();
	if (err)
		goto fail;
	return 0;
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, 2018, 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
@@ -51,7 +51,7 @@ struct diagfwd_bridge_info {
};

extern struct diagfwd_bridge_info bridge_info[NUM_REMOTE_DEV];
int diagfwd_bridge_init(void);
int diagfwd_bridge_init(bool use_mhi);
void diagfwd_bridge_exit(void);
int diagfwd_bridge_close(int id);
int diagfwd_bridge_write(int id, unsigned char *buf, int len);