Lines Matching +full:- +full:- +full:mode +full:- +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2016-2017 HiSilicon Co., Ltd. http://www.hisilicon.com
21 #include <dt-bindings/phy/phy.h>
50 struct histb_combphy_mode mode; member
56 void __iomem *reg = priv->mmio + COMBPHY_CFG_REG; in nano_register_write()
74 static int is_mode_fixed(struct histb_combphy_mode *mode) in is_mode_fixed() argument
76 return (mode->fixed != PHY_NONE) ? true : false; in is_mode_fixed()
81 struct histb_combphy_mode *mode = &priv->mode; in histb_combphy_set_mode() local
82 struct regmap *syscon = priv->syscon; in histb_combphy_set_mode()
85 if (is_mode_fixed(mode)) in histb_combphy_set_mode()
88 switch (mode->select) { in histb_combphy_set_mode()
99 return -EINVAL; in histb_combphy_set_mode()
102 return regmap_update_bits(syscon, mode->reg, mode->mask, in histb_combphy_set_mode()
103 hw_sel << mode->shift); in histb_combphy_set_mode()
117 val = readl(priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
119 writel(val, priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
121 ret = clk_prepare_enable(priv->ref_clk); in histb_combphy_init()
125 reset_control_deassert(priv->por_rst); in histb_combphy_init()
128 val = readl(priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
130 writel(val, priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
149 val = readl(priv->mmio + COMBPHY_CFG_REG); in histb_combphy_exit()
151 writel(val, priv->mmio + COMBPHY_CFG_REG); in histb_combphy_exit()
153 reset_control_assert(priv->por_rst); in histb_combphy_exit()
154 clk_disable_unprepare(priv->ref_clk); in histb_combphy_exit()
169 struct histb_combphy_mode *mode = &priv->mode; in histb_combphy_xlate() local
171 if (args->args_count < 1) { in histb_combphy_xlate()
173 return ERR_PTR(-EINVAL); in histb_combphy_xlate()
176 mode->select = args->args[0]; in histb_combphy_xlate()
178 if (mode->select < PHY_TYPE_SATA || mode->select > PHY_TYPE_USB3) { in histb_combphy_xlate()
179 dev_err(dev, "invalid phy mode select argument\n"); in histb_combphy_xlate()
180 return ERR_PTR(-EINVAL); in histb_combphy_xlate()
183 if (is_mode_fixed(mode) && mode->select != mode->fixed) { in histb_combphy_xlate()
184 dev_err(dev, "mode select %d mismatch fixed phy mode %d\n", in histb_combphy_xlate()
185 mode->select, mode->fixed); in histb_combphy_xlate()
186 return ERR_PTR(-EINVAL); in histb_combphy_xlate()
189 return priv->phy; in histb_combphy_xlate()
195 struct device *dev = &pdev->dev; in histb_combphy_probe()
197 struct device_node *np = dev->of_node; in histb_combphy_probe()
198 struct histb_combphy_mode *mode; in histb_combphy_probe() local
204 return -ENOMEM; in histb_combphy_probe()
206 priv->mmio = devm_platform_ioremap_resource(pdev, 0); in histb_combphy_probe()
207 if (IS_ERR(priv->mmio)) { in histb_combphy_probe()
208 ret = PTR_ERR(priv->mmio); in histb_combphy_probe()
212 priv->syscon = syscon_node_to_regmap(np->parent); in histb_combphy_probe()
213 if (IS_ERR(priv->syscon)) { in histb_combphy_probe()
215 return PTR_ERR(priv->syscon); in histb_combphy_probe()
218 mode = &priv->mode; in histb_combphy_probe()
219 mode->fixed = PHY_NONE; in histb_combphy_probe()
221 ret = of_property_read_u32(np, "hisilicon,fixed-mode", &mode->fixed); in histb_combphy_probe()
223 dev_dbg(dev, "found fixed phy mode %d\n", mode->fixed); in histb_combphy_probe()
225 ret = of_property_read_u32_array(np, "hisilicon,mode-select-bits", in histb_combphy_probe()
228 if (is_mode_fixed(mode)) { in histb_combphy_probe()
229 dev_err(dev, "found select bits for fixed mode phy\n"); in histb_combphy_probe()
230 return -EINVAL; in histb_combphy_probe()
233 mode->reg = vals[0]; in histb_combphy_probe()
234 mode->shift = vals[1]; in histb_combphy_probe()
235 mode->mask = vals[2]; in histb_combphy_probe()
236 dev_dbg(dev, "found mode select bits\n"); in histb_combphy_probe()
238 if (!is_mode_fixed(mode)) { in histb_combphy_probe()
239 dev_err(dev, "no valid select bits found for non-fixed phy\n"); in histb_combphy_probe()
240 return -ENODEV; in histb_combphy_probe()
244 priv->ref_clk = devm_clk_get(dev, NULL); in histb_combphy_probe()
245 if (IS_ERR(priv->ref_clk)) { in histb_combphy_probe()
247 return PTR_ERR(priv->ref_clk); in histb_combphy_probe()
250 priv->por_rst = devm_reset_control_get(dev, NULL); in histb_combphy_probe()
251 if (IS_ERR(priv->por_rst)) { in histb_combphy_probe()
253 return PTR_ERR(priv->por_rst); in histb_combphy_probe()
256 priv->phy = devm_phy_create(dev, NULL, &histb_combphy_ops); in histb_combphy_probe()
257 if (IS_ERR(priv->phy)) { in histb_combphy_probe()
259 return PTR_ERR(priv->phy); in histb_combphy_probe()
263 phy_set_drvdata(priv->phy, priv); in histb_combphy_probe()
270 { .compatible = "hisilicon,hi3798cv200-combphy" },