Lines Matching +full:static +full:- +full:enable

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"
22 /* Class-H registers for codecs from and above WCD9335 */
119 static inline void wcd_enable_clsh_block(struct wcd_clsh_ctrl *ctrl, in wcd_enable_clsh_block()
120 bool enable) in wcd_enable_clsh_block() argument
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()
128 enable); 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()
133 static inline bool wcd_clsh_enable_status(struct snd_soc_component *comp) in wcd_clsh_enable_status()
139 static inline void wcd_clsh_set_buck_mode(struct snd_soc_component *comp, in wcd_clsh_set_buck_mode()
153 static void wcd_clsh_v3_set_buck_mode(struct snd_soc_component *component, in wcd_clsh_v3_set_buck_mode()
167 static inline void wcd_clsh_set_flyback_mode(struct snd_soc_component *comp, in wcd_clsh_set_flyback_mode()
181 static void wcd_clsh_buck_ctrl(struct wcd_clsh_ctrl *ctrl, in wcd_clsh_buck_ctrl()
183 bool enable) in wcd_clsh_buck_ctrl() argument
185 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_buck_ctrl()
187 /* enable/disable buck */ in wcd_clsh_buck_ctrl()
188 if ((enable && (++ctrl->buck_users == 1)) || in wcd_clsh_buck_ctrl()
189 (!enable && (--ctrl->buck_users == 0))) in wcd_clsh_buck_ctrl()
192 enable << WCD9XXX_A_ANA_RX_VPOS_EN_SHIFT); in wcd_clsh_buck_ctrl()
194 * 500us sleep is required after buck enable/disable in wcd_clsh_buck_ctrl()
200 static void wcd_clsh_v3_buck_ctrl(struct snd_soc_component *component, in wcd_clsh_v3_buck_ctrl()
203 bool enable) in wcd_clsh_v3_buck_ctrl() argument
205 /* enable/disable buck */ in wcd_clsh_v3_buck_ctrl()
206 if ((enable && (++ctrl->buck_users == 1)) || in wcd_clsh_v3_buck_ctrl()
207 (!enable && (--ctrl->buck_users == 0))) { in wcd_clsh_v3_buck_ctrl()
210 (1 << 7), (enable << 7)); in wcd_clsh_v3_buck_ctrl()
212 * 500us sleep is required after buck enable/disable in wcd_clsh_v3_buck_ctrl()
230 static void wcd_clsh_flyback_ctrl(struct wcd_clsh_ctrl *ctrl, in wcd_clsh_flyback_ctrl()
232 bool enable) in wcd_clsh_flyback_ctrl() argument
234 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_flyback_ctrl()
236 /* enable/disable flyback */ in wcd_clsh_flyback_ctrl()
237 if ((enable && (++ctrl->flyback_users == 1)) || in wcd_clsh_flyback_ctrl()
238 (!enable && (--ctrl->flyback_users == 0))) { in wcd_clsh_flyback_ctrl()
241 enable << WCD9XXX_A_ANA_RX_VNEG_EN_SHIFT); in wcd_clsh_flyback_ctrl()
246 * 500us sleep is required after flyback enable/disable in wcd_clsh_flyback_ctrl()
252 static void wcd_clsh_set_gain_path(struct wcd_clsh_ctrl *ctrl, int mode) in wcd_clsh_set_gain_path()
254 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_set_gain_path()
279 static void wcd_clsh_v2_set_hph_mode(struct snd_soc_component *comp, int mode) in wcd_clsh_v2_set_hph_mode()
323 static void wcd_clsh_v3_set_hph_mode(struct snd_soc_component *component, in wcd_clsh_v3_set_hph_mode()
347 dev_err(component->dev, "%s:Invalid mode %d\n", __func__, mode); in wcd_clsh_v3_set_hph_mode()
356 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_set_hph_mode()
358 if (ctrl->codec_version >= WCD937X) in wcd_clsh_set_hph_mode()
365 static void wcd_clsh_set_flyback_current(struct snd_soc_component *comp, in wcd_clsh_set_flyback_current()
377 static void wcd_clsh_set_buck_regulator_mode(struct snd_soc_component *comp, in wcd_clsh_set_buck_regulator_mode()
390 static void wcd_clsh_v3_set_buck_regulator_mode(struct snd_soc_component *component, in wcd_clsh_v3_set_buck_regulator_mode()
397 static void wcd_clsh_v3_set_flyback_mode(struct snd_soc_component *component, in wcd_clsh_v3_set_flyback_mode()
418 static void wcd_clsh_v3_force_iq_ctl(struct snd_soc_component *component, in wcd_clsh_v3_force_iq_ctl()
419 int mode, bool enable) in wcd_clsh_v3_force_iq_ctl() argument
421 if (enable) { in wcd_clsh_v3_force_iq_ctl()
457 static void wcd_clsh_v3_flyback_ctrl(struct snd_soc_component *component, in wcd_clsh_v3_flyback_ctrl()
460 bool enable) in wcd_clsh_v3_flyback_ctrl() argument
462 /* enable/disable flyback */ in wcd_clsh_v3_flyback_ctrl()
463 if ((enable && (++ctrl->flyback_users == 1)) || in wcd_clsh_v3_flyback_ctrl()
464 (!enable && (--ctrl->flyback_users == 0))) { in wcd_clsh_v3_flyback_ctrl()
470 (1 << 6), (enable << 6)); in wcd_clsh_v3_flyback_ctrl()
472 * 100us sleep is required after flyback enable/disable in wcd_clsh_v3_flyback_ctrl()
484 static void wcd_clsh_v3_set_flyback_current(struct snd_soc_component *component, in wcd_clsh_v3_set_flyback_current()
495 static void wcd_clsh_v3_state_aux(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_aux()
498 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_aux()
514 static void wcd_clsh_state_lo(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_lo()
517 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_lo()
520 dev_err(comp->dev, "%s: LO cannot be in this mode: %d\n", in wcd_clsh_state_lo()
541 static void wcd_clsh_v3_state_hph_r(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_hph_r()
544 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_hph_r()
547 dev_dbg(component->dev, "%s: Normal mode not applicable for hph_r\n", in wcd_clsh_v3_state_hph_r()
573 static void wcd_clsh_state_hph_r(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_hph_r()
576 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_r()
579 dev_err(comp->dev, "%s: Normal mode not applicable for hph_r\n", in wcd_clsh_state_hph_r()
631 static void wcd_clsh_v3_state_hph_l(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_hph_l()
634 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_hph_l()
637 dev_dbg(component->dev, "%s: Normal mode not applicable for hph_l\n", in wcd_clsh_v3_state_hph_l()
663 static void wcd_clsh_state_hph_l(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_hph_l()
666 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_l()
669 dev_err(comp->dev, "%s: Normal mode not applicable for hph_l\n", in wcd_clsh_state_hph_l()
721 static void wcd_clsh_v3_state_ear(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_ear()
724 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_ear()
747 static void wcd_clsh_state_ear(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_ear()
750 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_ear()
753 dev_err(comp->dev, "%s: mode: %d cannot be used for EAR\n", in wcd_clsh_state_ear()
782 static int _wcd_clsh_ctrl_set_state(struct wcd_clsh_ctrl *ctrl, int req_state, in _wcd_clsh_ctrl_set_state()
787 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
793 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
799 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
805 if (ctrl->codec_version < WCD937X) in _wcd_clsh_ctrl_set_state()
809 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
825 static bool wcd_clsh_is_state_valid(int state) in wcd_clsh_is_state_valid()
854 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_ctrl_set_state()
856 if (nstate == ctrl->state) in wcd_clsh_ctrl_set_state()
860 dev_err(comp->dev, "Class-H not a valid new state:\n"); in wcd_clsh_ctrl_set_state()
861 return -EINVAL; in wcd_clsh_ctrl_set_state()
873 ctrl->state = nstate; in wcd_clsh_ctrl_set_state()
874 ctrl->mode = mode; in wcd_clsh_ctrl_set_state()
881 return ctrl->state; in wcd_clsh_ctrl_get_state()
891 return ERR_PTR(-ENOMEM); in wcd_clsh_ctrl_alloc()
893 ctrl->state = WCD_CLSH_STATE_IDLE; in wcd_clsh_ctrl_alloc()
894 ctrl->comp = comp; in wcd_clsh_ctrl_alloc()
895 ctrl->codec_version = version; in wcd_clsh_ctrl_alloc()