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

Commit 49e9a820 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: misc: nb7vpq904m: update suspend and resume function"

parents ff744e68 829fa944
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 */

#include <linux/module.h>
@@ -153,6 +153,8 @@ struct ssusb_redriver {
	u8	loss_match[CHAN_MODE_NUM][CHANNEL_NUM];
	u8	flat_gain[CHAN_MODE_NUM][CHANNEL_NUM];

	u8	gen_dev_val;

	struct dentry	*debug_root;
};

@@ -210,7 +212,7 @@ static void ssusb_redriver_gen_dev_set(
		struct ssusb_redriver *redriver, bool on)
{
	int ret;
	u8 val;
	u8 val, oldval;

	val = 0;

@@ -276,11 +278,18 @@ static void ssusb_redriver_gen_dev_set(
	}

	/* exit/enter deep-sleep power mode */
	if (on)
	oldval = redriver->gen_dev_val;
	if (on) {
		val |= CHIP_EN;
	else
		val &= ~CHIP_EN;
		if (val == oldval)
			return;
	} else {
		/* no operation if already disabled */
		if (oldval && !(oldval & CHIP_EN))
			return;

		val &= ~CHIP_EN;
	}
	ret = redriver_i2c_reg_set(redriver, GEN_DEV_SET_REG, val);
	if (ret < 0)
		goto err_exit;
@@ -289,6 +298,7 @@ static void ssusb_redriver_gen_dev_set(
		"successfully (%s) the redriver chip, reg 0x00 = 0x%x\n",
		on ? "ENABLE":"DISABLE", val);

	redriver->gen_dev_val = val;
	return;

err_exit:
@@ -1142,8 +1152,10 @@ static int __maybe_unused redriver_i2c_suspend(struct device *dev)
			__func__);

	/* Disable redriver chip when USB cable disconnected */
	if (!redriver->vbus_active && !redriver->host_active &&
	    redriver->op_mode != OP_MODE_DP)
	if ((!redriver->vbus_active && !redriver->host_active &&
	     redriver->op_mode != OP_MODE_DP) ||
	    (redriver->host_active &&
	     redriver->op_mode == OP_MODE_USB_AND_DP))
		ssusb_redriver_gen_dev_set(redriver, false);

	flush_workqueue(redriver->redriver_wq);
@@ -1159,6 +1171,10 @@ static int __maybe_unused redriver_i2c_resume(struct device *dev)
	dev_dbg(redriver->dev, "%s: SS USB redriver resume.\n",
			__func__);

	if (redriver->host_active &&
	    redriver->op_mode == OP_MODE_USB_AND_DP)
		ssusb_redriver_gen_dev_set(redriver, true);

	flush_workqueue(redriver->redriver_wq);

	return 0;