Lines Matching +full:valid +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2019-2024 Linaro Ltd.
35 * whether power is enabled using two SMP2P state bits--one to indicate
37 * bit is valid. The modem will poll the valid bit until it is set, and
45 * struct ipa_smp2p - IPA SMP2P information
47 * @valid_state: SMEM state indicating enabled state is valid
49 * @valid_bit: Valid bit in 32-bit SMEM state mask
50 * @enabled_bit: Enabled bit in 32-bit SMEM state mask
51 * @enabled_bit: Enabled bit in 32-bit SMEM state mask
57 * @mutex: Mutex protecting ready-interrupt/shutdown interlock
76 * ipa_smp2p_notify() - use SMP2P to tell modem about IPA power state
81 * (via a panic notifier). It sets the two SMP2P state bits--one saying
83 * is valid.
88 u32 mask; in ipa_smp2p_notify() local
90 if (smp2p->notified) in ipa_smp2p_notify()
93 smp2p->power_on = pm_runtime_get_if_active(smp2p->ipa->dev) > 0; in ipa_smp2p_notify()
96 mask = BIT(smp2p->enabled_bit); in ipa_smp2p_notify()
97 value = smp2p->power_on ? mask : 0; in ipa_smp2p_notify()
98 qcom_smem_state_update_bits(smp2p->enabled_state, mask, value); in ipa_smp2p_notify()
100 /* Now indicate that the enabled flag is valid */ in ipa_smp2p_notify()
101 mask = BIT(smp2p->valid_bit); in ipa_smp2p_notify()
102 value = mask; in ipa_smp2p_notify()
103 qcom_smem_state_update_bits(smp2p->valid_state, mask, value); in ipa_smp2p_notify()
105 smp2p->notified = true; in ipa_smp2p_notify()
108 /* Threaded IRQ handler for modem "ipa-clock-query" SMP2P interrupt */
127 if (smp2p->power_on) in ipa_smp2p_panic_notifier()
128 ipa_uc_panic_notifier(smp2p->ipa); in ipa_smp2p_panic_notifier()
136 smp2p->panic_notifier.notifier_call = ipa_smp2p_panic_notifier; in ipa_smp2p_panic_notifier_register()
137 smp2p->panic_notifier.priority = INT_MAX; /* Do it early */ in ipa_smp2p_panic_notifier_register()
140 &smp2p->panic_notifier); in ipa_smp2p_panic_notifier_register()
146 &smp2p->panic_notifier); in ipa_smp2p_panic_notifier_unregister()
149 /* Threaded IRQ handler for modem "ipa-setup-ready" SMP2P interrupt */
153 struct ipa *ipa = smp2p->ipa; in ipa_smp2p_modem_setup_ready_isr()
158 if (ipa->setup_complete) in ipa_smp2p_modem_setup_ready_isr()
162 dev = ipa->dev; in ipa_smp2p_modem_setup_ready_isr()
185 struct device *dev = &pdev->dev; in ipa_smp2p_irq_init()
191 return ret ? : -EINVAL; in ipa_smp2p_irq_init()
211 struct device *dev = ipa->dev; in ipa_smp2p_power_release()
213 if (!ipa->smp2p->power_on) in ipa_smp2p_power_release()
218 ipa->smp2p->power_on = false; in ipa_smp2p_power_release()
226 struct device *dev = &pdev->dev; in ipa_smp2p_init()
233 valid_state = qcom_smem_state_get(dev, "ipa-clock-enabled-valid", in ipa_smp2p_init()
238 return -EINVAL; in ipa_smp2p_init()
240 enabled_state = qcom_smem_state_get(dev, "ipa-clock-enabled", in ipa_smp2p_init()
245 return -EINVAL; in ipa_smp2p_init()
249 return -ENOMEM; in ipa_smp2p_init()
251 smp2p->ipa = ipa; in ipa_smp2p_init()
256 mutex_init(&smp2p->mutex); in ipa_smp2p_init()
257 smp2p->valid_state = valid_state; in ipa_smp2p_init()
258 smp2p->valid_bit = valid_bit; in ipa_smp2p_init()
259 smp2p->enabled_state = enabled_state; in ipa_smp2p_init()
260 smp2p->enabled_bit = enabled_bit; in ipa_smp2p_init()
263 ipa->smp2p = smp2p; in ipa_smp2p_init()
265 ret = ipa_smp2p_irq_init(smp2p, pdev, "ipa-clock-query", in ipa_smp2p_init()
269 smp2p->clock_query_irq = ret; in ipa_smp2p_init()
276 /* Result will be non-zero (negative for error) */ in ipa_smp2p_init()
277 ret = ipa_smp2p_irq_init(smp2p, pdev, "ipa-setup-ready", in ipa_smp2p_init()
281 smp2p->setup_ready_irq = ret; in ipa_smp2p_init()
289 ipa_smp2p_irq_exit(smp2p, smp2p->clock_query_irq); in ipa_smp2p_init()
291 ipa->smp2p = NULL; in ipa_smp2p_init()
292 mutex_destroy(&smp2p->mutex); in ipa_smp2p_init()
300 struct ipa_smp2p *smp2p = ipa->smp2p; in ipa_smp2p_exit()
302 if (smp2p->setup_ready_irq) in ipa_smp2p_exit()
303 ipa_smp2p_irq_exit(smp2p, smp2p->setup_ready_irq); in ipa_smp2p_exit()
305 ipa_smp2p_irq_exit(smp2p, smp2p->clock_query_irq); in ipa_smp2p_exit()
308 ipa->smp2p = NULL; in ipa_smp2p_exit()
309 mutex_destroy(&smp2p->mutex); in ipa_smp2p_exit()
315 struct ipa_smp2p *smp2p = ipa->smp2p; in ipa_smp2p_irq_disable_setup()
317 if (!smp2p->setup_ready_irq) in ipa_smp2p_irq_disable_setup()
320 mutex_lock(&smp2p->mutex); in ipa_smp2p_irq_disable_setup()
322 if (!smp2p->setup_disabled) { in ipa_smp2p_irq_disable_setup()
323 disable_irq(smp2p->setup_ready_irq); in ipa_smp2p_irq_disable_setup()
324 smp2p->setup_disabled = true; in ipa_smp2p_irq_disable_setup()
327 mutex_unlock(&smp2p->mutex); in ipa_smp2p_irq_disable_setup()
333 struct ipa_smp2p *smp2p = ipa->smp2p; in ipa_smp2p_notify_reset()
334 u32 mask; in ipa_smp2p_notify_reset() local
336 if (!smp2p->notified) in ipa_smp2p_notify_reset()
341 /* Reset the power enabled valid flag */ in ipa_smp2p_notify_reset()
342 mask = BIT(smp2p->valid_bit); in ipa_smp2p_notify_reset()
343 qcom_smem_state_update_bits(smp2p->valid_state, mask, 0); in ipa_smp2p_notify_reset()
346 mask = BIT(smp2p->enabled_bit); in ipa_smp2p_notify_reset()
347 qcom_smem_state_update_bits(smp2p->enabled_state, mask, 0); in ipa_smp2p_notify_reset()
349 smp2p->notified = false; in ipa_smp2p_notify_reset()