Lines Matching +full:serdes +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Samsung SATA SerDes(PHY) driver
10 #include <linux/clk.h>
50 struct clk *phyclk;
66 return -EFAULT; in wait_for_reg_status()
73 return regmap_update_bits(sata_phy->pmureg, SATAPHY_CONTROL_OFFSET, in exynos_sata_phy_power_on()
82 return regmap_update_bits(sata_phy->pmureg, SATAPHY_CONTROL_OFFSET, in exynos_sata_phy_power_off()
94 ret = regmap_update_bits(sata_phy->pmureg, SATAPHY_CONTROL_OFFSET, in exynos_sata_phy_init()
97 dev_err(&sata_phy->phy->dev, "phy init failed\n"); in exynos_sata_phy_init()
99 writel(val, sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
101 val = readl(sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
105 writel(val, sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
107 val = readl(sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
109 writel(val, sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
111 val = readl(sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
113 writel(val, sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
115 val = readl(sata_phy->regs + EXYNOS5_SATA_PHSATA_CTRLM); in exynos_sata_phy_init()
117 writel(val, sata_phy->regs + EXYNOS5_SATA_PHSATA_CTRLM); in exynos_sata_phy_init()
120 val = readl(sata_phy->regs + EXYNOS5_SATA_PHSATA_CTRLM); in exynos_sata_phy_init()
122 writel(val, sata_phy->regs + EXYNOS5_SATA_PHSATA_CTRLM); in exynos_sata_phy_init()
124 val = readl(sata_phy->regs + EXYNOS5_SATA_CTRL0); in exynos_sata_phy_init()
126 writel(val, sata_phy->regs + EXYNOS5_SATA_CTRL0); in exynos_sata_phy_init()
128 val = readl(sata_phy->regs + EXYNOS5_SATA_MODE0); in exynos_sata_phy_init()
130 writel(val, sata_phy->regs + EXYNOS5_SATA_MODE0); in exynos_sata_phy_init()
132 ret = i2c_master_send(sata_phy->client, buf, sizeof(buf)); in exynos_sata_phy_init()
137 val = readl(sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
139 writel(val, sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
141 val = readl(sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
143 writel(val, sata_phy->regs + EXYNOS5_SATA_RESET); in exynos_sata_phy_init()
145 ret = wait_for_reg_status(sata_phy->regs, in exynos_sata_phy_init()
149 dev_err(&sata_phy->phy->dev, in exynos_sata_phy_init()
164 struct device *dev = &pdev->dev; in exynos_sata_phy_probe()
171 return -ENOMEM; in exynos_sata_phy_probe()
173 sata_phy->regs = devm_platform_ioremap_resource(pdev, 0); in exynos_sata_phy_probe()
174 if (IS_ERR(sata_phy->regs)) in exynos_sata_phy_probe()
175 return PTR_ERR(sata_phy->regs); in exynos_sata_phy_probe()
177 sata_phy->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node, in exynos_sata_phy_probe()
178 "samsung,syscon-phandle"); in exynos_sata_phy_probe()
179 if (IS_ERR(sata_phy->pmureg)) { in exynos_sata_phy_probe()
181 return PTR_ERR(sata_phy->pmureg); in exynos_sata_phy_probe()
184 node = of_parse_phandle(dev->of_node, in exynos_sata_phy_probe()
185 "samsung,exynos-sataphy-i2c-phandle", 0); in exynos_sata_phy_probe()
187 return -EINVAL; in exynos_sata_phy_probe()
189 sata_phy->client = of_find_i2c_device_by_node(node); in exynos_sata_phy_probe()
191 if (!sata_phy->client) in exynos_sata_phy_probe()
192 return -EPROBE_DEFER; in exynos_sata_phy_probe()
196 sata_phy->phyclk = devm_clk_get(dev, "sata_phyctrl"); in exynos_sata_phy_probe()
197 if (IS_ERR(sata_phy->phyclk)) { in exynos_sata_phy_probe()
198 dev_err(dev, "failed to get clk for PHY\n"); in exynos_sata_phy_probe()
199 ret = PTR_ERR(sata_phy->phyclk); in exynos_sata_phy_probe()
203 ret = clk_prepare_enable(sata_phy->phyclk); in exynos_sata_phy_probe()
205 dev_err(dev, "failed to enable source clk\n"); in exynos_sata_phy_probe()
209 sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops); in exynos_sata_phy_probe()
210 if (IS_ERR(sata_phy->phy)) { in exynos_sata_phy_probe()
212 ret = PTR_ERR(sata_phy->phy); in exynos_sata_phy_probe()
216 phy_set_drvdata(sata_phy->phy, sata_phy); in exynos_sata_phy_probe()
228 clk_disable_unprepare(sata_phy->phyclk); in exynos_sata_phy_probe()
230 put_device(&sata_phy->client->dev); in exynos_sata_phy_probe()
236 { .compatible = "samsung,exynos5250-sata-phy" },
245 .name = "samsung,sata-phy",
251 MODULE_DESCRIPTION("Samsung SerDes PHY driver");