Lines Matching +full:- +full:- +full:mode +full:- +full:-

1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
3 // Copyright (c) 2017-2018, Linaro Limited
10 #include "wcd-clsh-v2.h"
14 int mode; member
22 /* Class-H registers for codecs from and above WCD9335 */
122 struct snd_soc_component *comp = ctrl->comp; in wcd_enable_clsh_block()
124 if ((enable && ++ctrl->clsh_users == 1) || in wcd_enable_clsh_block()
125 (!enable && --ctrl->clsh_users == 0)) in wcd_enable_clsh_block()
129 if (ctrl->clsh_users < 0) in wcd_enable_clsh_block()
130 ctrl->clsh_users = 0; in wcd_enable_clsh_block()
134 int mode) in wcd_clsh_set_buck_mode() argument
137 if (mode == CLS_H_HIFI) in wcd_clsh_set_buck_mode()
148 int mode) in wcd_clsh_v3_set_buck_mode() argument
150 if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || in wcd_clsh_v3_set_buck_mode()
151 mode == CLS_AB_HIFI || mode == CLS_AB_LOHIFI) in wcd_clsh_v3_set_buck_mode()
162 int mode) in wcd_clsh_set_flyback_mode() argument
165 if (mode == CLS_H_HIFI) in wcd_clsh_set_flyback_mode()
176 int mode, in wcd_clsh_buck_ctrl() argument
179 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_buck_ctrl()
182 if ((enable && (++ctrl->buck_users == 1)) || in wcd_clsh_buck_ctrl()
183 (!enable && (--ctrl->buck_users == 0))) in wcd_clsh_buck_ctrl()
196 int mode, in wcd_clsh_v3_buck_ctrl() argument
200 if ((enable && (++ctrl->buck_users == 1)) || in wcd_clsh_v3_buck_ctrl()
201 (!enable && (--ctrl->buck_users == 0))) { in wcd_clsh_v3_buck_ctrl()
210 if (mode == CLS_H_LOHIFI || mode == CLS_H_ULP || in wcd_clsh_v3_buck_ctrl()
211 mode == CLS_H_HIFI || mode == CLS_H_LP) in wcd_clsh_v3_buck_ctrl()
225 int mode, in wcd_clsh_flyback_ctrl() argument
228 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_flyback_ctrl()
231 if ((enable && (++ctrl->flyback_users == 1)) || in wcd_clsh_flyback_ctrl()
232 (!enable && (--ctrl->flyback_users == 0))) { in wcd_clsh_flyback_ctrl()
246 static void wcd_clsh_set_gain_path(struct wcd_clsh_ctrl *ctrl, int mode) in wcd_clsh_set_gain_path() argument
248 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_set_gain_path()
251 switch (mode) { in wcd_clsh_set_gain_path()
273 static void wcd_clsh_v2_set_hph_mode(struct snd_soc_component *comp, int mode) in wcd_clsh_v2_set_hph_mode() argument
279 switch (mode) { in wcd_clsh_v2_set_hph_mode()
307 if (mode != CLS_H_LP) in wcd_clsh_v2_set_hph_mode()
318 int mode) in wcd_clsh_v3_set_hph_mode() argument
322 switch (mode) { in wcd_clsh_v3_set_hph_mode()
341 dev_err(component->dev, "%s:Invalid mode %d\n", __func__, mode); in wcd_clsh_v3_set_hph_mode()
348 void wcd_clsh_set_hph_mode(struct wcd_clsh_ctrl *ctrl, int mode) in wcd_clsh_set_hph_mode() argument
350 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_set_hph_mode()
352 if (ctrl->codec_version >= WCD937X) in wcd_clsh_set_hph_mode()
353 wcd_clsh_v3_set_hph_mode(comp, mode); in wcd_clsh_set_hph_mode()
355 wcd_clsh_v2_set_hph_mode(comp, mode); in wcd_clsh_set_hph_mode()
361 int mode) in wcd_clsh_set_flyback_current() argument
373 int mode) in wcd_clsh_set_buck_regulator_mode() argument
375 if (mode == CLS_AB) in wcd_clsh_set_buck_regulator_mode()
386 int mode) in wcd_clsh_v3_set_buck_regulator_mode() argument
393 int mode) in wcd_clsh_v3_set_flyback_mode() argument
395 if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || in wcd_clsh_v3_set_flyback_mode()
396 mode == CLS_AB_HIFI || mode == CLS_AB_LOHIFI) { in wcd_clsh_v3_set_flyback_mode()
414 int mode, bool enable) in wcd_clsh_v3_force_iq_ctl() argument
428 if (mode == CLS_H_LOHIFI || mode == CLS_AB_LOHIFI) { in wcd_clsh_v3_force_iq_ctl()
454 int mode, in wcd_clsh_v3_flyback_ctrl() argument
458 if ((enable && (++ctrl->flyback_users == 1)) || in wcd_clsh_v3_flyback_ctrl()
459 (!enable && (--ctrl->flyback_users == 0))) { in wcd_clsh_v3_flyback_ctrl()
480 int mode) in wcd_clsh_v3_set_flyback_current() argument
491 bool is_enable, int mode) in wcd_clsh_v3_state_aux() argument
493 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_aux()
496 wcd_clsh_v3_set_buck_mode(component, mode); in wcd_clsh_v3_state_aux()
497 wcd_clsh_v3_set_flyback_mode(component, mode); in wcd_clsh_v3_state_aux()
498 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_aux()
499 wcd_clsh_v3_set_flyback_current(component, mode); in wcd_clsh_v3_state_aux()
500 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_aux()
502 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, false); in wcd_clsh_v3_state_aux()
503 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, false); in wcd_clsh_v3_state_aux()
510 bool is_enable, int mode) in wcd_clsh_state_lo() argument
512 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_lo()
514 if (mode != CLS_AB) { in wcd_clsh_state_lo()
515 dev_err(comp->dev, "%s: LO cannot be in this mode: %d\n", in wcd_clsh_state_lo()
516 __func__, mode); in wcd_clsh_state_lo()
521 wcd_clsh_set_buck_regulator_mode(comp, mode); in wcd_clsh_state_lo()
522 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_lo()
523 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_lo()
524 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_lo()
525 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_lo()
526 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_lo()
528 wcd_clsh_buck_ctrl(ctrl, mode, false); in wcd_clsh_state_lo()
529 wcd_clsh_flyback_ctrl(ctrl, mode, false); in wcd_clsh_state_lo()
537 bool is_enable, int mode) in wcd_clsh_v3_state_hph_r() argument
539 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_hph_r()
541 if (mode == CLS_H_NORMAL) { in wcd_clsh_v3_state_hph_r()
542 dev_dbg(component->dev, "%s: Normal mode not applicable for hph_r\n", in wcd_clsh_v3_state_hph_r()
548 wcd_clsh_v3_set_buck_regulator_mode(component, mode); in wcd_clsh_v3_state_hph_r()
549 wcd_clsh_v3_set_flyback_mode(component, mode); in wcd_clsh_v3_state_hph_r()
550 wcd_clsh_v3_force_iq_ctl(component, mode, true); in wcd_clsh_v3_state_hph_r()
551 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_r()
552 wcd_clsh_v3_set_flyback_current(component, mode); in wcd_clsh_v3_state_hph_r()
553 wcd_clsh_v3_set_buck_mode(component, mode); in wcd_clsh_v3_state_hph_r()
554 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_r()
555 wcd_clsh_v3_set_hph_mode(component, mode); in wcd_clsh_v3_state_hph_r()
559 /* buck and flyback set to default mode and disable */ in wcd_clsh_v3_state_hph_r()
569 bool is_enable, int mode) in wcd_clsh_state_hph_r() argument
571 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_r()
573 if (mode == CLS_H_NORMAL) { in wcd_clsh_state_hph_r()
574 dev_err(comp->dev, "%s: Normal mode not applicable for hph_r\n", in wcd_clsh_state_hph_r()
580 if (mode != CLS_AB) { in wcd_clsh_state_hph_r()
599 wcd_clsh_set_buck_regulator_mode(comp, mode); in wcd_clsh_state_hph_r()
600 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_hph_r()
601 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_r()
602 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_hph_r()
603 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_hph_r()
604 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_r()
605 wcd_clsh_v2_set_hph_mode(comp, mode); in wcd_clsh_state_hph_r()
606 wcd_clsh_set_gain_path(ctrl, mode); in wcd_clsh_state_hph_r()
610 if (mode != CLS_AB) { in wcd_clsh_state_hph_r()
617 /* buck and flyback set to default mode and disable */ in wcd_clsh_state_hph_r()
627 bool is_enable, int mode) in wcd_clsh_v3_state_hph_l() argument
629 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_hph_l()
631 if (mode == CLS_H_NORMAL) { in wcd_clsh_v3_state_hph_l()
632 dev_dbg(component->dev, "%s: Normal mode not applicable for hph_l\n", in wcd_clsh_v3_state_hph_l()
638 wcd_clsh_v3_set_buck_regulator_mode(component, mode); in wcd_clsh_v3_state_hph_l()
639 wcd_clsh_v3_set_flyback_mode(component, mode); in wcd_clsh_v3_state_hph_l()
640 wcd_clsh_v3_force_iq_ctl(component, mode, true); in wcd_clsh_v3_state_hph_l()
641 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_l()
642 wcd_clsh_v3_set_flyback_current(component, mode); in wcd_clsh_v3_state_hph_l()
643 wcd_clsh_v3_set_buck_mode(component, mode); in wcd_clsh_v3_state_hph_l()
644 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_l()
645 wcd_clsh_v3_set_hph_mode(component, mode); in wcd_clsh_v3_state_hph_l()
649 /* set buck and flyback to Default Mode */ in wcd_clsh_v3_state_hph_l()
659 bool is_enable, int mode) in wcd_clsh_state_hph_l() argument
661 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_l()
663 if (mode == CLS_H_NORMAL) { in wcd_clsh_state_hph_l()
664 dev_err(comp->dev, "%s: Normal mode not applicable for hph_l\n", in wcd_clsh_state_hph_l()
670 if (mode != CLS_AB) { in wcd_clsh_state_hph_l()
689 wcd_clsh_set_buck_regulator_mode(comp, mode); in wcd_clsh_state_hph_l()
690 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_hph_l()
691 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_l()
692 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_hph_l()
693 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_hph_l()
694 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_l()
695 wcd_clsh_v2_set_hph_mode(comp, mode); in wcd_clsh_state_hph_l()
696 wcd_clsh_set_gain_path(ctrl, mode); in wcd_clsh_state_hph_l()
700 if (mode != CLS_AB) { in wcd_clsh_state_hph_l()
707 /* set buck and flyback to Default Mode */ in wcd_clsh_state_hph_l()
717 bool is_enable, int mode) in wcd_clsh_v3_state_ear() argument
719 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_ear()
722 wcd_clsh_v3_set_buck_regulator_mode(component, mode); in wcd_clsh_v3_state_ear()
723 wcd_clsh_v3_set_flyback_mode(component, mode); in wcd_clsh_v3_state_ear()
724 wcd_clsh_v3_force_iq_ctl(component, mode, true); in wcd_clsh_v3_state_ear()
725 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_ear()
726 wcd_clsh_v3_set_flyback_current(component, mode); in wcd_clsh_v3_state_ear()
727 wcd_clsh_v3_set_buck_mode(component, mode); in wcd_clsh_v3_state_ear()
728 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_ear()
729 wcd_clsh_v3_set_hph_mode(component, mode); in wcd_clsh_v3_state_ear()
733 /* set buck and flyback to Default Mode */ in wcd_clsh_v3_state_ear()
743 bool is_enable, int mode) in wcd_clsh_state_ear() argument
745 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_ear()
747 if (mode != CLS_H_NORMAL) { in wcd_clsh_state_ear()
748 dev_err(comp->dev, "%s: mode: %d cannot be used for EAR\n", in wcd_clsh_state_ear()
749 __func__, mode); in wcd_clsh_state_ear()
759 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_ear()
760 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_ear()
761 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_ear()
762 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_ear()
763 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_ear()
770 wcd_clsh_buck_ctrl(ctrl, mode, false); in wcd_clsh_state_ear()
771 wcd_clsh_flyback_ctrl(ctrl, mode, false); in wcd_clsh_state_ear()
778 bool is_enable, int mode) in _wcd_clsh_ctrl_set_state() argument
782 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
783 wcd_clsh_v3_state_ear(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
785 wcd_clsh_state_ear(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
788 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
789 wcd_clsh_v3_state_hph_l(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
791 wcd_clsh_state_hph_l(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
794 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
795 wcd_clsh_v3_state_hph_r(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
797 wcd_clsh_state_hph_r(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
800 if (ctrl->codec_version < WCD937X) in _wcd_clsh_ctrl_set_state()
801 wcd_clsh_state_lo(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
804 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
805 wcd_clsh_v3_state_aux(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
847 enum wcd_clsh_mode mode) in wcd_clsh_ctrl_set_state() argument
849 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_ctrl_set_state()
851 if (nstate == ctrl->state) in wcd_clsh_ctrl_set_state()
855 dev_err(comp->dev, "Class-H not a valid new state:\n"); in wcd_clsh_ctrl_set_state()
856 return -EINVAL; in wcd_clsh_ctrl_set_state()
861 _wcd_clsh_ctrl_set_state(ctrl, nstate, CLSH_REQ_ENABLE, mode); in wcd_clsh_ctrl_set_state()
864 _wcd_clsh_ctrl_set_state(ctrl, nstate, CLSH_REQ_DISABLE, mode); in wcd_clsh_ctrl_set_state()
868 ctrl->state = nstate; in wcd_clsh_ctrl_set_state()
869 ctrl->mode = mode; in wcd_clsh_ctrl_set_state()
877 return ctrl->state; in wcd_clsh_ctrl_get_state()
888 return ERR_PTR(-ENOMEM); in wcd_clsh_ctrl_alloc()
890 ctrl->state = WCD_CLSH_STATE_IDLE; in wcd_clsh_ctrl_alloc()
891 ctrl->comp = comp; in wcd_clsh_ctrl_alloc()
892 ctrl->codec_version = version; in wcd_clsh_ctrl_alloc()
904 MODULE_DESCRIPTION("WCD93XX Class-H driver");