Commit 8c2a794c authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman
Browse files

staging: hikey9xx: phy-hi3670-usb3: fix coding style

parent cf58bf42
Loading
Loading
Loading
Loading
+75 −80
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Phy provider for USB 3.1 controller on HiSilicon Kirin970 platform
 *
 * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd.
 * Copyright (C) 2017-2020 Hilisicon Electronics Co., Ltd.
 *		http://www.huawei.com
 *
 * Authors: Yu Chen <chenyu56@huawei.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2  of
 * the License 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.
 */

#include <linux/clk.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/clk.h>

#define SCTRL_SCDEEPSLEEPED		(0x0)
#define USB_CLK_SELECTED		BIT(20)
@@ -116,7 +108,7 @@
#define TCPC_VALID			BIT(4)
#define TCPC_LOW_POWER_EN		BIT(3)
#define TCPC_MUX_CONTROL_MASK		(3 << 0)
#define TCPC_MUX_CONTROL_USB31		(1 << 0)
#define TCPC_MUX_CONTROL_USB31		BIT(0)

#define SYSMODE_CFG_TYPEC_DISABLE	BIT(3)

@@ -174,10 +166,12 @@ static int hi3670_phy_cr_start(struct regmap *usb31misc, int direction)

	if (direction)
		ret = regmap_update_bits(usb31misc, USB_MISC_CFG54,
			CFG54_USB31PHY_CR_WR_EN, CFG54_USB31PHY_CR_WR_EN);
					 CFG54_USB31PHY_CR_WR_EN,
					 CFG54_USB31PHY_CR_WR_EN);
	else
		ret = regmap_update_bits(usb31misc, USB_MISC_CFG54,
			CFG54_USB31PHY_CR_RD_EN, CFG54_USB31PHY_CR_RD_EN);
					 CFG54_USB31PHY_CR_RD_EN,
					 CFG54_USB31PHY_CR_RD_EN);

	if (ret)
		return ret;
@@ -223,8 +217,7 @@ static int hi3670_phy_cr_set_addr(struct regmap *usb31misc, u32 addr)
		return ret;

	reg &= ~(CFG54_USB31PHY_CR_ADDR_MASK << CFG54_USB31PHY_CR_ADDR_SHIFT);
	reg |= ((addr & CFG54_USB31PHY_CR_ADDR_MASK) <<
			CFG54_USB31PHY_CR_ADDR_SHIFT);
	reg |= ((addr & CFG54_USB31PHY_CR_ADDR_MASK) << CFG54_USB31PHY_CR_ADDR_SHIFT);
	ret = regmap_write(usb31misc, USB_MISC_CFG54, reg);

	return ret;
@@ -319,7 +312,8 @@ static int hi3670_phy_set_params(struct hi3670_priv *priv)
					 TX_VBOOST_LVL_REG, &reg);
		if (!ret)
			break;
		else if (ret != -ETIMEDOUT) {

		if (ret != -ETIMEDOUT) {
			dev_err(priv->dev, "read TX_VBOOST_LVL_REG failed\n");
			return ret;
		}
@@ -327,8 +321,7 @@ static int hi3670_phy_set_params(struct hi3670_priv *priv)
	if (ret)
		return ret;

	reg |= (TX_VBOOST_LVL_ENABLE |
			(priv->tx_vboost_lvl << TX_VBOOST_LVL_START));
	reg |= (TX_VBOOST_LVL_ENABLE | (priv->tx_vboost_lvl << TX_VBOOST_LVL_START));
	ret = hi3670_phy_cr_write(priv->usb31misc, TX_VBOOST_LVL_REG, reg);
	if (ret)
		dev_err(priv->dev, "write TX_VBOOST_LVL_REG failed\n");
@@ -393,7 +386,10 @@ static int hi3670_config_phy_clock(struct hi3670_priv *priv)
		ret = regmap_write(priv->usb31misc, USB3OTG_CTRL7, val);
		if (ret)
			goto out;
	} else {

		return 0;
	}

	ret = regmap_update_bits(priv->usb31misc, USB_MISC_CFG54,
				 CFG54_USB3PHY_REF_USE_PAD,
				 CFG54_USB3PHY_REF_USE_PAD);
@@ -419,7 +415,6 @@ static int hi3670_config_phy_clock(struct hi3670_priv *priv)
			   PERI_CRG_PEREN6, GT_CLK_USB2PHY_REF);
	if (ret)
		goto out;
	}

	return 0;
out:
@@ -512,7 +507,7 @@ static int hi3670_phy_init(struct phy *phy)
	if (ret)
		goto out;

	udelay(100);
	usleep_range(100, 120);

	/* Tell the PHY power is stable */
	val = CFG54_USB3_PHY0_ANA_PWR_EN | CFG54_PHY0_PCS_PWR_STABLE |
@@ -539,7 +534,7 @@ static int hi3670_phy_init(struct phy *phy)
	if (ret)
		goto out;

	udelay(100);
	usleep_range(100, 120);

	/* Set fake vbus valid signal */
	val = CTRL0_USB3_VBUSVLD | CTRL0_USB3_VBUSVLD_SEL;
@@ -552,7 +547,7 @@ static int hi3670_phy_init(struct phy *phy)
	if (ret)
		goto out;

	udelay(100);
	usleep_range(100, 120);

	ret = hi3670_phy_set_params(priv);
	if (ret)
@@ -640,11 +635,11 @@ static int hi3670_phy_probe(struct platform_device *pdev)
	}

	if (of_property_read_u32(dev->of_node, "eye-diagram-param",
				&(priv->eye_diagram_param)))
				 &priv->eye_diagram_param))
		priv->eye_diagram_param = KIRIN970_USB_DEFAULT_PHY_PARAM;

	if (of_property_read_u32(dev->of_node, "usb3-phy-tx-vboost-lvl",
				&(priv->tx_vboost_lvl)))
				 &priv->tx_vboost_lvl))
		priv->eye_diagram_param = KIRIN970_USB_DEFAULT_PHY_VBOOST;

	phy = devm_phy_create(dev, NULL, &hi3670_phy_ops);
@@ -657,7 +652,7 @@ static int hi3670_phy_probe(struct platform_device *pdev)
}

static const struct of_device_id hi3670_phy_of_match[] = {
	{.compatible = "hisilicon,hi3670-usb-phy",},
	{ .compatible = "hisilicon,hi3670-usb-phy" },
	{ },
};
MODULE_DEVICE_TABLE(of, hi3670_phy_of_match);