^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2018-2020 Linaro Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef _IPA_INTERRUPT_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define _IPA_INTERRUPT_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/bits.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct ipa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct ipa_interrupt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * enum ipa_irq_id - IPA interrupt type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * @IPA_IRQ_UC_0: Microcontroller event interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * @IPA_IRQ_UC_1: Microcontroller response interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * @IPA_IRQ_TX_SUSPEND: Data ready interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * The data ready interrupt is signaled if data has arrived that is destined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * for an AP RX endpoint whose underlying GSI channel is suspended/stopped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) enum ipa_irq_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) IPA_IRQ_UC_0 = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) IPA_IRQ_UC_1 = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) IPA_IRQ_TX_SUSPEND = 14,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) IPA_IRQ_COUNT, /* Number of interrupt types (not an index) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * typedef ipa_irq_handler_t - IPA interrupt handler function type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * @ipa: IPA pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * @irq_id: interrupt type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * Callback function registered by ipa_interrupt_add() to handle a specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * IPA interrupt type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) typedef void (*ipa_irq_handler_t)(struct ipa *ipa, enum ipa_irq_id irq_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * ipa_interrupt_add() - Register a handler for an IPA interrupt type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * @irq_id: IPA interrupt type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @handler: Handler function for the interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * Add a handler for an IPA interrupt and enable it. IPA interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * handlers are run in threaded interrupt context, so are allowed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) void ipa_interrupt_add(struct ipa_interrupt *interrupt, enum ipa_irq_id irq_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ipa_irq_handler_t handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * ipa_interrupt_remove() - Remove the handler for an IPA interrupt type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @interrupt: IPA interrupt structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * @irq_id: IPA interrupt type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * Remove an IPA interrupt handler and disable it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void ipa_interrupt_remove(struct ipa_interrupt *interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) enum ipa_irq_id irq_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * ipa_interrupt_suspend_enable - Enable TX_SUSPEND for an endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @interrupt: IPA interrupt structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @endpoint_id: Endpoint whose interrupt should be enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Note: The "TX" in the name is from the perspective of the IPA hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * A TX_SUSPEND interrupt arrives on an AP RX enpoint when packet data can't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * be delivered to the endpoint because it is suspended (or its underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * channel is stopped).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) void ipa_interrupt_suspend_enable(struct ipa_interrupt *interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u32 endpoint_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * ipa_interrupt_suspend_disable - Disable TX_SUSPEND for an endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * @interrupt: IPA interrupt structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * @endpoint_id: Endpoint whose interrupt should be disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) void ipa_interrupt_suspend_disable(struct ipa_interrupt *interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u32 endpoint_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * ipa_interrupt_suspend_clear_all - clear all suspend interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * @interrupt: IPA interrupt structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * Clear the TX_SUSPEND interrupt for all endpoints that signaled it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * ipa_interrupt_simulate_suspend() - Simulate TX_SUSPEND IPA interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @interrupt: IPA interrupt structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * This calls the TX_SUSPEND interrupt handler, as if such an interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * had been signaled. This is needed to work around a hardware quirk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * that occurs if aggregation is active on an endpoint when its underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * channel is suspended.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * ipa_interrupt_setup() - Set up the IPA interrupt framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * @ipa: IPA pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * Return: Pointer to IPA SMP2P info, or a pointer-coded error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * ipa_interrupt_teardown() - Tear down the IPA interrupt framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * @interrupt: IPA interrupt structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) void ipa_interrupt_teardown(struct ipa_interrupt *interrupt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #endif /* _IPA_INTERRUPT_H_ */