ipa.h (5371B)
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_H_ 7#define _IPA_H_ 8 9#include <linux/types.h> 10#include <linux/device.h> 11#include <linux/notifier.h> 12#include <linux/pm_wakeup.h> 13 14#include "ipa_version.h" 15#include "gsi.h" 16#include "ipa_mem.h" 17#include "ipa_qmi.h" 18#include "ipa_endpoint.h" 19#include "ipa_interrupt.h" 20 21struct clk; 22struct icc_path; 23struct net_device; 24struct platform_device; 25 26struct ipa_power; 27struct ipa_smp2p; 28struct ipa_interrupt; 29 30/** 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 * @interrupt: IPA Interrupt information 43 * @uc_powered: true if power is active by proxy for microcontroller 44 * @uc_loaded: true after microcontroller has reported it's ready 45 * @reg_addr: DMA address used for IPA register access 46 * @reg_virt: Virtual address used for IPA register access 47 * @mem_addr: DMA address of IPA-local memory space 48 * @mem_virt: Virtual address of IPA-local memory space 49 * @mem_offset: Offset from @mem_virt used for access to IPA memory 50 * @mem_size: Total size (bytes) of memory at @mem_virt 51 * @mem_count: Number of entries in the mem array 52 * @mem: Array of IPA-local memory region descriptors 53 * @imem_iova: I/O virtual address of IPA region in IMEM 54 * @imem_size: Size of IMEM region 55 * @smem_iova: I/O virtual address of IPA region in SMEM 56 * @smem_size: Size of SMEM region 57 * @zero_addr: DMA address of preallocated zero-filled memory 58 * @zero_virt: Virtual address of preallocated zero-filled memory 59 * @zero_size: Size (bytes) of preallocated zero-filled memory 60 * @available: Bit mask indicating endpoints hardware supports 61 * @filter_map: Bit mask indicating endpoints that support filtering 62 * @initialized: Bit mask indicating endpoints initialized 63 * @set_up: Bit mask indicating endpoints set up 64 * @enabled: Bit mask indicating endpoints enabled 65 * @modem_tx_count: Number of defined modem TX endoints 66 * @endpoint: Array of endpoint information 67 * @channel_map: Mapping of GSI channel to IPA endpoint 68 * @name_map: Mapping of IPA endpoint name to IPA endpoint 69 * @setup_complete: Flag indicating whether setup stage has completed 70 * @modem_state: State of modem (stopped, running) 71 * @modem_netdev: Network device structure used for modem 72 * @qmi: QMI information 73 */ 74struct ipa { 75 struct gsi gsi; 76 enum ipa_version version; 77 struct platform_device *pdev; 78 struct completion completion; 79 struct notifier_block nb; 80 void *notifier; 81 struct ipa_smp2p *smp2p; 82 struct ipa_power *power; 83 84 dma_addr_t table_addr; 85 __le64 *table_virt; 86 87 struct ipa_interrupt *interrupt; 88 bool uc_powered; 89 bool uc_loaded; 90 91 dma_addr_t reg_addr; 92 void __iomem *reg_virt; 93 94 dma_addr_t mem_addr; 95 void *mem_virt; 96 u32 mem_offset; 97 u32 mem_size; 98 u32 mem_count; 99 const struct ipa_mem *mem; 100 101 unsigned long imem_iova; 102 size_t imem_size; 103 104 unsigned long smem_iova; 105 size_t smem_size; 106 107 dma_addr_t zero_addr; 108 void *zero_virt; 109 size_t zero_size; 110 111 /* Bit masks indicating endpoint state */ 112 u32 available; /* supported by hardware */ 113 u32 filter_map; 114 u32 initialized; 115 u32 set_up; 116 u32 enabled; 117 118 u32 modem_tx_count; 119 struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX]; 120 struct ipa_endpoint *channel_map[GSI_CHANNEL_COUNT_MAX]; 121 struct ipa_endpoint *name_map[IPA_ENDPOINT_COUNT]; 122 123 bool setup_complete; 124 125 atomic_t modem_state; /* enum ipa_modem_state */ 126 struct net_device *modem_netdev; 127 struct ipa_qmi qmi; 128}; 129 130/** 131 * ipa_setup() - Perform IPA setup 132 * @ipa: IPA pointer 133 * 134 * IPA initialization is broken into stages: init; config; and setup. 135 * (These have inverses exit, deconfig, and teardown.) 136 * 137 * Activities performed at the init stage can be done without requiring 138 * any access to IPA hardware. Activities performed at the config stage 139 * require IPA power, because they involve access to IPA registers. 140 * The setup stage is performed only after the GSI hardware is ready 141 * (more on this below). The setup stage allows the AP to perform 142 * more complex initialization by issuing "immediate commands" using 143 * a special interface to the IPA. 144 * 145 * This function, @ipa_setup(), starts the setup stage. 146 * 147 * In order for the GSI hardware to be functional it needs firmware to be 148 * loaded (in addition to some other low-level initialization). This early 149 * GSI initialization can be done either by Trust Zone on the AP or by the 150 * modem. 151 * 152 * If it's done by Trust Zone, the AP loads the GSI firmware and supplies 153 * it to Trust Zone to verify and install. When this completes, if 154 * verification was successful, the GSI layer is ready and ipa_setup() 155 * implements the setup phase of initialization. 156 * 157 * If the modem performs early GSI initialization, the AP needs to know 158 * when this has occurred. An SMP2P interrupt is used for this purpose, 159 * and receipt of that interrupt triggers the call to ipa_setup(). 160 */ 161int ipa_setup(struct ipa *ipa); 162 163#endif /* _IPA_H_ */