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