2020-03-05 21:28:17 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
|
2024-04-16 16:10:13 -07:00
|
|
|
* Copyright (C) 2018-2024 Linaro Ltd.
|
2020-03-05 21:28:17 -07:00
|
|
|
*/
|
|
|
|
#ifndef _IPA_H_
|
|
|
|
#define _IPA_H_
|
|
|
|
|
|
|
|
#include <linux/notifier.h>
|
2024-04-16 16:10:18 -07:00
|
|
|
#include <linux/types.h>
|
2020-03-05 21:28:17 -07:00
|
|
|
|
|
|
|
#include "gsi.h"
|
2024-04-16 16:10:18 -07:00
|
|
|
#include "ipa_endpoint.h"
|
2020-03-05 21:28:17 -07:00
|
|
|
#include "ipa_mem.h"
|
|
|
|
#include "ipa_qmi.h"
|
2024-04-16 16:10:18 -07:00
|
|
|
#include "ipa_version.h"
|
2020-03-05 21:28:17 -07:00
|
|
|
|
|
|
|
struct net_device;
|
|
|
|
|
2024-04-16 16:10:18 -07:00
|
|
|
struct ipa_interrupt;
|
2021-08-20 09:01:28 -07:00
|
|
|
struct ipa_power;
|
2020-03-05 21:28:17 -07:00
|
|
|
struct ipa_smp2p;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct ipa - IPA information
|
|
|
|
* @gsi: Embedded GSI structure
|
|
|
|
* @version: IPA hardware version
|
2024-03-01 10:02:42 -07:00
|
|
|
* @dev: IPA device pointer
|
2021-01-26 11:57:01 -07:00
|
|
|
* @completion: Used to signal pipeline clear transfer complete
|
2021-03-28 10:31:05 -07:00
|
|
|
* @nb: Notifier block used for remoteproc SSR
|
|
|
|
* @notifier: Remoteproc SSR notifier
|
2020-03-05 21:28:17 -07:00
|
|
|
* @smp2p: SMP2P information
|
2021-08-20 09:01:28 -07:00
|
|
|
* @power: IPA power information
|
2020-03-05 21:28:17 -07:00
|
|
|
* @table_addr: DMA address of filter/route table content
|
|
|
|
* @table_virt: Virtual address of filter/route table content
|
2022-10-25 12:51:40 -07:00
|
|
|
* @route_count: Total number of entries in a routing table
|
2022-10-25 12:51:42 -07:00
|
|
|
* @modem_route_count: Number of modem entries in a routing table
|
2022-10-25 12:51:43 -07:00
|
|
|
* @filter_count: Maximum number of entries in a filter table
|
2020-03-05 21:28:17 -07:00
|
|
|
* @interrupt: IPA Interrupt information
|
2021-08-20 09:01:28 -07:00
|
|
|
* @uc_powered: true if power is active by proxy for microcontroller
|
2020-03-05 21:28:17 -07:00
|
|
|
* @uc_loaded: true after microcontroller has reported it's ready
|
|
|
|
* @reg_virt: Virtual address used for IPA register access
|
2022-09-26 15:09:19 -07:00
|
|
|
* @regs: IPA register definitions
|
2020-03-05 21:28:17 -07:00
|
|
|
* @mem_addr: DMA address of IPA-local memory space
|
|
|
|
* @mem_virt: Virtual address of IPA-local memory space
|
|
|
|
* @mem_offset: Offset from @mem_virt used for access to IPA memory
|
|
|
|
* @mem_size: Total size (bytes) of memory at @mem_virt
|
2021-05-11 12:42:04 -07:00
|
|
|
* @mem_count: Number of entries in the mem array
|
2020-03-05 21:28:17 -07:00
|
|
|
* @mem: Array of IPA-local memory region descriptors
|
2020-05-04 10:58:58 -07:00
|
|
|
* @imem_iova: I/O virtual address of IPA region in IMEM
|
2021-03-28 10:31:05 -07:00
|
|
|
* @imem_size: Size of IMEM region
|
2020-05-04 10:58:59 -07:00
|
|
|
* @smem_iova: I/O virtual address of IPA region in SMEM
|
2021-03-28 10:31:05 -07:00
|
|
|
* @smem_size: Size of SMEM region
|
2020-03-05 21:28:17 -07:00
|
|
|
* @zero_addr: DMA address of preallocated zero-filled memory
|
|
|
|
* @zero_virt: Virtual address of preallocated zero-filled memory
|
|
|
|
* @zero_size: Size (bytes) of preallocated zero-filled memory
|
2022-11-02 15:11:36 -07:00
|
|
|
* @endpoint_count: Number of defined bits in most bitmaps below
|
|
|
|
* @available_count: Number of defined bits in the available bitmap
|
2022-11-02 15:11:35 -07:00
|
|
|
* @defined: Bitmap of endpoints defined in config data
|
2022-11-02 15:11:36 -07:00
|
|
|
* @available: Bitmap of endpoints supported by hardware
|
2022-11-02 15:11:37 -07:00
|
|
|
* @filtered: Bitmap of endpoints that support filtering
|
2022-11-02 15:11:38 -07:00
|
|
|
* @set_up: Bitmap of endpoints that are set up for use
|
2022-11-02 15:11:39 -07:00
|
|
|
* @enabled: Bitmap of currently enabled endpoints
|
2022-05-21 17:32:19 -07:00
|
|
|
* @modem_tx_count: Number of defined modem TX endoints
|
2020-03-05 21:28:17 -07:00
|
|
|
* @endpoint: Array of endpoint information
|
|
|
|
* @channel_map: Mapping of GSI channel to IPA endpoint
|
|
|
|
* @name_map: Mapping of IPA endpoint name to IPA endpoint
|
|
|
|
* @setup_complete: Flag indicating whether setup stage has completed
|
|
|
|
* @modem_state: State of modem (stopped, running)
|
|
|
|
* @modem_netdev: Network device structure used for modem
|
|
|
|
* @qmi: QMI information
|
|
|
|
*/
|
|
|
|
struct ipa {
|
|
|
|
struct gsi gsi;
|
|
|
|
enum ipa_version version;
|
2024-03-01 10:02:42 -07:00
|
|
|
struct device *dev;
|
2021-01-26 11:57:01 -07:00
|
|
|
struct completion completion;
|
2020-07-24 11:11:41 -07:00
|
|
|
struct notifier_block nb;
|
|
|
|
void *notifier;
|
2020-03-05 21:28:17 -07:00
|
|
|
struct ipa_smp2p *smp2p;
|
2021-08-20 09:01:28 -07:00
|
|
|
struct ipa_power *power;
|
2020-03-05 21:28:17 -07:00
|
|
|
|
|
|
|
dma_addr_t table_addr;
|
|
|
|
__le64 *table_virt;
|
2022-10-25 12:51:40 -07:00
|
|
|
u32 route_count;
|
2022-10-25 12:51:42 -07:00
|
|
|
u32 modem_route_count;
|
2022-10-25 12:51:43 -07:00
|
|
|
u32 filter_count;
|
2020-03-05 21:28:17 -07:00
|
|
|
|
|
|
|
struct ipa_interrupt *interrupt;
|
2021-08-20 09:01:28 -07:00
|
|
|
bool uc_powered;
|
2020-03-05 21:28:17 -07:00
|
|
|
bool uc_loaded;
|
|
|
|
|
|
|
|
void __iomem *reg_virt;
|
net: ipa: start generalizing "ipa_reg"
IPA register definitions have evolved with each new version. The
changes required to support more than 32 endpoints in IPA v5.0 made
it best to define a unified mechanism for defining registers and
their fields.
GSI register definitions, meanwhile, have remained fairly stable.
And even as the total number of IPA endpoints goes beyond 32, the
number of GSI channels on a given EE that underly endpoints still
remains 32 or less.
Despite that, GSI v3.0 (which is used with IPA v5.0) extends the
number of channels (and events) it supports to be about 256, and as
a result, many GSI register definitions must change significantly.
To address this, we'll use the same "ipa_reg" mechanism to define
the GSI registers.
As a first step in generalizing the "ipa_reg" to also support GSI
registers, isolate the definitions of the "ipa_reg" and "ipa_regs"
structure types (and some supporting macros) into a new header file,
and remove the "ipa_" and "IPA_" from symbol names.
Separate the IPA register ID validity checking from the generic
check that a register ID is in range. Aside from that, this is
intended to have no functional effect on the code.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-02-08 13:56:51 -07:00
|
|
|
const struct regs *regs;
|
2020-03-05 21:28:17 -07:00
|
|
|
|
|
|
|
dma_addr_t mem_addr;
|
|
|
|
void *mem_virt;
|
|
|
|
u32 mem_offset;
|
|
|
|
u32 mem_size;
|
2021-05-11 12:42:04 -07:00
|
|
|
u32 mem_count;
|
2020-03-05 21:28:17 -07:00
|
|
|
const struct ipa_mem *mem;
|
|
|
|
|
2020-05-04 10:58:58 -07:00
|
|
|
unsigned long imem_iova;
|
|
|
|
size_t imem_size;
|
2020-05-04 10:58:59 -07:00
|
|
|
|
|
|
|
unsigned long smem_iova;
|
|
|
|
size_t smem_size;
|
2020-05-04 10:58:58 -07:00
|
|
|
|
2020-03-05 21:28:17 -07:00
|
|
|
dma_addr_t zero_addr;
|
|
|
|
void *zero_virt;
|
|
|
|
size_t zero_size;
|
|
|
|
|
2022-11-02 15:11:35 -07:00
|
|
|
/* Bitmaps indicating endpoint state */
|
2022-10-27 05:26:32 -07:00
|
|
|
u32 endpoint_count;
|
2022-11-02 15:11:36 -07:00
|
|
|
u32 available_count;
|
2022-11-02 15:11:35 -07:00
|
|
|
unsigned long *defined; /* Defined in configuration data */
|
2022-11-02 15:11:36 -07:00
|
|
|
unsigned long *available; /* Supported by hardware */
|
2022-11-02 15:11:37 -07:00
|
|
|
u64 filtered; /* Support filtering (AP and modem) */
|
2022-11-02 15:11:38 -07:00
|
|
|
unsigned long *set_up;
|
2022-11-02 15:11:39 -07:00
|
|
|
unsigned long *enabled;
|
2020-03-05 21:28:17 -07:00
|
|
|
|
2022-05-21 17:32:19 -07:00
|
|
|
u32 modem_tx_count;
|
2020-03-05 21:28:17 -07:00
|
|
|
struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX];
|
|
|
|
struct ipa_endpoint *channel_map[GSI_CHANNEL_COUNT_MAX];
|
|
|
|
struct ipa_endpoint *name_map[IPA_ENDPOINT_COUNT];
|
|
|
|
|
|
|
|
bool setup_complete;
|
|
|
|
|
|
|
|
atomic_t modem_state; /* enum ipa_modem_state */
|
|
|
|
struct net_device *modem_netdev;
|
|
|
|
struct ipa_qmi qmi;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ipa_setup() - Perform IPA setup
|
|
|
|
* @ipa: IPA pointer
|
|
|
|
*
|
|
|
|
* IPA initialization is broken into stages: init; config; and setup.
|
|
|
|
* (These have inverses exit, deconfig, and teardown.)
|
|
|
|
*
|
|
|
|
* Activities performed at the init stage can be done without requiring
|
|
|
|
* any access to IPA hardware. Activities performed at the config stage
|
2021-08-20 09:01:28 -07:00
|
|
|
* require IPA power, because they involve access to IPA registers.
|
|
|
|
* The setup stage is performed only after the GSI hardware is ready
|
|
|
|
* (more on this below). The setup stage allows the AP to perform
|
|
|
|
* more complex initialization by issuing "immediate commands" using
|
|
|
|
* a special interface to the IPA.
|
2020-03-05 21:28:17 -07:00
|
|
|
*
|
|
|
|
* This function, @ipa_setup(), starts the setup stage.
|
|
|
|
*
|
|
|
|
* In order for the GSI hardware to be functional it needs firmware to be
|
|
|
|
* loaded (in addition to some other low-level initialization). This early
|
|
|
|
* GSI initialization can be done either by Trust Zone on the AP or by the
|
|
|
|
* modem.
|
|
|
|
*
|
|
|
|
* If it's done by Trust Zone, the AP loads the GSI firmware and supplies
|
|
|
|
* it to Trust Zone to verify and install. When this completes, if
|
|
|
|
* verification was successful, the GSI layer is ready and ipa_setup()
|
|
|
|
* implements the setup phase of initialization.
|
|
|
|
*
|
|
|
|
* If the modem performs early GSI initialization, the AP needs to know
|
|
|
|
* when this has occurred. An SMP2P interrupt is used for this purpose,
|
|
|
|
* and receipt of that interrupt triggers the call to ipa_setup().
|
|
|
|
*/
|
|
|
|
int ipa_setup(struct ipa *ipa);
|
|
|
|
|
|
|
|
#endif /* _IPA_H_ */
|