Lines Matching refs:sr
39 static inline void sr_write_reg(struct omap_sr *sr, unsigned offset, u32 value) in sr_write_reg() argument
41 __raw_writel(value, (sr->base + offset)); in sr_write_reg()
44 static inline void sr_modify_reg(struct omap_sr *sr, unsigned offset, u32 mask, in sr_modify_reg() argument
58 if (sr->ip_type == SR_TYPE_V1 && offset == ERRCONFIG_V1) in sr_modify_reg()
60 else if (sr->ip_type == SR_TYPE_V2 && offset == ERRCONFIG_V2) in sr_modify_reg()
63 reg_val = __raw_readl(sr->base + offset); in sr_modify_reg()
70 __raw_writel(reg_val, (sr->base + offset)); in sr_modify_reg()
73 static inline u32 sr_read_reg(struct omap_sr *sr, unsigned offset) in sr_read_reg() argument
75 return __raw_readl(sr->base + offset); in sr_read_reg()
127 static void sr_set_clk_length(struct omap_sr *sr) in sr_set_clk_length() argument
132 if (IS_ERR(sr->fck)) in sr_set_clk_length()
135 fclk_speed = clk_get_rate(sr->fck); in sr_set_clk_length()
139 sr->clk_length = SRCLKLENGTH_12MHZ_SYSCLK; in sr_set_clk_length()
142 sr->clk_length = SRCLKLENGTH_13MHZ_SYSCLK; in sr_set_clk_length()
145 sr->clk_length = SRCLKLENGTH_19MHZ_SYSCLK; in sr_set_clk_length()
148 sr->clk_length = SRCLKLENGTH_26MHZ_SYSCLK; in sr_set_clk_length()
151 sr->clk_length = SRCLKLENGTH_38MHZ_SYSCLK; in sr_set_clk_length()
154 dev_err(&sr->pdev->dev, "%s: Invalid fclk rate: %d\n", in sr_set_clk_length()
160 static void sr_start_vddautocomp(struct omap_sr *sr) in sr_start_vddautocomp() argument
163 dev_warn(&sr->pdev->dev, in sr_start_vddautocomp()
169 if (!sr_class->enable(sr)) in sr_start_vddautocomp()
170 sr->autocomp_active = true; in sr_start_vddautocomp()
173 static void sr_stop_vddautocomp(struct omap_sr *sr) in sr_stop_vddautocomp() argument
176 dev_warn(&sr->pdev->dev, in sr_stop_vddautocomp()
182 if (sr->autocomp_active) { in sr_stop_vddautocomp()
183 sr_class->disable(sr, 1); in sr_stop_vddautocomp()
184 sr->autocomp_active = false; in sr_stop_vddautocomp()
221 static void sr_v1_disable(struct omap_sr *sr) in sr_v1_disable() argument
228 sr_modify_reg(sr, ERRCONFIG_V1, in sr_v1_disable()
232 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0); in sr_v1_disable()
235 if (sr_read_reg(sr, ERRCONFIG_V1) & ERRCONFIG_VPBOUNDINTST_V1) in sr_v1_disable()
237 sr_modify_reg(sr, ERRCONFIG_V1, in sr_v1_disable()
246 sr_test_cond_timeout((sr_read_reg(sr, ERRCONFIG_V1) & in sr_v1_disable()
251 dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", in sr_v1_disable()
255 sr_modify_reg(sr, ERRCONFIG_V1, ERRCONFIG_MCUDISACKINTEN, in sr_v1_disable()
259 static void sr_v2_disable(struct omap_sr *sr) in sr_v2_disable() argument
264 sr_write_reg(sr, IRQENABLE_SET, IRQENABLE_MCUDISABLEACKINT); in sr_v2_disable()
267 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0); in sr_v2_disable()
274 if (sr_read_reg(sr, ERRCONFIG_V2) & ERRCONFIG_VPBOUNDINTST_V2) in sr_v2_disable()
275 sr_modify_reg(sr, ERRCONFIG_V2, ERRCONFIG_VPBOUNDINTEN_V2, in sr_v2_disable()
278 sr_modify_reg(sr, ERRCONFIG_V2, ERRCONFIG_VPBOUNDINTEN_V2, in sr_v2_disable()
280 sr_write_reg(sr, IRQENABLE_CLR, (IRQENABLE_MCUACCUMINT | in sr_v2_disable()
283 sr_write_reg(sr, IRQSTATUS, (IRQSTATUS_MCUACCUMINT | in sr_v2_disable()
291 sr_test_cond_timeout((sr_read_reg(sr, IRQSTATUS) & in sr_v2_disable()
296 dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", in sr_v2_disable()
300 sr_write_reg(sr, IRQENABLE_CLR, IRQENABLE_MCUDISABLEACKINT); in sr_v2_disable()
301 sr_write_reg(sr, IRQSTATUS, IRQSTATUS_MCUDISABLEACKINT); in sr_v2_disable()
305 struct omap_sr *sr, u32 efuse_offs) in sr_retrieve_nvalue_row() argument
309 if (!sr->nvalue_table) { in sr_retrieve_nvalue_row()
310 dev_warn(&sr->pdev->dev, "%s: Missing ntarget value table\n", in sr_retrieve_nvalue_row()
315 for (i = 0; i < sr->nvalue_count; i++) { in sr_retrieve_nvalue_row()
316 if (sr->nvalue_table[i].efuse_offs == efuse_offs) in sr_retrieve_nvalue_row()
317 return &sr->nvalue_table[i]; in sr_retrieve_nvalue_row()
337 int sr_configure_errgen(struct omap_sr *sr) in sr_configure_errgen() argument
344 if (!sr) { in sr_configure_errgen()
350 if (!sr->clk_length) in sr_configure_errgen()
351 sr_set_clk_length(sr); in sr_configure_errgen()
353 senp_en = sr->senp_mod; in sr_configure_errgen()
354 senn_en = sr->senn_mod; in sr_configure_errgen()
356 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) | in sr_configure_errgen()
359 switch (sr->ip_type) { in sr_configure_errgen()
376 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex module without specifying the ip\n", in sr_configure_errgen()
382 sr_write_reg(sr, SRCONFIG, sr_config); in sr_configure_errgen()
383 sr_errconfig = (sr->err_weight << ERRCONFIG_ERRWEIGHT_SHIFT) | in sr_configure_errgen()
384 (sr->err_maxlimit << ERRCONFIG_ERRMAXLIMIT_SHIFT) | in sr_configure_errgen()
385 (sr->err_minlimit << ERRCONFIG_ERRMINLIMIT_SHIFT); in sr_configure_errgen()
386 sr_modify_reg(sr, errconfig_offs, (SR_ERRWEIGHT_MASK | in sr_configure_errgen()
391 sr_modify_reg(sr, errconfig_offs, (vpboundint_en | vpboundint_st), in sr_configure_errgen()
406 int sr_disable_errgen(struct omap_sr *sr) in sr_disable_errgen() argument
411 if (!sr) { in sr_disable_errgen()
417 switch (sr->ip_type) { in sr_disable_errgen()
429 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex module without specifying the ip\n", in sr_disable_errgen()
435 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN, 0); in sr_disable_errgen()
443 sr_modify_reg(sr, errconfig_offs, vpboundint_en | vpboundint_st, 0); in sr_disable_errgen()
460 int sr_configure_minmax(struct omap_sr *sr) in sr_configure_minmax() argument
466 if (!sr) { in sr_configure_minmax()
472 if (!sr->clk_length) in sr_configure_minmax()
473 sr_set_clk_length(sr); in sr_configure_minmax()
475 senp_en = sr->senp_mod; in sr_configure_minmax()
476 senn_en = sr->senn_mod; in sr_configure_minmax()
478 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) | in sr_configure_minmax()
480 (sr->accum_data << SRCONFIG_ACCUMDATA_SHIFT); in sr_configure_minmax()
482 switch (sr->ip_type) { in sr_configure_minmax()
493 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex module without specifying the ip\n", in sr_configure_minmax()
499 sr_write_reg(sr, SRCONFIG, sr_config); in sr_configure_minmax()
500 sr_avgwt = (sr->senp_avgweight << AVGWEIGHT_SENPAVGWEIGHT_SHIFT) | in sr_configure_minmax()
501 (sr->senn_avgweight << AVGWEIGHT_SENNAVGWEIGHT_SHIFT); in sr_configure_minmax()
502 sr_write_reg(sr, AVGWEIGHT, sr_avgwt); in sr_configure_minmax()
508 switch (sr->ip_type) { in sr_configure_minmax()
510 sr_modify_reg(sr, ERRCONFIG_V1, in sr_configure_minmax()
518 sr_write_reg(sr, IRQSTATUS, in sr_configure_minmax()
521 sr_write_reg(sr, IRQENABLE_SET, in sr_configure_minmax()
526 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex module without specifying the ip\n", in sr_configure_minmax()
545 int sr_enable(struct omap_sr *sr, unsigned long volt) in sr_enable() argument
551 if (!sr) { in sr_enable()
557 volt_data = omap_voltage_get_voltdata(sr->voltdm, volt); in sr_enable()
560 dev_warn(&sr->pdev->dev, "%s: Unable to get voltage table for nominal voltage %ld\n", in sr_enable()
565 nvalue_row = sr_retrieve_nvalue_row(sr, volt_data->sr_efuse_offs); in sr_enable()
568 dev_warn(&sr->pdev->dev, "%s: failure getting SR data for this voltage %ld\n", in sr_enable()
574 sr->err_minlimit = nvalue_row->errminlimit; in sr_enable()
576 clk_enable(sr->fck); in sr_enable()
579 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) in sr_enable()
583 ret = sr_class->configure(sr); in sr_enable()
587 sr_write_reg(sr, NVALUERECIPROCAL, nvalue_row->nvalue); in sr_enable()
590 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, SRCONFIG_SRENABLE); in sr_enable()
593 sr->enabled = 1; in sr_enable()
605 void sr_disable(struct omap_sr *sr) in sr_disable() argument
607 if (!sr) { in sr_disable()
614 if (!sr->enabled) in sr_disable()
621 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) { in sr_disable()
622 switch (sr->ip_type) { in sr_disable()
624 sr_v1_disable(sr); in sr_disable()
627 sr_v2_disable(sr); in sr_disable()
630 dev_err(&sr->pdev->dev, "UNKNOWN IP type %d\n", in sr_disable()
631 sr->ip_type); in sr_disable()
635 clk_disable(sr->fck); in sr_disable()
636 sr->enabled = 0; in sr_disable()
687 struct omap_sr *sr = _sr_lookup(voltdm); in omap_sr_enable() local
689 if (IS_ERR(sr)) { in omap_sr_enable()
694 if (!sr->autocomp_active) in omap_sr_enable()
698 dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not registered\n", in omap_sr_enable()
703 sr_class->enable(sr); in omap_sr_enable()
719 struct omap_sr *sr = _sr_lookup(voltdm); in omap_sr_disable() local
721 if (IS_ERR(sr)) { in omap_sr_disable()
726 if (!sr->autocomp_active) in omap_sr_disable()
730 dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not registered\n", in omap_sr_disable()
735 sr_class->disable(sr, 0); in omap_sr_disable()
751 struct omap_sr *sr = _sr_lookup(voltdm); in omap_sr_disable_reset_volt() local
753 if (IS_ERR(sr)) { in omap_sr_disable_reset_volt()
758 if (!sr->autocomp_active) in omap_sr_disable_reset_volt()
762 dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not registered\n", in omap_sr_disable_reset_volt()
767 sr_class->disable(sr, 1); in omap_sr_disable_reset_volt()