18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2003-2012 Broadcom Corporation
38c2ecf20Sopenharmony_ci * All Rights Reserved
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
68c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
78c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
88c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the Broadcom
98c2ecf20Sopenharmony_ci * license below:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
128c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
138c2ecf20Sopenharmony_ci * are met:
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
168c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
178c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
188c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
198c2ecf20Sopenharmony_ci *    the documentation and/or other materials provided with the
208c2ecf20Sopenharmony_ci *    distribution.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
238c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
248c2ecf20Sopenharmony_ci * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
258c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
268c2ecf20Sopenharmony_ci * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
278c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
288c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
298c2ecf20Sopenharmony_ci * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
308c2ecf20Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
318c2ecf20Sopenharmony_ci * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
328c2ecf20Sopenharmony_ci * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifndef __NLM_HAL_PCIBUS_H__
368c2ecf20Sopenharmony_ci#define __NLM_HAL_PCIBUS_H__
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* PCIE Memory and IO regions */
398c2ecf20Sopenharmony_ci#define PCIE_MEM_BASE			0xd0000000ULL
408c2ecf20Sopenharmony_ci#define PCIE_MEM_LIMIT			0xdfffffffULL
418c2ecf20Sopenharmony_ci#define PCIE_IO_BASE			0x14000000ULL
428c2ecf20Sopenharmony_ci#define PCIE_IO_LIMIT			0x15ffffffULL
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define PCIE_BRIDGE_CMD			0x1
458c2ecf20Sopenharmony_ci#define PCIE_BRIDGE_MSI_CAP		0x14
468c2ecf20Sopenharmony_ci#define PCIE_BRIDGE_MSI_ADDRL		0x15
478c2ecf20Sopenharmony_ci#define PCIE_BRIDGE_MSI_ADDRH		0x16
488c2ecf20Sopenharmony_ci#define PCIE_BRIDGE_MSI_DATA		0x17
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* XLP Global PCIE configuration space registers */
518c2ecf20Sopenharmony_ci#define PCIE_BYTE_SWAP_MEM_BASE		0x247
528c2ecf20Sopenharmony_ci#define PCIE_BYTE_SWAP_MEM_LIM		0x248
538c2ecf20Sopenharmony_ci#define PCIE_BYTE_SWAP_IO_BASE		0x249
548c2ecf20Sopenharmony_ci#define PCIE_BYTE_SWAP_IO_LIM		0x24A
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define PCIE_BRIDGE_MSIX_ADDR_BASE	0x24F
578c2ecf20Sopenharmony_ci#define PCIE_BRIDGE_MSIX_ADDR_LIMIT	0x250
588c2ecf20Sopenharmony_ci#define PCIE_MSI_STATUS			0x25A
598c2ecf20Sopenharmony_ci#define PCIE_MSI_EN			0x25B
608c2ecf20Sopenharmony_ci#define PCIE_MSIX_STATUS		0x25D
618c2ecf20Sopenharmony_ci#define PCIE_INT_STATUS0		0x25F
628c2ecf20Sopenharmony_ci#define PCIE_INT_STATUS1		0x260
638c2ecf20Sopenharmony_ci#define PCIE_INT_EN0			0x261
648c2ecf20Sopenharmony_ci#define PCIE_INT_EN1			0x262
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* XLP9XX has basic changes */
678c2ecf20Sopenharmony_ci#define PCIE_9XX_BYTE_SWAP_MEM_BASE	0x25c
688c2ecf20Sopenharmony_ci#define PCIE_9XX_BYTE_SWAP_MEM_LIM	0x25d
698c2ecf20Sopenharmony_ci#define PCIE_9XX_BYTE_SWAP_IO_BASE	0x25e
708c2ecf20Sopenharmony_ci#define PCIE_9XX_BYTE_SWAP_IO_LIM	0x25f
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define PCIE_9XX_BRIDGE_MSIX_ADDR_BASE	0x264
738c2ecf20Sopenharmony_ci#define PCIE_9XX_BRIDGE_MSIX_ADDR_LIMIT	0x265
748c2ecf20Sopenharmony_ci#define PCIE_9XX_MSI_STATUS		0x283
758c2ecf20Sopenharmony_ci#define PCIE_9XX_MSI_EN			0x284
768c2ecf20Sopenharmony_ci/* 128 MSIX vectors available in 9xx */
778c2ecf20Sopenharmony_ci#define PCIE_9XX_MSIX_STATUS0		0x286
788c2ecf20Sopenharmony_ci#define PCIE_9XX_MSIX_STATUSX(n)	(n + 0x286)
798c2ecf20Sopenharmony_ci#define PCIE_9XX_MSIX_VEC		0x296
808c2ecf20Sopenharmony_ci#define PCIE_9XX_MSIX_VECX(n)		(n + 0x296)
818c2ecf20Sopenharmony_ci#define PCIE_9XX_INT_STATUS0		0x397
828c2ecf20Sopenharmony_ci#define PCIE_9XX_INT_STATUS1		0x398
838c2ecf20Sopenharmony_ci#define PCIE_9XX_INT_EN0		0x399
848c2ecf20Sopenharmony_ci#define PCIE_9XX_INT_EN1		0x39a
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/* other */
878c2ecf20Sopenharmony_ci#define PCIE_NLINKS			4
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* MSI addresses */
908c2ecf20Sopenharmony_ci#define MSI_ADDR_BASE			0xfffee00000ULL
918c2ecf20Sopenharmony_ci#define MSI_ADDR_SZ			0x10000
928c2ecf20Sopenharmony_ci#define MSI_LINK_ADDR(n, l)		(MSI_ADDR_BASE + \
938c2ecf20Sopenharmony_ci				(PCIE_NLINKS * (n) + (l)) * MSI_ADDR_SZ)
948c2ecf20Sopenharmony_ci#define MSIX_ADDR_BASE			0xfffef00000ULL
958c2ecf20Sopenharmony_ci#define MSIX_LINK_ADDR(n, l)		(MSIX_ADDR_BASE + \
968c2ecf20Sopenharmony_ci				(PCIE_NLINKS * (n) + (l)) * MSI_ADDR_SZ)
978c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define nlm_read_pcie_reg(b, r)		nlm_read_reg(b, r)
1008c2ecf20Sopenharmony_ci#define nlm_write_pcie_reg(b, r, v)	nlm_write_reg(b, r, v)
1018c2ecf20Sopenharmony_ci#define nlm_get_pcie_base(node, inst)	nlm_pcicfg_base(cpu_is_xlp9xx() ? \
1028c2ecf20Sopenharmony_ci	XLP9XX_IO_PCIE_OFFSET(node, inst) : XLP_IO_PCIE_OFFSET(node, inst))
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI_MSI
1058c2ecf20Sopenharmony_civoid xlp_init_node_msi_irqs(int node, int link);
1068c2ecf20Sopenharmony_ci#else
1078c2ecf20Sopenharmony_cistatic inline void xlp_init_node_msi_irqs(int node, int link) {}
1088c2ecf20Sopenharmony_ci#endif
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistruct pci_dev *xlp_get_pcie_link(const struct pci_dev *dev);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#endif
1138c2ecf20Sopenharmony_ci#endif /* __NLM_HAL_PCIBUS_H__ */
114