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

Commit c3355f3b authored by Linyu Yuan's avatar Linyu Yuan
Browse files

usb: misc: nb7vpq904m: support 4 lanes display



change to DP only mode when display is 4 lanes.

Change-Id: I5bd383ccc44afc2d60fff7068f0c52f45a3a93a5
Signed-off-by: default avatarLinyu Yuan <linyyuan@codeaurora.org>
parent 197f1cc9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include <linux/reset.h>
#include <linux/usb/dwc3-msm.h>
#include <linux/usb/role.h>
#include <linux/usb/redriver.h>

#include "core.h"
#include "gadget.h"
@@ -3985,6 +3986,7 @@ int dwc3_msm_release_ss_lane(struct device *dev)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dev);
	struct dwc3 *dwc = NULL;
	struct device_node *ssusb_redriver_node;

	if (mdwc == NULL) {
		dev_err(dev, "dwc3-msm is not initialized yet.\n");
@@ -4002,6 +4004,10 @@ int dwc3_msm_release_ss_lane(struct device *dev)
	flush_work(&mdwc->resume_work);
	drain_workqueue(mdwc->sm_usb_wq);

	ssusb_redriver_node =
		of_parse_phandle(mdwc->dev->of_node, "ssusb_redriver", 0);
	redriver_release_usb_lanes(ssusb_redriver_node);

	mdwc->ss_release_called = true;
	if (mdwc->id_state == DWC3_ID_GROUND) {
		/* stop USB host mode */
+4 −0
Original line number Diff line number Diff line
@@ -266,8 +266,12 @@ config USB_CHAOSKEY
	  To compile this driver as a module, choose M here: the
	  module will be called chaoskey.

config USB_REDRIVER
	bool

config USB_REDRIVER_NB7VPQ904M
	tristate "USB 3.1 Gen1/Gen2 10Gbps re-driver driver for NB7VPQ904M"
	depends on USB_PHY
	select USB_REDRIVER
	help
	  Say Y here if you want to support USB super speed re-driver NB7VPQ904M.
+41 −2
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/usb/ucsi_glink.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_gpio.h>
#include <linux/usb/redriver.h>

/* priority: INT_MAX >= x >= 0 */
#define NOTIFIER_PRIORITY		1
@@ -503,10 +504,21 @@ static int ssusb_redriver_ucsi_notifier(struct notifier_block *nb,
	struct ucsi_glink_constat_info *info = data;
	enum operation_mode op_mode;

	if (info->partner_usb && info->partner_alternate_mode)
	/*
	 * when connect a DP only cable,
	 * ucsi set usb flag first, then set usb and alternate mode
	 * after dp start link training.
	 * it should only set alternate_mode flag ???
	 */
	if (info->partner_usb && info->partner_alternate_mode) {
		if (redriver->op_mode == OP_MODE_DP)
			return NOTIFY_OK;
		op_mode = OP_MODE_USB_AND_DP;
	else if (info->partner_usb)
	} else if (info->partner_usb) {
		if (redriver->op_mode == OP_MODE_DP)
			return NOTIFY_OK;
		op_mode = OP_MODE_USB;
	}
	else if (info->partner_alternate_mode)
		op_mode = OP_MODE_DP;
	else
@@ -534,6 +546,33 @@ static int ssusb_redriver_ucsi_notifier(struct notifier_block *nb,
	return NOTIFY_OK;
}

int redriver_release_usb_lanes(struct device_node *node)
{
	struct ssusb_redriver *redriver;
	struct i2c_client *client;

	if (!node)
		return -EINVAL;

	client = of_find_i2c_device_by_node(node);
	if (!client)
		return -EINVAL;

	redriver = i2c_get_clientdata(client);

	if (redriver->op_mode == OP_MODE_DP)
		return 0;

	dev_dbg(redriver->dev, "display notify 4 lane mode\n");
	redriver->op_mode = OP_MODE_DP;

	ssusb_redriver_channel_update(redriver);
	ssusb_redriver_gen_dev_set(redriver);

	return 0;
}
EXPORT_SYMBOL(redriver_release_usb_lanes);

static void ssusb_redriver_orientation_gpio_init(
		struct ssusb_redriver *redriver)
{
+22 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
 */

#ifndef __LINUX_USB_REDRIVER_H
#define __LINUX_USB_REDRIVER_H

#ifdef CONFIG_USB_REDRIVER

int redriver_release_usb_lanes(struct device_node *node);

#else

static inline int redriver_release_usb_lanes(struct device_node *node)
{
	return 0;
}

#endif

#endif /*__LINUX_USB_REDRIVER_H */