Linux Audio

Check our new training course

Open-source upstreaming

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