1 /* SPDX-License-Identifier: GPL-2.0 */
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2020 Linaro Ltd.
6 #ifndef _IPA_INTERRUPT_H_
7 #define _IPA_INTERRUPT_H_
9 #include <linux/types.h>
10 #include <linux/bits.h>
16 * enum ipa_irq_id - IPA interrupt type
17 * @IPA_IRQ_UC_0: Microcontroller event interrupt
18 * @IPA_IRQ_UC_1: Microcontroller response interrupt
19 * @IPA_IRQ_TX_SUSPEND: Data ready interrupt
21 * The data ready interrupt is signaled if data has arrived that is destined
22 * for an AP RX endpoint whose underlying GSI channel is suspended/stopped.
27 IPA_IRQ_TX_SUSPEND = 14,
28 IPA_IRQ_COUNT, /* Number of interrupt types (not an index) */
32 * typedef ipa_irq_handler_t - IPA interrupt handler function type
34 * @irq_id: interrupt type
36 * Callback function registered by ipa_interrupt_add() to handle a specific
39 typedef void (*ipa_irq_handler_t)(struct ipa *ipa, enum ipa_irq_id irq_id);
42 * ipa_interrupt_add() - Register a handler for an IPA interrupt type
43 * @irq_id: IPA interrupt type
44 * @handler: Handler function for the interrupt
46 * Add a handler for an IPA interrupt and enable it. IPA interrupt
47 * handlers are run in threaded interrupt context, so are allowed to
50 void ipa_interrupt_add(struct ipa_interrupt *interrupt, enum ipa_irq_id irq_id,
51 ipa_irq_handler_t handler);
54 * ipa_interrupt_remove() - Remove the handler for an IPA interrupt type
55 * @interrupt: IPA interrupt structure
56 * @irq_id: IPA interrupt type
58 * Remove an IPA interrupt handler and disable it.
60 void ipa_interrupt_remove(struct ipa_interrupt *interrupt,
61 enum ipa_irq_id irq_id);
64 * ipa_interrupt_suspend_enable - Enable TX_SUSPEND for an endpoint
65 * @interrupt: IPA interrupt structure
66 * @endpoint_id: Endpoint whose interrupt should be enabled
68 * Note: The "TX" in the name is from the perspective of the IPA hardware.
69 * A TX_SUSPEND interrupt arrives on an AP RX enpoint when packet data can't
70 * be delivered to the endpoint because it is suspended (or its underlying
71 * channel is stopped).
73 void ipa_interrupt_suspend_enable(struct ipa_interrupt *interrupt,
77 * ipa_interrupt_suspend_disable - Disable TX_SUSPEND for an endpoint
78 * @interrupt: IPA interrupt structure
79 * @endpoint_id: Endpoint whose interrupt should be disabled
81 void ipa_interrupt_suspend_disable(struct ipa_interrupt *interrupt,
85 * ipa_interrupt_suspend_clear_all - clear all suspend interrupts
86 * @interrupt: IPA interrupt structure
88 * Clear the TX_SUSPEND interrupt for all endpoints that signaled it.
90 void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt);
93 * ipa_interrupt_simulate_suspend() - Simulate TX_SUSPEND IPA interrupt
94 * @interrupt: IPA interrupt structure
96 * This calls the TX_SUSPEND interrupt handler, as if such an interrupt
97 * had been signaled. This is needed to work around a hardware quirk
98 * that occurs if aggregation is active on an endpoint when its underlying
99 * channel is suspended.
101 void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt);
104 * ipa_interrupt_setup() - Set up the IPA interrupt framework
107 * Return: Pointer to IPA SMP2P info, or a pointer-coded error
109 struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa);
112 * ipa_interrupt_teardown() - Tear down the IPA interrupt framework
113 * @interrupt: IPA interrupt structure
115 void ipa_interrupt_teardown(struct ipa_interrupt *interrupt);
117 #endif /* _IPA_INTERRUPT_H_ */