Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Govind Singh | df35f3e | 2016-05-06 15:57:36 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | #ifndef __CEPCI_H__ |
| 29 | #define __CEPCI_H__ |
| 30 | |
| 31 | /* |
| 32 | * Support for Copy Engine over PCI. |
| 33 | * Structures shared between Host software and Target firmware. |
| 34 | */ |
| 35 | |
| 36 | /* |
| 37 | * Total number of PCIe MSI interrupts requested for all interrupt sources. |
| 38 | * PCIe standard forces this to be a power of 2. |
| 39 | * Some Host OS's limit MSI requests that can be granted to 8 |
| 40 | * so for now we abide by this limit and avoid requesting more |
| 41 | * than that. |
| 42 | */ |
Govind Singh | df35f3e | 2016-05-06 15:57:36 +0530 | [diff] [blame] | 43 | #define MSI_NUM_REQUEST_LOG2 3 |
| 44 | #define MSI_NUM_REQUEST (1<<MSI_NUM_REQUEST_LOG2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 45 | |
| 46 | /* |
| 47 | * Granted MSIs are assigned as follows: |
| 48 | * Firmware uses the first |
| 49 | * Remaining MSIs, if any, are used by Copy Engines |
| 50 | * This mapping is known to both Target firmware and Host software. |
| 51 | * It may be changed as long as Host and Target are kept in sync. |
| 52 | */ |
| 53 | #define MSI_ASSIGN_FW 0 /* 1 MSI for firmware (errors, etc.) */ |
| 54 | #define MSI_ASSIGN_CE_INITIAL 1 /* 7 MSIs for Copy Engines */ |
| 55 | #define MSI_ASSIGN_CE_MAX 7 |
| 56 | |
| 57 | /* |
| 58 | * PCI-specific Target state. Much of this may be of interest |
| 59 | * to the Host so HOST_INTEREST->hi_interconnect_state points |
| 60 | * here (and all members are 32-bit quantities in order to |
| 61 | * facilitate Host access). In particular, Host software is |
| 62 | * required to initialize pipe_cfg_addr and svc_to_pipe_map. |
| 63 | */ |
| 64 | struct pcie_state_s { |
Komal Seelam | 04d3d6a | 2016-02-04 15:57:52 +0530 | [diff] [blame] | 65 | uint32_t pipe_cfg_addr; /* Pipe configuration Target address */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 66 | /* NB: CE_pipe_config[CE_COUNT] */ |
| 67 | |
Komal Seelam | 04d3d6a | 2016-02-04 15:57:52 +0530 | [diff] [blame] | 68 | uint32_t svc_to_pipe_map; /* Service to pipe map Target address */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 69 | /* NB: service_to_pipe[PIPE_TO_CE_MAP_CN] */ |
| 70 | |
Komal Seelam | 04d3d6a | 2016-02-04 15:57:52 +0530 | [diff] [blame] | 71 | uint32_t MSI_requested; /* number of MSI interrupts requested */ |
| 72 | uint32_t MSI_granted; /* number of MSI interrupts granted */ |
| 73 | uint32_t MSI_addr; /* Message Signalled Interrupt address */ |
| 74 | uint32_t MSI_data; /* Base data */ |
| 75 | uint32_t MSI_fw_intr_data; /* Data for firmware interrupt; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | MSI data for other interrupts are |
| 77 | in various SoC registers */ |
| 78 | |
Komal Seelam | 04d3d6a | 2016-02-04 15:57:52 +0530 | [diff] [blame] | 79 | uint32_t power_mgmt_method; /* PCIE_PWR_METHOD_* */ |
| 80 | uint32_t config_flags; /* PCIE_CONFIG_FLAG_* */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | /* |
| 84 | * PCIE_CONFIG_FLAG definitions |
| 85 | */ |
Govind Singh | 55b8daf | 2016-06-09 16:02:47 +0530 | [diff] [blame] | 86 | #if defined(AR900B) |
Govind Singh | 55b8daf | 2016-06-09 16:02:47 +0530 | [diff] [blame] | 87 | #define CE_PKTLOG_PIPE 8 /* used by both host and target side */ |
| 88 | #endif |
| 89 | |
Govind Singh | 805ac5b | 2016-06-09 18:36:01 +0530 | [diff] [blame] | 90 | #define PCIE_CONFIG_FLAG_ENABLE_L1 0x0000001 |
Govind Singh | 55b8daf | 2016-06-09 16:02:47 +0530 | [diff] [blame] | 91 | #define PCIE_CONFIG_FLAG_CLK_GATING_L1 0x0000001 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 92 | #define PCIE_CONFIG_FLAG_CLK_SWITCH_WAIT 0x0000002 |
| 93 | #define PCIE_CONFIG_FLAG_AXI_CLK_GATE 0x0000004 |
Govind Singh | 55b8daf | 2016-06-09 16:02:47 +0530 | [diff] [blame] | 94 | #define PCIE_CONFIG_FLAG_CLK_REQ_L1 0x0000008 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 95 | |
| 96 | #define PIPE_TO_CE_MAP_CNT 32 /* simple implementation constant */ |
| 97 | |
| 98 | /* |
| 99 | * Configuration information for a Copy Engine pipe. |
| 100 | * Passed from Host to Target during startup (one per CE). |
| 101 | */ |
| 102 | struct CE_pipe_config { |
Komal Seelam | 04d3d6a | 2016-02-04 15:57:52 +0530 | [diff] [blame] | 103 | uint32_t pipenum; |
| 104 | uint32_t pipedir; |
| 105 | uint32_t nentries; |
| 106 | uint32_t nbytes_max; |
| 107 | uint32_t flags; |
| 108 | uint32_t reserved; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 109 | }; |
| 110 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 111 | #endif /* __CEPCI_H__ */ |