168 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2 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_8 9#include <linux/notifier.h>10#include <linux/types.h>11 12#include "gsi.h"13#include "ipa_endpoint.h"14#include "ipa_mem.h"15#include "ipa_qmi.h"16#include "ipa_version.h"17 18struct net_device;19 20struct ipa_interrupt;21struct ipa_power;22struct ipa_smp2p;23 24/**25 * struct ipa - IPA information26 * @gsi: Embedded GSI structure27 * @version: IPA hardware version28 * @dev: IPA device pointer29 * @completion: Used to signal pipeline clear transfer complete30 * @nb: Notifier block used for remoteproc SSR31 * @notifier: Remoteproc SSR notifier32 * @smp2p: SMP2P information33 * @power: IPA power information34 * @table_addr: DMA address of filter/route table content35 * @table_virt: Virtual address of filter/route table content36 * @route_count: Total number of entries in a routing table37 * @modem_route_count: Number of modem entries in a routing table38 * @filter_count: Maximum number of entries in a filter table39 * @interrupt: IPA Interrupt information40 * @uc_powered: true if power is active by proxy for microcontroller41 * @uc_loaded: true after microcontroller has reported it's ready42 * @reg_virt: Virtual address used for IPA register access43 * @regs: IPA register definitions44 * @mem_addr: DMA address of IPA-local memory space45 * @mem_virt: Virtual address of IPA-local memory space46 * @mem_offset: Offset from @mem_virt used for access to IPA memory47 * @mem_size: Total size (bytes) of memory at @mem_virt48 * @mem_count: Number of entries in the mem array49 * @mem: Array of IPA-local memory region descriptors50 * @imem_iova: I/O virtual address of IPA region in IMEM51 * @imem_size: Size of IMEM region52 * @smem_iova: I/O virtual address of IPA region in SMEM53 * @smem_size: Size of SMEM region54 * @zero_addr: DMA address of preallocated zero-filled memory55 * @zero_virt: Virtual address of preallocated zero-filled memory56 * @zero_size: Size (bytes) of preallocated zero-filled memory57 * @endpoint_count: Number of defined bits in most bitmaps below58 * @available_count: Number of defined bits in the available bitmap59 * @defined: Bitmap of endpoints defined in config data60 * @available: Bitmap of endpoints supported by hardware61 * @filtered: Bitmap of endpoints that support filtering62 * @set_up: Bitmap of endpoints that are set up for use63 * @enabled: Bitmap of currently enabled endpoints64 * @modem_tx_count: Number of defined modem TX endoints65 * @endpoint: Array of endpoint information66 * @channel_map: Mapping of GSI channel to IPA endpoint67 * @name_map: Mapping of IPA endpoint name to IPA endpoint68 * @setup_complete: Flag indicating whether setup stage has completed69 * @modem_state: State of modem (stopped, running)70 * @modem_netdev: Network device structure used for modem71 * @qmi: QMI information72 */73struct 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;82 83 dma_addr_t table_addr;84 __le64 *table_virt;85 u32 route_count;86 u32 modem_route_count;87 u32 filter_count;88 89 struct ipa_interrupt *interrupt;90 bool uc_powered;91 bool uc_loaded;92 93 void __iomem *reg_virt;94 const struct regs *regs;95 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;102 103 unsigned long imem_iova;104 size_t imem_size;105 106 unsigned long smem_iova;107 size_t smem_size;108 109 dma_addr_t zero_addr;110 void *zero_virt;111 size_t zero_size;112 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;121 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];126 127 bool setup_complete;128 129 atomic_t modem_state; /* enum ipa_modem_state */130 struct net_device *modem_netdev;131 struct ipa_qmi qmi;132};133 134/**135 * ipa_setup() - Perform IPA setup136 * @ipa: IPA pointer137 *138 * IPA initialization is broken into stages: init; config; and setup.139 * (These have inverses exit, deconfig, and teardown.)140 *141 * Activities performed at the init stage can be done without requiring142 * any access to IPA hardware. Activities performed at the config stage143 * require IPA power, because they involve access to IPA registers.144 * The setup stage is performed only after the GSI hardware is ready145 * (more on this below). The setup stage allows the AP to perform146 * more complex initialization by issuing "immediate commands" using147 * a special interface to the IPA.148 *149 * This function, @ipa_setup(), starts the setup stage.150 *151 * In order for the GSI hardware to be functional it needs firmware to be152 * loaded (in addition to some other low-level initialization). This early153 * GSI initialization can be done either by Trust Zone on the AP or by the154 * modem.155 *156 * If it's done by Trust Zone, the AP loads the GSI firmware and supplies157 * it to Trust Zone to verify and install. When this completes, if158 * verification was successful, the GSI layer is ready and ipa_setup()159 * implements the setup phase of initialization.160 *161 * If the modem performs early GSI initialization, the AP needs to know162 * when this has occurred. An SMP2P interrupt is used for this purpose,163 * and receipt of that interrupt triggers the call to ipa_setup().164 */165int ipa_setup(struct ipa *ipa);166 167#endif /* _IPA_H_ */168