Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Netlogic: Add XLP platform files for XLP SoC

- Update common files to support XLP.
- Add arch/mips/include/asm/netlogic/xlp-hal for register definitions
and access macros
- Add arch/mips/netlogic/xlp/ for XLP specific files.

Signed-off-by: Jayachandran C <jayachandranc@netlogicmicro.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2967/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Jayachandran C and committed by
Ralf Baechle
65040e22 a3d4fb2d

+1938 -4
+21
arch/mips/include/asm/netlogic/haldefs.h
··· 40 40 * and will provide a way to read 32/64 bit memory mapped registers in 41 41 * all ABIs 42 42 */ 43 + #if !defined(CONFIG_64BIT) && defined(CONFIG_CPU_XLP) 44 + #error "o32 compile not supported on XLP yet" 45 + #endif 43 46 /* 44 47 * For o32 compilation, we have to disable interrupts and enable KX bit to 45 48 * access 64 bit addresses or data. ··· 136 133 /* Location where IO base is mapped */ 137 134 extern uint64_t nlm_io_base; 138 135 136 + #if defined(CONFIG_CPU_XLP) 137 + static inline uint64_t 138 + nlm_pcicfg_base(uint32_t devoffset) 139 + { 140 + return nlm_io_base + devoffset; 141 + } 142 + 143 + static inline uint64_t 144 + nlm_xkphys_map_pcibar0(uint64_t pcibase) 145 + { 146 + uint64_t paddr; 147 + 148 + paddr = nlm_read_reg(pcibase, 0x4) & ~0xfu; 149 + return (uint64_t)0x9000000000000000 | paddr; 150 + } 151 + #elif defined(CONFIG_CPU_XLR) 152 + 139 153 static inline uint64_t 140 154 nlm_mmio_base(uint32_t devoffset) 141 155 { 142 156 return nlm_io_base + devoffset; 143 157 } 158 + #endif 144 159 145 160 #endif
+187
arch/mips/include/asm/netlogic/xlp-hal/bridge.h
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #ifndef __NLM_HAL_BRIDGE_H__ 36 + #define __NLM_HAL_BRIDGE_H__ 37 + 38 + /** 39 + * @file_name mio.h 40 + * @author Netlogic Microsystems 41 + * @brief Basic definitions of XLP memory and io subsystem 42 + */ 43 + 44 + /* 45 + * BRIDGE specific registers 46 + * 47 + * These registers start after the PCIe header, which has 0x40 48 + * standard entries 49 + */ 50 + #define BRIDGE_MODE 0x00 51 + #define BRIDGE_PCI_CFG_BASE 0x01 52 + #define BRIDGE_PCI_CFG_LIMIT 0x02 53 + #define BRIDGE_PCIE_CFG_BASE 0x03 54 + #define BRIDGE_PCIE_CFG_LIMIT 0x04 55 + #define BRIDGE_BUSNUM_BAR0 0x05 56 + #define BRIDGE_BUSNUM_BAR1 0x06 57 + #define BRIDGE_BUSNUM_BAR2 0x07 58 + #define BRIDGE_BUSNUM_BAR3 0x08 59 + #define BRIDGE_BUSNUM_BAR4 0x09 60 + #define BRIDGE_BUSNUM_BAR5 0x0a 61 + #define BRIDGE_BUSNUM_BAR6 0x0b 62 + #define BRIDGE_FLASH_BAR0 0x0c 63 + #define BRIDGE_FLASH_BAR1 0x0d 64 + #define BRIDGE_FLASH_BAR2 0x0e 65 + #define BRIDGE_FLASH_BAR3 0x0f 66 + #define BRIDGE_FLASH_LIMIT0 0x10 67 + #define BRIDGE_FLASH_LIMIT1 0x11 68 + #define BRIDGE_FLASH_LIMIT2 0x12 69 + #define BRIDGE_FLASH_LIMIT3 0x13 70 + 71 + #define BRIDGE_DRAM_BAR(i) (0x14 + (i)) 72 + #define BRIDGE_DRAM_BAR0 0x14 73 + #define BRIDGE_DRAM_BAR1 0x15 74 + #define BRIDGE_DRAM_BAR2 0x16 75 + #define BRIDGE_DRAM_BAR3 0x17 76 + #define BRIDGE_DRAM_BAR4 0x18 77 + #define BRIDGE_DRAM_BAR5 0x19 78 + #define BRIDGE_DRAM_BAR6 0x1a 79 + #define BRIDGE_DRAM_BAR7 0x1b 80 + 81 + #define BRIDGE_DRAM_LIMIT(i) (0x1c + (i)) 82 + #define BRIDGE_DRAM_LIMIT0 0x1c 83 + #define BRIDGE_DRAM_LIMIT1 0x1d 84 + #define BRIDGE_DRAM_LIMIT2 0x1e 85 + #define BRIDGE_DRAM_LIMIT3 0x1f 86 + #define BRIDGE_DRAM_LIMIT4 0x20 87 + #define BRIDGE_DRAM_LIMIT5 0x21 88 + #define BRIDGE_DRAM_LIMIT6 0x22 89 + #define BRIDGE_DRAM_LIMIT7 0x23 90 + 91 + #define BRIDGE_DRAM_NODE_TRANSLN0 0x24 92 + #define BRIDGE_DRAM_NODE_TRANSLN1 0x25 93 + #define BRIDGE_DRAM_NODE_TRANSLN2 0x26 94 + #define BRIDGE_DRAM_NODE_TRANSLN3 0x27 95 + #define BRIDGE_DRAM_NODE_TRANSLN4 0x28 96 + #define BRIDGE_DRAM_NODE_TRANSLN5 0x29 97 + #define BRIDGE_DRAM_NODE_TRANSLN6 0x2a 98 + #define BRIDGE_DRAM_NODE_TRANSLN7 0x2b 99 + #define BRIDGE_DRAM_CHNL_TRANSLN0 0x2c 100 + #define BRIDGE_DRAM_CHNL_TRANSLN1 0x2d 101 + #define BRIDGE_DRAM_CHNL_TRANSLN2 0x2e 102 + #define BRIDGE_DRAM_CHNL_TRANSLN3 0x2f 103 + #define BRIDGE_DRAM_CHNL_TRANSLN4 0x30 104 + #define BRIDGE_DRAM_CHNL_TRANSLN5 0x31 105 + #define BRIDGE_DRAM_CHNL_TRANSLN6 0x32 106 + #define BRIDGE_DRAM_CHNL_TRANSLN7 0x33 107 + #define BRIDGE_PCIEMEM_BASE0 0x34 108 + #define BRIDGE_PCIEMEM_BASE1 0x35 109 + #define BRIDGE_PCIEMEM_BASE2 0x36 110 + #define BRIDGE_PCIEMEM_BASE3 0x37 111 + #define BRIDGE_PCIEMEM_LIMIT0 0x38 112 + #define BRIDGE_PCIEMEM_LIMIT1 0x39 113 + #define BRIDGE_PCIEMEM_LIMIT2 0x3a 114 + #define BRIDGE_PCIEMEM_LIMIT3 0x3b 115 + #define BRIDGE_PCIEIO_BASE0 0x3c 116 + #define BRIDGE_PCIEIO_BASE1 0x3d 117 + #define BRIDGE_PCIEIO_BASE2 0x3e 118 + #define BRIDGE_PCIEIO_BASE3 0x3f 119 + #define BRIDGE_PCIEIO_LIMIT0 0x40 120 + #define BRIDGE_PCIEIO_LIMIT1 0x41 121 + #define BRIDGE_PCIEIO_LIMIT2 0x42 122 + #define BRIDGE_PCIEIO_LIMIT3 0x43 123 + #define BRIDGE_PCIEMEM_BASE4 0x44 124 + #define BRIDGE_PCIEMEM_BASE5 0x45 125 + #define BRIDGE_PCIEMEM_BASE6 0x46 126 + #define BRIDGE_PCIEMEM_LIMIT4 0x47 127 + #define BRIDGE_PCIEMEM_LIMIT5 0x48 128 + #define BRIDGE_PCIEMEM_LIMIT6 0x49 129 + #define BRIDGE_PCIEIO_BASE4 0x4a 130 + #define BRIDGE_PCIEIO_BASE5 0x4b 131 + #define BRIDGE_PCIEIO_BASE6 0x4c 132 + #define BRIDGE_PCIEIO_LIMIT4 0x4d 133 + #define BRIDGE_PCIEIO_LIMIT5 0x4e 134 + #define BRIDGE_PCIEIO_LIMIT6 0x4f 135 + #define BRIDGE_NBU_EVENT_CNT_CTL 0x50 136 + #define BRIDGE_EVNTCTR1_LOW 0x51 137 + #define BRIDGE_EVNTCTR1_HI 0x52 138 + #define BRIDGE_EVNT_CNT_CTL2 0x53 139 + #define BRIDGE_EVNTCTR2_LOW 0x54 140 + #define BRIDGE_EVNTCTR2_HI 0x55 141 + #define BRIDGE_TRACEBUF_MATCH0 0x56 142 + #define BRIDGE_TRACEBUF_MATCH1 0x57 143 + #define BRIDGE_TRACEBUF_MATCH_LOW 0x58 144 + #define BRIDGE_TRACEBUF_MATCH_HI 0x59 145 + #define BRIDGE_TRACEBUF_CTRL 0x5a 146 + #define BRIDGE_TRACEBUF_INIT 0x5b 147 + #define BRIDGE_TRACEBUF_ACCESS 0x5c 148 + #define BRIDGE_TRACEBUF_READ_DATA0 0x5d 149 + #define BRIDGE_TRACEBUF_READ_DATA1 0x5d 150 + #define BRIDGE_TRACEBUF_READ_DATA2 0x5f 151 + #define BRIDGE_TRACEBUF_READ_DATA3 0x60 152 + #define BRIDGE_TRACEBUF_STATUS 0x61 153 + #define BRIDGE_ADDRESS_ERROR0 0x62 154 + #define BRIDGE_ADDRESS_ERROR1 0x63 155 + #define BRIDGE_ADDRESS_ERROR2 0x64 156 + #define BRIDGE_TAG_ECC_ADDR_ERROR0 0x65 157 + #define BRIDGE_TAG_ECC_ADDR_ERROR1 0x66 158 + #define BRIDGE_TAG_ECC_ADDR_ERROR2 0x67 159 + #define BRIDGE_LINE_FLUSH0 0x68 160 + #define BRIDGE_LINE_FLUSH1 0x69 161 + #define BRIDGE_NODE_ID 0x6a 162 + #define BRIDGE_ERROR_INTERRUPT_EN 0x6b 163 + #define BRIDGE_PCIE0_WEIGHT 0x2c0 164 + #define BRIDGE_PCIE1_WEIGHT 0x2c1 165 + #define BRIDGE_PCIE2_WEIGHT 0x2c2 166 + #define BRIDGE_PCIE3_WEIGHT 0x2c3 167 + #define BRIDGE_USB_WEIGHT 0x2c4 168 + #define BRIDGE_NET_WEIGHT 0x2c5 169 + #define BRIDGE_POE_WEIGHT 0x2c6 170 + #define BRIDGE_CMS_WEIGHT 0x2c7 171 + #define BRIDGE_DMAENG_WEIGHT 0x2c8 172 + #define BRIDGE_SEC_WEIGHT 0x2c9 173 + #define BRIDGE_COMP_WEIGHT 0x2ca 174 + #define BRIDGE_GIO_WEIGHT 0x2cb 175 + #define BRIDGE_FLASH_WEIGHT 0x2cc 176 + 177 + #ifndef __ASSEMBLY__ 178 + 179 + #define nlm_read_bridge_reg(b, r) nlm_read_reg(b, r) 180 + #define nlm_write_bridge_reg(b, r, v) nlm_write_reg(b, r, v) 181 + #define nlm_get_bridge_pcibase(node) \ 182 + nlm_pcicfg_base(XLP_IO_BRIDGE_OFFSET(node)) 183 + #define nlm_get_bridge_regbase(node) \ 184 + (nlm_get_bridge_pcibase(node) + XLP_IO_PCI_HDRSZ) 185 + 186 + #endif /* __ASSEMBLY__ */ 187 + #endif /* __NLM_HAL_BRIDGE_H__ */
+83
arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #ifndef __NLM_HAL_CPUCONTROL_H__ 36 + #define __NLM_HAL_CPUCONTROL_H__ 37 + 38 + #define CPU_BLOCKID_IFU 0 39 + #define CPU_BLOCKID_ICU 1 40 + #define CPU_BLOCKID_IEU 2 41 + #define CPU_BLOCKID_LSU 3 42 + #define CPU_BLOCKID_MMU 4 43 + #define CPU_BLOCKID_PRF 5 44 + #define CPU_BLOCKID_SCH 7 45 + #define CPU_BLOCKID_SCU 8 46 + #define CPU_BLOCKID_FPU 9 47 + #define CPU_BLOCKID_MAP 10 48 + 49 + #define LSU_DEFEATURE 0x304 50 + #define LSU_CERRLOG_REGID 0x09 51 + #define SCHED_DEFEATURE 0x700 52 + 53 + /* Offsets of interest from the 'MAP' Block */ 54 + #define MAP_THREADMODE 0x00 55 + #define MAP_EXT_EBASE_ENABLE 0x04 56 + #define MAP_CCDI_CONFIG 0x08 57 + #define MAP_THRD0_CCDI_STATUS 0x0c 58 + #define MAP_THRD1_CCDI_STATUS 0x10 59 + #define MAP_THRD2_CCDI_STATUS 0x14 60 + #define MAP_THRD3_CCDI_STATUS 0x18 61 + #define MAP_THRD0_DEBUG_MODE 0x1c 62 + #define MAP_THRD1_DEBUG_MODE 0x20 63 + #define MAP_THRD2_DEBUG_MODE 0x24 64 + #define MAP_THRD3_DEBUG_MODE 0x28 65 + #define MAP_MISC_STATE 0x60 66 + #define MAP_DEBUG_READ_CTL 0x64 67 + #define MAP_DEBUG_READ_REG0 0x68 68 + #define MAP_DEBUG_READ_REG1 0x6c 69 + 70 + #define MMU_SETUP 0x400 71 + #define MMU_LFSRSEED 0x401 72 + #define MMU_HPW_NUM_PAGE_LVL 0x410 73 + #define MMU_PGWKR_PGDBASE 0x411 74 + #define MMU_PGWKR_PGDSHFT 0x412 75 + #define MMU_PGWKR_PGDMASK 0x413 76 + #define MMU_PGWKR_PUDSHFT 0x414 77 + #define MMU_PGWKR_PUDMASK 0x415 78 + #define MMU_PGWKR_PMDSHFT 0x416 79 + #define MMU_PGWKR_PMDMASK 0x417 80 + #define MMU_PGWKR_PTESHFT 0x418 81 + #define MMU_PGWKR_PTEMASK 0x419 82 + 83 + #endif /* __NLM_CPUCONTROL_H__ */
+153
arch/mips/include/asm/netlogic/xlp-hal/iomap.h
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #ifndef __NLM_HAL_IOMAP_H__ 36 + #define __NLM_HAL_IOMAP_H__ 37 + 38 + #define XLP_DEFAULT_IO_BASE 0x18000000 39 + #define NMI_BASE 0xbfc00000 40 + #define XLP_IO_CLK 133333333 41 + 42 + #define XLP_PCIE_CFG_SIZE 0x1000 /* 4K */ 43 + #define XLP_PCIE_DEV_BLK_SIZE (8 * XLP_PCIE_CFG_SIZE) 44 + #define XLP_PCIE_BUS_BLK_SIZE (256 * XLP_PCIE_DEV_BLK_SIZE) 45 + #define XLP_IO_SIZE (64 << 20) /* ECFG space size */ 46 + #define XLP_IO_PCI_HDRSZ 0x100 47 + #define XLP_IO_DEV(node, dev) ((dev) + (node) * 8) 48 + #define XLP_HDR_OFFSET(node, bus, dev, fn) (((bus) << 20) | \ 49 + ((XLP_IO_DEV(node, dev)) << 15) | ((fn) << 12)) 50 + 51 + #define XLP_IO_BRIDGE_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 0) 52 + /* coherent inter chip */ 53 + #define XLP_IO_CIC0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 1) 54 + #define XLP_IO_CIC1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 2) 55 + #define XLP_IO_CIC2_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 3) 56 + #define XLP_IO_PIC_OFFSET(node) XLP_HDR_OFFSET(node, 0, 0, 4) 57 + 58 + #define XLP_IO_PCIE_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 1, i) 59 + #define XLP_IO_PCIE0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 0) 60 + #define XLP_IO_PCIE1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 1) 61 + #define XLP_IO_PCIE2_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 2) 62 + #define XLP_IO_PCIE3_OFFSET(node) XLP_HDR_OFFSET(node, 0, 1, 3) 63 + 64 + #define XLP_IO_USB_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 2, i) 65 + #define XLP_IO_USB_EHCI0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 0) 66 + #define XLP_IO_USB_OHCI0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 1) 67 + #define XLP_IO_USB_OHCI1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 2) 68 + #define XLP_IO_USB_EHCI1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 3) 69 + #define XLP_IO_USB_OHCI2_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 4) 70 + #define XLP_IO_USB_OHCI3_OFFSET(node) XLP_HDR_OFFSET(node, 0, 2, 5) 71 + 72 + #define XLP_IO_NAE_OFFSET(node) XLP_HDR_OFFSET(node, 0, 3, 0) 73 + #define XLP_IO_POE_OFFSET(node) XLP_HDR_OFFSET(node, 0, 3, 1) 74 + 75 + #define XLP_IO_CMS_OFFSET(node) XLP_HDR_OFFSET(node, 0, 4, 0) 76 + 77 + #define XLP_IO_DMA_OFFSET(node) XLP_HDR_OFFSET(node, 0, 5, 1) 78 + #define XLP_IO_SEC_OFFSET(node) XLP_HDR_OFFSET(node, 0, 5, 2) 79 + #define XLP_IO_CMP_OFFSET(node) XLP_HDR_OFFSET(node, 0, 5, 3) 80 + 81 + #define XLP_IO_UART_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 6, i) 82 + #define XLP_IO_UART0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 0) 83 + #define XLP_IO_UART1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 1) 84 + #define XLP_IO_I2C_OFFSET(node, i) XLP_HDR_OFFSET(node, 0, 6, 2 + i) 85 + #define XLP_IO_I2C0_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 2) 86 + #define XLP_IO_I2C1_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 3) 87 + #define XLP_IO_GPIO_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 4) 88 + /* system management */ 89 + #define XLP_IO_SYS_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 5) 90 + #define XLP_IO_JTAG_OFFSET(node) XLP_HDR_OFFSET(node, 0, 6, 6) 91 + 92 + #define XLP_IO_NOR_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 0) 93 + #define XLP_IO_NAND_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 1) 94 + #define XLP_IO_SPI_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 2) 95 + /* SD flash */ 96 + #define XLP_IO_SD_OFFSET(node) XLP_HDR_OFFSET(node, 0, 7, 3) 97 + #define XLP_IO_MMC_OFFSET(node, slot) \ 98 + ((XLP_IO_SD_OFFSET(node))+(slot*0x100)+XLP_IO_PCI_HDRSZ) 99 + 100 + /* PCI config header register id's */ 101 + #define XLP_PCI_CFGREG0 0x00 102 + #define XLP_PCI_CFGREG1 0x01 103 + #define XLP_PCI_CFGREG2 0x02 104 + #define XLP_PCI_CFGREG3 0x03 105 + #define XLP_PCI_CFGREG4 0x04 106 + #define XLP_PCI_CFGREG5 0x05 107 + #define XLP_PCI_DEVINFO_REG0 0x30 108 + #define XLP_PCI_DEVINFO_REG1 0x31 109 + #define XLP_PCI_DEVINFO_REG2 0x32 110 + #define XLP_PCI_DEVINFO_REG3 0x33 111 + #define XLP_PCI_DEVINFO_REG4 0x34 112 + #define XLP_PCI_DEVINFO_REG5 0x35 113 + #define XLP_PCI_DEVINFO_REG6 0x36 114 + #define XLP_PCI_DEVINFO_REG7 0x37 115 + #define XLP_PCI_DEVSCRATCH_REG0 0x38 116 + #define XLP_PCI_DEVSCRATCH_REG1 0x39 117 + #define XLP_PCI_DEVSCRATCH_REG2 0x3a 118 + #define XLP_PCI_DEVSCRATCH_REG3 0x3b 119 + #define XLP_PCI_MSGSTN_REG 0x3c 120 + #define XLP_PCI_IRTINFO_REG 0x3d 121 + #define XLP_PCI_UCODEINFO_REG 0x3e 122 + #define XLP_PCI_SBB_WT_REG 0x3f 123 + 124 + /* PCI IDs for SoC device */ 125 + #define PCI_VENDOR_NETLOGIC 0x184e 126 + 127 + #define PCI_DEVICE_ID_NLM_ROOT 0x1001 128 + #define PCI_DEVICE_ID_NLM_ICI 0x1002 129 + #define PCI_DEVICE_ID_NLM_PIC 0x1003 130 + #define PCI_DEVICE_ID_NLM_PCIE 0x1004 131 + #define PCI_DEVICE_ID_NLM_EHCI 0x1007 132 + #define PCI_DEVICE_ID_NLM_ILK 0x1008 133 + #define PCI_DEVICE_ID_NLM_NAE 0x1009 134 + #define PCI_DEVICE_ID_NLM_POE 0x100A 135 + #define PCI_DEVICE_ID_NLM_FMN 0x100B 136 + #define PCI_DEVICE_ID_NLM_RAID 0x100D 137 + #define PCI_DEVICE_ID_NLM_SAE 0x100D 138 + #define PCI_DEVICE_ID_NLM_RSA 0x100E 139 + #define PCI_DEVICE_ID_NLM_CMP 0x100F 140 + #define PCI_DEVICE_ID_NLM_UART 0x1010 141 + #define PCI_DEVICE_ID_NLM_I2C 0x1011 142 + #define PCI_DEVICE_ID_NLM_NOR 0x1015 143 + #define PCI_DEVICE_ID_NLM_NAND 0x1016 144 + #define PCI_DEVICE_ID_NLM_MMC 0x1018 145 + 146 + #ifndef __ASSEMBLY__ 147 + 148 + #define nlm_read_pci_reg(b, r) nlm_read_reg(b, r) 149 + #define nlm_write_pci_reg(b, r, v) nlm_write_reg(b, r, v) 150 + 151 + #endif /* !__ASSEMBLY */ 152 + 153 + #endif /* __NLM_HAL_IOMAP_H__ */
+411
arch/mips/include/asm/netlogic/xlp-hal/pic.h
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #ifndef _NLM_HAL_PIC_H 36 + #define _NLM_HAL_PIC_H 37 + 38 + /* PIC Specific registers */ 39 + #define PIC_CTRL 0x00 40 + 41 + /* PIC control register defines */ 42 + #define PIC_CTRL_ITV 32 /* interrupt timeout value */ 43 + #define PIC_CTRL_ICI 19 /* ICI interrupt timeout enable */ 44 + #define PIC_CTRL_ITE 18 /* interrupt timeout enable */ 45 + #define PIC_CTRL_STE 10 /* system timer interrupt enable */ 46 + #define PIC_CTRL_WWR1 8 /* watchdog 1 wraparound count for reset */ 47 + #define PIC_CTRL_WWR0 6 /* watchdog 0 wraparound count for reset */ 48 + #define PIC_CTRL_WWN1 4 /* watchdog 1 wraparound count for NMI */ 49 + #define PIC_CTRL_WWN0 2 /* watchdog 0 wraparound count for NMI */ 50 + #define PIC_CTRL_WTE 0 /* watchdog timer enable */ 51 + 52 + /* PIC Status register defines */ 53 + #define PIC_ICI_STATUS 33 /* ICI interrupt timeout status */ 54 + #define PIC_ITE_STATUS 32 /* interrupt timeout status */ 55 + #define PIC_STS_STATUS 4 /* System timer interrupt status */ 56 + #define PIC_WNS_STATUS 2 /* NMI status for watchdog timers */ 57 + #define PIC_WIS_STATUS 0 /* Interrupt status for watchdog timers */ 58 + 59 + /* PIC IPI control register offsets */ 60 + #define PIC_IPICTRL_NMI 32 61 + #define PIC_IPICTRL_RIV 20 /* received interrupt vector */ 62 + #define PIC_IPICTRL_IDB 16 /* interrupt destination base */ 63 + #define PIC_IPICTRL_DTE 0 /* interrupt destination thread enables */ 64 + 65 + /* PIC IRT register offsets */ 66 + #define PIC_IRT_ENABLE 31 67 + #define PIC_IRT_NMI 29 68 + #define PIC_IRT_SCH 28 /* Scheduling scheme */ 69 + #define PIC_IRT_RVEC 20 /* Interrupt receive vectors */ 70 + #define PIC_IRT_DT 19 /* Destination type */ 71 + #define PIC_IRT_DB 16 /* Destination base */ 72 + #define PIC_IRT_DTE 0 /* Destination thread enables */ 73 + 74 + #define PIC_BYTESWAP 0x02 75 + #define PIC_STATUS 0x04 76 + #define PIC_INTR_TIMEOUT 0x06 77 + #define PIC_ICI0_INTR_TIMEOUT 0x08 78 + #define PIC_ICI1_INTR_TIMEOUT 0x0a 79 + #define PIC_ICI2_INTR_TIMEOUT 0x0c 80 + #define PIC_IPI_CTL 0x0e 81 + #define PIC_INT_ACK 0x10 82 + #define PIC_INT_PENDING0 0x12 83 + #define PIC_INT_PENDING1 0x14 84 + #define PIC_INT_PENDING2 0x16 85 + 86 + #define PIC_WDOG0_MAXVAL 0x18 87 + #define PIC_WDOG0_COUNT 0x1a 88 + #define PIC_WDOG0_ENABLE0 0x1c 89 + #define PIC_WDOG0_ENABLE1 0x1e 90 + #define PIC_WDOG0_BEATCMD 0x20 91 + #define PIC_WDOG0_BEAT0 0x22 92 + #define PIC_WDOG0_BEAT1 0x24 93 + 94 + #define PIC_WDOG1_MAXVAL 0x26 95 + #define PIC_WDOG1_COUNT 0x28 96 + #define PIC_WDOG1_ENABLE0 0x2a 97 + #define PIC_WDOG1_ENABLE1 0x2c 98 + #define PIC_WDOG1_BEATCMD 0x2e 99 + #define PIC_WDOG1_BEAT0 0x30 100 + #define PIC_WDOG1_BEAT1 0x32 101 + 102 + #define PIC_WDOG_MAXVAL(i) (PIC_WDOG0_MAXVAL + ((i) ? 7 : 0)) 103 + #define PIC_WDOG_COUNT(i) (PIC_WDOG0_COUNT + ((i) ? 7 : 0)) 104 + #define PIC_WDOG_ENABLE0(i) (PIC_WDOG0_ENABLE0 + ((i) ? 7 : 0)) 105 + #define PIC_WDOG_ENABLE1(i) (PIC_WDOG0_ENABLE1 + ((i) ? 7 : 0)) 106 + #define PIC_WDOG_BEATCMD(i) (PIC_WDOG0_BEATCMD + ((i) ? 7 : 0)) 107 + #define PIC_WDOG_BEAT0(i) (PIC_WDOG0_BEAT0 + ((i) ? 7 : 0)) 108 + #define PIC_WDOG_BEAT1(i) (PIC_WDOG0_BEAT1 + ((i) ? 7 : 0)) 109 + 110 + #define PIC_TIMER0_MAXVAL 0x34 111 + #define PIC_TIMER1_MAXVAL 0x36 112 + #define PIC_TIMER2_MAXVAL 0x38 113 + #define PIC_TIMER3_MAXVAL 0x3a 114 + #define PIC_TIMER4_MAXVAL 0x3c 115 + #define PIC_TIMER5_MAXVAL 0x3e 116 + #define PIC_TIMER6_MAXVAL 0x40 117 + #define PIC_TIMER7_MAXVAL 0x42 118 + #define PIC_TIMER_MAXVAL(i) (PIC_TIMER0_MAXVAL + ((i) * 2)) 119 + 120 + #define PIC_TIMER0_COUNT 0x44 121 + #define PIC_TIMER1_COUNT 0x46 122 + #define PIC_TIMER2_COUNT 0x48 123 + #define PIC_TIMER3_COUNT 0x4a 124 + #define PIC_TIMER4_COUNT 0x4c 125 + #define PIC_TIMER5_COUNT 0x4e 126 + #define PIC_TIMER6_COUNT 0x50 127 + #define PIC_TIMER7_COUNT 0x52 128 + #define PIC_TIMER_COUNT(i) (PIC_TIMER0_COUNT + ((i) * 2)) 129 + 130 + #define PIC_ITE0_N0_N1 0x54 131 + #define PIC_ITE1_N0_N1 0x58 132 + #define PIC_ITE2_N0_N1 0x5c 133 + #define PIC_ITE3_N0_N1 0x60 134 + #define PIC_ITE4_N0_N1 0x64 135 + #define PIC_ITE5_N0_N1 0x68 136 + #define PIC_ITE6_N0_N1 0x6c 137 + #define PIC_ITE7_N0_N1 0x70 138 + #define PIC_ITE_N0_N1(i) (PIC_ITE0_N0_N1 + ((i) * 4)) 139 + 140 + #define PIC_ITE0_N2_N3 0x56 141 + #define PIC_ITE1_N2_N3 0x5a 142 + #define PIC_ITE2_N2_N3 0x5e 143 + #define PIC_ITE3_N2_N3 0x62 144 + #define PIC_ITE4_N2_N3 0x66 145 + #define PIC_ITE5_N2_N3 0x6a 146 + #define PIC_ITE6_N2_N3 0x6e 147 + #define PIC_ITE7_N2_N3 0x72 148 + #define PIC_ITE_N2_N3(i) (PIC_ITE0_N2_N3 + ((i) * 4)) 149 + 150 + #define PIC_IRT0 0x74 151 + #define PIC_IRT(i) (PIC_IRT0 + ((i) * 2)) 152 + 153 + #define TIMER_CYCLES_MAXVAL 0xffffffffffffffffULL 154 + 155 + /* 156 + * IRT Map 157 + */ 158 + #define PIC_NUM_IRTS 160 159 + 160 + #define PIC_IRT_WD_0_INDEX 0 161 + #define PIC_IRT_WD_1_INDEX 1 162 + #define PIC_IRT_WD_NMI_0_INDEX 2 163 + #define PIC_IRT_WD_NMI_1_INDEX 3 164 + #define PIC_IRT_TIMER_0_INDEX 4 165 + #define PIC_IRT_TIMER_1_INDEX 5 166 + #define PIC_IRT_TIMER_2_INDEX 6 167 + #define PIC_IRT_TIMER_3_INDEX 7 168 + #define PIC_IRT_TIMER_4_INDEX 8 169 + #define PIC_IRT_TIMER_5_INDEX 9 170 + #define PIC_IRT_TIMER_6_INDEX 10 171 + #define PIC_IRT_TIMER_7_INDEX 11 172 + #define PIC_IRT_CLOCK_INDEX PIC_IRT_TIMER_7_INDEX 173 + #define PIC_IRT_TIMER_INDEX(num) ((num) + PIC_IRT_TIMER_0_INDEX) 174 + 175 + 176 + /* 11 and 12 */ 177 + #define PIC_NUM_MSG_Q_IRTS 32 178 + #define PIC_IRT_MSG_Q0_INDEX 12 179 + #define PIC_IRT_MSG_Q_INDEX(qid) ((qid) + PIC_IRT_MSG_Q0_INDEX) 180 + /* 12 to 43 */ 181 + #define PIC_IRT_MSG_0_INDEX 44 182 + #define PIC_IRT_MSG_1_INDEX 45 183 + /* 44 and 45 */ 184 + #define PIC_NUM_PCIE_MSIX_IRTS 32 185 + #define PIC_IRT_PCIE_MSIX_0_INDEX 46 186 + #define PIC_IRT_PCIE_MSIX_INDEX(num) ((num) + PIC_IRT_PCIE_MSIX_0_INDEX) 187 + /* 46 to 77 */ 188 + #define PIC_NUM_PCIE_LINK_IRTS 4 189 + #define PIC_IRT_PCIE_LINK_0_INDEX 78 190 + #define PIC_IRT_PCIE_LINK_1_INDEX 79 191 + #define PIC_IRT_PCIE_LINK_2_INDEX 80 192 + #define PIC_IRT_PCIE_LINK_3_INDEX 81 193 + #define PIC_IRT_PCIE_LINK_INDEX(num) ((num) + PIC_IRT_PCIE_LINK_0_INDEX) 194 + /* 78 to 81 */ 195 + #define PIC_NUM_NA_IRTS 32 196 + /* 82 to 113 */ 197 + #define PIC_IRT_NA_0_INDEX 82 198 + #define PIC_IRT_NA_INDEX(num) ((num) + PIC_IRT_NA_0_INDEX) 199 + #define PIC_IRT_POE_INDEX 114 200 + 201 + #define PIC_NUM_USB_IRTS 6 202 + #define PIC_IRT_USB_0_INDEX 115 203 + #define PIC_IRT_EHCI_0_INDEX 115 204 + #define PIC_IRT_EHCI_1_INDEX 118 205 + #define PIC_IRT_USB_INDEX(num) ((num) + PIC_IRT_USB_0_INDEX) 206 + /* 115 to 120 */ 207 + #define PIC_IRT_GDX_INDEX 121 208 + #define PIC_IRT_SEC_INDEX 122 209 + #define PIC_IRT_RSA_INDEX 123 210 + 211 + #define PIC_NUM_COMP_IRTS 4 212 + #define PIC_IRT_COMP_0_INDEX 124 213 + #define PIC_IRT_COMP_INDEX(num) ((num) + PIC_IRT_COMP_0_INDEX) 214 + /* 124 to 127 */ 215 + #define PIC_IRT_GBU_INDEX 128 216 + #define PIC_IRT_ICC_0_INDEX 129 /* ICC - Inter Chip Coherency */ 217 + #define PIC_IRT_ICC_1_INDEX 130 218 + #define PIC_IRT_ICC_2_INDEX 131 219 + #define PIC_IRT_CAM_INDEX 132 220 + #define PIC_IRT_UART_0_INDEX 133 221 + #define PIC_IRT_UART_1_INDEX 134 222 + #define PIC_IRT_I2C_0_INDEX 135 223 + #define PIC_IRT_I2C_1_INDEX 136 224 + #define PIC_IRT_SYS_0_INDEX 137 225 + #define PIC_IRT_SYS_1_INDEX 138 226 + #define PIC_IRT_JTAG_INDEX 139 227 + #define PIC_IRT_PIC_INDEX 140 228 + #define PIC_IRT_NBU_INDEX 141 229 + #define PIC_IRT_TCU_INDEX 142 230 + #define PIC_IRT_GCU_INDEX 143 /* GBC - Global Coherency */ 231 + #define PIC_IRT_DMC_0_INDEX 144 232 + #define PIC_IRT_DMC_1_INDEX 145 233 + 234 + #define PIC_NUM_GPIO_IRTS 4 235 + #define PIC_IRT_GPIO_0_INDEX 146 236 + #define PIC_IRT_GPIO_INDEX(num) ((num) + PIC_IRT_GPIO_0_INDEX) 237 + 238 + /* 146 to 149 */ 239 + #define PIC_IRT_NOR_INDEX 150 240 + #define PIC_IRT_NAND_INDEX 151 241 + #define PIC_IRT_SPI_INDEX 152 242 + #define PIC_IRT_MMC_INDEX 153 243 + 244 + #define PIC_CLOCK_TIMER 7 245 + #define PIC_IRQ_BASE 8 246 + 247 + #if !defined(LOCORE) && !defined(__ASSEMBLY__) 248 + 249 + #define PIC_IRT_FIRST_IRQ (PIC_IRQ_BASE) 250 + #define PIC_IRT_LAST_IRQ 63 251 + #define PIC_IRQ_IS_IRT(irq) ((irq) >= PIC_IRT_FIRST_IRQ) 252 + 253 + /* 254 + * Misc 255 + */ 256 + #define PIC_IRT_VALID 1 257 + #define PIC_LOCAL_SCHEDULING 1 258 + #define PIC_GLOBAL_SCHEDULING 0 259 + 260 + #define nlm_read_pic_reg(b, r) nlm_read_reg64(b, r) 261 + #define nlm_write_pic_reg(b, r, v) nlm_write_reg64(b, r, v) 262 + #define nlm_get_pic_pcibase(node) nlm_pcicfg_base(XLP_IO_PIC_OFFSET(node)) 263 + #define nlm_get_pic_regbase(node) (nlm_get_pic_pcibase(node) + XLP_IO_PCI_HDRSZ) 264 + 265 + /* IRT and h/w interrupt routines */ 266 + static inline int 267 + nlm_pic_read_irt(uint64_t base, int irt_index) 268 + { 269 + return nlm_read_pic_reg(base, PIC_IRT(irt_index)); 270 + } 271 + 272 + static inline uint64_t 273 + nlm_pic_read_control(uint64_t base) 274 + { 275 + return nlm_read_pic_reg(base, PIC_CTRL); 276 + } 277 + 278 + static inline void 279 + nlm_pic_write_control(uint64_t base, uint64_t control) 280 + { 281 + nlm_write_pic_reg(base, PIC_CTRL, control); 282 + } 283 + 284 + static inline void 285 + nlm_pic_update_control(uint64_t base, uint64_t control) 286 + { 287 + uint64_t val; 288 + 289 + val = nlm_read_pic_reg(base, PIC_CTRL); 290 + nlm_write_pic_reg(base, PIC_CTRL, control | val); 291 + } 292 + 293 + static inline void 294 + nlm_set_irt_to_cpu(uint64_t base, int irt, int cpu) 295 + { 296 + uint64_t val; 297 + 298 + val = nlm_read_pic_reg(base, PIC_IRT(irt)); 299 + val |= cpu & 0xf; 300 + if (cpu > 15) 301 + val |= 1 << 16; 302 + nlm_write_pic_reg(base, PIC_IRT(irt), val); 303 + } 304 + 305 + static inline void 306 + nlm_pic_write_irt(uint64_t base, int irt_num, int en, int nmi, 307 + int sch, int vec, int dt, int db, int dte) 308 + { 309 + uint64_t val; 310 + 311 + val = (((uint64_t)en & 0x1) << 31) | ((nmi & 0x1) << 29) | 312 + ((sch & 0x1) << 28) | ((vec & 0x3f) << 20) | 313 + ((dt & 0x1) << 19) | ((db & 0x7) << 16) | 314 + (dte & 0xffff); 315 + 316 + nlm_write_pic_reg(base, PIC_IRT(irt_num), val); 317 + } 318 + 319 + static inline void 320 + nlm_pic_write_irt_direct(uint64_t base, int irt_num, int en, int nmi, 321 + int sch, int vec, int cpu) 322 + { 323 + nlm_pic_write_irt(base, irt_num, en, nmi, sch, vec, 1, 324 + (cpu >> 4), /* thread group */ 325 + 1 << (cpu & 0xf)); /* thread mask */ 326 + } 327 + 328 + static inline uint64_t 329 + nlm_pic_read_timer(uint64_t base, int timer) 330 + { 331 + return nlm_read_pic_reg(base, PIC_TIMER_COUNT(timer)); 332 + } 333 + 334 + static inline void 335 + nlm_pic_write_timer(uint64_t base, int timer, uint64_t value) 336 + { 337 + nlm_write_pic_reg(base, PIC_TIMER_COUNT(timer), value); 338 + } 339 + 340 + static inline void 341 + nlm_pic_set_timer(uint64_t base, int timer, uint64_t value, int irq, int cpu) 342 + { 343 + uint64_t pic_ctrl = nlm_read_pic_reg(base, PIC_CTRL); 344 + int en; 345 + 346 + en = (irq > 0); 347 + nlm_write_pic_reg(base, PIC_TIMER_MAXVAL(timer), value); 348 + nlm_pic_write_irt_direct(base, PIC_IRT_TIMER_INDEX(timer), 349 + en, 0, 0, irq, cpu); 350 + 351 + /* enable the timer */ 352 + pic_ctrl |= (1 << (PIC_CTRL_STE + timer)); 353 + nlm_write_pic_reg(base, PIC_CTRL, pic_ctrl); 354 + } 355 + 356 + static inline void 357 + nlm_pic_enable_irt(uint64_t base, int irt) 358 + { 359 + uint64_t reg; 360 + 361 + reg = nlm_read_pic_reg(base, PIC_IRT(irt)); 362 + nlm_write_pic_reg(base, PIC_IRT(irt), reg | (1u << 31)); 363 + } 364 + 365 + static inline void 366 + nlm_pic_disable_irt(uint64_t base, int irt) 367 + { 368 + uint32_t reg; 369 + 370 + reg = nlm_read_pic_reg(base, PIC_IRT(irt)); 371 + nlm_write_pic_reg(base, PIC_IRT(irt), reg & ~((uint64_t)1 << 31)); 372 + } 373 + 374 + static inline void 375 + nlm_pic_send_ipi(uint64_t base, int hwt, int irq, int nmi) 376 + { 377 + uint64_t ipi; 378 + int node, ncpu; 379 + 380 + node = hwt / 32; 381 + ncpu = hwt & 0x1f; 382 + ipi = ((uint64_t)nmi << 31) | (irq << 20) | (node << 17) | 383 + (1 << (ncpu & 0xf)); 384 + if (ncpu > 15) 385 + ipi |= 0x10000; /* Setting bit 16 to select cpus 16-31 */ 386 + 387 + nlm_write_pic_reg(base, PIC_IPI_CTL, ipi); 388 + } 389 + 390 + static inline void 391 + nlm_pic_ack(uint64_t base, int irt_num) 392 + { 393 + nlm_write_pic_reg(base, PIC_INT_ACK, irt_num); 394 + 395 + /* Ack the Status register for Watchdog & System timers */ 396 + if (irt_num < 12) 397 + nlm_write_pic_reg(base, PIC_STATUS, (1 << irt_num)); 398 + } 399 + 400 + static inline void 401 + nlm_pic_init_irt(uint64_t base, int irt, int irq, int hwt) 402 + { 403 + nlm_pic_write_irt_direct(base, irt, 0, 0, 0, irq, 0); 404 + } 405 + 406 + extern uint64_t nlm_pic_base; 407 + int nlm_irq_to_irt(int irq); 408 + int nlm_irt_to_irq(int irt); 409 + 410 + #endif /* __ASSEMBLY__ */ 411 + #endif /* _NLM_HAL_PIC_H */
+129
arch/mips/include/asm/netlogic/xlp-hal/sys.h
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #ifndef __NLM_HAL_SYS_H__ 36 + #define __NLM_HAL_SYS_H__ 37 + 38 + /** 39 + * @file_name sys.h 40 + * @author Netlogic Microsystems 41 + * @brief HAL for System configuration registers 42 + */ 43 + #define SYS_CHIP_RESET 0x00 44 + #define SYS_POWER_ON_RESET_CFG 0x01 45 + #define SYS_EFUSE_DEVICE_CFG_STATUS0 0x02 46 + #define SYS_EFUSE_DEVICE_CFG_STATUS1 0x03 47 + #define SYS_EFUSE_DEVICE_CFG_STATUS2 0x04 48 + #define SYS_EFUSE_DEVICE_CFG3 0x05 49 + #define SYS_EFUSE_DEVICE_CFG4 0x06 50 + #define SYS_EFUSE_DEVICE_CFG5 0x07 51 + #define SYS_EFUSE_DEVICE_CFG6 0x08 52 + #define SYS_EFUSE_DEVICE_CFG7 0x09 53 + #define SYS_PLL_CTRL 0x0a 54 + #define SYS_CPU_RESET 0x0b 55 + #define SYS_CPU_NONCOHERENT_MODE 0x0d 56 + #define SYS_CORE_DFS_DIS_CTRL 0x0e 57 + #define SYS_CORE_DFS_RST_CTRL 0x0f 58 + #define SYS_CORE_DFS_BYP_CTRL 0x10 59 + #define SYS_CORE_DFS_PHA_CTRL 0x11 60 + #define SYS_CORE_DFS_DIV_INC_CTRL 0x12 61 + #define SYS_CORE_DFS_DIV_DEC_CTRL 0x13 62 + #define SYS_CORE_DFS_DIV_VALUE 0x14 63 + #define SYS_RESET 0x15 64 + #define SYS_DFS_DIS_CTRL 0x16 65 + #define SYS_DFS_RST_CTRL 0x17 66 + #define SYS_DFS_BYP_CTRL 0x18 67 + #define SYS_DFS_DIV_INC_CTRL 0x19 68 + #define SYS_DFS_DIV_DEC_CTRL 0x1a 69 + #define SYS_DFS_DIV_VALUE0 0x1b 70 + #define SYS_DFS_DIV_VALUE1 0x1c 71 + #define SYS_SENSE_AMP_DLY 0x1d 72 + #define SYS_SOC_SENSE_AMP_DLY 0x1e 73 + #define SYS_CTRL0 0x1f 74 + #define SYS_CTRL1 0x20 75 + #define SYS_TIMEOUT_BS1 0x21 76 + #define SYS_BYTE_SWAP 0x22 77 + #define SYS_VRM_VID 0x23 78 + #define SYS_PWR_RAM_CMD 0x24 79 + #define SYS_PWR_RAM_ADDR 0x25 80 + #define SYS_PWR_RAM_DATA0 0x26 81 + #define SYS_PWR_RAM_DATA1 0x27 82 + #define SYS_PWR_RAM_DATA2 0x28 83 + #define SYS_PWR_UCODE 0x29 84 + #define SYS_CPU0_PWR_STATUS 0x2a 85 + #define SYS_CPU1_PWR_STATUS 0x2b 86 + #define SYS_CPU2_PWR_STATUS 0x2c 87 + #define SYS_CPU3_PWR_STATUS 0x2d 88 + #define SYS_CPU4_PWR_STATUS 0x2e 89 + #define SYS_CPU5_PWR_STATUS 0x2f 90 + #define SYS_CPU6_PWR_STATUS 0x30 91 + #define SYS_CPU7_PWR_STATUS 0x31 92 + #define SYS_STATUS 0x32 93 + #define SYS_INT_POL 0x33 94 + #define SYS_INT_TYPE 0x34 95 + #define SYS_INT_STATUS 0x35 96 + #define SYS_INT_MASK0 0x36 97 + #define SYS_INT_MASK1 0x37 98 + #define SYS_UCO_S_ECC 0x38 99 + #define SYS_UCO_M_ECC 0x39 100 + #define SYS_UCO_ADDR 0x3a 101 + #define SYS_UCO_INSTR 0x3b 102 + #define SYS_MEM_BIST0 0x3c 103 + #define SYS_MEM_BIST1 0x3d 104 + #define SYS_MEM_BIST2 0x3e 105 + #define SYS_MEM_BIST3 0x3f 106 + #define SYS_MEM_BIST4 0x40 107 + #define SYS_MEM_BIST5 0x41 108 + #define SYS_MEM_BIST6 0x42 109 + #define SYS_MEM_BIST7 0x43 110 + #define SYS_MEM_BIST8 0x44 111 + #define SYS_MEM_BIST9 0x45 112 + #define SYS_MEM_BIST10 0x46 113 + #define SYS_MEM_BIST11 0x47 114 + #define SYS_MEM_BIST12 0x48 115 + #define SYS_SCRTCH0 0x49 116 + #define SYS_SCRTCH1 0x4a 117 + #define SYS_SCRTCH2 0x4b 118 + #define SYS_SCRTCH3 0x4c 119 + 120 + #ifndef __ASSEMBLY__ 121 + 122 + #define nlm_read_sys_reg(b, r) nlm_read_reg(b, r) 123 + #define nlm_write_sys_reg(b, r, v) nlm_write_reg(b, r, v) 124 + #define nlm_get_sys_pcibase(node) nlm_pcicfg_base(XLP_IO_SYS_OFFSET(node)) 125 + #define nlm_get_sys_regbase(node) (nlm_get_sys_pcibase(node) + XLP_IO_PCI_HDRSZ) 126 + 127 + extern uint64_t nlm_sys_base; 128 + #endif 129 + #endif
+191
arch/mips/include/asm/netlogic/xlp-hal/uart.h
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #ifndef __XLP_HAL_UART_H__ 36 + #define __XLP_HAL_UART_H__ 37 + 38 + /* UART Specific registers */ 39 + #define UART_RX_DATA 0x00 40 + #define UART_TX_DATA 0x00 41 + 42 + #define UART_INT_EN 0x01 43 + #define UART_INT_ID 0x02 44 + #define UART_FIFO_CTL 0x02 45 + #define UART_LINE_CTL 0x03 46 + #define UART_MODEM_CTL 0x04 47 + #define UART_LINE_STS 0x05 48 + #define UART_MODEM_STS 0x06 49 + 50 + #define UART_DIVISOR0 0x00 51 + #define UART_DIVISOR1 0x01 52 + 53 + #define BASE_BAUD (XLP_IO_CLK/16) 54 + #define BAUD_DIVISOR(baud) (BASE_BAUD / baud) 55 + 56 + /* LCR mask values */ 57 + #define LCR_5BITS 0x00 58 + #define LCR_6BITS 0x01 59 + #define LCR_7BITS 0x02 60 + #define LCR_8BITS 0x03 61 + #define LCR_STOPB 0x04 62 + #define LCR_PENAB 0x08 63 + #define LCR_PODD 0x00 64 + #define LCR_PEVEN 0x10 65 + #define LCR_PONE 0x20 66 + #define LCR_PZERO 0x30 67 + #define LCR_SBREAK 0x40 68 + #define LCR_EFR_ENABLE 0xbf 69 + #define LCR_DLAB 0x80 70 + 71 + /* MCR mask values */ 72 + #define MCR_DTR 0x01 73 + #define MCR_RTS 0x02 74 + #define MCR_DRS 0x04 75 + #define MCR_IE 0x08 76 + #define MCR_LOOPBACK 0x10 77 + 78 + /* FCR mask values */ 79 + #define FCR_RCV_RST 0x02 80 + #define FCR_XMT_RST 0x04 81 + #define FCR_RX_LOW 0x00 82 + #define FCR_RX_MEDL 0x40 83 + #define FCR_RX_MEDH 0x80 84 + #define FCR_RX_HIGH 0xc0 85 + 86 + /* IER mask values */ 87 + #define IER_ERXRDY 0x1 88 + #define IER_ETXRDY 0x2 89 + #define IER_ERLS 0x4 90 + #define IER_EMSC 0x8 91 + 92 + #if !defined(LOCORE) && !defined(__ASSEMBLY__) 93 + 94 + #define nlm_read_uart_reg(b, r) nlm_read_reg(b, r) 95 + #define nlm_write_uart_reg(b, r, v) nlm_write_reg(b, r, v) 96 + #define nlm_get_uart_pcibase(node, inst) \ 97 + nlm_pcicfg_base(XLP_IO_UART_OFFSET(node, inst)) 98 + #define nlm_get_uart_regbase(node, inst) \ 99 + (nlm_get_uart_pcibase(node, inst) + XLP_IO_PCI_HDRSZ) 100 + 101 + static inline void 102 + nlm_uart_set_baudrate(uint64_t base, int baud) 103 + { 104 + uint32_t lcr; 105 + 106 + lcr = nlm_read_uart_reg(base, UART_LINE_CTL); 107 + 108 + /* enable divisor register, and write baud values */ 109 + nlm_write_uart_reg(base, UART_LINE_CTL, lcr | (1 << 7)); 110 + nlm_write_uart_reg(base, UART_DIVISOR0, 111 + (BAUD_DIVISOR(baud) & 0xff)); 112 + nlm_write_uart_reg(base, UART_DIVISOR1, 113 + ((BAUD_DIVISOR(baud) >> 8) & 0xff)); 114 + 115 + /* restore default lcr */ 116 + nlm_write_uart_reg(base, UART_LINE_CTL, lcr); 117 + } 118 + 119 + static inline void 120 + nlm_uart_outbyte(uint64_t base, char c) 121 + { 122 + uint32_t lsr; 123 + 124 + for (;;) { 125 + lsr = nlm_read_uart_reg(base, UART_LINE_STS); 126 + if (lsr & 0x20) 127 + break; 128 + } 129 + 130 + nlm_write_uart_reg(base, UART_TX_DATA, (int)c); 131 + } 132 + 133 + static inline char 134 + nlm_uart_inbyte(uint64_t base) 135 + { 136 + int data, lsr; 137 + 138 + for (;;) { 139 + lsr = nlm_read_uart_reg(base, UART_LINE_STS); 140 + if (lsr & 0x80) { /* parity/frame/break-error - push a zero */ 141 + data = 0; 142 + break; 143 + } 144 + if (lsr & 0x01) { /* Rx data */ 145 + data = nlm_read_uart_reg(base, UART_RX_DATA); 146 + break; 147 + } 148 + } 149 + 150 + return (char)data; 151 + } 152 + 153 + static inline int 154 + nlm_uart_init(uint64_t base, int baud, int databits, int stopbits, 155 + int parity, int int_en, int loopback) 156 + { 157 + uint32_t lcr; 158 + 159 + lcr = 0; 160 + if (databits >= 8) 161 + lcr |= LCR_8BITS; 162 + else if (databits == 7) 163 + lcr |= LCR_7BITS; 164 + else if (databits == 6) 165 + lcr |= LCR_6BITS; 166 + else 167 + lcr |= LCR_5BITS; 168 + 169 + if (stopbits > 1) 170 + lcr |= LCR_STOPB; 171 + 172 + lcr |= parity << 3; 173 + 174 + /* setup default lcr */ 175 + nlm_write_uart_reg(base, UART_LINE_CTL, lcr); 176 + 177 + /* Reset the FIFOs */ 178 + nlm_write_uart_reg(base, UART_LINE_CTL, FCR_RCV_RST | FCR_XMT_RST); 179 + 180 + nlm_uart_set_baudrate(base, baud); 181 + 182 + if (loopback) 183 + nlm_write_uart_reg(base, UART_MODEM_CTL, 0x1f); 184 + 185 + if (int_en) 186 + nlm_write_uart_reg(base, UART_INT_EN, IER_ERXRDY | IER_ETXRDY); 187 + 188 + return 0; 189 + } 190 + #endif /* !LOCORE && !__ASSEMBLY__ */ 191 + #endif /* __XLP_HAL_UART_H__ */
+54
arch/mips/include/asm/netlogic/xlp-hal/xlp.h
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #ifndef _NLM_HAL_XLP_H 36 + #define _NLM_HAL_XLP_H 37 + 38 + #define RESET_VEC_PHYS 0x1fc00000 39 + #define RESET_DATA_PHYS (RESET_VEC_PHYS + (1<<10)) 40 + #define BOOT_THREAD_MODE 0 41 + 42 + #define PIC_UART_0_IRQ 17 43 + #define PIC_UART_1_IRQ 18 44 + 45 + #ifndef __ASSEMBLY__ 46 + 47 + /* SMP support functions */ 48 + void nlm_boot_core0_siblings(void); 49 + 50 + void xlp_mmu_init(void); 51 + void nlm_hal_init(void); 52 + 53 + #endif /* !__ASSEMBLY__ */ 54 + #endif /* _ASM_NLM_XLP_H */
+9
arch/mips/netlogic/common/earlycons.c
··· 38 38 #include <asm/mipsregs.h> 39 39 #include <asm/netlogic/haldefs.h> 40 40 41 + #if defined(CONFIG_CPU_XLP) 42 + #include <asm/netlogic/xlp-hal/iomap.h> 43 + #include <asm/netlogic/xlp-hal/uart.h> 44 + #elif defined(CONFIG_CPU_XLR) 41 45 #include <asm/netlogic/xlr/iomap.h> 46 + #endif 42 47 43 48 void prom_putchar(char c) 44 49 { 45 50 uint64_t uartbase; 46 51 52 + #if defined(CONFIG_CPU_XLP) 53 + uartbase = nlm_get_uart_regbase(0, 0); 54 + #elif defined(CONFIG_CPU_XLR) 47 55 uartbase = nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET); 56 + #endif 48 57 while (nlm_read_reg(uartbase, UART_LSR) == 0) 49 58 ; 50 59 nlm_write_reg(uartbase, UART_TX, c);
+8
arch/mips/netlogic/common/irq.c
··· 53 53 #include <asm/netlogic/haldefs.h> 54 54 #include <asm/netlogic/common.h> 55 55 56 + #if defined(CONFIG_CPU_XLP) 57 + #include <asm/netlogic/xlp-hal/iomap.h> 58 + #include <asm/netlogic/xlp-hal/xlp.h> 59 + #include <asm/netlogic/xlp-hal/pic.h> 60 + #elif defined(CONFIG_CPU_XLR) 56 61 #include <asm/netlogic/xlr/iomap.h> 57 62 #include <asm/netlogic/xlr/pic.h> 63 + #else 64 + #error "Unknown CPU" 65 + #endif 58 66 /* 59 67 * These are the routines that handle all the low level interrupt stuff. 60 68 * Actions handled here are: initialization of the interrupt map, requesting of
+12 -4
arch/mips/netlogic/common/smp.c
··· 45 45 #include <asm/netlogic/haldefs.h> 46 46 #include <asm/netlogic/common.h> 47 47 48 + #if defined(CONFIG_CPU_XLP) 49 + #include <asm/netlogic/xlp-hal/iomap.h> 50 + #include <asm/netlogic/xlp-hal/pic.h> 51 + #elif defined(CONFIG_CPU_XLR) 48 52 #include <asm/netlogic/xlr/iomap.h> 49 53 #include <asm/netlogic/xlr/pic.h> 54 + #else 55 + #error "Unknown CPU" 56 + #endif 50 57 51 58 void nlm_send_ipi_single(int logical_cpu, unsigned int action) 52 59 { ··· 77 70 /* IRQ_IPI_SMP_FUNCTION Handler */ 78 71 void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc) 79 72 { 80 - smp_call_function_interrupt(); 81 73 write_c0_eirr(1ull << irq); 74 + smp_call_function_interrupt(); 82 75 } 83 76 84 77 /* IRQ_IPI_SMP_RESCHEDULE handler */ 85 78 void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc) 86 79 { 87 - scheduler_ipi(); 88 80 write_c0_eirr(1ull << irq); 81 + scheduler_ipi(); 89 82 } 90 83 91 84 /* ··· 93 86 */ 94 87 void nlm_early_init_secondary(int cpu) 95 88 { 89 + change_c0_config(CONF_CM_CMASK, 0x3); 96 90 write_c0_ebase((uint32_t)nlm_common_ebase); 97 - #ifdef NLM_XLP 98 - if (cpu % 4 == 0) 91 + #ifdef CONFIG_CPU_XLP 92 + if (hard_smp_processor_id() % 4 == 0) 99 93 xlp_mmu_init(); 100 94 #endif 101 95 }
+105
arch/mips/netlogic/xlp/nlm_hal.c
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #include <linux/types.h> 36 + #include <linux/kernel.h> 37 + #include <linux/mm.h> 38 + #include <linux/delay.h> 39 + 40 + #include <asm/mipsregs.h> 41 + #include <asm/time.h> 42 + 43 + #include <asm/netlogic/haldefs.h> 44 + #include <asm/netlogic/xlp-hal/iomap.h> 45 + #include <asm/netlogic/xlp-hal/xlp.h> 46 + #include <asm/netlogic/xlp-hal/pic.h> 47 + #include <asm/netlogic/xlp-hal/sys.h> 48 + 49 + /* These addresses are computed by the nlm_hal_init() */ 50 + uint64_t nlm_io_base; 51 + uint64_t nlm_sys_base; 52 + uint64_t nlm_pic_base; 53 + 54 + /* Main initialization */ 55 + void nlm_hal_init(void) 56 + { 57 + nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); 58 + nlm_sys_base = nlm_get_sys_regbase(0); /* node 0 */ 59 + nlm_pic_base = nlm_get_pic_regbase(0); /* node 0 */ 60 + } 61 + 62 + int nlm_irq_to_irt(int irq) 63 + { 64 + if (!PIC_IRQ_IS_IRT(irq)) 65 + return -1; 66 + 67 + switch (irq) { 68 + case PIC_UART_0_IRQ: 69 + return PIC_IRT_UART_0_INDEX; 70 + case PIC_UART_1_IRQ: 71 + return PIC_IRT_UART_1_INDEX; 72 + default: 73 + return -1; 74 + } 75 + } 76 + 77 + int nlm_irt_to_irq(int irt) 78 + { 79 + switch (irt) { 80 + case PIC_IRT_UART_0_INDEX: 81 + return PIC_UART_0_IRQ; 82 + case PIC_IRT_UART_1_INDEX: 83 + return PIC_UART_1_IRQ; 84 + default: 85 + return -1; 86 + } 87 + } 88 + 89 + unsigned int nlm_get_cpu_frequency(void) 90 + { 91 + unsigned int pll_divf, pll_divr, dfs_div, denom; 92 + unsigned int val; 93 + uint64_t num; 94 + 95 + val = nlm_read_sys_reg(nlm_sys_base, SYS_POWER_ON_RESET_CFG); 96 + pll_divf = (val >> 10) & 0x7f; 97 + pll_divr = (val >> 8) & 0x3; 98 + dfs_div = (val >> 17) & 0x3; 99 + 100 + num = pll_divf + 1; 101 + denom = 3 * (pll_divr + 1) * (1 << (dfs_div + 1)); 102 + num = num * 800000000ULL; 103 + do_div(num, denom); 104 + return (unsigned int)num; 105 + }
+108
arch/mips/netlogic/xlp/platform.c
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #include <linux/dma-mapping.h> 36 + #include <linux/kernel.h> 37 + #include <linux/delay.h> 38 + #include <linux/init.h> 39 + #include <linux/platform_device.h> 40 + #include <linux/serial.h> 41 + #include <linux/serial_8250.h> 42 + #include <linux/pci.h> 43 + #include <linux/serial_reg.h> 44 + #include <linux/spinlock.h> 45 + 46 + #include <asm/time.h> 47 + #include <asm/addrspace.h> 48 + #include <asm/netlogic/haldefs.h> 49 + #include <asm/netlogic/xlp-hal/iomap.h> 50 + #include <asm/netlogic/xlp-hal/xlp.h> 51 + #include <asm/netlogic/xlp-hal/pic.h> 52 + #include <asm/netlogic/xlp-hal/uart.h> 53 + 54 + static unsigned int nlm_xlp_uart_in(struct uart_port *p, int offset) 55 + { 56 + return nlm_read_reg(p->iobase, offset); 57 + } 58 + 59 + static void nlm_xlp_uart_out(struct uart_port *p, int offset, int value) 60 + { 61 + nlm_write_reg(p->iobase, offset, value); 62 + } 63 + 64 + #define PORT(_irq) \ 65 + { \ 66 + .irq = _irq, \ 67 + .regshift = 2, \ 68 + .iotype = UPIO_MEM32, \ 69 + .flags = (UPF_SKIP_TEST|UPF_FIXED_TYPE|\ 70 + UPF_BOOT_AUTOCONF), \ 71 + .uartclk = XLP_IO_CLK, \ 72 + .type = PORT_16550A, \ 73 + .serial_in = nlm_xlp_uart_in, \ 74 + .serial_out = nlm_xlp_uart_out, \ 75 + } 76 + 77 + static struct plat_serial8250_port xlp_uart_data[] = { 78 + PORT(PIC_UART_0_IRQ), 79 + PORT(PIC_UART_1_IRQ), 80 + {}, 81 + }; 82 + 83 + static struct platform_device uart_device = { 84 + .name = "serial8250", 85 + .id = PLAT8250_DEV_PLATFORM, 86 + .dev = { 87 + .platform_data = xlp_uart_data, 88 + }, 89 + }; 90 + 91 + static int __init nlm_platform_uart_init(void) 92 + { 93 + unsigned long mmio; 94 + 95 + mmio = (unsigned long)nlm_get_uart_regbase(0, 0); 96 + xlp_uart_data[0].iobase = mmio; 97 + xlp_uart_data[0].membase = (void __iomem *)mmio; 98 + xlp_uart_data[0].mapbase = mmio; 99 + 100 + mmio = (unsigned long)nlm_get_uart_regbase(0, 1); 101 + xlp_uart_data[1].iobase = mmio; 102 + xlp_uart_data[1].membase = (void __iomem *)mmio; 103 + xlp_uart_data[1].mapbase = mmio; 104 + 105 + return platform_device_register(&uart_device); 106 + } 107 + 108 + arch_initcall(nlm_platform_uart_init);
+101
arch/mips/netlogic/xlp/setup.c
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #include <linux/kernel.h> 36 + #include <linux/serial_8250.h> 37 + #include <linux/pm.h> 38 + 39 + #include <asm/reboot.h> 40 + #include <asm/time.h> 41 + #include <asm/bootinfo.h> 42 + 43 + #include <linux/of_fdt.h> 44 + 45 + #include <asm/netlogic/haldefs.h> 46 + #include <asm/netlogic/common.h> 47 + 48 + #include <asm/netlogic/xlp-hal/iomap.h> 49 + #include <asm/netlogic/xlp-hal/xlp.h> 50 + #include <asm/netlogic/xlp-hal/sys.h> 51 + 52 + unsigned long nlm_common_ebase = 0x0; 53 + 54 + static void nlm_linux_exit(void) 55 + { 56 + nlm_write_sys_reg(nlm_sys_base, SYS_CHIP_RESET, 1); 57 + for ( ; ; ) 58 + cpu_wait(); 59 + } 60 + 61 + void __init plat_mem_setup(void) 62 + { 63 + panic_timeout = 5; 64 + _machine_restart = (void (*)(char *))nlm_linux_exit; 65 + _machine_halt = nlm_linux_exit; 66 + pm_power_off = nlm_linux_exit; 67 + } 68 + 69 + const char *get_system_type(void) 70 + { 71 + return "Netlogic XLP Series"; 72 + } 73 + 74 + void __init prom_free_prom_memory(void) 75 + { 76 + /* Nothing yet */ 77 + } 78 + 79 + void xlp_mmu_init(void) 80 + { 81 + write_c0_config6(read_c0_config6() | 0x24); 82 + current_cpu_data.tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1; 83 + write_c0_config7(PM_DEFAULT_MASK >> 84 + (13 + (ffz(PM_DEFAULT_MASK >> 13) / 2))); 85 + } 86 + 87 + void __init prom_init(void) 88 + { 89 + void *fdtp; 90 + 91 + fdtp = (void *)(long)fw_arg0; 92 + xlp_mmu_init(); 93 + nlm_hal_init(); 94 + early_init_devtree(fdtp); 95 + 96 + nlm_common_ebase = read_c0_ebase() & (~((1 << 12) - 1)); 97 + #ifdef CONFIG_SMP 98 + nlm_wakeup_secondary_cpus(0xffffffff); 99 + register_smp_ops(&nlm_smp_ops); 100 + #endif 101 + }
+217
arch/mips/netlogic/xlp/smpboot.S
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #include <linux/init.h> 36 + 37 + #include <asm/asm.h> 38 + #include <asm/asm-offsets.h> 39 + #include <asm/regdef.h> 40 + #include <asm/mipsregs.h> 41 + #include <asm/stackframe.h> 42 + #include <asm/asmmacro.h> 43 + #include <asm/addrspace.h> 44 + 45 + #include <asm/netlogic/xlp-hal/iomap.h> 46 + #include <asm/netlogic/xlp-hal/xlp.h> 47 + #include <asm/netlogic/xlp-hal/sys.h> 48 + #include <asm/netlogic/xlp-hal/cpucontrol.h> 49 + 50 + #define CP0_EBASE $15 51 + #define SYS_CPU_COHERENT_BASE(node) CKSEG1ADDR(XLP_DEFAULT_IO_BASE) + \ 52 + XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \ 53 + SYS_CPU_NONCOHERENT_MODE * 4 54 + 55 + .macro __config_lsu 56 + li t0, LSU_DEFEATURE 57 + mfcr t1, t0 58 + 59 + lui t2, 0x4080 /* Enable Unaligned Access, L2HPE */ 60 + or t1, t1, t2 61 + li t2, ~0xe /* S1RCM */ 62 + and t1, t1, t2 63 + mtcr t1, t0 64 + 65 + li t0, SCHED_DEFEATURE 66 + lui t1, 0x0100 /* Experimental: Disable BRU accepting ALU ops */ 67 + mtcr t1, t0 68 + .endm 69 + 70 + .set noreorder 71 + .set arch=xlr /* for mfcr/mtcr, XLR is sufficient */ 72 + 73 + __CPUINIT 74 + EXPORT(nlm_reset_entry) 75 + mfc0 t0, CP0_EBASE, 1 76 + mfc0 t1, CP0_EBASE, 1 77 + srl t1, 5 78 + andi t1, 0x3 /* t1 <- node */ 79 + li t2, 0x40000 80 + mul t3, t2, t1 /* t3 = node * 0x40000 */ 81 + srl t0, t0, 2 82 + and t0, t0, 0x7 /* t0 <- core */ 83 + li t1, 0x1 84 + sll t0, t1, t0 85 + nor t0, t0, zero /* t0 <- ~(1 << core) */ 86 + li t2, SYS_CPU_COHERENT_BASE(0) 87 + add t2, t2, t3 /* t2 <- SYS offset for node */ 88 + lw t1, 0(t2) 89 + and t1, t1, t0 90 + sw t1, 0(t2) 91 + 92 + /* read back to ensure complete */ 93 + lw t1, 0(t2) 94 + sync 95 + 96 + /* Configure LSU on Non-0 Cores. */ 97 + __config_lsu 98 + 99 + /* 100 + * Wake up sibling threads from the initial thread in 101 + * a core. 102 + */ 103 + EXPORT(nlm_boot_siblings) 104 + li t0, CKSEG1ADDR(RESET_DATA_PHYS) 105 + lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */ 106 + li t0, ((CPU_BLOCKID_MAP << 8) | MAP_THREADMODE) 107 + mfcr t2, t0 108 + or t2, t2, t1 109 + mtcr t2, t0 110 + 111 + /* 112 + * The new hardware thread starts at the next instruction 113 + * For all the cases other than core 0 thread 0, we will 114 + * jump to the secondary wait function. 115 + */ 116 + mfc0 v0, CP0_EBASE, 1 117 + andi v0, 0x7f /* v0 <- node/core */ 118 + 119 + #if 1 120 + /* A0 errata - Write MMU_SETUP after changing thread mode register. */ 121 + andi v1, v0, 0x3 /* v1 <- thread id */ 122 + bnez v1, 2f 123 + nop 124 + 125 + li t0, MMU_SETUP 126 + li t1, 0 127 + mtcr t1, t0 128 + ehb 129 + #endif 130 + 131 + 2: beqz v0, 3f 132 + nop 133 + 134 + /* setup status reg */ 135 + mfc0 t1, CP0_STATUS 136 + li t0, ST0_BEV 137 + or t1, t0 138 + xor t1, t0 139 + #ifdef CONFIG_64BIT 140 + ori t1, ST0_KX 141 + #endif 142 + mtc0 t1, CP0_STATUS 143 + 144 + /* SETUP TLBs for a mapped kernel here */ 145 + PTR_LA t0, prom_pre_boot_secondary_cpus 146 + jalr t0 147 + nop 148 + 149 + /* 150 + * For the boot CPU, we have to restore registers and 151 + * return 152 + */ 153 + 3: dmfc0 t0, $4, 2 /* restore SP from UserLocal */ 154 + li t1, 0xfadebeef 155 + dmtc0 t1, $4, 2 /* restore SP from UserLocal */ 156 + PTR_SUBU sp, t0, PT_SIZE 157 + RESTORE_ALL 158 + jr ra 159 + nop 160 + EXPORT(nlm_reset_entry_end) 161 + 162 + EXPORT(nlm_boot_core0_siblings) /* "Master" (n0c0t0) cpu starts from here */ 163 + __config_lsu 164 + dmtc0 sp, $4, 2 /* SP saved in UserLocal */ 165 + SAVE_ALL 166 + sync 167 + /* find the location to which nlm_boot_siblings was relocated */ 168 + li t0, CKSEG1ADDR(RESET_VEC_PHYS) 169 + dla t1, nlm_reset_entry 170 + dla t2, nlm_boot_siblings 171 + dsubu t2, t1 172 + daddu t2, t0 173 + /* call it */ 174 + jr t2 175 + nop 176 + __FINIT 177 + 178 + __CPUINIT 179 + NESTED(prom_pre_boot_secondary_cpus, 16, sp) 180 + .set mips64 181 + mfc0 a0, CP0_EBASE, 1 /* read ebase */ 182 + andi a0, 0x3ff /* a0 has the processor_id() */ 183 + sll t0, a0, 2 /* offset in cpu array */ 184 + 185 + PTR_LA t1, nlm_cpu_ready /* mark CPU ready */ 186 + PTR_ADDU t1, t0 187 + li t2, 1 188 + sw t2, 0(t1) 189 + 190 + PTR_LA t1, nlm_cpu_unblock 191 + PTR_ADDU t1, t0 192 + 1: lw t2, 0(t1) /* wait till unblocked */ 193 + bnez t2, 2f 194 + nop 195 + nop 196 + nop 197 + nop 198 + nop 199 + nop 200 + j 1b 201 + nop 202 + 203 + 2: PTR_LA t1, nlm_next_sp 204 + PTR_L sp, 0(t1) 205 + PTR_LA t1, nlm_next_gp 206 + PTR_L gp, 0(t1) 207 + 208 + /* a0 has the processor id */ 209 + PTR_LA t0, nlm_early_init_secondary 210 + jalr t0 211 + nop 212 + 213 + PTR_LA t0, smp_bootstrap 214 + jr t0 215 + nop 216 + END(prom_pre_boot_secondary_cpus) 217 + __FINIT
+149
arch/mips/netlogic/xlp/wakeup.c
··· 1 + /* 2 + * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights 3 + * reserved. 4 + * 5 + * This software is available to you under a choice of one of two 6 + * licenses. You may choose to be licensed under the terms of the GNU 7 + * General Public License (GPL) Version 2, available from the file 8 + * COPYING in the main directory of this source tree, or the NetLogic 9 + * license below: 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions and the following disclaimer. 17 + * 2. Redistributions in binary form must reproduce the above copyright 18 + * notice, this list of conditions and the following disclaimer in 19 + * the documentation and/or other materials provided with the 20 + * distribution. 21 + * 22 + * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR 23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 + * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE 26 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 + */ 34 + 35 + #include <linux/init.h> 36 + #include <linux/kernel.h> 37 + #include <linux/threads.h> 38 + 39 + #include <asm/asm.h> 40 + #include <asm/asm-offsets.h> 41 + #include <asm/mipsregs.h> 42 + #include <asm/addrspace.h> 43 + #include <asm/string.h> 44 + 45 + #include <asm/netlogic/haldefs.h> 46 + #include <asm/netlogic/common.h> 47 + #include <asm/netlogic/mips-extns.h> 48 + 49 + #include <asm/netlogic/xlp-hal/iomap.h> 50 + #include <asm/netlogic/xlp-hal/pic.h> 51 + #include <asm/netlogic/xlp-hal/xlp.h> 52 + #include <asm/netlogic/xlp-hal/sys.h> 53 + 54 + unsigned long secondary_entry; 55 + uint32_t nlm_coremask; 56 + unsigned int nlm_threads_per_core; 57 + unsigned int nlm_threadmode; 58 + 59 + static void nlm_enable_secondary_cores(unsigned int cores_bitmap) 60 + { 61 + uint32_t core, value, coremask; 62 + 63 + for (core = 1; core < 8; core++) { 64 + coremask = 1 << core; 65 + if ((cores_bitmap & coremask) == 0) 66 + continue; 67 + 68 + /* Enable CPU clock */ 69 + value = nlm_read_sys_reg(nlm_sys_base, SYS_CORE_DFS_DIS_CTRL); 70 + value &= ~coremask; 71 + nlm_write_sys_reg(nlm_sys_base, SYS_CORE_DFS_DIS_CTRL, value); 72 + 73 + /* Remove CPU Reset */ 74 + value = nlm_read_sys_reg(nlm_sys_base, SYS_CPU_RESET); 75 + value &= ~coremask; 76 + nlm_write_sys_reg(nlm_sys_base, SYS_CPU_RESET, value); 77 + 78 + /* Poll for CPU to mark itself coherent */ 79 + do { 80 + value = nlm_read_sys_reg(nlm_sys_base, 81 + SYS_CPU_NONCOHERENT_MODE); 82 + } while ((value & coremask) != 0); 83 + } 84 + } 85 + 86 + 87 + static void nlm_parse_cpumask(u32 cpu_mask) 88 + { 89 + uint32_t core0_thr_mask, core_thr_mask; 90 + int i; 91 + 92 + core0_thr_mask = cpu_mask & 0xf; 93 + switch (core0_thr_mask) { 94 + case 1: 95 + nlm_threads_per_core = 1; 96 + nlm_threadmode = 0; 97 + break; 98 + case 3: 99 + nlm_threads_per_core = 2; 100 + nlm_threadmode = 2; 101 + break; 102 + case 0xf: 103 + nlm_threads_per_core = 4; 104 + nlm_threadmode = 3; 105 + break; 106 + default: 107 + goto unsupp; 108 + } 109 + 110 + /* Verify other cores CPU masks */ 111 + nlm_coremask = 1; 112 + for (i = 1; i < 8; i++) { 113 + core_thr_mask = (cpu_mask >> (i * 4)) & 0xf; 114 + if (core_thr_mask) { 115 + if (core_thr_mask != core0_thr_mask) 116 + goto unsupp; 117 + nlm_coremask |= 1 << i; 118 + } 119 + } 120 + return; 121 + 122 + unsupp: 123 + panic("Unsupported CPU mask %x\n", cpu_mask); 124 + } 125 + 126 + int __cpuinit nlm_wakeup_secondary_cpus(u32 wakeup_mask) 127 + { 128 + unsigned long reset_vec; 129 + unsigned int *reset_data; 130 + 131 + /* Update reset entry point with CPU init code */ 132 + reset_vec = CKSEG1ADDR(RESET_VEC_PHYS); 133 + memcpy((void *)reset_vec, (void *)nlm_reset_entry, 134 + (nlm_reset_entry_end - nlm_reset_entry)); 135 + 136 + /* verify the mask and setup core config variables */ 137 + nlm_parse_cpumask(wakeup_mask); 138 + 139 + /* Setup CPU init parameters */ 140 + reset_data = (unsigned int *)CKSEG1ADDR(RESET_DATA_PHYS); 141 + reset_data[BOOT_THREAD_MODE] = nlm_threadmode; 142 + 143 + /* first wakeup core 0 siblings */ 144 + nlm_boot_core0_siblings(); 145 + 146 + /* enable the reset of the cores */ 147 + nlm_enable_secondary_cores(nlm_coremask); 148 + return 0; 149 + }