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

MIPS: Netlogic: Move code common with XLP to common/

- Move code that can be shared with XLP (irq.c, smp.c, time.c and
xlr_console.c) to arch/mips/netlogic/common
- Add asm/netlogic/haldefs.h and asm/netlogic/common.h for common and
io functions shared with XLP
- remove type 'nlm_reg_t *' and use uint64_t for mmio offsets
- Move XLR specific code in smp.c to xlr/wakeup.c
- Move XLR specific PCI code from irq.c to mips/pci/pci-xlr.c
- Provide API for pic functions called from common/irq.c

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

authored by

Jayachandran C and committed by
Ralf Baechle
0c965407 99fb2f79

+721 -464
+56
arch/mips/include/asm/netlogic/common.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 _NETLOGIC_COMMON_H_ 36 + #define _NETLOGIC_COMMON_H_ 37 + 38 + /* 39 + * Common SMP definitions 40 + */ 41 + struct irq_desc; 42 + extern struct plat_smp_ops nlm_smp_ops; 43 + extern char nlm_reset_entry[], nlm_reset_entry_end[]; 44 + void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc); 45 + void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc); 46 + void nlm_smp_irq_init(void); 47 + void prom_pre_boot_secondary_cpus(void); 48 + int nlm_wakeup_secondary_cpus(u32 wakeup_mask); 49 + void nlm_boot_smp_nmi(void); 50 + 51 + /* 52 + * Misc. 53 + */ 54 + extern unsigned long nlm_common_ebase; 55 + unsigned int nlm_get_cpu_frequency(void); 56 + #endif /* _NETLOGIC_COMMON_H_ */
+142
arch/mips/include/asm/netlogic/haldefs.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_HALDEFS_H__ 36 + #define __NLM_HAL_HALDEFS_H__ 37 + 38 + /* 39 + * This file contains platform specific memory mapped IO implementation 40 + * and will provide a way to read 32/64 bit memory mapped registers in 41 + * all ABIs 42 + */ 43 + /* 44 + * For o32 compilation, we have to disable interrupts and enable KX bit to 45 + * access 64 bit addresses or data. 46 + * 47 + * We need to disable interrupts because we save just the lower 32 bits of 48 + * registers in interrupt handling. So if we get hit by an interrupt while 49 + * using the upper 32 bits of a register, we lose. 50 + */ 51 + static inline uint32_t nlm_save_flags_kx(void) 52 + { 53 + return change_c0_status(ST0_KX | ST0_IE, ST0_KX); 54 + } 55 + 56 + static inline uint32_t nlm_save_flags_cop2(void) 57 + { 58 + return change_c0_status(ST0_CU2 | ST0_IE, ST0_CU2); 59 + } 60 + 61 + static inline void nlm_restore_flags(uint32_t sr) 62 + { 63 + write_c0_status(sr); 64 + } 65 + 66 + /* 67 + * The n64 implementations are simple, the o32 implementations when they 68 + * are added, will have to disable interrupts and enable KX before doing 69 + * 64 bit ops. 70 + */ 71 + static inline uint32_t 72 + nlm_read_reg(uint64_t base, uint32_t reg) 73 + { 74 + volatile uint32_t *addr = (volatile uint32_t *)(long)base + reg; 75 + 76 + return *addr; 77 + } 78 + 79 + static inline void 80 + nlm_write_reg(uint64_t base, uint32_t reg, uint32_t val) 81 + { 82 + volatile uint32_t *addr = (volatile uint32_t *)(long)base + reg; 83 + 84 + *addr = val; 85 + } 86 + 87 + static inline uint64_t 88 + nlm_read_reg64(uint64_t base, uint32_t reg) 89 + { 90 + uint64_t addr = base + (reg >> 1) * sizeof(uint64_t); 91 + volatile uint64_t *ptr = (volatile uint64_t *)(long)addr; 92 + 93 + return *ptr; 94 + } 95 + 96 + static inline void 97 + nlm_write_reg64(uint64_t base, uint32_t reg, uint64_t val) 98 + { 99 + uint64_t addr = base + (reg >> 1) * sizeof(uint64_t); 100 + volatile uint64_t *ptr = (volatile uint64_t *)(long)addr; 101 + 102 + *ptr = val; 103 + } 104 + 105 + /* 106 + * Routines to store 32/64 bit values to 64 bit addresses, 107 + * used when going thru XKPHYS to access registers 108 + */ 109 + static inline uint32_t 110 + nlm_read_reg_xkphys(uint64_t base, uint32_t reg) 111 + { 112 + return nlm_read_reg(base, reg); 113 + } 114 + 115 + static inline void 116 + nlm_write_reg_xkphys(uint64_t base, uint32_t reg, uint32_t val) 117 + { 118 + nlm_write_reg(base, reg, val); 119 + } 120 + 121 + static inline uint64_t 122 + nlm_read_reg64_xkphys(uint64_t base, uint32_t reg) 123 + { 124 + return nlm_read_reg64(base, reg); 125 + } 126 + 127 + static inline void 128 + nlm_write_reg64_xkphys(uint64_t base, uint32_t reg, uint64_t val) 129 + { 130 + nlm_write_reg64(base, reg, val); 131 + } 132 + 133 + /* Location where IO base is mapped */ 134 + extern uint64_t nlm_io_base; 135 + 136 + static inline uint64_t 137 + nlm_mmio_base(uint32_t devoffset) 138 + { 139 + return nlm_io_base + devoffset; 140 + } 141 + 142 + #endif
-22
arch/mips/include/asm/netlogic/xlr/iomap.h
··· 106 106 #define DEFAULT_HT_TYPE0_CFG_BASE 0x16000000 107 107 #define DEFAULT_HT_TYPE1_CFG_BASE 0x17000000 108 108 109 - #ifndef __ASSEMBLY__ 110 - #include <linux/types.h> 111 - #include <asm/byteorder.h> 112 - 113 - typedef volatile __u32 nlm_reg_t; 114 - extern unsigned long netlogic_io_base; 115 - 116 - /* FIXME read once in write_reg */ 117 - #ifdef CONFIG_CPU_LITTLE_ENDIAN 118 - #define netlogic_read_reg(base, offset) ((base)[(offset)]) 119 - #define netlogic_write_reg(base, offset, value) ((base)[(offset)] = (value)) 120 - #else 121 - #define netlogic_read_reg(base, offset) (be32_to_cpu((base)[(offset)])) 122 - #define netlogic_write_reg(base, offset, value) \ 123 - ((base)[(offset)] = cpu_to_be32((value))) 124 - #endif 125 - 126 - #define netlogic_read_reg_le32(base, offset) (le32_to_cpu((base)[(offset)])) 127 - #define netlogic_write_reg_le32(base, offset, value) \ 128 - ((base)[(offset)] = cpu_to_le32((value))) 129 - #define netlogic_io_mmio(offset) ((nlm_reg_t *)(netlogic_io_base+(offset))) 130 - #endif /* __ASSEMBLY__ */ 131 109 #endif
+62 -29
arch/mips/include/asm/netlogic/xlr/pic.h
··· 193 193 /* end XLS */ 194 194 195 195 #ifndef __ASSEMBLY__ 196 - static inline void pic_send_ipi(u32 ipi) 197 - { 198 - nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 199 - 200 - netlogic_write_reg(mmio, PIC_IPI, ipi); 201 - } 202 - 203 - static inline u32 pic_read_control(void) 204 - { 205 - nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 206 - 207 - return netlogic_read_reg(mmio, PIC_CTRL); 208 - } 209 - 210 - static inline void pic_write_control(u32 control) 211 - { 212 - nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 213 - 214 - netlogic_write_reg(mmio, PIC_CTRL, control); 215 - } 216 - 217 - static inline void pic_update_control(u32 control) 218 - { 219 - nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 220 - 221 - netlogic_write_reg(mmio, PIC_CTRL, 222 - (control | netlogic_read_reg(mmio, PIC_CTRL))); 223 - } 224 196 225 197 #define PIC_IRQ_IS_EDGE_TRIGGERED(irq) (((irq) >= PIC_TIMER_0_IRQ) && \ 226 198 ((irq) <= PIC_TIMER_7_IRQ)) 227 199 #define PIC_IRQ_IS_IRT(irq) (((irq) >= PIC_IRT_FIRST_IRQ) && \ 228 200 ((irq) <= PIC_IRT_LAST_IRQ)) 229 - #endif 230 201 202 + static inline int 203 + nlm_irq_to_irt(int irq) 204 + { 205 + if (PIC_IRQ_IS_IRT(irq) == 0) 206 + return -1; 207 + 208 + return PIC_IRQ_TO_INTR(irq); 209 + } 210 + 211 + static inline int 212 + nlm_irt_to_irq(int irt) 213 + { 214 + 215 + return PIC_INTR_TO_IRQ(irt); 216 + } 217 + 218 + static inline void 219 + nlm_pic_enable_irt(uint64_t base, int irt) 220 + { 221 + uint32_t reg; 222 + 223 + reg = nlm_read_reg(base, PIC_IRT_1(irt)); 224 + nlm_write_reg(base, PIC_IRT_1(irt), reg | (1u << 31)); 225 + } 226 + 227 + static inline void 228 + nlm_pic_disable_irt(uint64_t base, int irt) 229 + { 230 + uint32_t reg; 231 + 232 + reg = nlm_read_reg(base, PIC_IRT_1(irt)); 233 + nlm_write_reg(base, PIC_IRT_1(irt), reg & ~(1u << 31)); 234 + } 235 + 236 + static inline void 237 + nlm_pic_send_ipi(uint64_t base, int hwt, int irq, int nmi) 238 + { 239 + unsigned int tid, pid; 240 + 241 + tid = hwt & 0x3; 242 + pid = (hwt >> 2) & 0x07; 243 + nlm_write_reg(base, PIC_IPI, 244 + (pid << 20) | (tid << 16) | (nmi << 8) | irq); 245 + } 246 + 247 + static inline void 248 + nlm_pic_ack(uint64_t base, int irt) 249 + { 250 + nlm_write_reg(base, PIC_INT_ACK, 1u << irt); 251 + } 252 + 253 + static inline void 254 + nlm_pic_init_irt(uint64_t base, int irt, int irq, int hwt) 255 + { 256 + nlm_write_reg(base, PIC_IRT_0(irt), (1u << hwt)); 257 + /* local scheduling, invalid, level by default */ 258 + nlm_write_reg(base, PIC_IRT_1(irt), 259 + (1 << 30) | (1 << 6) | irq); 260 + } 261 + 262 + extern uint64_t nlm_pic_base; 263 + #endif 231 264 #endif /* _ASM_NLM_XLR_PIC_H */
-11
arch/mips/include/asm/netlogic/xlr/xlr.h
··· 40 40 unsigned int nlm_xlr_uart_in(struct uart_port *, int); 41 41 void nlm_xlr_uart_out(struct uart_port *, int, int); 42 42 43 - /* SMP support functions */ 44 - struct irq_desc; 45 - void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc); 46 - void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc); 47 - int nlm_wakeup_secondary_cpus(u32 wakeup_mask); 48 - void nlm_smp_irq_init(void); 49 - void nlm_boot_smp_nmi(void); 50 - void prom_pre_boot_secondary_cpus(void); 51 - 52 - extern struct plat_smp_ops nlm_smp_ops; 53 - extern unsigned long nlm_common_ebase; 54 43 55 44 /* XLS B silicon "Rook" */ 56 45 static inline unsigned int nlm_chip_is_xls_b(void)
+2
arch/mips/netlogic/Makefile
··· 1 + obj-$(CONFIG_NLM_COMMON) += common/ 2 + obj-$(CONFIG_CPU_XLR) += xlr/
+1 -1
arch/mips/netlogic/Platform
··· 12 12 # 13 13 # NETLOGIC processor support 14 14 # 15 - platform-$(CONFIG_CPU_XLR) += netlogic/xlr 15 + platform-$(CONFIG_NLM_COMMON) += netlogic/ 16 16 load-$(CONFIG_NLM_COMMON) += 0xffffffff80100000
+3
arch/mips/netlogic/common/Makefile
··· 1 + obj-y += irq.o time.o 2 + obj-$(CONFIG_SMP) += smp.o 3 + obj-$(CONFIG_EARLY_PRINTK) += earlycons.o
+230
arch/mips/netlogic/common/irq.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/init.h> 37 + #include <linux/linkage.h> 38 + #include <linux/interrupt.h> 39 + #include <linux/spinlock.h> 40 + #include <linux/mm.h> 41 + #include <linux/slab.h> 42 + #include <linux/irq.h> 43 + 44 + #include <asm/errno.h> 45 + #include <asm/signal.h> 46 + #include <asm/system.h> 47 + #include <asm/ptrace.h> 48 + #include <asm/mipsregs.h> 49 + #include <asm/thread_info.h> 50 + 51 + #include <asm/netlogic/mips-extns.h> 52 + #include <asm/netlogic/interrupt.h> 53 + #include <asm/netlogic/haldefs.h> 54 + #include <asm/netlogic/common.h> 55 + 56 + #include <asm/netlogic/xlr/iomap.h> 57 + #include <asm/netlogic/xlr/pic.h> 58 + /* 59 + * These are the routines that handle all the low level interrupt stuff. 60 + * Actions handled here are: initialization of the interrupt map, requesting of 61 + * interrupt lines by handlers, dispatching if interrupts to handlers, probing 62 + * for interrupt lines 63 + */ 64 + 65 + /* Globals */ 66 + static uint64_t nlm_irq_mask; 67 + static DEFINE_SPINLOCK(nlm_pic_lock); 68 + 69 + static void xlp_pic_enable(struct irq_data *d) 70 + { 71 + unsigned long flags; 72 + int irt; 73 + 74 + irt = nlm_irq_to_irt(d->irq); 75 + if (irt == -1) 76 + return; 77 + spin_lock_irqsave(&nlm_pic_lock, flags); 78 + nlm_pic_enable_irt(nlm_pic_base, irt); 79 + spin_unlock_irqrestore(&nlm_pic_lock, flags); 80 + } 81 + 82 + static void xlp_pic_disable(struct irq_data *d) 83 + { 84 + unsigned long flags; 85 + int irt; 86 + 87 + irt = nlm_irq_to_irt(d->irq); 88 + if (irt == -1) 89 + return; 90 + spin_lock_irqsave(&nlm_pic_lock, flags); 91 + nlm_pic_disable_irt(nlm_pic_base, irt); 92 + spin_unlock_irqrestore(&nlm_pic_lock, flags); 93 + } 94 + 95 + static void xlp_pic_mask_ack(struct irq_data *d) 96 + { 97 + uint64_t mask = 1ull << d->irq; 98 + 99 + write_c0_eirr(mask); /* ack by writing EIRR */ 100 + } 101 + 102 + static void xlp_pic_unmask(struct irq_data *d) 103 + { 104 + void *hd = irq_data_get_irq_handler_data(d); 105 + int irt; 106 + 107 + irt = nlm_irq_to_irt(d->irq); 108 + if (irt == -1) 109 + return; 110 + 111 + if (hd) { 112 + void (*extra_ack)(void *) = hd; 113 + extra_ack(d); 114 + } 115 + /* Ack is a single write, no need to lock */ 116 + nlm_pic_ack(nlm_pic_base, irt); 117 + } 118 + 119 + static struct irq_chip xlp_pic = { 120 + .name = "XLP-PIC", 121 + .irq_enable = xlp_pic_enable, 122 + .irq_disable = xlp_pic_disable, 123 + .irq_mask_ack = xlp_pic_mask_ack, 124 + .irq_unmask = xlp_pic_unmask, 125 + }; 126 + 127 + static void cpuintr_disable(struct irq_data *d) 128 + { 129 + uint64_t eimr; 130 + uint64_t mask = 1ull << d->irq; 131 + 132 + eimr = read_c0_eimr(); 133 + write_c0_eimr(eimr & ~mask); 134 + } 135 + 136 + static void cpuintr_enable(struct irq_data *d) 137 + { 138 + uint64_t eimr; 139 + uint64_t mask = 1ull << d->irq; 140 + 141 + eimr = read_c0_eimr(); 142 + write_c0_eimr(eimr | mask); 143 + } 144 + 145 + static void cpuintr_ack(struct irq_data *d) 146 + { 147 + uint64_t mask = 1ull << d->irq; 148 + 149 + write_c0_eirr(mask); 150 + } 151 + 152 + static void cpuintr_nop(struct irq_data *d) 153 + { 154 + WARN(d->irq >= PIC_IRQ_BASE, "Bad irq %d", d->irq); 155 + } 156 + 157 + /* 158 + * Chip definition for CPU originated interrupts(timer, msg) and 159 + * IPIs 160 + */ 161 + struct irq_chip nlm_cpu_intr = { 162 + .name = "XLP-CPU-INTR", 163 + .irq_enable = cpuintr_enable, 164 + .irq_disable = cpuintr_disable, 165 + .irq_mask = cpuintr_nop, 166 + .irq_ack = cpuintr_nop, 167 + .irq_eoi = cpuintr_ack, 168 + }; 169 + 170 + void __init init_nlm_common_irqs(void) 171 + { 172 + int i, irq, irt; 173 + 174 + for (i = 0; i < PIC_IRT_FIRST_IRQ; i++) 175 + irq_set_chip_and_handler(i, &nlm_cpu_intr, handle_percpu_irq); 176 + 177 + for (i = PIC_IRT_FIRST_IRQ; i <= PIC_IRT_LAST_IRQ ; i++) 178 + irq_set_chip_and_handler(i, &xlp_pic, handle_level_irq); 179 + 180 + #ifdef CONFIG_SMP 181 + irq_set_chip_and_handler(IRQ_IPI_SMP_FUNCTION, &nlm_cpu_intr, 182 + nlm_smp_function_ipi_handler); 183 + irq_set_chip_and_handler(IRQ_IPI_SMP_RESCHEDULE, &nlm_cpu_intr, 184 + nlm_smp_resched_ipi_handler); 185 + nlm_irq_mask |= 186 + ((1ULL << IRQ_IPI_SMP_FUNCTION) | (1ULL << IRQ_IPI_SMP_RESCHEDULE)); 187 + #endif 188 + 189 + for (irq = PIC_IRT_FIRST_IRQ; irq <= PIC_IRT_LAST_IRQ; irq++) { 190 + irt = nlm_irq_to_irt(irq); 191 + if (irt == -1) 192 + continue; 193 + nlm_irq_mask |= (1ULL << irq); 194 + nlm_pic_init_irt(nlm_pic_base, irt, irq, 0); 195 + } 196 + 197 + nlm_irq_mask |= (1ULL << IRQ_TIMER); 198 + } 199 + 200 + void __init arch_init_irq(void) 201 + { 202 + /* Initialize the irq descriptors */ 203 + init_nlm_common_irqs(); 204 + 205 + write_c0_eimr(nlm_irq_mask); 206 + } 207 + 208 + void __cpuinit nlm_smp_irq_init(void) 209 + { 210 + /* set interrupt mask for non-zero cpus */ 211 + write_c0_eimr(nlm_irq_mask); 212 + } 213 + 214 + asmlinkage void plat_irq_dispatch(void) 215 + { 216 + uint64_t eirr; 217 + int i; 218 + 219 + eirr = read_c0_eirr() & read_c0_eimr(); 220 + if (eirr & (1 << IRQ_TIMER)) { 221 + do_IRQ(IRQ_TIMER); 222 + return; 223 + } 224 + 225 + i = __ilog2_u64(eirr); 226 + if (i == -1) 227 + return; 228 + 229 + do_IRQ(i); 230 + }
+51
arch/mips/netlogic/common/time.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 + 37 + #include <asm/time.h> 38 + #include <asm/netlogic/interrupt.h> 39 + #include <asm/netlogic/common.h> 40 + 41 + unsigned int __cpuinit get_c0_compare_int(void) 42 + { 43 + return IRQ_TIMER; 44 + } 45 + 46 + void __init plat_time_init(void) 47 + { 48 + mips_hpt_frequency = nlm_get_cpu_frequency(); 49 + pr_info("MIPS counter frequency [%ld]\n", 50 + (unsigned long)mips_hpt_frequency); 51 + }
+2 -3
arch/mips/netlogic/xlr/Makefile
··· 1 - obj-y += setup.o platform.o irq.o setup.o time.o 2 - obj-$(CONFIG_SMP) += smp.o smpboot.o 3 - obj-$(CONFIG_EARLY_PRINTK) += xlr_console.o 1 + obj-y += setup.o platform.o 2 + obj-$(CONFIG_SMP) += smpboot.o wakeup.o
-305
arch/mips/netlogic/xlr/irq.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/init.h> 37 - #include <linux/linkage.h> 38 - #include <linux/interrupt.h> 39 - #include <linux/spinlock.h> 40 - #include <linux/mm.h> 41 - #include <linux/msi.h> 42 - #include <linux/irq.h> 43 - #include <linux/irqdesc.h> 44 - #include <linux/pci.h> 45 - 46 - #include <asm/mipsregs.h> 47 - 48 - #include <asm/netlogic/xlr/msidef.h> 49 - #include <asm/netlogic/xlr/iomap.h> 50 - #include <asm/netlogic/xlr/pic.h> 51 - #include <asm/netlogic/xlr/xlr.h> 52 - 53 - #include <asm/netlogic/interrupt.h> 54 - #include <asm/netlogic/mips-extns.h> 55 - 56 - static u64 nlm_irq_mask; 57 - static DEFINE_SPINLOCK(nlm_pic_lock); 58 - 59 - static void xlr_pic_enable(struct irq_data *d) 60 - { 61 - nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 62 - unsigned long flags; 63 - nlm_reg_t reg; 64 - int irq = d->irq; 65 - 66 - WARN(!PIC_IRQ_IS_IRT(irq), "Bad irq %d", irq); 67 - 68 - spin_lock_irqsave(&nlm_pic_lock, flags); 69 - reg = netlogic_read_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE); 70 - netlogic_write_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE, 71 - reg | (1 << 6) | (1 << 30) | (1 << 31)); 72 - spin_unlock_irqrestore(&nlm_pic_lock, flags); 73 - } 74 - 75 - static void xlr_pic_mask(struct irq_data *d) 76 - { 77 - nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 78 - unsigned long flags; 79 - nlm_reg_t reg; 80 - int irq = d->irq; 81 - 82 - WARN(!PIC_IRQ_IS_IRT(irq), "Bad irq %d", irq); 83 - 84 - spin_lock_irqsave(&nlm_pic_lock, flags); 85 - reg = netlogic_read_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE); 86 - netlogic_write_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE, 87 - reg | (1 << 6) | (1 << 30) | (0 << 31)); 88 - spin_unlock_irqrestore(&nlm_pic_lock, flags); 89 - } 90 - 91 - #ifdef CONFIG_PCI 92 - /* Extra ACK needed for XLR on chip PCI controller */ 93 - static void xlr_pci_ack(struct irq_data *d) 94 - { 95 - nlm_reg_t *pci_mmio = netlogic_io_mmio(NETLOGIC_IO_PCIX_OFFSET); 96 - 97 - netlogic_read_reg(pci_mmio, (0x140 >> 2)); 98 - } 99 - 100 - /* Extra ACK needed for XLS on chip PCIe controller */ 101 - static void xls_pcie_ack(struct irq_data *d) 102 - { 103 - nlm_reg_t *pcie_mmio_le = netlogic_io_mmio(NETLOGIC_IO_PCIE_1_OFFSET); 104 - 105 - switch (d->irq) { 106 - case PIC_PCIE_LINK0_IRQ: 107 - netlogic_write_reg(pcie_mmio_le, (0x90 >> 2), 0xffffffff); 108 - break; 109 - case PIC_PCIE_LINK1_IRQ: 110 - netlogic_write_reg(pcie_mmio_le, (0x94 >> 2), 0xffffffff); 111 - break; 112 - case PIC_PCIE_LINK2_IRQ: 113 - netlogic_write_reg(pcie_mmio_le, (0x190 >> 2), 0xffffffff); 114 - break; 115 - case PIC_PCIE_LINK3_IRQ: 116 - netlogic_write_reg(pcie_mmio_le, (0x194 >> 2), 0xffffffff); 117 - break; 118 - } 119 - } 120 - 121 - /* For XLS B silicon, the 3,4 PCI interrupts are different */ 122 - static void xls_pcie_ack_b(struct irq_data *d) 123 - { 124 - nlm_reg_t *pcie_mmio_le = netlogic_io_mmio(NETLOGIC_IO_PCIE_1_OFFSET); 125 - 126 - switch (d->irq) { 127 - case PIC_PCIE_LINK0_IRQ: 128 - netlogic_write_reg(pcie_mmio_le, (0x90 >> 2), 0xffffffff); 129 - break; 130 - case PIC_PCIE_LINK1_IRQ: 131 - netlogic_write_reg(pcie_mmio_le, (0x94 >> 2), 0xffffffff); 132 - break; 133 - case PIC_PCIE_XLSB0_LINK2_IRQ: 134 - netlogic_write_reg(pcie_mmio_le, (0x190 >> 2), 0xffffffff); 135 - break; 136 - case PIC_PCIE_XLSB0_LINK3_IRQ: 137 - netlogic_write_reg(pcie_mmio_le, (0x194 >> 2), 0xffffffff); 138 - break; 139 - } 140 - } 141 - #endif 142 - 143 - static void xlr_pic_ack(struct irq_data *d) 144 - { 145 - unsigned long flags; 146 - nlm_reg_t *mmio; 147 - int irq = d->irq; 148 - void *hd = irq_data_get_irq_handler_data(d); 149 - 150 - WARN(!PIC_IRQ_IS_IRT(irq), "Bad irq %d", irq); 151 - 152 - if (hd) { 153 - void (*extra_ack)(void *) = hd; 154 - extra_ack(d); 155 - } 156 - mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 157 - spin_lock_irqsave(&nlm_pic_lock, flags); 158 - netlogic_write_reg(mmio, PIC_INT_ACK, (1 << (irq - PIC_IRQ_BASE))); 159 - spin_unlock_irqrestore(&nlm_pic_lock, flags); 160 - } 161 - 162 - /* 163 - * This chip definition handles interrupts routed thru the XLR 164 - * hardware PIC, currently IRQs 8-39 are mapped to hardware intr 165 - * 0-31 wired the XLR PIC 166 - */ 167 - static struct irq_chip xlr_pic = { 168 - .name = "XLR-PIC", 169 - .irq_enable = xlr_pic_enable, 170 - .irq_mask = xlr_pic_mask, 171 - .irq_ack = xlr_pic_ack, 172 - }; 173 - 174 - static void rsvd_irq_handler(struct irq_data *d) 175 - { 176 - WARN(d->irq >= PIC_IRQ_BASE, "Bad irq %d", d->irq); 177 - } 178 - 179 - /* 180 - * Chip definition for CPU originated interrupts(timer, msg) and 181 - * IPIs 182 - */ 183 - struct irq_chip nlm_cpu_intr = { 184 - .name = "XLR-CPU-INTR", 185 - .irq_enable = rsvd_irq_handler, 186 - .irq_mask = rsvd_irq_handler, 187 - .irq_ack = rsvd_irq_handler, 188 - }; 189 - 190 - void __init init_xlr_irqs(void) 191 - { 192 - nlm_reg_t *mmio = netlogic_io_mmio(NETLOGIC_IO_PIC_OFFSET); 193 - uint32_t thread_mask = 1; 194 - int level, i; 195 - 196 - pr_info("Interrupt thread mask [%x]\n", thread_mask); 197 - for (i = 0; i < PIC_NUM_IRTS; i++) { 198 - level = PIC_IRQ_IS_EDGE_TRIGGERED(i); 199 - 200 - /* Bind all PIC irqs to boot cpu */ 201 - netlogic_write_reg(mmio, PIC_IRT_0_BASE + i, thread_mask); 202 - 203 - /* 204 - * Use local scheduling and high polarity for all IRTs 205 - * Invalidate all IRTs, by default 206 - */ 207 - netlogic_write_reg(mmio, PIC_IRT_1_BASE + i, 208 - (level << 30) | (1 << 6) | (PIC_IRQ_BASE + i)); 209 - } 210 - 211 - /* Make all IRQs as level triggered by default */ 212 - for (i = 0; i < NR_IRQS; i++) { 213 - if (PIC_IRQ_IS_IRT(i)) 214 - irq_set_chip_and_handler(i, &xlr_pic, handle_level_irq); 215 - else 216 - irq_set_chip_and_handler(i, &nlm_cpu_intr, 217 - handle_percpu_irq); 218 - } 219 - #ifdef CONFIG_SMP 220 - irq_set_chip_and_handler(IRQ_IPI_SMP_FUNCTION, &nlm_cpu_intr, 221 - nlm_smp_function_ipi_handler); 222 - irq_set_chip_and_handler(IRQ_IPI_SMP_RESCHEDULE, &nlm_cpu_intr, 223 - nlm_smp_resched_ipi_handler); 224 - nlm_irq_mask |= 225 - ((1ULL << IRQ_IPI_SMP_FUNCTION) | (1ULL << IRQ_IPI_SMP_RESCHEDULE)); 226 - #endif 227 - 228 - #ifdef CONFIG_PCI 229 - /* 230 - * For PCI interrupts, we need to ack the PIC controller too, overload 231 - * irq handler data to do this 232 - */ 233 - if (nlm_chip_is_xls()) { 234 - if (nlm_chip_is_xls_b()) { 235 - irq_set_handler_data(PIC_PCIE_LINK0_IRQ, 236 - xls_pcie_ack_b); 237 - irq_set_handler_data(PIC_PCIE_LINK1_IRQ, 238 - xls_pcie_ack_b); 239 - irq_set_handler_data(PIC_PCIE_XLSB0_LINK2_IRQ, 240 - xls_pcie_ack_b); 241 - irq_set_handler_data(PIC_PCIE_XLSB0_LINK3_IRQ, 242 - xls_pcie_ack_b); 243 - } else { 244 - irq_set_handler_data(PIC_PCIE_LINK0_IRQ, xls_pcie_ack); 245 - irq_set_handler_data(PIC_PCIE_LINK1_IRQ, xls_pcie_ack); 246 - irq_set_handler_data(PIC_PCIE_LINK2_IRQ, xls_pcie_ack); 247 - irq_set_handler_data(PIC_PCIE_LINK3_IRQ, xls_pcie_ack); 248 - } 249 - } else { 250 - /* XLR PCI controller ACK */ 251 - irq_set_handler_data(PIC_PCIE_XLSB0_LINK3_IRQ, xlr_pci_ack); 252 - } 253 - #endif 254 - /* unmask all PIC related interrupts. If no handler is installed by the 255 - * drivers, it'll just ack the interrupt and return 256 - */ 257 - for (i = PIC_IRT_FIRST_IRQ; i <= PIC_IRT_LAST_IRQ; i++) 258 - nlm_irq_mask |= (1ULL << i); 259 - 260 - nlm_irq_mask |= (1ULL << IRQ_TIMER); 261 - } 262 - 263 - void __init arch_init_irq(void) 264 - { 265 - /* Initialize the irq descriptors */ 266 - init_xlr_irqs(); 267 - write_c0_eimr(nlm_irq_mask); 268 - } 269 - 270 - void __cpuinit nlm_smp_irq_init(void) 271 - { 272 - /* set interrupt mask for non-zero cpus */ 273 - write_c0_eimr(nlm_irq_mask); 274 - } 275 - 276 - asmlinkage void plat_irq_dispatch(void) 277 - { 278 - uint64_t eirr; 279 - int i; 280 - 281 - eirr = read_c0_eirr() & read_c0_eimr(); 282 - if (!eirr) 283 - return; 284 - 285 - /* no need of EIRR here, writing compare clears interrupt */ 286 - if (eirr & (1 << IRQ_TIMER)) { 287 - do_IRQ(IRQ_TIMER); 288 - return; 289 - } 290 - 291 - /* use dcltz: optimize below code */ 292 - for (i = 63; i != -1; i--) { 293 - if (eirr & (1ULL << i)) 294 - break; 295 - } 296 - if (i == -1) { 297 - pr_err("no interrupt !!\n"); 298 - return; 299 - } 300 - 301 - /* Ack eirr */ 302 - write_c0_eirr(1ULL << i); 303 - 304 - do_IRQ(i); 305 - }
+16 -15
arch/mips/netlogic/xlr/platform.c
··· 15 15 #include <linux/serial_8250.h> 16 16 #include <linux/serial_reg.h> 17 17 18 + #include <asm/netlogic/haldefs.h> 18 19 #include <asm/netlogic/xlr/iomap.h> 19 20 #include <asm/netlogic/xlr/pic.h> 20 21 #include <asm/netlogic/xlr/xlr.h> 21 22 22 23 unsigned int nlm_xlr_uart_in(struct uart_port *p, int offset) 23 24 { 24 - nlm_reg_t *mmio; 25 + uint64_t uartbase; 25 26 unsigned int value; 26 27 27 - /* XLR uart does not need any mapping of regs */ 28 - mmio = (nlm_reg_t *)(p->membase + (offset << p->regshift)); 29 - value = netlogic_read_reg(mmio, 0); 28 + /* sign extend to 64 bits, if needed */ 29 + uartbase = (uint64_t)(long)p->membase; 30 + value = nlm_read_reg(uartbase, offset); 30 31 31 32 /* See XLR/XLS errata */ 32 33 if (offset == UART_MSR) ··· 40 39 41 40 void nlm_xlr_uart_out(struct uart_port *p, int offset, int value) 42 41 { 43 - nlm_reg_t *mmio; 42 + uint64_t uartbase; 44 43 45 - /* XLR uart does not need any mapping of regs */ 46 - mmio = (nlm_reg_t *)(p->membase + (offset << p->regshift)); 44 + /* sign extend to 64 bits, if needed */ 45 + uartbase = (uint64_t)(long)p->membase; 47 46 48 47 /* See XLR/XLS errata */ 49 48 if (offset == UART_MSR) ··· 51 50 else if (offset == UART_MCR) 52 51 value ^= 0x3; 53 52 54 - netlogic_write_reg(mmio, 0, value); 53 + nlm_write_reg(uartbase, offset, value); 55 54 } 56 55 57 56 #define PORT(_irq) \ ··· 83 82 84 83 static int __init nlm_uart_init(void) 85 84 { 86 - nlm_reg_t *mmio; 85 + unsigned long uartbase; 87 86 88 - mmio = netlogic_io_mmio(NETLOGIC_IO_UART_0_OFFSET); 89 - xlr_uart_data[0].membase = (void __iomem *)mmio; 90 - xlr_uart_data[0].mapbase = CPHYSADDR((unsigned long)mmio); 87 + uartbase = (unsigned long)nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET); 88 + xlr_uart_data[0].membase = (void __iomem *)uartbase; 89 + xlr_uart_data[0].mapbase = CPHYSADDR(uartbase); 91 90 92 - mmio = netlogic_io_mmio(NETLOGIC_IO_UART_1_OFFSET); 93 - xlr_uart_data[1].membase = (void __iomem *)mmio; 94 - xlr_uart_data[1].mapbase = CPHYSADDR((unsigned long)mmio); 91 + uartbase = (unsigned long)nlm_mmio_base(NETLOGIC_IO_UART_1_OFFSET); 92 + xlr_uart_data[1].membase = (void __iomem *)uartbase; 93 + xlr_uart_data[1].mapbase = CPHYSADDR(uartbase); 95 94 96 95 return platform_device_register(&uart_device); 97 96 }
+16 -8
arch/mips/netlogic/xlr/setup.c
··· 39 39 #include <asm/reboot.h> 40 40 #include <asm/time.h> 41 41 #include <asm/bootinfo.h> 42 - #include <asm/smp-ops.h> 43 42 44 43 #include <asm/netlogic/interrupt.h> 45 44 #include <asm/netlogic/psb-bootinfo.h> 45 + #include <asm/netlogic/haldefs.h> 46 + #include <asm/netlogic/common.h> 46 47 47 48 #include <asm/netlogic/xlr/xlr.h> 48 49 #include <asm/netlogic/xlr/iomap.h> 49 50 #include <asm/netlogic/xlr/pic.h> 50 51 #include <asm/netlogic/xlr/gpio.h> 51 52 52 - unsigned long netlogic_io_base = (unsigned long)(DEFAULT_NETLOGIC_IO_BASE); 53 + uint64_t nlm_io_base = DEFAULT_NETLOGIC_IO_BASE; 54 + uint64_t nlm_pic_base; 53 55 unsigned long nlm_common_ebase = 0x0; 54 56 struct psb_info nlm_prom_info; 55 57 56 58 static void __init nlm_early_serial_setup(void) 57 59 { 58 60 struct uart_port s; 59 - nlm_reg_t *uart_base; 61 + unsigned long uart_base; 60 62 61 - uart_base = netlogic_io_mmio(NETLOGIC_IO_UART_0_OFFSET); 63 + uart_base = (unsigned long)nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET); 62 64 memset(&s, 0, sizeof(s)); 63 65 s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST; 64 66 s.iotype = UPIO_MEM32; ··· 69 67 s.uartclk = PIC_CLKS_PER_SEC; 70 68 s.serial_in = nlm_xlr_uart_in; 71 69 s.serial_out = nlm_xlr_uart_out; 72 - s.mapbase = (unsigned long)uart_base; 70 + s.mapbase = uart_base; 73 71 s.membase = (unsigned char __iomem *)uart_base; 74 72 early_serial_setup(&s); 75 73 } 76 74 77 75 static void nlm_linux_exit(void) 78 76 { 79 - nlm_reg_t *mmio; 77 + uint64_t gpiobase; 80 78 81 - mmio = netlogic_io_mmio(NETLOGIC_IO_GPIO_OFFSET); 79 + gpiobase = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET); 82 80 /* trigger a chip reset by writing 1 to GPIO_SWRESET_REG */ 83 - netlogic_write_reg(mmio, NETLOGIC_GPIO_SWRESET_REG, 1); 81 + nlm_write_reg(gpiobase, NETLOGIC_GPIO_SWRESET_REG, 1); 84 82 for ( ; ; ) 85 83 cpu_wait(); 86 84 } ··· 96 94 const char *get_system_type(void) 97 95 { 98 96 return "Netlogic XLR/XLS Series"; 97 + } 98 + 99 + unsigned int nlm_get_cpu_frequency(void) 100 + { 101 + return (unsigned int)nlm_prom_info.cpu_frequency; 99 102 } 100 103 101 104 void __init prom_free_prom_memory(void) ··· 182 175 prom_infop = (struct psb_info *)(long)(int)fw_arg3; 183 176 184 177 nlm_prom_info = *prom_infop; 178 + nlm_pic_base = nlm_mmio_base(NETLOGIC_IO_PIC_OFFSET); 185 179 186 180 nlm_early_serial_setup(); 187 181 build_arcs_cmdline(argv);
+16 -48
arch/mips/netlogic/xlr/smp.c arch/mips/netlogic/common/smp.c
··· 42 42 43 43 #include <asm/netlogic/interrupt.h> 44 44 #include <asm/netlogic/mips-extns.h> 45 + #include <asm/netlogic/haldefs.h> 46 + #include <asm/netlogic/common.h> 45 47 46 48 #include <asm/netlogic/xlr/iomap.h> 47 49 #include <asm/netlogic/xlr/pic.h> 48 - #include <asm/netlogic/xlr/xlr.h> 49 50 50 - void core_send_ipi(int logical_cpu, unsigned int action) 51 + void nlm_send_ipi_single(int logical_cpu, unsigned int action) 51 52 { 52 53 int cpu = cpu_logical_map(logical_cpu); 53 - u32 tid = cpu & 0x3; 54 - u32 pid = (cpu >> 2) & 0x07; 55 - u32 ipi = (tid << 16) | (pid << 20); 56 54 57 55 if (action & SMP_CALL_FUNCTION) 58 - ipi |= IRQ_IPI_SMP_FUNCTION; 59 - else if (action & SMP_RESCHEDULE_YOURSELF) 60 - ipi |= IRQ_IPI_SMP_RESCHEDULE; 61 - else 62 - return; 63 - 64 - pic_send_ipi(ipi); 65 - } 66 - 67 - void nlm_send_ipi_single(int cpu, unsigned int action) 68 - { 69 - core_send_ipi(cpu, action); 56 + nlm_pic_send_ipi(nlm_pic_base, cpu, IRQ_IPI_SMP_FUNCTION, 0); 57 + if (action & SMP_RESCHEDULE_YOURSELF) 58 + nlm_pic_send_ipi(nlm_pic_base, cpu, IRQ_IPI_SMP_RESCHEDULE, 0); 70 59 } 71 60 72 61 void nlm_send_ipi_mask(const struct cpumask *mask, unsigned int action) ··· 63 74 int cpu; 64 75 65 76 for_each_cpu(cpu, mask) { 66 - core_send_ipi(cpu, action); 77 + nlm_send_ipi_single(cpu, action); 67 78 } 68 79 } 69 80 ··· 71 82 void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc) 72 83 { 73 84 smp_call_function_interrupt(); 85 + write_c0_eirr(1ull << irq); 74 86 } 75 87 76 88 /* IRQ_IPI_SMP_RESCHEDULE handler */ 77 89 void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc) 78 90 { 79 91 scheduler_ipi(); 92 + write_c0_eirr(1ull << irq); 80 93 } 81 94 82 95 /* 83 96 * Called before going into mips code, early cpu init 84 97 */ 85 - void nlm_early_init_secondary(void) 98 + void nlm_early_init_secondary(int cpu) 86 99 { 87 100 write_c0_ebase((uint32_t)nlm_common_ebase); 88 - /* TLB partition here later */ 101 + #ifdef NLM_XLP 102 + if (cpu % 4 == 0) 103 + xlp_mmu_init(); 104 + #endif 89 105 } 90 106 91 107 /* ··· 153 159 num_cpus = 1; 154 160 for (i = 0; i < NR_CPUS; i++) { 155 161 /* 156 - * BSP is not set in nlm_cpu_ready array, it is only for 157 - * ASPs (goto see smpboot.S) 162 + * nlm_cpu_ready array is not set for the boot_cpu, 163 + * it is only set for ASPs (see smpboot.S) 158 164 */ 159 165 if (nlm_cpu_ready[i]) { 160 166 cpu_set(i, phys_cpu_present_map); ··· 186 192 .smp_setup = nlm_smp_setup, 187 193 .prepare_cpus = nlm_prepare_cpus, 188 194 }; 189 - 190 - unsigned long secondary_entry_point; 191 - 192 - int __cpuinit nlm_wakeup_secondary_cpus(u32 wakeup_mask) 193 - { 194 - unsigned int tid, pid, ipi, i, boot_cpu; 195 - void *reset_vec; 196 - 197 - secondary_entry_point = (unsigned long)prom_pre_boot_secondary_cpus; 198 - reset_vec = (void *)CKSEG1ADDR(0x1fc00000); 199 - memcpy(reset_vec, nlm_boot_smp_nmi, 0x80); 200 - boot_cpu = hard_smp_processor_id(); 201 - 202 - for (i = 0; i < NR_CPUS; i++) { 203 - if (i == boot_cpu) 204 - continue; 205 - if (wakeup_mask & (1u << i)) { 206 - tid = i & 0x3; 207 - pid = (i >> 2) & 0x7; 208 - ipi = (tid << 16) | (pid << 20) | (1 << 8); 209 - pic_send_ipi(ipi); 210 - } 211 - } 212 - 213 - return 0; 214 - }
+3 -3
arch/mips/netlogic/xlr/smpboot.S
··· 75 75 jr t0 76 76 nop 77 77 END(prom_pre_boot_secondary_cpus) 78 - __FINIT 79 78 80 79 /* 81 80 * NMI code, used for CPU wakeup, copied to reset entry 82 81 */ 83 - NESTED(nlm_boot_smp_nmi, 0, sp) 82 + EXPORT(nlm_reset_entry) 84 83 .set push 85 84 .set noat 86 85 .set mips64 ··· 96 97 jr k0 97 98 nop 98 99 .set pop 99 - END(nlm_boot_smp_nmi) 100 + EXPORT(nlm_reset_entry_end) 101 + __FINIT
+12 -12
arch/mips/netlogic/xlr/time.c arch/mips/netlogic/common/earlycons.c
··· 32 32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 33 */ 34 34 35 - #include <linux/init.h> 35 + #include <linux/types.h> 36 + #include <linux/serial_reg.h> 36 37 37 - #include <asm/time.h> 38 - #include <asm/netlogic/interrupt.h> 39 - #include <asm/netlogic/psb-bootinfo.h> 38 + #include <asm/mipsregs.h> 39 + #include <asm/netlogic/haldefs.h> 40 40 41 - unsigned int __cpuinit get_c0_compare_int(void) 41 + #include <asm/netlogic/xlr/iomap.h> 42 + 43 + void prom_putchar(char c) 42 44 { 43 - return IRQ_TIMER; 44 - } 45 + uint64_t uartbase; 45 46 46 - void __init plat_time_init(void) 47 - { 48 - mips_hpt_frequency = nlm_prom_info.cpu_frequency; 49 - pr_info("MIPS counter frequency [%ld]\n", 50 - (unsigned long)mips_hpt_frequency); 47 + uartbase = nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET); 48 + while (nlm_read_reg(uartbase, UART_LSR) == 0) 49 + ; 50 + nlm_write_reg(uartbase, UART_TX, c); 51 51 }
+32 -7
arch/mips/netlogic/xlr/xlr_console.c arch/mips/netlogic/xlr/wakeup.c
··· 32 32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 33 */ 34 34 35 - #include <linux/types.h> 35 + #include <linux/init.h> 36 + #include <linux/threads.h> 37 + 38 + #include <asm/asm.h> 39 + #include <asm/asm-offsets.h> 40 + #include <asm/mipsregs.h> 41 + #include <asm/addrspace.h> 42 + #include <asm/string.h> 43 + 44 + #include <asm/netlogic/haldefs.h> 45 + #include <asm/netlogic/common.h> 46 + #include <asm/netlogic/mips-extns.h> 47 + 36 48 #include <asm/netlogic/xlr/iomap.h> 49 + #include <asm/netlogic/xlr/pic.h> 37 50 38 - void prom_putchar(char c) 51 + unsigned long secondary_entry_point; 52 + 53 + int __cpuinit nlm_wakeup_secondary_cpus(u32 wakeup_mask) 39 54 { 40 - nlm_reg_t *mmio; 55 + unsigned int i, boot_cpu; 56 + void *reset_vec; 41 57 42 - mmio = netlogic_io_mmio(NETLOGIC_IO_UART_0_OFFSET); 43 - while (netlogic_read_reg(mmio, 0x5) == 0) 44 - ; 45 - netlogic_write_reg(mmio, 0x0, c); 58 + secondary_entry_point = (unsigned long)prom_pre_boot_secondary_cpus; 59 + reset_vec = (void *)CKSEG1ADDR(0x1fc00000); 60 + memcpy(reset_vec, (void *)nlm_reset_entry, 61 + (nlm_reset_entry_end - nlm_reset_entry)); 62 + boot_cpu = hard_smp_processor_id(); 63 + 64 + for (i = 0; i < NR_CPUS; i++) { 65 + if (i == boot_cpu || (wakeup_mask & (1u << i)) == 0) 66 + continue; 67 + nlm_pic_send_ipi(nlm_pic_base, i, 1, 1); /* send NMI */ 68 + } 69 + 70 + return 0; 46 71 }
+77
arch/mips/pci/pci-xlr.c
··· 45 45 #include <asm/io.h> 46 46 47 47 #include <asm/netlogic/interrupt.h> 48 + #include <asm/netlogic/haldefs.h> 49 + 48 50 #include <asm/netlogic/xlr/msidef.h> 49 51 #include <asm/netlogic/xlr/iomap.h> 50 52 #include <asm/netlogic/xlr/pic.h> ··· 228 226 } 229 227 #endif 230 228 229 + /* Extra ACK needed for XLR on chip PCI controller */ 230 + static void xlr_pci_ack(struct irq_data *d) 231 + { 232 + uint64_t pcibase = nlm_mmio_base(NETLOGIC_IO_PCIX_OFFSET); 233 + 234 + nlm_read_reg(pcibase, (0x140 >> 2)); 235 + } 236 + 237 + /* Extra ACK needed for XLS on chip PCIe controller */ 238 + static void xls_pcie_ack(struct irq_data *d) 239 + { 240 + uint64_t pciebase_le = nlm_mmio_base(NETLOGIC_IO_PCIE_1_OFFSET); 241 + 242 + switch (d->irq) { 243 + case PIC_PCIE_LINK0_IRQ: 244 + nlm_write_reg(pciebase_le, (0x90 >> 2), 0xffffffff); 245 + break; 246 + case PIC_PCIE_LINK1_IRQ: 247 + nlm_write_reg(pciebase_le, (0x94 >> 2), 0xffffffff); 248 + break; 249 + case PIC_PCIE_LINK2_IRQ: 250 + nlm_write_reg(pciebase_le, (0x190 >> 2), 0xffffffff); 251 + break; 252 + case PIC_PCIE_LINK3_IRQ: 253 + nlm_write_reg(pciebase_le, (0x194 >> 2), 0xffffffff); 254 + break; 255 + } 256 + } 257 + 258 + /* For XLS B silicon, the 3,4 PCI interrupts are different */ 259 + static void xls_pcie_ack_b(struct irq_data *d) 260 + { 261 + uint64_t pciebase_le = nlm_mmio_base(NETLOGIC_IO_PCIE_1_OFFSET); 262 + 263 + switch (d->irq) { 264 + case PIC_PCIE_LINK0_IRQ: 265 + nlm_write_reg(pciebase_le, (0x90 >> 2), 0xffffffff); 266 + break; 267 + case PIC_PCIE_LINK1_IRQ: 268 + nlm_write_reg(pciebase_le, (0x94 >> 2), 0xffffffff); 269 + break; 270 + case PIC_PCIE_XLSB0_LINK2_IRQ: 271 + nlm_write_reg(pciebase_le, (0x190 >> 2), 0xffffffff); 272 + break; 273 + case PIC_PCIE_XLSB0_LINK3_IRQ: 274 + nlm_write_reg(pciebase_le, (0x194 >> 2), 0xffffffff); 275 + break; 276 + } 277 + } 278 + 231 279 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 232 280 { 233 281 return get_irq_vector(dev); ··· 304 252 305 253 pr_info("Registering XLR/XLS PCIX/PCIE Controller.\n"); 306 254 register_pci_controller(&nlm_pci_controller); 255 + 256 + /* 257 + * For PCI interrupts, we need to ack the PCI controller too, overload 258 + * irq handler data to do this 259 + */ 260 + if (nlm_chip_is_xls()) { 261 + if (nlm_chip_is_xls_b()) { 262 + irq_set_handler_data(PIC_PCIE_LINK0_IRQ, 263 + xls_pcie_ack_b); 264 + irq_set_handler_data(PIC_PCIE_LINK1_IRQ, 265 + xls_pcie_ack_b); 266 + irq_set_handler_data(PIC_PCIE_XLSB0_LINK2_IRQ, 267 + xls_pcie_ack_b); 268 + irq_set_handler_data(PIC_PCIE_XLSB0_LINK3_IRQ, 269 + xls_pcie_ack_b); 270 + } else { 271 + irq_set_handler_data(PIC_PCIE_LINK0_IRQ, xls_pcie_ack); 272 + irq_set_handler_data(PIC_PCIE_LINK1_IRQ, xls_pcie_ack); 273 + irq_set_handler_data(PIC_PCIE_LINK2_IRQ, xls_pcie_ack); 274 + irq_set_handler_data(PIC_PCIE_LINK3_IRQ, xls_pcie_ack); 275 + } 276 + } else { 277 + /* XLR PCI controller ACK */ 278 + irq_set_handler_data(PIC_PCIE_XLSB0_LINK3_IRQ, xlr_pci_ack); 279 + } 307 280 308 281 return 0; 309 282 }