![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only 0002 * 0003 * Copyright (C) 2020-21 Intel Corporation. 0004 */ 0005 0006 #ifndef IOSM_IPC_PCIE_H 0007 #define IOSM_IPC_PCIE_H 0008 0009 #include <linux/device.h> 0010 #include <linux/pci.h> 0011 #include <linux/skbuff.h> 0012 0013 #include "iosm_ipc_irq.h" 0014 0015 /* Device ID */ 0016 #define INTEL_CP_DEVICE_7560_ID 0x7560 0017 #define INTEL_CP_DEVICE_7360_ID 0x7360 0018 0019 /* Define for BAR area usage */ 0020 #define IPC_DOORBELL_BAR0 0 0021 #define IPC_SCRATCHPAD_BAR2 2 0022 0023 /* Defines for DOORBELL registers information */ 0024 #define IPC_DOORBELL_CH_OFFSET BIT(5) 0025 #define IPC_WRITE_PTR_REG_0 BIT(4) 0026 #define IPC_CAPTURE_PTR_REG_0 BIT(3) 0027 0028 /* Number of MSI used for IPC */ 0029 #define IPC_MSI_VECTORS 1 0030 0031 /* Total number of Maximum IPC IRQ vectors used for IPC */ 0032 #define IPC_IRQ_VECTORS IPC_MSI_VECTORS 0033 0034 /** 0035 * enum ipc_pcie_sleep_state - Enum type to different sleep state transitions 0036 * @IPC_PCIE_D0L12: Put the sleep state in D0L12 0037 * @IPC_PCIE_D3L2: Put the sleep state in D3L2 0038 */ 0039 enum ipc_pcie_sleep_state { 0040 IPC_PCIE_D0L12, 0041 IPC_PCIE_D3L2, 0042 }; 0043 0044 /** 0045 * struct iosm_pcie - IPC_PCIE struct. 0046 * @pci: Address of the device description 0047 * @dev: Pointer to generic device structure 0048 * @ipc_regs: Remapped CP doorbell address of the irq register 0049 * set, to fire the doorbell irq. 0050 * @scratchpad: Remapped CP scratchpad address, to send the 0051 * configuration. tuple and the IPC descriptors 0052 * to CP in the ROM phase. The config tuple 0053 * information are saved on the MSI scratchpad. 0054 * @imem: Pointer to imem data struct 0055 * @ipc_regs_bar_nr: BAR number to be used for IPC doorbell 0056 * @scratchpad_bar_nr: BAR number to be used for Scratchpad 0057 * @nvec: number of requested irq vectors 0058 * @doorbell_reg_offset: doorbell_reg_offset 0059 * @doorbell_write: doorbell write register 0060 * @doorbell_capture: doorbell capture resgister 0061 * @suspend: S2IDLE sleep/active 0062 * @d3l2_support: Read WWAN RTD3 BIOS setting for D3L2 support 0063 */ 0064 struct iosm_pcie { 0065 struct pci_dev *pci; 0066 struct device *dev; 0067 void __iomem *ipc_regs; 0068 void __iomem *scratchpad; 0069 struct iosm_imem *imem; 0070 int ipc_regs_bar_nr; 0071 int scratchpad_bar_nr; 0072 int nvec; 0073 u32 doorbell_reg_offset; 0074 u32 doorbell_write; 0075 u32 doorbell_capture; 0076 unsigned long suspend; 0077 enum ipc_pcie_sleep_state d3l2_support; 0078 }; 0079 0080 /** 0081 * struct ipc_skb_cb - Struct definition of the socket buffer which is mapped to 0082 * the cb field of sbk 0083 * @mapping: Store physical or IOVA mapped address of skb virtual add. 0084 * @direction: DMA direction 0085 * @len: Length of the DMA mapped region 0086 * @op_type: Expected values are defined about enum ipc_ul_usr_op. 0087 */ 0088 struct ipc_skb_cb { 0089 dma_addr_t mapping; 0090 int direction; 0091 int len; 0092 u8 op_type; 0093 }; 0094 0095 /** 0096 * enum ipc_ul_usr_op - Control operation to execute the right action on 0097 * the user interface. 0098 * @UL_USR_OP_BLOCKED: The uplink app was blocked until CP confirms that the 0099 * uplink buffer was consumed triggered by the IRQ. 0100 * @UL_MUX_OP_ADB: In MUX mode the UL ADB shall be addedd to the free list. 0101 * @UL_DEFAULT: SKB in non muxing mode 0102 */ 0103 enum ipc_ul_usr_op { 0104 UL_USR_OP_BLOCKED, 0105 UL_MUX_OP_ADB, 0106 UL_DEFAULT, 0107 }; 0108 0109 /** 0110 * ipc_pcie_addr_map - Maps the kernel's virtual address to either IOVA 0111 * address space or Physical address space, the mapping is 0112 * stored in the skb's cb. 0113 * @ipc_pcie: Pointer to struct iosm_pcie 0114 * @data: Skb mem containing data 0115 * @size: Data size 0116 * @mapping: Dma mapping address 0117 * @direction: Data direction 0118 * 0119 * Returns: 0 on success and failure value on error 0120 */ 0121 int ipc_pcie_addr_map(struct iosm_pcie *ipc_pcie, unsigned char *data, 0122 size_t size, dma_addr_t *mapping, int direction); 0123 0124 /** 0125 * ipc_pcie_addr_unmap - Unmaps the skb memory region from IOVA address space 0126 * @ipc_pcie: Pointer to struct iosm_pcie 0127 * @size: Data size 0128 * @mapping: Dma mapping address 0129 * @direction: Data direction 0130 */ 0131 void ipc_pcie_addr_unmap(struct iosm_pcie *ipc_pcie, size_t size, 0132 dma_addr_t mapping, int direction); 0133 0134 /** 0135 * ipc_pcie_alloc_skb - Allocate an uplink SKB for the given size. 0136 * @ipc_pcie: Pointer to struct iosm_pcie 0137 * @size: Size of the SKB required. 0138 * @flags: Allocation flags 0139 * @mapping: Copies either mapped IOVA add. or converted Phy address 0140 * @direction: DMA data direction 0141 * @headroom: Header data offset 0142 * 0143 * Returns: Pointer to ipc_skb on Success, NULL on failure. 0144 */ 0145 struct sk_buff *ipc_pcie_alloc_skb(struct iosm_pcie *ipc_pcie, size_t size, 0146 gfp_t flags, dma_addr_t *mapping, 0147 int direction, size_t headroom); 0148 0149 /** 0150 * ipc_pcie_alloc_local_skb - Allocate a local SKB for the given size. 0151 * @ipc_pcie: Pointer to struct iosm_pcie 0152 * @flags: Allocation flags 0153 * @size: Size of the SKB required. 0154 * 0155 * Returns: Pointer to ipc_skb on Success, NULL on failure. 0156 */ 0157 struct sk_buff *ipc_pcie_alloc_local_skb(struct iosm_pcie *ipc_pcie, 0158 gfp_t flags, size_t size); 0159 0160 /** 0161 * ipc_pcie_kfree_skb - Free skb allocated by ipc_pcie_alloc_*_skb(). 0162 * @ipc_pcie: Pointer to struct iosm_pcie 0163 * @skb: Pointer to the skb 0164 */ 0165 void ipc_pcie_kfree_skb(struct iosm_pcie *ipc_pcie, struct sk_buff *skb); 0166 0167 /** 0168 * ipc_pcie_check_data_link_active - Check Data Link Layer Active 0169 * @ipc_pcie: Pointer to struct iosm_pcie 0170 * 0171 * Returns: true if active, otherwise false 0172 */ 0173 bool ipc_pcie_check_data_link_active(struct iosm_pcie *ipc_pcie); 0174 0175 /** 0176 * ipc_pcie_suspend - Callback invoked by pm_runtime_suspend. It decrements 0177 * the device's usage count then, carry out a suspend, 0178 * either synchronous or asynchronous. 0179 * @ipc_pcie: Pointer to struct iosm_pcie 0180 * 0181 * Returns: 0 on success and failure value on error 0182 */ 0183 int ipc_pcie_suspend(struct iosm_pcie *ipc_pcie); 0184 0185 /** 0186 * ipc_pcie_resume - Callback invoked by pm_runtime_resume. It increments 0187 * the device's usage count then, carry out a resume, 0188 * either synchronous or asynchronous. 0189 * @ipc_pcie: Pointer to struct iosm_pcie 0190 * 0191 * Returns: 0 on success and failure value on error 0192 */ 0193 int ipc_pcie_resume(struct iosm_pcie *ipc_pcie); 0194 0195 /** 0196 * ipc_pcie_check_aspm_enabled - Check if ASPM L1 is already enabled 0197 * @ipc_pcie: Pointer to struct iosm_pcie 0198 * @parent: True if checking ASPM L1 for parent else false 0199 * 0200 * Returns: true if ASPM is already enabled else false 0201 */ 0202 bool ipc_pcie_check_aspm_enabled(struct iosm_pcie *ipc_pcie, 0203 bool parent); 0204 /** 0205 * ipc_pcie_config_aspm - Configure ASPM L1 0206 * @ipc_pcie: Pointer to struct iosm_pcie 0207 */ 0208 void ipc_pcie_config_aspm(struct iosm_pcie *ipc_pcie); 0209 0210 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |