Lines Matching +full:out +full:- +full:amplitude +full:- +full:microvolt
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for Renesas 9-series PCIe clock generator driver
6 * - 9FGV/9DBV/9DMV/9FGL/9DML/9QXL/9SQ
8 * - 9FGV0241
9 * - 9FGV0441
10 * - 9FGV0841
15 #include <linux/clk-provider.h>
56 /* Structure to describe features of a particular 9-series model */
74 * Renesas 9-series i2c regmap
110 return -EIO; in rs9_regmap_i2c_write()
122 xfer[0].addr = i2c->addr; in rs9_regmap_i2c_read()
127 xfer[1].addr = i2c->addr; in rs9_regmap_i2c_read()
132 ret = i2c_transfer(i2c->adapter, xfer, 2); in rs9_regmap_i2c_read()
136 return -EIO; in rs9_regmap_i2c_read()
166 return BIT(idx + rs9->chip_info->outshift); in rs9_calc_dif()
171 struct i2c_client *client = rs9->client; in rs9_get_output_config()
179 rs9->clk_dif_sr |= dif; in rs9_get_output_config()
182 np = of_get_child_by_name(client->dev.of_node, name); in rs9_get_output_config()
187 ret = of_property_read_u32(np, "renesas,slew-rate", &sr); in rs9_get_output_config()
191 rs9->clk_dif_sr &= ~dif; in rs9_get_output_config()
193 rs9->clk_dif_sr |= dif; in rs9_get_output_config()
195 ret = dev_err_probe(&client->dev, -EINVAL, in rs9_get_output_config()
196 "Invalid renesas,slew-rate value\n"); in rs9_get_output_config()
204 struct i2c_client *client = rs9->client; in rs9_get_common_config()
205 struct device_node *np = client->dev.of_node; in rs9_get_common_config()
210 rs9->pll_amplitude = RS9_REG_SS_AMP_DEFAULT; in rs9_get_common_config()
211 rs9->pll_ssc = RS9_REG_SS_SSC_DEFAULT; in rs9_get_common_config()
213 /* Output clock amplitude */ in rs9_get_common_config()
214 ret = of_property_read_u32(np, "renesas,out-amplitude-microvolt", in rs9_get_common_config()
218 rs9->pll_amplitude = RS9_REG_SS_AMP_0V6; in rs9_get_common_config()
220 rs9->pll_amplitude = RS9_REG_SS_AMP_0V7; in rs9_get_common_config()
222 rs9->pll_amplitude = RS9_REG_SS_AMP_0V8; in rs9_get_common_config()
224 rs9->pll_amplitude = RS9_REG_SS_AMP_0V9; in rs9_get_common_config()
226 return dev_err_probe(&client->dev, -EINVAL, in rs9_get_common_config()
227 "Invalid renesas,out-amplitude-microvolt value\n"); in rs9_get_common_config()
231 ret = of_property_read_u32(np, "renesas,out-spread-spectrum", &ssc); in rs9_get_common_config()
234 rs9->pll_ssc = RS9_REG_SS_SSC_100; in rs9_get_common_config()
235 else if (ssc == 99750) /* -0.25% ... down spread */ in rs9_get_common_config()
236 rs9->pll_ssc = RS9_REG_SS_SSC_M025; in rs9_get_common_config()
237 else if (ssc == 99500) /* -0.50% ... down spread */ in rs9_get_common_config()
238 rs9->pll_ssc = RS9_REG_SS_SSC_M050; in rs9_get_common_config()
240 return dev_err_probe(&client->dev, -EINVAL, in rs9_get_common_config()
241 "Invalid renesas,out-spread-spectrum value\n"); in rs9_get_common_config()
251 /* If amplitude is non-default, update it. */ in rs9_update_config()
252 if (rs9->pll_amplitude != RS9_REG_SS_AMP_DEFAULT) { in rs9_update_config()
253 regmap_update_bits(rs9->regmap, RS9_REG_SS, RS9_REG_SS_AMP_MASK, in rs9_update_config()
254 rs9->pll_amplitude); in rs9_update_config()
257 /* If SSC is non-default, update it. */ in rs9_update_config()
258 if (rs9->pll_ssc != RS9_REG_SS_SSC_DEFAULT) { in rs9_update_config()
259 regmap_update_bits(rs9->regmap, RS9_REG_SS, RS9_REG_SS_SSC_MASK, in rs9_update_config()
260 rs9->pll_ssc); in rs9_update_config()
263 for (i = 0; i < rs9->chip_info->num_clks; i++) { in rs9_update_config()
266 if (rs9->clk_dif_sr & dif) in rs9_update_config()
269 regmap_update_bits(rs9->regmap, RS9_REG_SR, dif, in rs9_update_config()
270 rs9->clk_dif_sr & dif); in rs9_update_config()
278 unsigned int idx = clkspec->args[0]; in rs9_of_clk_get()
280 return rs9->clk_dif[idx]; in rs9_of_clk_get()
291 rs9 = devm_kzalloc(&client->dev, sizeof(*rs9), GFP_KERNEL); in rs9_probe()
293 return -ENOMEM; in rs9_probe()
296 rs9->client = client; in rs9_probe()
297 rs9->chip_info = i2c_get_match_data(client); in rs9_probe()
298 if (!rs9->chip_info) in rs9_probe()
299 return -EINVAL; in rs9_probe()
307 for (i = 0; i < rs9->chip_info->num_clks; i++) { in rs9_probe()
313 rs9->regmap = devm_regmap_init(&client->dev, NULL, in rs9_probe()
315 if (IS_ERR(rs9->regmap)) in rs9_probe()
316 return dev_err_probe(&client->dev, PTR_ERR(rs9->regmap), in rs9_probe()
320 ret = regmap_write(rs9->regmap, RS9_REG_BCP, 1); in rs9_probe()
324 ret = regmap_read(rs9->regmap, RS9_REG_VID, &vid); in rs9_probe()
328 ret = regmap_read(rs9->regmap, RS9_REG_DID, &did); in rs9_probe()
333 if (vid != RS9_REG_VID_IDT || did != rs9->chip_info->did) in rs9_probe()
334 return dev_err_probe(&client->dev, -ENODEV, in rs9_probe()
337 rs9->chip_info->did); in rs9_probe()
340 for (i = 0; i < rs9->chip_info->num_clks; i++) { in rs9_probe()
342 hw = devm_clk_hw_register_fixed_factor_index(&client->dev, name, in rs9_probe()
347 rs9->clk_dif[i] = hw; in rs9_probe()
350 ret = devm_of_clk_add_hw_provider(&client->dev, rs9_of_clk_get, rs9); in rs9_probe()
361 regcache_cache_only(rs9->regmap, true); in rs9_suspend()
362 regcache_mark_dirty(rs9->regmap); in rs9_suspend()
372 regcache_cache_only(rs9->regmap, false); in rs9_resume()
373 ret = regcache_sync(rs9->regmap); in rs9_resume()
417 .name = "clk-renesas-pcie-9series",
427 MODULE_DESCRIPTION("Renesas 9-series PCIe clock generator driver");