blob: bd1a60eaaa862be02c67b0d6fd28db852c60944c [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/*
2<:copyright-BRCM:2016:DUAL/GPL:standard
3
4 Broadcom Proprietary and Confidential.(c) 2016 Broadcom
5 All Rights Reserved
6
7Unless you and Broadcom execute a separate written software license
8agreement governing use of this software, this software is licensed
9to you under the terms of the GNU General Public License version 2
10(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
11with the following added to such license:
12
13 As a special exception, the copyright holders of this software give
14 you permission to link this software with independent modules, and
15 to copy and distribute the resulting executable under terms of your
16 choice, provided that you also meet, for each linked independent
17 module, the terms and conditions of the license of that module.
18 An independent module is a module which is not derived from this
19 software. The special exception does not apply to any modifications
20 of the software.
21
22Not withstanding the above, under no circumstances may you combine
23this software in any way with any other Broadcom software provided
24under a license other than the GPL, without Broadcom's express prior
25written consent.
26
27:>
28 */
29
30/*
31 * bcm_llpcie.h - Low-level PCIe driver interface
32 */
33
34#ifndef BCMOLT_LLPCIE_H_
35#define BCMOLT_LLPCIE_H_
36
37#include "bcmos_system.h"
38#define MAPLE_MAX_DEVICES BCMTR_MAX_OLTS
39
40/** Low-level device info */
41typedef struct bcmolt_ll_dev_info
42{
43 unsigned long soc_regs_base; /**< Device registers base in host address space */
44 unsigned long soc_sram_base; /**< Device SRAM base in host address space */
45 unsigned long soc_ddr_base; /**< Device DDR base in host address space */
46 uint32_t soc_ddr_length; /**< Device DDR window size */
47 uint32_t irq; /**< Device irq number */
48 int irq_connected; /**< Device irq number connected */
49} bcm_ll_dev_info;
50
51/** Device PCIe link status change notification callback */
52typedef enum
53{
54 BCM_LL_PCIE_LINK_DOWN, /**< PCIe link is down */
55 BCM_LL_PCIE_LINK_UP, /**< PCIe link is up */
56} bcm_ll_pcie_link_status;
57
58/** Low-level device handle */
59typedef void *bcm_ll_pcie_dev;
60
61/** Status change indication */
62typedef void (*bcm_ll_pcie_status_change)(uint8_t dev_id, bcm_ll_pcie_link_status status);
63
64/** Register status change notification callback
65 * \param[in] cb Status change notification callback
66 * \return 0=OK or error <0
67 */
68bcmos_errno bcm_ll_pcie_status_change_register(bcm_ll_pcie_status_change cb);
69
70/** Unregister status change notification callback
71 * \return 0=OK or error <0
72 */
73bcmos_errno bcm_ll_pcie_status_change_unregister(void);
74
75/** Query PCIe device
76 * \param[in] dev_id Device id
77 * \param[out] info Device info
78 * \return 0=OK, BCM_ERR_IO-dev_id is in proper range, but link is down
79 */
80bcmos_errno bcm_ll_pcie_query(uint8_t dev_id, bcm_ll_dev_info *info);
81
82/** Get low-level device handle
83 * \param[in] dev_id Device id
84 * \param[out] lldev Low-level device handle
85 * \return device handle or NULL if link is down
86 */
87bcm_ll_pcie_dev bcm_ll_pcie_dev_get(uint8_t dev_id);
88
89/* Initialize low-level PCIe driver
90 * \return
91 * - 0=OK
92 * - BCM_ERR_INTERNAL - failed to register with PCI subsystem
93 */
94bcmos_errno bcm_ll_pcie_init(void);
95
96/* Cleanup low-level PCIe driver */
97void bcm_ll_pcie_cleanup(void);
98
99/** Enable PCI access to device
100 * \param[in] dev_id Device id
101 * \return
102 * - 0=OK
103 * - BCM_ERR_PARM-dev_id is invalid
104 * - BCM_ERR_IO-dev_id is in proper range, but link is down
105 */
106bcmos_errno bcm_ll_pcie_dev_enable(int dev_id);
107
108/** Disable PCI access to device
109 * \param[in] dev_id Device id
110 * \return
111 * - 0=OK
112 * - BCM_ERR_PARM-dev_id is invalid
113 */
114bcmos_errno bcm_ll_pcie_dev_disable(int dev_id);
115
116/** Enable/disable host reset for all PCIe interfaces (automatic
117 * device reset when host is reset)
118 * \param[in] enabled Whether or not hot reset should be enabled
119 * \return 0=OK or error <0
120 */
121bcmos_errno bcm_ll_pcie_host_reset_enable(uint8_t dev_id, bcmos_bool enabled);
122
123#ifdef TX_ENABLE_EVENT_TRACE
124/** Handle low-level trace on target
125 * \param[in] dev_id Device id
126 * \param[in] lfile name for trace
127 * \return device handle or NULL if link is down
128 */
129bcmos_errno bcm_ll_pcie_setrace(uint8_t dev_id);
130bcmos_errno bcm_ll_pcie_cleartrace(uint8_t dev_id);
131bcmos_errno bcm_ll_pcie_savetrace(uint8_t dev_id, char *tracefilename);
132#endif
133
134#endif