Lines Matching refs:rs9

159 static u8 rs9_calc_dif(const struct rs9_driver_data *rs9, int idx)  in rs9_calc_dif()  argument
166 return BIT(idx + rs9->chip_info->outshift); in rs9_calc_dif()
169 static int rs9_get_output_config(struct rs9_driver_data *rs9, int idx) in rs9_get_output_config() argument
171 struct i2c_client *client = rs9->client; in rs9_get_output_config()
172 u8 dif = rs9_calc_dif(rs9, idx); in rs9_get_output_config()
179 rs9->clk_dif_sr |= dif; 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()
202 static int rs9_get_common_config(struct rs9_driver_data *rs9) in rs9_get_common_config() argument
204 struct i2c_client *client = rs9->client; 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()
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()
234 rs9->pll_ssc = RS9_REG_SS_SSC_100; in rs9_get_common_config()
236 rs9->pll_ssc = RS9_REG_SS_SSC_M025; in rs9_get_common_config()
238 rs9->pll_ssc = RS9_REG_SS_SSC_M050; in rs9_get_common_config()
247 static void rs9_update_config(struct rs9_driver_data *rs9) in rs9_update_config() argument
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()
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()
264 u8 dif = rs9_calc_dif(rs9, 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()
277 struct rs9_driver_data *rs9 = data; in rs9_of_clk_get() local
280 return rs9->clk_dif[idx]; in rs9_of_clk_get()
286 struct rs9_driver_data *rs9; in rs9_probe() local
291 rs9 = devm_kzalloc(&client->dev, sizeof(*rs9), GFP_KERNEL); in rs9_probe()
292 if (!rs9) in rs9_probe()
295 i2c_set_clientdata(client, rs9); 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()
302 ret = rs9_get_common_config(rs9); in rs9_probe()
307 for (i = 0; i < rs9->chip_info->num_clks; i++) { in rs9_probe()
308 ret = rs9_get_output_config(rs9, 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()
337 rs9->chip_info->did); in rs9_probe()
340 for (i = 0; i < rs9->chip_info->num_clks; i++) { 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()
352 rs9_update_config(rs9); in rs9_probe()
359 struct rs9_driver_data *rs9 = dev_get_drvdata(dev); in rs9_suspend() local
361 regcache_cache_only(rs9->regmap, true); in rs9_suspend()
362 regcache_mark_dirty(rs9->regmap); in rs9_suspend()
369 struct rs9_driver_data *rs9 = dev_get_drvdata(dev); in rs9_resume() local
372 regcache_cache_only(rs9->regmap, false); in rs9_resume()
373 ret = regcache_sync(rs9->regmap); in rs9_resume()