Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / net / ipa / ipa.h
blob7ef10a4ff35e1dd4ba2e08bc456028539709cb01
1 /* SPDX-License-Identifier: GPL-2.0 */
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2024 Linaro Ltd.
5 */
6 #ifndef _IPA_H_
7 #define _IPA_H_
9 #include <linux/notifier.h>
10 #include <linux/types.h>
12 #include "gsi.h"
13 #include "ipa_endpoint.h"
14 #include "ipa_mem.h"
15 #include "ipa_qmi.h"
16 #include "ipa_version.h"
18 struct net_device;
20 struct ipa_interrupt;
21 struct ipa_power;
22 struct ipa_smp2p;
24 /**
25 * struct ipa - IPA information
26 * @gsi: Embedded GSI structure
27 * @version: IPA hardware version
28 * @dev: IPA device pointer
29 * @completion: Used to signal pipeline clear transfer complete
30 * @nb: Notifier block used for remoteproc SSR
31 * @notifier: Remoteproc SSR notifier
32 * @smp2p: SMP2P information
33 * @power: IPA power information
34 * @table_addr: DMA address of filter/route table content
35 * @table_virt: Virtual address of filter/route table content
36 * @route_count: Total number of entries in a routing table
37 * @modem_route_count: Number of modem entries in a routing table
38 * @filter_count: Maximum number of entries in a filter table
39 * @interrupt: IPA Interrupt information
40 * @uc_powered: true if power is active by proxy for microcontroller
41 * @uc_loaded: true after microcontroller has reported it's ready
42 * @reg_virt: Virtual address used for IPA register access
43 * @regs: IPA register definitions
44 * @mem_addr: DMA address of IPA-local memory space
45 * @mem_virt: Virtual address of IPA-local memory space
46 * @mem_offset: Offset from @mem_virt used for access to IPA memory
47 * @mem_size: Total size (bytes) of memory at @mem_virt
48 * @mem_count: Number of entries in the mem array
49 * @mem: Array of IPA-local memory region descriptors
50 * @imem_iova: I/O virtual address of IPA region in IMEM
51 * @imem_size: Size of IMEM region
52 * @smem_iova: I/O virtual address of IPA region in SMEM
53 * @smem_size: Size of SMEM region
54 * @zero_addr: DMA address of preallocated zero-filled memory
55 * @zero_virt: Virtual address of preallocated zero-filled memory
56 * @zero_size: Size (bytes) of preallocated zero-filled memory
57 * @endpoint_count: Number of defined bits in most bitmaps below
58 * @available_count: Number of defined bits in the available bitmap
59 * @defined: Bitmap of endpoints defined in config data
60 * @available: Bitmap of endpoints supported by hardware
61 * @filtered: Bitmap of endpoints that support filtering
62 * @set_up: Bitmap of endpoints that are set up for use
63 * @enabled: Bitmap of currently enabled endpoints
64 * @modem_tx_count: Number of defined modem TX endoints
65 * @endpoint: Array of endpoint information
66 * @channel_map: Mapping of GSI channel to IPA endpoint
67 * @name_map: Mapping of IPA endpoint name to IPA endpoint
68 * @setup_complete: Flag indicating whether setup stage has completed
69 * @modem_state: State of modem (stopped, running)
70 * @modem_netdev: Network device structure used for modem
71 * @qmi: QMI information
73 struct ipa {
74 struct gsi gsi;
75 enum ipa_version version;
76 struct device *dev;
77 struct completion completion;
78 struct notifier_block nb;
79 void *notifier;
80 struct ipa_smp2p *smp2p;
81 struct ipa_power *power;
83 dma_addr_t table_addr;
84 __le64 *table_virt;
85 u32 route_count;
86 u32 modem_route_count;
87 u32 filter_count;
89 struct ipa_interrupt *interrupt;
90 bool uc_powered;
91 bool uc_loaded;
93 void __iomem *reg_virt;
94 const struct regs *regs;
96 dma_addr_t mem_addr;
97 void *mem_virt;
98 u32 mem_offset;
99 u32 mem_size;
100 u32 mem_count;
101 const struct ipa_mem *mem;
103 unsigned long imem_iova;
104 size_t imem_size;
106 unsigned long smem_iova;
107 size_t smem_size;
109 dma_addr_t zero_addr;
110 void *zero_virt;
111 size_t zero_size;
113 /* Bitmaps indicating endpoint state */
114 u32 endpoint_count;
115 u32 available_count;
116 unsigned long *defined; /* Defined in configuration data */
117 unsigned long *available; /* Supported by hardware */
118 u64 filtered; /* Support filtering (AP and modem) */
119 unsigned long *set_up;
120 unsigned long *enabled;
122 u32 modem_tx_count;
123 struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX];
124 struct ipa_endpoint *channel_map[GSI_CHANNEL_COUNT_MAX];
125 struct ipa_endpoint *name_map[IPA_ENDPOINT_COUNT];
127 bool setup_complete;
129 atomic_t modem_state; /* enum ipa_modem_state */
130 struct net_device *modem_netdev;
131 struct ipa_qmi qmi;
135 * ipa_setup() - Perform IPA setup
136 * @ipa: IPA pointer
138 * IPA initialization is broken into stages: init; config; and setup.
139 * (These have inverses exit, deconfig, and teardown.)
141 * Activities performed at the init stage can be done without requiring
142 * any access to IPA hardware. Activities performed at the config stage
143 * require IPA power, because they involve access to IPA registers.
144 * The setup stage is performed only after the GSI hardware is ready
145 * (more on this below). The setup stage allows the AP to perform
146 * more complex initialization by issuing "immediate commands" using
147 * a special interface to the IPA.
149 * This function, @ipa_setup(), starts the setup stage.
151 * In order for the GSI hardware to be functional it needs firmware to be
152 * loaded (in addition to some other low-level initialization). This early
153 * GSI initialization can be done either by Trust Zone on the AP or by the
154 * modem.
156 * If it's done by Trust Zone, the AP loads the GSI firmware and supplies
157 * it to Trust Zone to verify and install. When this completes, if
158 * verification was successful, the GSI layer is ready and ipa_setup()
159 * implements the setup phase of initialization.
161 * If the modem performs early GSI initialization, the AP needs to know
162 * when this has occurred. An SMP2P interrupt is used for this purpose,
163 * and receipt of that interrupt triggers the call to ipa_setup().
165 int ipa_setup(struct ipa *ipa);
167 #endif /* _IPA_H_ */