1 /* SPDX-License-Identifier: GPL-2.0 */
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2022 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 * struct ipa - IPA information
32 * @gsi: Embedded GSI structure
33 * @version: IPA hardware version
34 * @pdev: Platform device
35 * @completion: Used to signal pipeline clear transfer complete
36 * @nb: Notifier block used for remoteproc SSR
37 * @notifier: Remoteproc SSR notifier
38 * @smp2p: SMP2P information
39 * @power: IPA power information
40 * @table_addr: DMA address of filter/route table content
41 * @table_virt: Virtual address of filter/route table content
42 * @route_count: Total number of entries in a routing table
43 * @modem_route_count: Number of modem entries in a routing table
44 * @filter_count: Maximum number of entries in a filter table
45 * @interrupt: IPA Interrupt information
46 * @uc_powered: true if power is active by proxy for microcontroller
47 * @uc_loaded: true after microcontroller has reported it's ready
48 * @reg_addr: DMA address used for IPA register access
49 * @reg_virt: Virtual address used for IPA register access
50 * @regs: IPA register definitions
51 * @mem_addr: DMA address of IPA-local memory space
52 * @mem_virt: Virtual address of IPA-local memory space
53 * @mem_offset: Offset from @mem_virt used for access to IPA memory
54 * @mem_size: Total size (bytes) of memory at @mem_virt
55 * @mem_count: Number of entries in the mem array
56 * @mem: Array of IPA-local memory region descriptors
57 * @imem_iova: I/O virtual address of IPA region in IMEM
58 * @imem_size: Size of IMEM region
59 * @smem_iova: I/O virtual address of IPA region in SMEM
60 * @smem_size: Size of SMEM region
61 * @zero_addr: DMA address of preallocated zero-filled memory
62 * @zero_virt: Virtual address of preallocated zero-filled memory
63 * @zero_size: Size (bytes) of preallocated zero-filled memory
64 * @endpoint_count: Number of defined bits in most bitmaps below
65 * @available_count: Number of defined bits in the available bitmap
66 * @defined: Bitmap of endpoints defined in config data
67 * @available: Bitmap of endpoints supported by hardware
68 * @filtered: Bitmap of endpoints that support filtering
69 * @set_up: Bitmap of endpoints that are set up for use
70 * @enabled: Bitmap of currently enabled endpoints
71 * @modem_tx_count: Number of defined modem TX endoints
72 * @endpoint: Array of endpoint information
73 * @channel_map: Mapping of GSI channel to IPA endpoint
74 * @name_map: Mapping of IPA endpoint name to IPA endpoint
75 * @setup_complete: Flag indicating whether setup stage has completed
76 * @modem_state: State of modem (stopped, running)
77 * @modem_netdev: Network device structure used for modem
78 * @qmi: QMI information
82 enum ipa_version version;
83 struct platform_device *pdev;
84 struct completion completion;
85 struct notifier_block nb;
87 struct ipa_smp2p *smp2p;
88 struct ipa_power *power;
90 dma_addr_t table_addr;
93 u32 modem_route_count;
96 struct ipa_interrupt *interrupt;
101 void __iomem *reg_virt;
102 const struct ipa_regs *regs;
109 const struct ipa_mem *mem;
111 unsigned long imem_iova;
114 unsigned long smem_iova;
117 dma_addr_t zero_addr;
121 /* Bitmaps indicating endpoint state */
124 unsigned long *defined; /* Defined in configuration data */
125 unsigned long *available; /* Supported by hardware */
126 u64 filtered; /* Support filtering (AP and modem) */
127 unsigned long *set_up;
128 unsigned long *enabled;
131 struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX];
132 struct ipa_endpoint *channel_map[GSI_CHANNEL_COUNT_MAX];
133 struct ipa_endpoint *name_map[IPA_ENDPOINT_COUNT];
137 atomic_t modem_state; /* enum ipa_modem_state */
138 struct net_device *modem_netdev;
143 * ipa_setup() - Perform IPA setup
146 * IPA initialization is broken into stages: init; config; and setup.
147 * (These have inverses exit, deconfig, and teardown.)
149 * Activities performed at the init stage can be done without requiring
150 * any access to IPA hardware. Activities performed at the config stage
151 * require IPA power, because they involve access to IPA registers.
152 * The setup stage is performed only after the GSI hardware is ready
153 * (more on this below). The setup stage allows the AP to perform
154 * more complex initialization by issuing "immediate commands" using
155 * a special interface to the IPA.
157 * This function, @ipa_setup(), starts the setup stage.
159 * In order for the GSI hardware to be functional it needs firmware to be
160 * loaded (in addition to some other low-level initialization). This early
161 * GSI initialization can be done either by Trust Zone on the AP or by the
164 * If it's done by Trust Zone, the AP loads the GSI firmware and supplies
165 * it to Trust Zone to verify and install. When this completes, if
166 * verification was successful, the GSI layer is ready and ipa_setup()
167 * implements the setup phase of initialization.
169 * If the modem performs early GSI initialization, the AP needs to know
170 * when this has occurred. An SMP2P interrupt is used for this purpose,
171 * and receipt of that interrupt triggers the call to ipa_setup().
173 int ipa_setup(struct ipa *ipa);