Lines Matching +full:9 +full:- +full:series

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for Renesas 9-series PCIe clock generator driver
5 * The following series can be supported:
6 * - 9FGV/9DBV/9DMV/9FGL/9DML/9QXL/9SQ
8 * - 9FGV0241
9 * - 9FGV0441
14 #include <linux/clk-provider.h>
54 /* Supported Renesas 9-series models. */
60 /* Structure to describe features of a particular 9-series model */
78 * Renesas 9-series i2c regmap
114 return -EIO; in rs9_regmap_i2c_write()
126 xfer[0].addr = i2c->addr; in rs9_regmap_i2c_read()
131 xfer[1].addr = i2c->addr; in rs9_regmap_i2c_read()
136 ret = i2c_transfer(i2c->adapter, xfer, 2); in rs9_regmap_i2c_read()
140 return -EIO; in rs9_regmap_i2c_read()
165 enum rs9_model model = rs9->chip_info->model; in rs9_calc_dif()
177 struct i2c_client *client = rs9->client; in rs9_get_output_config()
185 rs9->clk_dif_sr |= dif; in rs9_get_output_config()
188 np = of_get_child_by_name(client->dev.of_node, name); in rs9_get_output_config()
193 ret = of_property_read_u32(np, "renesas,slew-rate", &sr); in rs9_get_output_config()
197 rs9->clk_dif_sr &= ~dif; in rs9_get_output_config()
199 rs9->clk_dif_sr |= dif; in rs9_get_output_config()
201 ret = dev_err_probe(&client->dev, -EINVAL, in rs9_get_output_config()
202 "Invalid renesas,slew-rate value\n"); in rs9_get_output_config()
210 struct i2c_client *client = rs9->client; in rs9_get_common_config()
211 struct device_node *np = client->dev.of_node; in rs9_get_common_config()
216 rs9->pll_amplitude = RS9_REG_SS_AMP_DEFAULT; in rs9_get_common_config()
217 rs9->pll_ssc = RS9_REG_SS_SSC_DEFAULT; in rs9_get_common_config()
220 ret = of_property_read_u32(np, "renesas,out-amplitude-microvolt", in rs9_get_common_config()
224 rs9->pll_amplitude = RS9_REG_SS_AMP_0V6; in rs9_get_common_config()
226 rs9->pll_amplitude = RS9_REG_SS_AMP_0V7; in rs9_get_common_config()
228 rs9->pll_amplitude = RS9_REG_SS_AMP_0V8; in rs9_get_common_config()
230 rs9->pll_amplitude = RS9_REG_SS_AMP_0V9; in rs9_get_common_config()
232 return dev_err_probe(&client->dev, -EINVAL, in rs9_get_common_config()
233 "Invalid renesas,out-amplitude-microvolt value\n"); in rs9_get_common_config()
237 ret = of_property_read_u32(np, "renesas,out-spread-spectrum", &ssc); in rs9_get_common_config()
240 rs9->pll_ssc = RS9_REG_SS_SSC_100; in rs9_get_common_config()
241 else if (ssc == 99750) /* -0.25% ... down spread */ in rs9_get_common_config()
242 rs9->pll_ssc = RS9_REG_SS_SSC_M025; in rs9_get_common_config()
243 else if (ssc == 99500) /* -0.50% ... down spread */ in rs9_get_common_config()
244 rs9->pll_ssc = RS9_REG_SS_SSC_M050; in rs9_get_common_config()
246 return dev_err_probe(&client->dev, -EINVAL, in rs9_get_common_config()
247 "Invalid renesas,out-spread-spectrum value\n"); in rs9_get_common_config()
257 /* If amplitude is non-default, update it. */ in rs9_update_config()
258 if (rs9->pll_amplitude != RS9_REG_SS_AMP_DEFAULT) { in rs9_update_config()
259 regmap_update_bits(rs9->regmap, RS9_REG_SS, RS9_REG_SS_AMP_MASK, in rs9_update_config()
260 rs9->pll_amplitude); in rs9_update_config()
263 /* If SSC is non-default, update it. */ in rs9_update_config()
264 if (rs9->pll_ssc != RS9_REG_SS_SSC_DEFAULT) { in rs9_update_config()
265 regmap_update_bits(rs9->regmap, RS9_REG_SS, RS9_REG_SS_SSC_MASK, in rs9_update_config()
266 rs9->pll_ssc); in rs9_update_config()
269 for (i = 0; i < rs9->chip_info->num_clks; i++) { in rs9_update_config()
272 if (rs9->clk_dif_sr & dif) in rs9_update_config()
275 regmap_update_bits(rs9->regmap, RS9_REG_SR, dif, in rs9_update_config()
276 rs9->clk_dif_sr & dif); in rs9_update_config()
284 unsigned int idx = clkspec->args[0]; in rs9_of_clk_get()
286 return rs9->clk_dif[idx]; in rs9_of_clk_get()
297 rs9 = devm_kzalloc(&client->dev, sizeof(*rs9), GFP_KERNEL); in rs9_probe()
299 return -ENOMEM; in rs9_probe()
302 rs9->client = client; in rs9_probe()
303 rs9->chip_info = device_get_match_data(&client->dev); in rs9_probe()
304 if (!rs9->chip_info) in rs9_probe()
305 return -EINVAL; in rs9_probe()
313 for (i = 0; i < rs9->chip_info->num_clks; i++) { in rs9_probe()
319 rs9->regmap = devm_regmap_init(&client->dev, NULL, in rs9_probe()
321 if (IS_ERR(rs9->regmap)) in rs9_probe()
322 return dev_err_probe(&client->dev, PTR_ERR(rs9->regmap), in rs9_probe()
326 ret = regmap_write(rs9->regmap, RS9_REG_BCP, 1); in rs9_probe()
330 ret = regmap_read(rs9->regmap, RS9_REG_VID, &vid); in rs9_probe()
334 ret = regmap_read(rs9->regmap, RS9_REG_DID, &did); in rs9_probe()
338 if (vid != RS9_REG_VID_IDT || did != rs9->chip_info->did) in rs9_probe()
339 return dev_err_probe(&client->dev, -ENODEV, in rs9_probe()
342 rs9->chip_info->did); in rs9_probe()
345 for (i = 0; i < rs9->chip_info->num_clks; i++) { in rs9_probe()
347 hw = devm_clk_hw_register_fixed_factor_index(&client->dev, name, in rs9_probe()
352 rs9->clk_dif[i] = hw; in rs9_probe()
355 ret = devm_of_clk_add_hw_provider(&client->dev, rs9_of_clk_get, rs9); in rs9_probe()
366 regcache_cache_only(rs9->regmap, true); in rs9_suspend()
367 regcache_mark_dirty(rs9->regmap); in rs9_suspend()
377 regcache_cache_only(rs9->regmap, false); in rs9_resume()
378 ret = regcache_sync(rs9->regmap); in rs9_resume()
397 { "9fgv0241", .driver_data = (kernel_ulong_t)&renesas_9fgv0241_info },
398 { "9fgv0441", .driver_data = (kernel_ulong_t)&renesas_9fgv0441_info },
404 { .compatible = "renesas,9fgv0241", .data = &renesas_9fgv0241_info },
405 { .compatible = "renesas,9fgv0441", .data = &renesas_9fgv0441_info },
414 .name = "clk-renesas-pcie-9series",
424 MODULE_DESCRIPTION("Renesas 9-series PCIe clock generator driver");