MIPS: Netlogic: Move code common with XLP to common/
PATCH 4/12 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
--- arch/mips/include/asm/netlogic/common.h | 56 +++++ arch/mips/include/asm/netlogic/haldefs.h | 142 +++++++++++++ arch/mips/include/asm/netlogic/xlr/iomap.h | 22 -- arch/mips/include/asm/netlogic/xlr/pic.h | 69 +++++-- arch/mips/include/asm/netlogic/xlr/xlr.h | 11 - arch/mips/netlogic/Makefile | 2 + arch/mips/netlogic/Platform | 2 +- arch/mips/netlogic/common/Makefile | 3 + arch/mips/netlogic/common/earlycons.c | 51 +++++ arch/mips/netlogic/common/irq.c | 230 +++++++++++++++++++++ arch/mips/netlogic/common/smp.c | 184 +++++++++++++++++ arch/mips/netlogic/common/time.c | 51 +++++ arch/mips/netlogic/xlr/Makefile | 5 +- arch/mips/netlogic/xlr/irq.c | 305 ---------------------------- arch/mips/netlogic/xlr/platform.c | 31 ++-- arch/mips/netlogic/xlr/setup.c | 24 ++- arch/mips/netlogic/xlr/smp.c | 216 -------------------- arch/mips/netlogic/xlr/smpboot.S | 6 +- arch/mips/netlogic/xlr/time.c | 51 ----- arch/mips/netlogic/xlr/wakeup.c | 71 +++++++ arch/mips/netlogic/xlr/xlr_console.c | 46 ---- arch/mips/pci/pci-xlr.c | 77 +++++++ 22 files changed, 956 insertions(+), 699 deletions(-) create mode 100644 arch/mips/include/asm/netlogic/common.h create mode 100644 arch/mips/include/asm/netlogic/haldefs.h create mode 100644 arch/mips/netlogic/Makefile create mode 100644 arch/mips/netlogic/common/Makefile create mode 100644 arch/mips/netlogic/common/earlycons.c create mode 100644 arch/mips/netlogic/common/irq.c create mode 100644 arch/mips/netlogic/common/smp.c create mode 100644 arch/mips/netlogic/common/time.c delete mode 100644 arch/mips/netlogic/xlr/irq.c delete mode 100644 arch/mips/netlogic/xlr/smp.c delete mode 100644 arch/mips/netlogic/xlr/time.c create mode 100644 arch/mips/netlogic/xlr/wakeup.c delete mode 100644 arch/mips/netlogic/xlr/xlr_console.c
arch/mips/include/asm/netlogic/common.h new file +56 -0
@@ -0,0 +1,56 @@ +/* +* Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights +* reserved. +* +* This software is available to you under a choice of one of two +* licenses. You may choose to be licensed under the terms of the GNU +* General Public License (GPL) Version 2, available from the file +* COPYING in the main directory of this source tree, or the NetLogic +* license below: +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _NETLOGIC_COMMON_H_ +#define _NETLOGIC_COMMON_H_ + +/* +* Common SMP definitions +*/ +struct irq_desc ; +extern struct plat_smp_ops nlm_smp_ops; +extern char nlm_reset_entry[], nlm_reset_entry_end[]; +void nlm_smp_function_ipi_handler (unsigned int irq,struct irq_desc *desc); +void nlm_smp_resched_ipi_handler (unsigned int irq,struct irq_desc *desc); +void nlm_smp_irq_init (void ); +void prom_pre_boot_secondary_cpus (void ); +int nlm_wakeup_secondary_cpus (u32 wakeup_mask); +void nlm_boot_smp_nmi (void ); + +/* +* Misc. +*/ +extern unsigned long nlm_common_ebase; +unsigned int nlm_get_cpu_frequency (void ); +#endif /* _NETLOGIC_COMMON_H_ */
arch/mips/include/asm/netlogic/haldefs.h new file +142 -0
142 lines not on this page · raw message
arch/mips/include/asm/netlogic/xlr/iomap.h +0 -22
@@ -106,26 +106,4 @@#define DEFAULT_HT_TYPE0_CFG_BASE 0x16000000#define DEFAULT_HT_TYPE1_CFG_BASE 0x17000000 -#ifndef __ASSEMBLY__ -#include <linux/types.h> -#include <asm/byteorder.h> - -typedef volatile __u32 nlm_reg_t ; -extern unsigned long netlogic_io_base; - -/* FIXME read once in write_reg */ -#ifdef CONFIG_CPU_LITTLE_ENDIAN -#define netlogic_read_reg (base, offset) ((base)[(offset)]) -#define netlogic_write_reg (base, offset, value) ((base)[(offset)] = (value)) -#else -#define netlogic_read_reg (base, offset) (be32_to_cpu((base)[(offset)])) -#define netlogic_write_reg (base, offset, value) \ - ((base)[(offset)] = cpu_to_be32((value))) -#endif - -#define netlogic_read_reg_le32 (base, offset) (le32_to_cpu((base)[(offset)])) -#define netlogic_write_reg_le32 (base, offset, value) \ - ((base)[(offset)] = cpu_to_le32((value))) -#define netlogic_io_mmio (offset) ((nlm_reg_t *)(netlogic_io_base+(offset))) -#endif /* __ASSEMBLY__ */ #endif
arch/mips/include/asm/netlogic/xlr/pic.h +51 -18
90 lines not on this page · raw message
arch/mips/include/asm/netlogic/xlr/xlr.h +0 -11
@@ -40,17 +40,6 @@ struct uart_port;unsigned int nlm_xlr_uart_in (struct uart_port *,int );void nlm_xlr_uart_out (struct uart_port *,int ,int ); -/* SMP support functions */ -struct irq_desc ; -void nlm_smp_function_ipi_handler (unsigned int irq,struct irq_desc *desc); -void nlm_smp_resched_ipi_handler (unsigned int irq,struct irq_desc *desc); -int nlm_wakeup_secondary_cpus (u32 wakeup_mask); -void nlm_smp_irq_init (void ); -void nlm_boot_smp_nmi (void ); -void prom_pre_boot_secondary_cpus (void ); - -extern struct plat_smp_ops nlm_smp_ops; -extern unsigned long nlm_common_ebase;/* XLS B silicon "Rook" */ static inline unsigned int nlm_chip_is_xls_b (void )
arch/mips/netlogic/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_NLM_COMMON) += common/ +obj-$(CONFIG_CPU_XLR) += xlr/
arch/mips/netlogic/Platform +1 -1
@@ -12,5 +12,5 @@ cflags-$(CONFIG_CPU_XLR) += $(call cc-option,-march=xlr,-march=mips64) # # NETLOGIC processor support # -platform-$(CONFIG_CPU_XLR) += netlogic/xlr +platform-$(CONFIG_NLM_COMMON) += netlogic/ load-$(CONFIG_NLM_COMMON) += 0xffffffff80100000
arch/mips/netlogic/common/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-y += irq.o time.o +obj-$(CONFIG_SMP) += smp.o +obj-$(CONFIG_EARLY_PRINTK) += earlycons.o
arch/mips/netlogic/common/earlycons.c new file +51 -0
51 lines not on this page · raw message
arch/mips/netlogic/common/irq.c new file +230 -0
230 lines not on this page · raw message
arch/mips/netlogic/common/smp.c new file +184 -0
184 lines not on this page · raw message
arch/mips/netlogic/common/time.c new file +51 -0
51 lines not on this page · raw message
arch/mips/netlogic/xlr/Makefile +2 -3
@@ -1,3 +1,2 @@ -obj-y += setup.o platform.o irq.o setup.o time.o -obj-$(CONFIG_SMP) += smp.o smpboot.o -obj-$(CONFIG_EARLY_PRINTK) += xlr_console.o +obj-y += setup.o platform.o +obj-$(CONFIG_SMP) += smpboot.o wakeup.o
arch/mips/netlogic/xlr/irq.c deleted +0 -305
305 lines not on this page · raw message
arch/mips/netlogic/xlr/platform.c +16 -15
@@ -15,18 +15,19 @@#include <linux/serial_8250.h> #include <linux/serial_reg.h> +#include <asm/netlogic/haldefs.h> #include <asm/netlogic/xlr/iomap.h> #include <asm/netlogic/xlr/pic.h> #include <asm/netlogic/xlr/xlr.h> unsigned int nlm_xlr_uart_in (struct uart_port *p,int offset) { -nlm_reg_t *mmio; +uint64_t uartbase;unsigned int value; -/* XLR uart does not need any mapping of regs */ - mmio = (nlm_reg_t *)(p->membase + (offset << p->regshift)); - value =netlogic_read_reg (mmio,0 ); +/* sign extend to 64 bits, if needed */ + uartbase = (uint64_t )(long )p->membase; + value =nlm_read_reg (uartbase, offset);/* See XLR/XLS errata */ if (offset ==UART_MSR )
@@ -39,10 +40,10 @@ unsigned int nlm_xlr_uart_in(struct uart_port *p, int offset)void nlm_xlr_uart_out (struct uart_port *p,int offset,int value) { -nlm_reg_t *mmio; +uint64_t uartbase; -/* XLR uart does not need any mapping of regs */ - mmio = (nlm_reg_t *)(p->membase + (offset << p->regshift)); +/* sign extend to 64 bits, if needed */ + uartbase = (uint64_t )(long )p->membase;/* See XLR/XLS errata */ if (offset ==UART_MSR )
@@ -50,7 +51,7 @@ void nlm_xlr_uart_out(struct uart_port *p, int offset, int value)else if (offset ==UART_MCR ) value ^=0x3 ; -netlogic_write_reg (mmio,0 , value); +nlm_write_reg (uartbase, offset, value); }#define PORT (_irq) \
@@ -82,15 +83,15 @@ static struct platform_device uart_device = {static int __init nlm_uart_init (void ) { -nlm_reg_t *mmio; +unsigned long uartbase; - mmio =netlogic_io_mmio (NETLOGIC_IO_UART_0_OFFSET ); - xlr_uart_data[0 ].membase = (void __iomem *)mmio; - xlr_uart_data[0 ].mapbase =CPHYSADDR ((unsigned long )mmio); + uartbase = (unsigned long )nlm_mmio_base (NETLOGIC_IO_UART_0_OFFSET ); + xlr_uart_data[0 ].membase = (void __iomem *)uartbase; + xlr_uart_data[0 ].mapbase =CPHYSADDR (uartbase); - mmio =netlogic_io_mmio (NETLOGIC_IO_UART_1_OFFSET ); - xlr_uart_data[1 ].membase = (void __iomem *)mmio; - xlr_uart_data[1 ].mapbase =CPHYSADDR ((unsigned long )mmio); + uartbase = (unsigned long )nlm_mmio_base (NETLOGIC_IO_UART_1_OFFSET ); + xlr_uart_data[1 ].membase = (void __iomem *)uartbase; + xlr_uart_data[1 ].mapbase =CPHYSADDR (uartbase);return platform_device_register (&uart_device); }
arch/mips/netlogic/xlr/setup.c +16 -8
@@ -39,26 +39,28 @@#include <asm/reboot.h> #include <asm/time.h> #include <asm/bootinfo.h> -#include <asm/smp-ops.h> #include <asm/netlogic/interrupt.h> #include <asm/netlogic/psb-bootinfo.h> +#include <asm/netlogic/haldefs.h> +#include <asm/netlogic/common.h> #include <asm/netlogic/xlr/xlr.h> #include <asm/netlogic/xlr/iomap.h> #include <asm/netlogic/xlr/pic.h> #include <asm/netlogic/xlr/gpio.h> -unsigned long netlogic_io_base = (unsigned long )(DEFAULT_NETLOGIC_IO_BASE ); +uint64_t nlm_io_base =DEFAULT_NETLOGIC_IO_BASE ; +uint64_t nlm_pic_base;unsigned long nlm_common_ebase =0x0 ;struct psb_info nlm_prom_info;static void __init nlm_early_serial_setup (void ) {struct uart_port s; -nlm_reg_t *uart_base; +unsigned long uart_base; - uart_base =netlogic_io_mmio (NETLOGIC_IO_UART_0_OFFSET ); + uart_base = (unsigned long )nlm_mmio_base (NETLOGIC_IO_UART_0_OFFSET );memset (&s,0 ,sizeof (s)); s.flags =ASYNC_BOOT_AUTOCONF |ASYNC_SKIP_TEST ; s.iotype =UPIO_MEM32 ;
@@ -67,18 +69,18 @@ static void __init nlm_early_serial_setup(void) s.uartclk =PIC_CLKS_PER_SEC ; s.serial_in = nlm_xlr_uart_in; s.serial_out = nlm_xlr_uart_out; - s.mapbase = (unsigned long )uart_base; + s.mapbase = uart_base; s.membase = (unsigned char __iomem *)uart_base;early_serial_setup (&s); }static void nlm_linux_exit (void ) { -nlm_reg_t *mmio; +uint64_t gpiobase; - mmio =netlogic_io_mmio (NETLOGIC_IO_GPIO_OFFSET ); + gpiobase =nlm_mmio_base (NETLOGIC_IO_GPIO_OFFSET );/* trigger a chip reset by writing 1 to GPIO_SWRESET_REG */ -netlogic_write_reg (mmio,NETLOGIC_GPIO_SWRESET_REG ,1 ); +nlm_write_reg (gpiobase,NETLOGIC_GPIO_SWRESET_REG ,1 );for ( ; ; )cpu_wait (); }
@@ -96,6 +98,11 @@ const char *get_system_type(void)return "Netlogic XLR/XLS Series" ; } +unsigned int nlm_get_cpu_frequency (void ) +{ +return (unsigned int )nlm_prom_info.cpu_frequency; +} +void __init prom_free_prom_memory (void ) {/* Nothing yet */
@@ -175,6 +182,7 @@ void __init prom_init(void) prom_infop = (struct psb_info *)(long )(int )fw_arg3; nlm_prom_info = *prom_infop; + nlm_pic_base =nlm_mmio_base (NETLOGIC_IO_PIC_OFFSET );nlm_early_serial_setup ();build_arcs_cmdline (argv);
arch/mips/netlogic/xlr/smp.c deleted +0 -216
216 lines not on this page · raw message
arch/mips/netlogic/xlr/smpboot.S +3 -3
@@ -75,12 +75,11 @@ NESTED(prom_pre_boot_secondary_cpus, 16, sp) jr t0 nop END(prom_pre_boot_secondary_cpus) - __FINIT /* * NMI code, used for CPU wakeup, copied to reset entry */ -NESTED(nlm_boot_smp_nmi, 0, sp) +EXPORT(nlm_reset_entry) .set push .set noat .set mips64
@@ -97,4 +96,5 @@ NESTED(nlm_boot_smp_nmi, 0, sp) jr k0 nop .set pop -END(nlm_boot_smp_nmi) +EXPORT(nlm_reset_entry_end) + __FINIT
arch/mips/netlogic/xlr/time.c deleted +0 -51
51 lines not on this page · raw message
arch/mips/netlogic/xlr/wakeup.c new file +71 -0
71 lines not on this page · raw message
arch/mips/netlogic/xlr/xlr_console.c deleted +0 -46
46 lines not on this page · raw message
arch/mips/pci/pci-xlr.c +77 -0
95 lines not on this page · raw message
Signature · 1 line
1.7.4.1