Lines Matching +full:reset +full:- +full:n +full:- +full:io
1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io>
7 * Based on phy-sun9i-usb.c, which is:
9 * Copyright (C) 2014-2015 Chen-Yu Tsai <wens@csie.org>
13 * Copyright (c) 2010-2015 Allwinner Technology Co., Ltd.
18 #include <linux/io.h>
22 #include <linux/reset.h>
43 #define SUNXI_TX_DEEMPH_3P5DB(n) ((n) << 19) argument
45 #define SUNXI_TX_DEEMPH_6DB(n) ((n) << 13) argument
47 #define SUNXI_TX_SWING_FULL(n) ((n) << 6) argument
49 #define SUNXI_LOS_BIAS(n) ((n) << 3) argument
51 #define SUNXI_TXVBOOSTLVL(n) ((n) << 0) argument
57 struct reset_control *reset; member
65 val = readl(phy->regs + SUNXI_PHY_EXTERNAL_CONTROL); in sun50i_usb3_phy_open()
68 writel(val, phy->regs + SUNXI_PHY_EXTERNAL_CONTROL); in sun50i_usb3_phy_open()
70 val = readl(phy->regs + SUNXI_PIPE_CLOCK_CONTROL); in sun50i_usb3_phy_open()
72 writel(val, phy->regs + SUNXI_PIPE_CLOCK_CONTROL); in sun50i_usb3_phy_open()
74 val = readl(phy->regs + SUNXI_ISCR); in sun50i_usb3_phy_open()
76 writel(val, phy->regs + SUNXI_ISCR); in sun50i_usb3_phy_open()
83 writel(0x0047fc87, phy->regs + SUNXI_PHY_TUNE_LOW); in sun50i_usb3_phy_open()
85 val = readl(phy->regs + SUNXI_PHY_TUNE_HIGH); in sun50i_usb3_phy_open()
94 writel(val, phy->regs + SUNXI_PHY_TUNE_HIGH); in sun50i_usb3_phy_open()
102 ret = clk_prepare_enable(phy->clk); in sun50i_usb3_phy_init()
106 ret = reset_control_deassert(phy->reset); in sun50i_usb3_phy_init()
108 clk_disable_unprepare(phy->clk); in sun50i_usb3_phy_init()
120 reset_control_assert(phy->reset); in sun50i_usb3_phy_exit()
121 clk_disable_unprepare(phy->clk); in sun50i_usb3_phy_exit()
135 struct device *dev = &pdev->dev; in sun50i_usb3_phy_probe()
140 return -ENOMEM; in sun50i_usb3_phy_probe()
142 phy->clk = devm_clk_get(dev, NULL); in sun50i_usb3_phy_probe()
143 if (IS_ERR(phy->clk)) { in sun50i_usb3_phy_probe()
144 if (PTR_ERR(phy->clk) != -EPROBE_DEFER) in sun50i_usb3_phy_probe()
145 dev_err(dev, "failed to get phy clock\n"); in sun50i_usb3_phy_probe()
146 return PTR_ERR(phy->clk); in sun50i_usb3_phy_probe()
149 phy->reset = devm_reset_control_get(dev, NULL); in sun50i_usb3_phy_probe()
150 if (IS_ERR(phy->reset)) { in sun50i_usb3_phy_probe()
151 dev_err(dev, "failed to get reset control\n"); in sun50i_usb3_phy_probe()
152 return PTR_ERR(phy->reset); in sun50i_usb3_phy_probe()
155 phy->regs = devm_platform_ioremap_resource(pdev, 0); in sun50i_usb3_phy_probe()
156 if (IS_ERR(phy->regs)) in sun50i_usb3_phy_probe()
157 return PTR_ERR(phy->regs); in sun50i_usb3_phy_probe()
159 phy->phy = devm_phy_create(dev, NULL, &sun50i_usb3_phy_ops); in sun50i_usb3_phy_probe()
160 if (IS_ERR(phy->phy)) { in sun50i_usb3_phy_probe()
161 dev_err(dev, "failed to create PHY\n"); in sun50i_usb3_phy_probe()
162 return PTR_ERR(phy->phy); in sun50i_usb3_phy_probe()
165 phy_set_drvdata(phy->phy, phy); in sun50i_usb3_phy_probe()
172 { .compatible = "allwinner,sun50i-h6-usb3-phy" },
181 .name = "sun50i-usb3-phy",
187 MODULE_AUTHOR("Icenowy Zheng <icenowy@aosc.io>");