Lines Matching full:smp2p
20 * DOC: IPA SMP2P communication with the modem
22 * SMP2P is a primitive communication mechanism available between the AP and
29 * latter case, the modem uses an SMP2P interrupt to tell the AP IPA driver
33 * clock by trigging another SMP2P interrupt to the AP. We communicate
34 * whether the clock is enabled using two SMP2P state bits--one to
39 * Finally, if the AP kernel panics, we update the SMP2P state bits even if
44 * struct ipa_smp2p - IPA SMP2P information
75 * ipa_smp2p_notify() - use SMP2P to tell modem about IPA clock state
76 * @smp2p: SMP2P information
80 * (via a panic notifier). It sets the two SMP2P state bits--one saying
84 static void ipa_smp2p_notify(struct ipa_smp2p *smp2p) in ipa_smp2p_notify() argument
89 if (smp2p->notified) in ipa_smp2p_notify()
92 smp2p->clock_on = ipa_clock_get_additional(smp2p->ipa); in ipa_smp2p_notify()
95 mask = BIT(smp2p->enabled_bit); in ipa_smp2p_notify()
96 value = smp2p->clock_on ? mask : 0; in ipa_smp2p_notify()
97 qcom_smem_state_update_bits(smp2p->enabled_state, mask, value); in ipa_smp2p_notify()
100 mask = BIT(smp2p->valid_bit); in ipa_smp2p_notify()
102 qcom_smem_state_update_bits(smp2p->valid_state, mask, value); in ipa_smp2p_notify()
104 smp2p->notified = true; in ipa_smp2p_notify()
107 /* Threaded IRQ handler for modem "ipa-clock-query" SMP2P interrupt */
110 struct ipa_smp2p *smp2p = dev_id; in ipa_smp2p_modem_clk_query_isr() local
112 ipa_smp2p_notify(smp2p); in ipa_smp2p_modem_clk_query_isr()
120 struct ipa_smp2p *smp2p; in ipa_smp2p_panic_notifier() local
122 smp2p = container_of(nb, struct ipa_smp2p, panic_notifier); in ipa_smp2p_panic_notifier()
124 ipa_smp2p_notify(smp2p); in ipa_smp2p_panic_notifier()
126 if (smp2p->clock_on) in ipa_smp2p_panic_notifier()
127 ipa_uc_panic_notifier(smp2p->ipa); in ipa_smp2p_panic_notifier()
132 static int ipa_smp2p_panic_notifier_register(struct ipa_smp2p *smp2p) in ipa_smp2p_panic_notifier_register() argument
135 smp2p->panic_notifier.notifier_call = ipa_smp2p_panic_notifier; in ipa_smp2p_panic_notifier_register()
136 smp2p->panic_notifier.priority = INT_MAX; /* Do it early */ in ipa_smp2p_panic_notifier_register()
139 &smp2p->panic_notifier); in ipa_smp2p_panic_notifier_register()
142 static void ipa_smp2p_panic_notifier_unregister(struct ipa_smp2p *smp2p) in ipa_smp2p_panic_notifier_unregister() argument
145 &smp2p->panic_notifier); in ipa_smp2p_panic_notifier_unregister()
148 /* Threaded IRQ handler for modem "ipa-setup-ready" SMP2P interrupt */
151 struct ipa_smp2p *smp2p = dev_id; in ipa_smp2p_modem_setup_ready_isr() local
153 mutex_lock(&smp2p->mutex); in ipa_smp2p_modem_setup_ready_isr()
155 if (!smp2p->disabled) { in ipa_smp2p_modem_setup_ready_isr()
158 ret = ipa_setup(smp2p->ipa); in ipa_smp2p_modem_setup_ready_isr()
160 dev_err(&smp2p->ipa->pdev->dev, in ipa_smp2p_modem_setup_ready_isr()
162 smp2p->disabled = true; in ipa_smp2p_modem_setup_ready_isr()
165 mutex_unlock(&smp2p->mutex); in ipa_smp2p_modem_setup_ready_isr()
170 /* Initialize SMP2P interrupts */
171 static int ipa_smp2p_irq_init(struct ipa_smp2p *smp2p, const char *name, in ipa_smp2p_irq_init() argument
174 struct device *dev = &smp2p->ipa->pdev->dev; in ipa_smp2p_irq_init()
178 ret = platform_get_irq_byname(smp2p->ipa->pdev, name); in ipa_smp2p_irq_init()
186 ret = request_threaded_irq(irq, NULL, handler, 0, name, smp2p); in ipa_smp2p_irq_init()
195 static void ipa_smp2p_irq_exit(struct ipa_smp2p *smp2p, u32 irq) in ipa_smp2p_irq_exit() argument
197 free_irq(irq, smp2p); in ipa_smp2p_irq_exit()
203 if (!ipa->smp2p->clock_on) in ipa_smp2p_clock_release()
207 ipa->smp2p->clock_on = false; in ipa_smp2p_clock_release()
210 /* Initialize the IPA SMP2P subsystem */
216 struct ipa_smp2p *smp2p; in ipa_smp2p_init() local
235 smp2p = kzalloc(sizeof(*smp2p), GFP_KERNEL); in ipa_smp2p_init()
236 if (!smp2p) in ipa_smp2p_init()
239 smp2p->ipa = ipa; in ipa_smp2p_init()
244 mutex_init(&smp2p->mutex); in ipa_smp2p_init()
245 smp2p->valid_state = valid_state; in ipa_smp2p_init()
246 smp2p->valid_bit = valid_bit; in ipa_smp2p_init()
247 smp2p->enabled_state = enabled_state; in ipa_smp2p_init()
248 smp2p->enabled_bit = enabled_bit; in ipa_smp2p_init()
251 ipa->smp2p = smp2p; in ipa_smp2p_init()
253 ret = ipa_smp2p_irq_init(smp2p, "ipa-clock-query", in ipa_smp2p_init()
257 smp2p->clock_query_irq = ret; in ipa_smp2p_init()
259 ret = ipa_smp2p_panic_notifier_register(smp2p); in ipa_smp2p_init()
265 ret = ipa_smp2p_irq_init(smp2p, "ipa-setup-ready", in ipa_smp2p_init()
269 smp2p->setup_ready_irq = ret; in ipa_smp2p_init()
275 ipa_smp2p_panic_notifier_unregister(smp2p); in ipa_smp2p_init()
277 ipa_smp2p_irq_exit(smp2p, smp2p->clock_query_irq); in ipa_smp2p_init()
279 ipa->smp2p = NULL; in ipa_smp2p_init()
280 mutex_destroy(&smp2p->mutex); in ipa_smp2p_init()
281 kfree(smp2p); in ipa_smp2p_init()
288 struct ipa_smp2p *smp2p = ipa->smp2p; in ipa_smp2p_exit() local
290 if (smp2p->setup_ready_irq) in ipa_smp2p_exit()
291 ipa_smp2p_irq_exit(smp2p, smp2p->setup_ready_irq); in ipa_smp2p_exit()
292 ipa_smp2p_panic_notifier_unregister(smp2p); in ipa_smp2p_exit()
293 ipa_smp2p_irq_exit(smp2p, smp2p->clock_query_irq); in ipa_smp2p_exit()
296 ipa->smp2p = NULL; in ipa_smp2p_exit()
297 mutex_destroy(&smp2p->mutex); in ipa_smp2p_exit()
298 kfree(smp2p); in ipa_smp2p_exit()
303 struct ipa_smp2p *smp2p = ipa->smp2p; in ipa_smp2p_disable() local
305 if (!smp2p->setup_ready_irq) in ipa_smp2p_disable()
308 mutex_lock(&smp2p->mutex); in ipa_smp2p_disable()
310 smp2p->disabled = true; in ipa_smp2p_disable()
312 mutex_unlock(&smp2p->mutex); in ipa_smp2p_disable()
318 struct ipa_smp2p *smp2p = ipa->smp2p; in ipa_smp2p_notify_reset() local
321 if (!smp2p->notified) in ipa_smp2p_notify_reset()
327 mask = BIT(smp2p->valid_bit); in ipa_smp2p_notify_reset()
328 qcom_smem_state_update_bits(smp2p->valid_state, mask, 0); in ipa_smp2p_notify_reset()
331 mask = BIT(smp2p->enabled_bit); in ipa_smp2p_notify_reset()
332 qcom_smem_state_update_bits(smp2p->enabled_state, mask, 0); in ipa_smp2p_notify_reset()
334 smp2p->notified = false; in ipa_smp2p_notify_reset()