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.
9 #include <linux/types.h>
10 #include <linux/device.h>
11 #include <linux/notifier.h>
12 #include <linux/pm_wakeup.h>
14 #include "ipa_version.h"
18 #include "ipa_endpoint.h"
19 #include "ipa_interrupt.h"
24 struct platform_device;
31 * enum ipa_flag - IPA state flags
32 * @IPA_FLAG_RESUMED: Whether resume from suspend has been signaled
33 * @IPA_FLAG_COUNT: Number of defined IPA flags
37 IPA_FLAG_COUNT, /* Last; not a flag */
41 * struct ipa - IPA information
42 * @gsi: Embedded GSI structure
43 * @flags: Boolean state flags
44 * @version: IPA hardware version
45 * @pdev: Platform device
46 * @modem_rproc: Remoteproc handle for modem subsystem
47 * @smp2p: SMP2P information
48 * @clock: IPA clocking information
49 * @table_addr: DMA address of filter/route table content
50 * @table_virt: Virtual address of filter/route table content
51 * @interrupt: IPA Interrupt information
52 * @uc_loaded: true after microcontroller has reported it's ready
53 * @reg_addr: DMA address used for IPA register access
54 * @reg_virt: Virtual address used for IPA register access
55 * @mem_addr: DMA address of IPA-local memory space
56 * @mem_virt: Virtual address of IPA-local memory space
57 * @mem_offset: Offset from @mem_virt used for access to IPA memory
58 * @mem_size: Total size (bytes) of memory at @mem_virt
59 * @mem: Array of IPA-local memory region descriptors
60 * @imem_iova: I/O virtual address of IPA region in IMEM
61 * @imem_size; Size of IMEM region
62 * @smem_iova: I/O virtual address of IPA region in SMEM
63 * @smem_size; Size of SMEM region
64 * @zero_addr: DMA address of preallocated zero-filled memory
65 * @zero_virt: Virtual address of preallocated zero-filled memory
66 * @zero_size: Size (bytes) of preallocated zero-filled memory
67 * @wakeup_source: Wakeup source information
68 * @available: Bit mask indicating endpoints hardware supports
69 * @filter_map: Bit mask indicating endpoints that support filtering
70 * @initialized: Bit mask indicating endpoints initialized
71 * @set_up: Bit mask indicating endpoints set up
72 * @enabled: Bit mask indicating endpoints enabled
73 * @endpoint: Array of endpoint information
74 * @channel_map: Mapping of GSI channel to IPA endpoint
75 * @name_map: Mapping of IPA endpoint name to IPA endpoint
76 * @setup_complete: Flag indicating whether setup stage has completed
77 * @modem_state: State of modem (stopped, running)
78 * @modem_netdev: Network device structure used for modem
79 * @qmi: QMI information
83 DECLARE_BITMAP(flags, IPA_FLAG_COUNT);
84 enum ipa_version version;
85 struct platform_device *pdev;
86 struct rproc *modem_rproc;
87 struct notifier_block nb;
89 struct ipa_smp2p *smp2p;
90 struct ipa_clock *clock;
92 dma_addr_t table_addr;
95 struct ipa_interrupt *interrupt;
99 void __iomem *reg_virt;
105 const struct ipa_mem *mem;
107 unsigned long imem_iova;
110 unsigned long smem_iova;
113 dma_addr_t zero_addr;
117 /* Bit masks indicating endpoint state */
118 u32 available; /* supported by hardware */
124 struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX];
125 struct ipa_endpoint *channel_map[GSI_CHANNEL_COUNT_MAX];
126 struct ipa_endpoint *name_map[IPA_ENDPOINT_COUNT];
130 atomic_t modem_state; /* enum ipa_modem_state */
131 struct net_device *modem_netdev;
136 * ipa_setup() - Perform IPA setup
139 * IPA initialization is broken into stages: init; config; and setup.
140 * (These have inverses exit, deconfig, and teardown.)
142 * Activities performed at the init stage can be done without requiring
143 * any access to IPA hardware. Activities performed at the config stage
144 * require the IPA clock to be running, because they involve access
145 * to IPA registers. The setup stage is performed only after the GSI
146 * hardware is ready (more on this below). The setup stage allows
147 * the AP to perform more complex initialization by issuing "immediate
148 * commands" using a special interface to the IPA.
150 * This function, @ipa_setup(), starts the setup stage.
152 * In order for the GSI hardware to be functional it needs firmware to be
153 * loaded (in addition to some other low-level initialization). This early
154 * GSI initialization can be done either by Trust Zone on the AP or by the
157 * If it's done by Trust Zone, the AP loads the GSI firmware and supplies
158 * it to Trust Zone to verify and install. When this completes, if
159 * verification was successful, the GSI layer is ready and ipa_setup()
160 * implements the setup phase of initialization.
162 * If the modem performs early GSI initialization, the AP needs to know
163 * when this has occurred. An SMP2P interrupt is used for this purpose,
164 * and receipt of that interrupt triggers the call to ipa_setup().
166 int ipa_setup(struct ipa *ipa);