blob: 5c2247eafd568cafb0c8f7b9af076a8771ca0e6d [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Govind Singhdf35f3e2016-05-06 15:57:36 +05302 * Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
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 Singhdf35f3e2016-05-06 15:57:36 +053043#define MSI_NUM_REQUEST_LOG2 3
44#define MSI_NUM_REQUEST (1<<MSI_NUM_REQUEST_LOG2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045
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 */
64struct pcie_state_s {
Komal Seelam04d3d6a2016-02-04 15:57:52 +053065 uint32_t pipe_cfg_addr; /* Pipe configuration Target address */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 /* NB: CE_pipe_config[CE_COUNT] */
67
Komal Seelam04d3d6a2016-02-04 15:57:52 +053068 uint32_t svc_to_pipe_map; /* Service to pipe map Target address */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069 /* NB: service_to_pipe[PIPE_TO_CE_MAP_CN] */
70
Komal Seelam04d3d6a2016-02-04 15:57:52 +053071 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 Dhavali7090c5f2015-11-02 17:55:19 -080076 MSI data for other interrupts are
77 in various SoC registers */
78
Komal Seelam04d3d6a2016-02-04 15:57:52 +053079 uint32_t power_mgmt_method; /* PCIE_PWR_METHOD_* */
80 uint32_t config_flags; /* PCIE_CONFIG_FLAG_* */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081};
82
83/*
84 * PCIE_CONFIG_FLAG definitions
85 */
Govind Singh55b8daf2016-06-09 16:02:47 +053086#if defined(AR900B)
Govind Singh55b8daf2016-06-09 16:02:47 +053087#define CE_PKTLOG_PIPE 8 /* used by both host and target side */
88#endif
89
Govind Singh805ac5b2016-06-09 18:36:01 +053090#define PCIE_CONFIG_FLAG_ENABLE_L1 0x0000001
Govind Singh55b8daf2016-06-09 16:02:47 +053091#define PCIE_CONFIG_FLAG_CLK_GATING_L1 0x0000001
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092#define PCIE_CONFIG_FLAG_CLK_SWITCH_WAIT 0x0000002
93#define PCIE_CONFIG_FLAG_AXI_CLK_GATE 0x0000004
Govind Singh55b8daf2016-06-09 16:02:47 +053094#define PCIE_CONFIG_FLAG_CLK_REQ_L1 0x0000008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095
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 */
102struct CE_pipe_config {
Komal Seelam04d3d6a2016-02-04 15:57:52 +0530103 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 Dhavali7090c5f2015-11-02 17:55:19 -0800109};
110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111#endif /* __CEPCI_H__ */