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
20 #include <dt-bindings/phy/phy.h>
49 struct histb_combphy_mode mode; member
55 void __iomem *reg = priv->mmio + COMBPHY_CFG_REG; in nano_register_write()
73 static int is_mode_fixed(struct histb_combphy_mode *mode) in is_mode_fixed() argument
75 return (mode->fixed != PHY_NONE) ? true : false; in is_mode_fixed()
80 struct histb_combphy_mode *mode = &priv->mode; in histb_combphy_set_mode() local
81 struct regmap *syscon = priv->syscon; in histb_combphy_set_mode()
84 if (is_mode_fixed(mode)) in histb_combphy_set_mode()
87 switch (mode->select) { in histb_combphy_set_mode()
98 return -EINVAL; in histb_combphy_set_mode()
101 return regmap_update_bits(syscon, mode->reg, mode->mask, in histb_combphy_set_mode()
102 hw_sel << mode->shift); in histb_combphy_set_mode()
116 val = readl(priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
118 writel(val, priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
120 ret = clk_prepare_enable(priv->ref_clk); in histb_combphy_init()
124 reset_control_deassert(priv->por_rst); in histb_combphy_init()
127 val = readl(priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
129 writel(val, priv->mmio + COMBPHY_CFG_REG); in histb_combphy_init()
148 val = readl(priv->mmio + COMBPHY_CFG_REG); in histb_combphy_exit()
150 writel(val, priv->mmio + COMBPHY_CFG_REG); in histb_combphy_exit()
152 reset_control_assert(priv->por_rst); in histb_combphy_exit()
153 clk_disable_unprepare(priv->ref_clk); in histb_combphy_exit()
168 struct histb_combphy_mode *mode = &priv->mode; in histb_combphy_xlate() local
170 if (args->args_count < 1) { in histb_combphy_xlate()
172 return ERR_PTR(-EINVAL); in histb_combphy_xlate()
175 mode->select = args->args[0]; in histb_combphy_xlate()
177 if (mode->select < PHY_TYPE_SATA || mode->select > PHY_TYPE_USB3) { in histb_combphy_xlate()
178 dev_err(dev, "invalid phy mode select argument\n"); in histb_combphy_xlate()
179 return ERR_PTR(-EINVAL); in histb_combphy_xlate()
182 if (is_mode_fixed(mode) && mode->select != mode->fixed) { in histb_combphy_xlate()
183 dev_err(dev, "mode select %d mismatch fixed phy mode %d\n", in histb_combphy_xlate()
184 mode->select, mode->fixed); in histb_combphy_xlate()
185 return ERR_PTR(-EINVAL); in histb_combphy_xlate()
188 return priv->phy; in histb_combphy_xlate()
194 struct device *dev = &pdev->dev; in histb_combphy_probe()
196 struct device_node *np = dev->of_node; in histb_combphy_probe()
197 struct histb_combphy_mode *mode; in histb_combphy_probe() local
203 return -ENOMEM; in histb_combphy_probe()
205 priv->mmio = devm_platform_ioremap_resource(pdev, 0); in histb_combphy_probe()
206 if (IS_ERR(priv->mmio)) { in histb_combphy_probe()
207 ret = PTR_ERR(priv->mmio); in histb_combphy_probe()
211 priv->syscon = syscon_node_to_regmap(np->parent); in histb_combphy_probe()
212 if (IS_ERR(priv->syscon)) { in histb_combphy_probe()
214 return PTR_ERR(priv->syscon); in histb_combphy_probe()
217 mode = &priv->mode; in histb_combphy_probe()
218 mode->fixed = PHY_NONE; in histb_combphy_probe()
220 ret = of_property_read_u32(np, "hisilicon,fixed-mode", &mode->fixed); in histb_combphy_probe()
222 dev_dbg(dev, "found fixed phy mode %d\n", mode->fixed); in histb_combphy_probe()
224 ret = of_property_read_u32_array(np, "hisilicon,mode-select-bits", in histb_combphy_probe()
227 if (is_mode_fixed(mode)) { in histb_combphy_probe()
228 dev_err(dev, "found select bits for fixed mode phy\n"); in histb_combphy_probe()
229 return -EINVAL; in histb_combphy_probe()
232 mode->reg = vals[0]; in histb_combphy_probe()
233 mode->shift = vals[1]; in histb_combphy_probe()
234 mode->mask = vals[2]; in histb_combphy_probe()
235 dev_dbg(dev, "found mode select bits\n"); in histb_combphy_probe()
237 if (!is_mode_fixed(mode)) { in histb_combphy_probe()
238 dev_err(dev, "no valid select bits found for non-fixed phy\n"); in histb_combphy_probe()
239 return -ENODEV; in histb_combphy_probe()
243 priv->ref_clk = devm_clk_get(dev, NULL); in histb_combphy_probe()
244 if (IS_ERR(priv->ref_clk)) { in histb_combphy_probe()
246 return PTR_ERR(priv->ref_clk); in histb_combphy_probe()
249 priv->por_rst = devm_reset_control_get(dev, NULL); in histb_combphy_probe()
250 if (IS_ERR(priv->por_rst)) { in histb_combphy_probe()
252 return PTR_ERR(priv->por_rst); in histb_combphy_probe()
255 priv->phy = devm_phy_create(dev, NULL, &histb_combphy_ops); in histb_combphy_probe()
256 if (IS_ERR(priv->phy)) { in histb_combphy_probe()
258 return PTR_ERR(priv->phy); in histb_combphy_probe()
262 phy_set_drvdata(priv->phy, priv); in histb_combphy_probe()
269 { .compatible = "hisilicon,hi3798cv200-combphy" },