18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 38c2ecf20Sopenharmony_ci * 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 NetLogic 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 NETLOGIC ``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 NETLOGIC 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_IOMAP_H__ 368c2ecf20Sopenharmony_ci#define __NLM_HAL_IOMAP_H__ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define XLP_DEFAULT_IO_BASE 0x18000000 398c2ecf20Sopenharmony_ci#define XLP_DEFAULT_PCI_ECFG_BASE XLP_DEFAULT_IO_BASE 408c2ecf20Sopenharmony_ci#define XLP_DEFAULT_PCI_CFG_BASE 0x1c000000 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define NMI_BASE 0xbfc00000 438c2ecf20Sopenharmony_ci#define XLP_IO_CLK 133333333 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define XLP_PCIE_CFG_SIZE 0x1000 /* 4K */ 468c2ecf20Sopenharmony_ci#define XLP_PCIE_DEV_BLK_SIZE (8 * XLP_PCIE_CFG_SIZE) 478c2ecf20Sopenharmony_ci#define XLP_PCIE_BUS_BLK_SIZE (256 * XLP_PCIE_DEV_BLK_SIZE) 488c2ecf20Sopenharmony_ci#define XLP_IO_SIZE (64 << 20) /* ECFG space size */ 498c2ecf20Sopenharmony_ci#define XLP_IO_PCI_HDRSZ 0x100 508c2ecf20Sopenharmony_ci#define XLP_IO_DEV(node, dev) ((dev) + (node) * 8) 518c2ecf20Sopenharmony_ci#define XLP_IO_PCI_OFFSET(b, d, f) (((b) << 20) | ((d) << 15) | ((f) << 12)) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define XLP_HDR_OFFSET(node, bus, dev, fn) \ 548c2ecf20Sopenharmony_ci XLP_IO_PCI_OFFSET(bus, XLP_IO_DEV(node, dev), fn) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define XLP_IO_BRIDGE_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 0) 578c2ecf20Sopenharmony_ci/* coherent inter chip */ 588c2ecf20Sopenharmony_ci#define XLP_IO_CIC0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 1) 598c2ecf20Sopenharmony_ci#define XLP_IO_CIC1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 2) 608c2ecf20Sopenharmony_ci#define XLP_IO_CIC2_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 3) 618c2ecf20Sopenharmony_ci#define XLP_IO_PIC_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 4) 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define XLP_IO_PCIE_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 1, i) 648c2ecf20Sopenharmony_ci#define XLP_IO_PCIE0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 0) 658c2ecf20Sopenharmony_ci#define XLP_IO_PCIE1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 1) 668c2ecf20Sopenharmony_ci#define XLP_IO_PCIE2_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 2) 678c2ecf20Sopenharmony_ci#define XLP_IO_PCIE3_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 3) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define XLP_IO_USB_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 2, i) 708c2ecf20Sopenharmony_ci#define XLP_IO_USB_EHCI0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 0) 718c2ecf20Sopenharmony_ci#define XLP_IO_USB_OHCI0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 1) 728c2ecf20Sopenharmony_ci#define XLP_IO_USB_OHCI1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 2) 738c2ecf20Sopenharmony_ci#define XLP_IO_USB_EHCI1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 3) 748c2ecf20Sopenharmony_ci#define XLP_IO_USB_OHCI2_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 4) 758c2ecf20Sopenharmony_ci#define XLP_IO_USB_OHCI3_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 5) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define XLP_IO_SATA_OFFSET(node) XLP_HDR_OFFSET(node, 0, 3, 2) 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* XLP2xx has an updated USB block */ 808c2ecf20Sopenharmony_ci#define XLP2XX_IO_USB_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 4, i) 818c2ecf20Sopenharmony_ci#define XLP2XX_IO_USB_XHCI0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 4, 1) 828c2ecf20Sopenharmony_ci#define XLP2XX_IO_USB_XHCI1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 4, 2) 838c2ecf20Sopenharmony_ci#define XLP2XX_IO_USB_XHCI2_OFFSET(node) XLP_HDR_OFFSET(node, 0, 4, 3) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#define XLP_IO_NAE_OFFSET(node) XLP_HDR_OFFSET(node, 0, 3, 0) 868c2ecf20Sopenharmony_ci#define XLP_IO_POE_OFFSET(node) XLP_HDR_OFFSET(node, 0, 3, 1) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define XLP_IO_CMS_OFFSET(node) XLP_HDR_OFFSET(node, 0, 4, 0) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define XLP_IO_DMA_OFFSET(node) XLP_HDR_OFFSET(node, 0, 5, 1) 918c2ecf20Sopenharmony_ci#define XLP_IO_SEC_OFFSET(node) XLP_HDR_OFFSET(node, 0, 5, 2) 928c2ecf20Sopenharmony_ci#define XLP_IO_CMP_OFFSET(node) XLP_HDR_OFFSET(node, 0, 5, 3) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define XLP_IO_UART_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 6, i) 958c2ecf20Sopenharmony_ci#define XLP_IO_UART0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 0) 968c2ecf20Sopenharmony_ci#define XLP_IO_UART1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 1) 978c2ecf20Sopenharmony_ci#define XLP_IO_I2C_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 6, 2 + i) 988c2ecf20Sopenharmony_ci#define XLP_IO_I2C0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 2) 998c2ecf20Sopenharmony_ci#define XLP_IO_I2C1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 3) 1008c2ecf20Sopenharmony_ci#define XLP_IO_GPIO_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 4) 1018c2ecf20Sopenharmony_ci/* on 2XX, all I2C busses are on the same block */ 1028c2ecf20Sopenharmony_ci#define XLP2XX_IO_I2C_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 7) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* system management */ 1058c2ecf20Sopenharmony_ci#define XLP_IO_SYS_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 5) 1068c2ecf20Sopenharmony_ci#define XLP_IO_JTAG_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 6) 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci/* Flash */ 1098c2ecf20Sopenharmony_ci#define XLP_IO_NOR_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 0) 1108c2ecf20Sopenharmony_ci#define XLP_IO_NAND_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 1) 1118c2ecf20Sopenharmony_ci#define XLP_IO_SPI_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 2) 1128c2ecf20Sopenharmony_ci#define XLP_IO_MMC_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 3) 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* Things have changed drastically in XLP 9XX */ 1158c2ecf20Sopenharmony_ci#define XLP9XX_HDR_OFFSET(n, d, f) \ 1168c2ecf20Sopenharmony_ci XLP_IO_PCI_OFFSET(xlp9xx_get_socbus(n), d, f) 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#define XLP9XX_IO_BRIDGE_OFFSET(node) XLP_IO_PCI_OFFSET(0, 0, node) 1198c2ecf20Sopenharmony_ci#define XLP9XX_IO_PIC_OFFSET(node) XLP9XX_HDR_OFFSET(node, 2, 0) 1208c2ecf20Sopenharmony_ci#define XLP9XX_IO_UART_OFFSET(node) XLP9XX_HDR_OFFSET(node, 2, 2) 1218c2ecf20Sopenharmony_ci#define XLP9XX_IO_SYS_OFFSET(node) XLP9XX_HDR_OFFSET(node, 6, 0) 1228c2ecf20Sopenharmony_ci#define XLP9XX_IO_FUSE_OFFSET(node) XLP9XX_HDR_OFFSET(node, 6, 1) 1238c2ecf20Sopenharmony_ci#define XLP9XX_IO_CLOCK_OFFSET(node) XLP9XX_HDR_OFFSET(node, 6, 2) 1248c2ecf20Sopenharmony_ci#define XLP9XX_IO_POWER_OFFSET(node) XLP9XX_HDR_OFFSET(node, 6, 3) 1258c2ecf20Sopenharmony_ci#define XLP9XX_IO_JTAG_OFFSET(node) XLP9XX_HDR_OFFSET(node, 6, 4) 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define XLP9XX_IO_PCIE_OFFSET(node, i) XLP9XX_HDR_OFFSET(node, 1, i) 1288c2ecf20Sopenharmony_ci#define XLP9XX_IO_PCIE0_OFFSET(node) XLP9XX_HDR_OFFSET(node, 1, 0) 1298c2ecf20Sopenharmony_ci#define XLP9XX_IO_PCIE2_OFFSET(node) XLP9XX_HDR_OFFSET(node, 1, 2) 1308c2ecf20Sopenharmony_ci#define XLP9XX_IO_PCIE3_OFFSET(node) XLP9XX_HDR_OFFSET(node, 1, 3) 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/* XLP9xx USB block */ 1338c2ecf20Sopenharmony_ci#define XLP9XX_IO_USB_OFFSET(node, i) XLP9XX_HDR_OFFSET(node, 4, i) 1348c2ecf20Sopenharmony_ci#define XLP9XX_IO_USB_XHCI0_OFFSET(node) XLP9XX_HDR_OFFSET(node, 4, 1) 1358c2ecf20Sopenharmony_ci#define XLP9XX_IO_USB_XHCI1_OFFSET(node) XLP9XX_HDR_OFFSET(node, 4, 2) 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* XLP9XX on-chip SATA controller */ 1388c2ecf20Sopenharmony_ci#define XLP9XX_IO_SATA_OFFSET(node) XLP9XX_HDR_OFFSET(node, 3, 2) 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci/* Flash */ 1418c2ecf20Sopenharmony_ci#define XLP9XX_IO_NOR_OFFSET(node) XLP9XX_HDR_OFFSET(node, 7, 0) 1428c2ecf20Sopenharmony_ci#define XLP9XX_IO_NAND_OFFSET(node) XLP9XX_HDR_OFFSET(node, 7, 1) 1438c2ecf20Sopenharmony_ci#define XLP9XX_IO_SPI_OFFSET(node) XLP9XX_HDR_OFFSET(node, 7, 2) 1448c2ecf20Sopenharmony_ci#define XLP9XX_IO_MMC_OFFSET(node) XLP9XX_HDR_OFFSET(node, 7, 3) 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci/* PCI config header register id's */ 1478c2ecf20Sopenharmony_ci#define XLP_PCI_CFGREG0 0x00 1488c2ecf20Sopenharmony_ci#define XLP_PCI_CFGREG1 0x01 1498c2ecf20Sopenharmony_ci#define XLP_PCI_CFGREG2 0x02 1508c2ecf20Sopenharmony_ci#define XLP_PCI_CFGREG3 0x03 1518c2ecf20Sopenharmony_ci#define XLP_PCI_CFGREG4 0x04 1528c2ecf20Sopenharmony_ci#define XLP_PCI_CFGREG5 0x05 1538c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG0 0x30 1548c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG1 0x31 1558c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG2 0x32 1568c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG3 0x33 1578c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG4 0x34 1588c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG5 0x35 1598c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG6 0x36 1608c2ecf20Sopenharmony_ci#define XLP_PCI_DEVINFO_REG7 0x37 1618c2ecf20Sopenharmony_ci#define XLP_PCI_DEVSCRATCH_REG0 0x38 1628c2ecf20Sopenharmony_ci#define XLP_PCI_DEVSCRATCH_REG1 0x39 1638c2ecf20Sopenharmony_ci#define XLP_PCI_DEVSCRATCH_REG2 0x3a 1648c2ecf20Sopenharmony_ci#define XLP_PCI_DEVSCRATCH_REG3 0x3b 1658c2ecf20Sopenharmony_ci#define XLP_PCI_MSGSTN_REG 0x3c 1668c2ecf20Sopenharmony_ci#define XLP_PCI_IRTINFO_REG 0x3d 1678c2ecf20Sopenharmony_ci#define XLP_PCI_UCODEINFO_REG 0x3e 1688c2ecf20Sopenharmony_ci#define XLP_PCI_SBB_WT_REG 0x3f 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* PCI IDs for SoC device */ 1718c2ecf20Sopenharmony_ci#define PCI_VENDOR_NETLOGIC 0x184e 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_ROOT 0x1001 1748c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_ICI 0x1002 1758c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_PIC 0x1003 1768c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_PCIE 0x1004 1778c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_EHCI 0x1007 1788c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_OHCI 0x1008 1798c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_NAE 0x1009 1808c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_POE 0x100A 1818c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_FMN 0x100B 1828c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_RAID 0x100D 1838c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_SAE 0x100D 1848c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_RSA 0x100E 1858c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_CMP 0x100F 1868c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_UART 0x1010 1878c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_I2C 0x1011 1888c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_NOR 0x1015 1898c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_NAND 0x1016 1908c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_MMC 0x1018 1918c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_SATA 0x101A 1928c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NLM_XHCI 0x101D 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_XLP9XX_MMC 0x9018 1958c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_XLP9XX_SATA 0x901A 1968c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_XLP9XX_XHCI 0x901D 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#define nlm_read_pci_reg(b, r) nlm_read_reg(b, r) 2018c2ecf20Sopenharmony_ci#define nlm_write_pci_reg(b, r, v) nlm_write_reg(b, r, v) 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cistatic inline int xlp9xx_get_socbus(int node) 2048c2ecf20Sopenharmony_ci{ 2058c2ecf20Sopenharmony_ci uint64_t socbridge; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci if (node == 0) 2088c2ecf20Sopenharmony_ci return 1; 2098c2ecf20Sopenharmony_ci socbridge = nlm_pcicfg_base(XLP9XX_IO_BRIDGE_OFFSET(node)); 2108c2ecf20Sopenharmony_ci return (nlm_read_pci_reg(socbridge, 0x6) >> 8) & 0xff; 2118c2ecf20Sopenharmony_ci} 2128c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY */ 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci#endif /* __NLM_HAL_IOMAP_H__ */ 215