Commit 85749d24bcf90440b10394312e5b1c96d1a62cdb
Committed by
Ralf Baechle
1 parent
8e4971175a
Exists in
master
and in
4 other branches
MIPS: Loongson: Split common loongson source code out
To share common loongson source code between all of the loongson-based machines. there is a need to split it out of the fuloong-2e/ directory. at the same time, other according tuning is needed. the machine-specific parts are defined as macros in relative header file, pci.h, mem.h, machine.h. Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Showing 33 changed files with 720 additions and 502 deletions Side-by-side Diff
- arch/mips/Kconfig
- arch/mips/Makefile
- arch/mips/include/asm/mach-loongson/loongson.h
- arch/mips/include/asm/mach-loongson/machine.h
- arch/mips/include/asm/mach-loongson/mem.h
- arch/mips/include/asm/mach-loongson/pci.h
- arch/mips/loongson/Kconfig
- arch/mips/loongson/Makefile
- arch/mips/loongson/common/Makefile
- arch/mips/loongson/common/bonito-irq.c
- arch/mips/loongson/common/cmdline.c
- arch/mips/loongson/common/early_printk.c
- arch/mips/loongson/common/env.c
- arch/mips/loongson/common/init.c
- arch/mips/loongson/common/irq.c
- arch/mips/loongson/common/machtype.c
- arch/mips/loongson/common/mem.c
- arch/mips/loongson/common/pci.c
- arch/mips/loongson/common/reset.c
- arch/mips/loongson/common/setup.c
- arch/mips/loongson/common/time.c
- arch/mips/loongson/fuloong-2e/Makefile
- arch/mips/loongson/fuloong-2e/bonito-irq.c
- arch/mips/loongson/fuloong-2e/cmdline.c
- arch/mips/loongson/fuloong-2e/early_printk.c
- arch/mips/loongson/fuloong-2e/env.c
- arch/mips/loongson/fuloong-2e/init.c
- arch/mips/loongson/fuloong-2e/irq.c
- arch/mips/loongson/fuloong-2e/machtype.c
- arch/mips/loongson/fuloong-2e/mem.c
- arch/mips/loongson/fuloong-2e/pci.c
- arch/mips/loongson/fuloong-2e/reset.c
- arch/mips/loongson/fuloong-2e/time.c
arch/mips/Kconfig
... | ... | @@ -174,31 +174,16 @@ |
174 | 174 | select SYS_SUPPORTS_64BIT_KERNEL if BROKEN |
175 | 175 | select SYS_SUPPORTS_LITTLE_ENDIAN |
176 | 176 | |
177 | -config LEMOTE_FULOONG2E | |
178 | - bool "Lemote Fuloong2e mini-PC" | |
179 | - select ARCH_SPARSEMEM_ENABLE | |
180 | - select CEVT_R4K | |
181 | - select CSRC_R4K | |
182 | - select SYS_HAS_CPU_LOONGSON2 | |
183 | - select DMA_NONCOHERENT | |
184 | - select BOOT_ELF32 | |
185 | - select BOARD_SCACHE | |
186 | - select HAVE_STD_PC_SERIAL_PORT | |
187 | - select HW_HAS_PCI | |
188 | - select I8259 | |
189 | - select ISA | |
190 | - select IRQ_CPU | |
191 | - select SYS_SUPPORTS_32BIT_KERNEL | |
192 | - select SYS_SUPPORTS_64BIT_KERNEL | |
193 | - select SYS_SUPPORTS_LITTLE_ENDIAN | |
194 | - select SYS_SUPPORTS_HIGHMEM | |
195 | - select SYS_HAS_EARLY_PRINTK | |
196 | - select GENERIC_ISA_DMA_SUPPORT_BROKEN | |
197 | - select CPU_HAS_WB | |
177 | +config MACH_LOONGSON | |
178 | + bool "Loongson family of machines" | |
198 | 179 | help |
199 | - Lemote Fuloong2e mini-PC board based on the Chinese Loongson-2E CPU and | |
200 | - an FPGA northbridge | |
180 | + This enables the support of Loongson family of machines. | |
201 | 181 | |
182 | + Loongson is a family of general-purpose MIPS-compatible CPUs. | |
183 | + developed at Institute of Computing Technology (ICT), | |
184 | + Chinese Academy of Sciences (CAS) in the People's Republic | |
185 | + of China. The chief architect is Professor Weiwu Hu. | |
186 | + | |
202 | 187 | config MIPS_MALTA |
203 | 188 | bool "MIPS Malta board" |
204 | 189 | select ARCH_MAY_HAVE_PC_FDC |
... | ... | @@ -668,6 +653,7 @@ |
668 | 653 | source "arch/mips/txx9/Kconfig" |
669 | 654 | source "arch/mips/vr41xx/Kconfig" |
670 | 655 | source "arch/mips/cavium-octeon/Kconfig" |
656 | +source "arch/mips/loongson/Kconfig" | |
671 | 657 | |
672 | 658 | endmenu |
673 | 659 |
arch/mips/Makefile
... | ... | @@ -314,11 +314,12 @@ |
314 | 314 | load-$(CONFIG_WR_PPMC) += 0xffffffff80100000 |
315 | 315 | |
316 | 316 | # |
317 | -# lemote fuloong2e mini-PC board | |
317 | +# Loongson family | |
318 | 318 | # |
319 | -core-$(CONFIG_LEMOTE_FULOONG2E) +=arch/mips/loongson/fuloong-2e/ | |
319 | +core-$(CONFIG_MACH_LOONGSON) +=arch/mips/loongson/ | |
320 | +cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-loongson \ | |
321 | + -mno-branch-likely | |
320 | 322 | load-$(CONFIG_LEMOTE_FULOONG2E) +=0xffffffff80100000 |
321 | -cflags-$(CONFIG_LEMOTE_FULOONG2E) += -I$(srctree)/arch/mips/include/asm/mach-loongson/ | |
322 | 323 | |
323 | 324 | # |
324 | 325 | # MIPS Malta board |
arch/mips/include/asm/mach-loongson/loongson.h
... | ... | @@ -21,6 +21,10 @@ |
21 | 21 | /* loongson internal northbridge initialization */ |
22 | 22 | extern void bonito_irq_init(void); |
23 | 23 | |
24 | +/* machine-specific reboot/halt operation */ | |
25 | +extern void mach_prepare_reboot(void); | |
26 | +extern void mach_prepare_shutdown(void); | |
27 | + | |
24 | 28 | /* environment arguments from bootloader */ |
25 | 29 | extern unsigned long bus_clock, cpu_clock_freq; |
26 | 30 | extern unsigned long memsize, highmemsize; |
... | ... | @@ -29,6 +33,13 @@ |
29 | 33 | extern void __init prom_init_memory(void); |
30 | 34 | extern void __init prom_init_cmdline(void); |
31 | 35 | extern void __init prom_init_env(void); |
36 | + | |
37 | +/* irq operation functions */ | |
38 | +extern void bonito_irqdispatch(void); | |
39 | +extern void __init bonito_irq_init(void); | |
40 | +extern void __init set_irq_trigger_mode(void); | |
41 | +extern void __init mach_init_irq(void); | |
42 | +extern void mach_irq_dispatch(unsigned int pending); | |
32 | 43 | |
33 | 44 | /* PCI Configuration Registers */ |
34 | 45 | #define LOONGSON_PCI_ISR4C BONITO_PCI_REG(0x4c) |
arch/mips/include/asm/mach-loongson/machine.h
1 | +/* | |
2 | + * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | |
3 | + * Author: Wu Zhangjin <wuzj@lemote.com> | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License as published by the | |
7 | + * Free Software Foundation; either version 2 of the License, or (at your | |
8 | + * option) any later version. | |
9 | + */ | |
10 | + | |
11 | +#ifndef __ASM_MACH_LOONGSON_MACHINE_H | |
12 | +#define __ASM_MACH_LOONGSON_MACHINE_H | |
13 | + | |
14 | +#ifdef CONFIG_LEMOTE_FULOONG2E | |
15 | + | |
16 | +#define LOONGSON_UART_BASE (BONITO_PCIIO_BASE + 0x3f8) | |
17 | + | |
18 | +#define LOONGSON_MACHNAME "lemote-fuloong-2e-box" | |
19 | + | |
20 | +#endif | |
21 | + | |
22 | +#endif /* __ASM_MACH_LOONGSON_MACHINE_H */ |
arch/mips/include/asm/mach-loongson/mem.h
1 | +/* | |
2 | + * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | |
3 | + * Author: Wu Zhangjin <wuzj@lemote.com> | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License as published by the | |
7 | + * Free Software Foundation; either version 2 of the License, or (at your | |
8 | + * option) any later version. | |
9 | + */ | |
10 | + | |
11 | +#ifndef __ASM_MACH_LOONGSON_MEM_H | |
12 | +#define __ASM_MACH_LOONGSON_MEM_H | |
13 | + | |
14 | +/* | |
15 | + * On Lemote Loongson 2e | |
16 | + * | |
17 | + * the high memory space starts from 512M. | |
18 | + * the peripheral registers reside between 0x1000:0000 and 0x2000:0000. | |
19 | + */ | |
20 | + | |
21 | +#ifdef CONFIG_LEMOTE_FULOONG2E | |
22 | + | |
23 | +#define LOONGSON_HIGHMEM_START 0x20000000 | |
24 | + | |
25 | +#define LOONGSON_MMIO_MEM_START 0x10000000 | |
26 | +#define LOONGSON_MMIO_MEM_END 0x20000000 | |
27 | + | |
28 | +#endif | |
29 | + | |
30 | +#endif /* __ASM_MACH_LOONGSON_MEM_H */ |
arch/mips/include/asm/mach-loongson/pci.h
... | ... | @@ -24,9 +24,15 @@ |
24 | 24 | |
25 | 25 | extern struct pci_ops bonito64_pci_ops; |
26 | 26 | |
27 | -#define LOONGSON2E_PCI_MEM_START BONITO_PCILO1_BASE | |
28 | -#define LOONGSON2E_PCI_MEM_END (BONITO_PCILO1_BASE + 0x04000000 * 2) | |
29 | -#define LOONGSON2E_PCI_IO_START 0x00004000UL | |
27 | +#ifdef CONFIG_LEMOTE_FULOONG2E | |
28 | + | |
29 | +/* this pci memory space is mapped by pcimap in pci.c */ | |
30 | +#define LOONGSON_PCI_MEM_START BONITO_PCILO1_BASE | |
31 | +#define LOONGSON_PCI_MEM_END (BONITO_PCILO1_BASE + 0x04000000 * 2) | |
32 | +/* this is an offset from mips_io_port_base */ | |
33 | +#define LOONGSON_PCI_IO_START 0x00004000UL | |
34 | + | |
35 | +#endif | |
30 | 36 | |
31 | 37 | #endif /* !__ASM_MACH_LOONGSON_PCI_H_ */ |
arch/mips/loongson/Kconfig
1 | +choice | |
2 | + prompt "Machine Type" | |
3 | + depends on MACH_LOONGSON | |
4 | + | |
5 | +config LEMOTE_FULOONG2E | |
6 | + bool "Lemote Fuloong(2e) mini-PC" | |
7 | + select ARCH_SPARSEMEM_ENABLE | |
8 | + select CEVT_R4K | |
9 | + select CSRC_R4K | |
10 | + select SYS_HAS_CPU_LOONGSON2 | |
11 | + select DMA_NONCOHERENT | |
12 | + select BOOT_ELF32 | |
13 | + select BOARD_SCACHE | |
14 | + select HW_HAS_PCI | |
15 | + select I8259 | |
16 | + select ISA | |
17 | + select IRQ_CPU | |
18 | + select SYS_SUPPORTS_32BIT_KERNEL | |
19 | + select SYS_SUPPORTS_64BIT_KERNEL | |
20 | + select SYS_SUPPORTS_LITTLE_ENDIAN | |
21 | + select SYS_SUPPORTS_HIGHMEM | |
22 | + select SYS_HAS_EARLY_PRINTK | |
23 | + select GENERIC_HARDIRQS_NO__DO_IRQ | |
24 | + select GENERIC_ISA_DMA_SUPPORT_BROKEN | |
25 | + select CPU_HAS_WB | |
26 | + help | |
27 | + Lemote Fuloong(2e) mini-PC board based on the Chinese Loongson-2E CPU and | |
28 | + an FPGA northbridge | |
29 | + | |
30 | + Lemote Fuloong(2e) mini PC have a VIA686B south bridge. | |
31 | +endchoice |
arch/mips/loongson/Makefile
arch/mips/loongson/common/Makefile
arch/mips/loongson/common/bonito-irq.c
1 | +/* | |
2 | + * Copyright 2001 MontaVista Software Inc. | |
3 | + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net | |
4 | + * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org) | |
5 | + * | |
6 | + * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
7 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
8 | + * | |
9 | + * This program is free software; you can redistribute it and/or modify it | |
10 | + * under the terms of the GNU General Public License as published by the | |
11 | + * Free Software Foundation; either version 2 of the License, or (at your | |
12 | + * option) any later version. | |
13 | + */ | |
14 | +#include <linux/interrupt.h> | |
15 | + | |
16 | +#include <loongson.h> | |
17 | + | |
18 | +static inline void bonito_irq_enable(unsigned int irq) | |
19 | +{ | |
20 | + BONITO_INTENSET = (1 << (irq - BONITO_IRQ_BASE)); | |
21 | + mmiowb(); | |
22 | +} | |
23 | + | |
24 | +static inline void bonito_irq_disable(unsigned int irq) | |
25 | +{ | |
26 | + BONITO_INTENCLR = (1 << (irq - BONITO_IRQ_BASE)); | |
27 | + mmiowb(); | |
28 | +} | |
29 | + | |
30 | +static struct irq_chip bonito_irq_type = { | |
31 | + .name = "bonito_irq", | |
32 | + .ack = bonito_irq_disable, | |
33 | + .mask = bonito_irq_disable, | |
34 | + .mask_ack = bonito_irq_disable, | |
35 | + .unmask = bonito_irq_enable, | |
36 | +}; | |
37 | + | |
38 | +static struct irqaction dma_timeout_irqaction = { | |
39 | + .handler = no_action, | |
40 | + .name = "dma_timeout", | |
41 | +}; | |
42 | + | |
43 | +void bonito_irq_init(void) | |
44 | +{ | |
45 | + u32 i; | |
46 | + | |
47 | + for (i = BONITO_IRQ_BASE; i < BONITO_IRQ_BASE + 32; i++) | |
48 | + set_irq_chip_and_handler(i, &bonito_irq_type, handle_level_irq); | |
49 | + | |
50 | + setup_irq(BONITO_IRQ_BASE + 10, &dma_timeout_irqaction); | |
51 | +} |
arch/mips/loongson/common/cmdline.c
1 | +/* | |
2 | + * Based on Ocelot Linux port, which is | |
3 | + * Copyright 2001 MontaVista Software Inc. | |
4 | + * Author: jsun@mvista.com or jsun@junsun.net | |
5 | + * | |
6 | + * Copyright 2003 ICT CAS | |
7 | + * Author: Michael Guo <guoyi@ict.ac.cn> | |
8 | + * | |
9 | + * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
10 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
11 | + * | |
12 | + * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
13 | + * Author: Wu Zhangjin, wuzj@lemote.com | |
14 | + * | |
15 | + * This program is free software; you can redistribute it and/or modify it | |
16 | + * under the terms of the GNU General Public License as published by the | |
17 | + * Free Software Foundation; either version 2 of the License, or (at your | |
18 | + * option) any later version. | |
19 | + */ | |
20 | +#include <asm/bootinfo.h> | |
21 | + | |
22 | +#include <loongson.h> | |
23 | + | |
24 | +int prom_argc; | |
25 | +/* pmon passes arguments in 32bit pointers */ | |
26 | +int *_prom_argv; | |
27 | + | |
28 | +void __init prom_init_cmdline(void) | |
29 | +{ | |
30 | + int i; | |
31 | + long l; | |
32 | + | |
33 | + /* firmware arguments are initialized in head.S */ | |
34 | + prom_argc = fw_arg0; | |
35 | + _prom_argv = (int *)fw_arg1; | |
36 | + | |
37 | + /* arg[0] is "g", the rest is boot parameters */ | |
38 | + arcs_cmdline[0] = '\0'; | |
39 | + for (i = 1; i < prom_argc; i++) { | |
40 | + l = (long)_prom_argv[i]; | |
41 | + if (strlen(arcs_cmdline) + strlen(((char *)l) + 1) | |
42 | + >= sizeof(arcs_cmdline)) | |
43 | + break; | |
44 | + strcat(arcs_cmdline, ((char *)l)); | |
45 | + strcat(arcs_cmdline, " "); | |
46 | + } | |
47 | + | |
48 | + if ((strstr(arcs_cmdline, "console=")) == NULL) | |
49 | + strcat(arcs_cmdline, " console=ttyS0,115200"); | |
50 | + if ((strstr(arcs_cmdline, "root=")) == NULL) | |
51 | + strcat(arcs_cmdline, " root=/dev/hda1"); | |
52 | +} |
arch/mips/loongson/common/early_printk.c
1 | +/* early printk support | |
2 | + * | |
3 | + * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca> | |
4 | + * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
5 | + * Author: Wu Zhangjin, wuzj@lemote.com | |
6 | + * | |
7 | + * This program is free software; you can redistribute it and/or modify it | |
8 | + * under the terms of the GNU General Public License as published by the | |
9 | + * Free Software Foundation; either version 2 of the License, or (at your | |
10 | + * option) any later version. | |
11 | + */ | |
12 | +#include <linux/serial_reg.h> | |
13 | + | |
14 | +#include <loongson.h> | |
15 | +#include <machine.h> | |
16 | + | |
17 | +#define PORT(base, offset) (u8 *)(base + offset) | |
18 | + | |
19 | +static inline unsigned int serial_in(phys_addr_t base, int offset) | |
20 | +{ | |
21 | + return readb(PORT(base, offset)); | |
22 | +} | |
23 | + | |
24 | +static inline void serial_out(phys_addr_t base, int offset, int value) | |
25 | +{ | |
26 | + writeb(value, PORT(base, offset)); | |
27 | +} | |
28 | + | |
29 | +void prom_putchar(char c) | |
30 | +{ | |
31 | + phys_addr_t uart_base = | |
32 | + (phys_addr_t) ioremap_nocache(LOONGSON_UART_BASE, 8); | |
33 | + | |
34 | + while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) | |
35 | + ; | |
36 | + | |
37 | + serial_out(uart_base, UART_TX, c); | |
38 | +} |
arch/mips/loongson/common/env.c
1 | +/* | |
2 | + * Based on Ocelot Linux port, which is | |
3 | + * Copyright 2001 MontaVista Software Inc. | |
4 | + * Author: jsun@mvista.com or jsun@junsun.net | |
5 | + * | |
6 | + * Copyright 2003 ICT CAS | |
7 | + * Author: Michael Guo <guoyi@ict.ac.cn> | |
8 | + * | |
9 | + * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
10 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
11 | + * | |
12 | + * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
13 | + * Author: Wu Zhangjin, wuzj@lemote.com | |
14 | + * | |
15 | + * This program is free software; you can redistribute it and/or modify it | |
16 | + * under the terms of the GNU General Public License as published by the | |
17 | + * Free Software Foundation; either version 2 of the License, or (at your | |
18 | + * option) any later version. | |
19 | + */ | |
20 | +#include <asm/bootinfo.h> | |
21 | + | |
22 | +#include <loongson.h> | |
23 | + | |
24 | +unsigned long bus_clock, cpu_clock_freq; | |
25 | +unsigned long memsize, highmemsize; | |
26 | + | |
27 | +/* pmon passes arguments in 32bit pointers */ | |
28 | +int *_prom_envp; | |
29 | + | |
30 | +#define parse_even_earlier(res, option, p) \ | |
31 | +do { \ | |
32 | + if (strncmp(option, (char *)p, strlen(option)) == 0) \ | |
33 | + strict_strtol((char *)p + strlen(option"="), \ | |
34 | + 10, &res); \ | |
35 | +} while (0) | |
36 | + | |
37 | +void __init prom_init_env(void) | |
38 | +{ | |
39 | + long l; | |
40 | + | |
41 | + /* firmware arguments are initialized in head.S */ | |
42 | + _prom_envp = (int *)fw_arg2; | |
43 | + | |
44 | + l = (long)*_prom_envp; | |
45 | + while (l != 0) { | |
46 | + parse_even_earlier(bus_clock, "busclock", l); | |
47 | + parse_even_earlier(cpu_clock_freq, "cpuclock", l); | |
48 | + parse_even_earlier(memsize, "memsize", l); | |
49 | + parse_even_earlier(highmemsize, "highmemsize", l); | |
50 | + _prom_envp++; | |
51 | + l = (long)*_prom_envp; | |
52 | + } | |
53 | + if (memsize == 0) | |
54 | + memsize = 256; | |
55 | + | |
56 | + pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n", | |
57 | + bus_clock, cpu_clock_freq, memsize, highmemsize); | |
58 | +} |
arch/mips/loongson/common/init.c
1 | +/* | |
2 | + * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
3 | + * Author: Wu Zhangjin, wuzj@lemote.com | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License as published by the | |
7 | + * Free Software Foundation; either version 2 of the License, or (at your | |
8 | + * option) any later version. | |
9 | + */ | |
10 | + | |
11 | +#include <linux/bootmem.h> | |
12 | + | |
13 | +#include <asm/bootinfo.h> | |
14 | + | |
15 | +#include <loongson.h> | |
16 | + | |
17 | +void __init prom_init(void) | |
18 | +{ | |
19 | + /* init base address of io space */ | |
20 | + set_io_port_base((unsigned long) | |
21 | + ioremap(BONITO_PCIIO_BASE, BONITO_PCIIO_SIZE)); | |
22 | + | |
23 | + prom_init_cmdline(); | |
24 | + prom_init_env(); | |
25 | + prom_init_memory(); | |
26 | +} | |
27 | + | |
28 | +void __init prom_free_prom_memory(void) | |
29 | +{ | |
30 | +} |
arch/mips/loongson/common/irq.c
1 | +/* | |
2 | + * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
3 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License as published by the | |
7 | + * Free Software Foundation; either version 2 of the License, or (at your | |
8 | + * option) any later version. | |
9 | + */ | |
10 | +#include <linux/delay.h> | |
11 | +#include <linux/interrupt.h> | |
12 | + | |
13 | +#include <loongson.h> | |
14 | +/* | |
15 | + * the first level int-handler will jump here if it is a bonito irq | |
16 | + */ | |
17 | +void bonito_irqdispatch(void) | |
18 | +{ | |
19 | + u32 int_status; | |
20 | + int i; | |
21 | + | |
22 | + /* workaround the IO dma problem: let cpu looping to allow DMA finish */ | |
23 | + int_status = BONITO_INTISR; | |
24 | + if (int_status & (1 << 10)) { | |
25 | + while (int_status & (1 << 10)) { | |
26 | + udelay(1); | |
27 | + int_status = BONITO_INTISR; | |
28 | + } | |
29 | + } | |
30 | + | |
31 | + /* Get pending sources, masked by current enables */ | |
32 | + int_status = BONITO_INTISR & BONITO_INTEN; | |
33 | + | |
34 | + if (int_status != 0) { | |
35 | + i = __ffs(int_status); | |
36 | + int_status &= ~(1 << i); | |
37 | + do_IRQ(BONITO_IRQ_BASE + i); | |
38 | + } | |
39 | +} | |
40 | + | |
41 | +asmlinkage void plat_irq_dispatch(void) | |
42 | +{ | |
43 | + unsigned int pending; | |
44 | + | |
45 | + pending = read_c0_cause() & read_c0_status() & ST0_IM; | |
46 | + | |
47 | + /* machine-specific plat_irq_dispatch */ | |
48 | + mach_irq_dispatch(pending); | |
49 | +} | |
50 | + | |
51 | +void __init arch_init_irq(void) | |
52 | +{ | |
53 | + /* | |
54 | + * Clear all of the interrupts while we change the able around a bit. | |
55 | + * int-handler is not on bootstrap | |
56 | + */ | |
57 | + clear_c0_status(ST0_IM | ST0_BEV); | |
58 | + local_irq_disable(); | |
59 | + | |
60 | + /* setting irq trigger mode */ | |
61 | + set_irq_trigger_mode(); | |
62 | + | |
63 | + /* no steer */ | |
64 | + BONITO_INTSTEER = 0; | |
65 | + | |
66 | + /* | |
67 | + * Mask out all interrupt by writing "1" to all bit position in | |
68 | + * the interrupt reset reg. | |
69 | + */ | |
70 | + BONITO_INTENCLR = ~0; | |
71 | + | |
72 | + /* machine specific irq init */ | |
73 | + mach_init_irq(); | |
74 | +} |
arch/mips/loongson/common/machtype.c
1 | +/* | |
2 | + * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
3 | + * Author: Wu Zhangjin, wuzj@lemote.com | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License as published by the | |
7 | + * Free Software Foundation; either version 2 of the License, or (at your | |
8 | + * option) any later version. | |
9 | + */ | |
10 | + | |
11 | +#include <machine.h> | |
12 | + | |
13 | +const char *get_system_type(void) | |
14 | +{ | |
15 | + return LOONGSON_MACHNAME; | |
16 | +} |
arch/mips/loongson/common/mem.c
1 | +/* | |
2 | + * This program is free software; you can redistribute it and/or modify it | |
3 | + * under the terms of the GNU General Public License as published by the | |
4 | + * Free Software Foundation; either version 2 of the License, or (at your | |
5 | + * option) any later version. | |
6 | + */ | |
7 | +#include <linux/fs.h> | |
8 | +#include <linux/fcntl.h> | |
9 | +#include <linux/mm.h> | |
10 | + | |
11 | +#include <asm/bootinfo.h> | |
12 | + | |
13 | +#include <loongson.h> | |
14 | +#include <mem.h> | |
15 | + | |
16 | +void __init prom_init_memory(void) | |
17 | +{ | |
18 | + add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); | |
19 | +#ifdef CONFIG_64BIT | |
20 | + if (highmemsize > 0) | |
21 | + add_memory_region(LOONGSON_HIGHMEM_START, | |
22 | + highmemsize << 20, BOOT_MEM_RAM); | |
23 | +#endif /* CONFIG_64BIT */ | |
24 | +} | |
25 | + | |
26 | +/* override of arch/mips/mm/cache.c: __uncached_access */ | |
27 | +int __uncached_access(struct file *file, unsigned long addr) | |
28 | +{ | |
29 | + if (file->f_flags & O_SYNC) | |
30 | + return 1; | |
31 | + | |
32 | + return addr >= __pa(high_memory) || | |
33 | + ((addr >= LOONGSON_MMIO_MEM_START) && | |
34 | + (addr < LOONGSON_MMIO_MEM_END)); | |
35 | +} |
arch/mips/loongson/common/pci.c
1 | +/* | |
2 | + * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | |
3 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License as published by the | |
7 | + * Free Software Foundation; either version 2 of the License, or (at your | |
8 | + * option) any later version. | |
9 | + */ | |
10 | +#include <linux/pci.h> | |
11 | + | |
12 | +#include <pci.h> | |
13 | +#include <loongson.h> | |
14 | + | |
15 | +static struct resource loongson_pci_mem_resource = { | |
16 | + .name = "pci memory space", | |
17 | + .start = LOONGSON_PCI_MEM_START, | |
18 | + .end = LOONGSON_PCI_MEM_END, | |
19 | + .flags = IORESOURCE_MEM, | |
20 | +}; | |
21 | + | |
22 | +static struct resource loongson_pci_io_resource = { | |
23 | + .name = "pci io space", | |
24 | + .start = LOONGSON_PCI_IO_START, | |
25 | + .end = IO_SPACE_LIMIT, | |
26 | + .flags = IORESOURCE_IO, | |
27 | +}; | |
28 | + | |
29 | +static struct pci_controller loongson_pci_controller = { | |
30 | + .pci_ops = &bonito64_pci_ops, | |
31 | + .io_resource = &loongson_pci_io_resource, | |
32 | + .mem_resource = &loongson_pci_mem_resource, | |
33 | + .mem_offset = 0x00000000UL, | |
34 | + .io_offset = 0x00000000UL, | |
35 | +}; | |
36 | + | |
37 | +static void __init setup_pcimap(void) | |
38 | +{ | |
39 | + /* | |
40 | + * local to PCI mapping for CPU accessing PCI space | |
41 | + * CPU address space [256M,448M] is window for accessing pci space | |
42 | + * we set pcimap_lo[0,1,2] to map it to pci space[0M,64M], [320M,448M] | |
43 | + * | |
44 | + * pcimap: PCI_MAP2 PCI_Mem_Lo2 PCI_Mem_Lo1 PCI_Mem_Lo0 | |
45 | + * [<2G] [384M,448M] [320M,384M] [0M,64M] | |
46 | + */ | |
47 | + BONITO_PCIMAP = BONITO_PCIMAP_PCIMAP_2 | | |
48 | + BONITO_PCIMAP_WIN(2, BONITO_PCILO2_BASE) | | |
49 | + BONITO_PCIMAP_WIN(1, BONITO_PCILO1_BASE) | | |
50 | + BONITO_PCIMAP_WIN(0, 0); | |
51 | + | |
52 | + /* | |
53 | + * PCI-DMA to local mapping: [2G,2G+256M] -> [0M,256M] | |
54 | + */ | |
55 | + BONITO_PCIBASE0 = 0x80000000ul; /* base: 2G -> mmap: 0M */ | |
56 | + /* size: 256M, burst transmission, pre-fetch enable, 64bit */ | |
57 | + LOONGSON_PCI_HIT0_SEL_L = 0xc000000cul; | |
58 | + LOONGSON_PCI_HIT0_SEL_H = 0xfffffffful; | |
59 | + LOONGSON_PCI_HIT1_SEL_L = 0x00000006ul; /* set this BAR as invalid */ | |
60 | + LOONGSON_PCI_HIT1_SEL_H = 0x00000000ul; | |
61 | + LOONGSON_PCI_HIT2_SEL_L = 0x00000006ul; /* set this BAR as invalid */ | |
62 | + LOONGSON_PCI_HIT2_SEL_H = 0x00000000ul; | |
63 | + | |
64 | + /* avoid deadlock of PCI reading/writing lock operation */ | |
65 | + LOONGSON_PCI_ISR4C = 0xd2000001ul; | |
66 | + | |
67 | + /* can not change gnt to break pci transfer when device's gnt not | |
68 | + deassert for some broken device */ | |
69 | + LOONGSON_PXARB_CFG = 0x00fe0105ul; | |
70 | +} | |
71 | + | |
72 | +static int __init pcibios_init(void) | |
73 | +{ | |
74 | + setup_pcimap(); | |
75 | + | |
76 | + loongson_pci_controller.io_map_base = mips_io_port_base; | |
77 | + | |
78 | + register_pci_controller(&loongson_pci_controller); | |
79 | + | |
80 | + return 0; | |
81 | +} | |
82 | + | |
83 | +arch_initcall(pcibios_init); |
arch/mips/loongson/common/reset.c
1 | +/* | |
2 | + * This program is free software; you can redistribute it and/or modify it | |
3 | + * under the terms of the GNU General Public License as published by the | |
4 | + * Free Software Foundation; either version 2 of the License, or (at your | |
5 | + * option) any later version. | |
6 | + * | |
7 | + * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | |
8 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
9 | + * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | |
10 | + * Author: Zhangjin Wu, wuzj@lemote.com | |
11 | + */ | |
12 | +#include <linux/init.h> | |
13 | +#include <linux/pm.h> | |
14 | + | |
15 | +#include <asm/reboot.h> | |
16 | + | |
17 | +#include <loongson.h> | |
18 | + | |
19 | +static void loongson_restart(char *command) | |
20 | +{ | |
21 | + /* do preparation for reboot */ | |
22 | + mach_prepare_reboot(); | |
23 | + | |
24 | + /* reboot via jumping to boot base address */ | |
25 | + ((void (*)(void))ioremap_nocache(BONITO_BOOT_BASE, 4)) (); | |
26 | +} | |
27 | + | |
28 | +static void loongson_halt(void) | |
29 | +{ | |
30 | + mach_prepare_shutdown(); | |
31 | + while (1) | |
32 | + ; | |
33 | +} | |
34 | + | |
35 | +static int __init mips_reboot_setup(void) | |
36 | +{ | |
37 | + _machine_restart = loongson_restart; | |
38 | + _machine_halt = loongson_halt; | |
39 | + pm_power_off = loongson_halt; | |
40 | + | |
41 | + return 0; | |
42 | +} | |
43 | + | |
44 | +arch_initcall(mips_reboot_setup); |
arch/mips/loongson/common/setup.c
1 | +/* | |
2 | + * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
3 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License as published by the | |
7 | + * Free Software Foundation; either version 2 of the License, or (at your | |
8 | + * option) any later version. | |
9 | + */ | |
10 | +#include <linux/module.h> | |
11 | + | |
12 | +#include <asm/wbflush.h> | |
13 | + | |
14 | +#include <loongson.h> | |
15 | + | |
16 | +#ifdef CONFIG_VT | |
17 | +#include <linux/console.h> | |
18 | +#include <linux/screen_info.h> | |
19 | +#endif | |
20 | + | |
21 | +void (*__wbflush)(void); | |
22 | +EXPORT_SYMBOL(__wbflush); | |
23 | + | |
24 | +static void wbflush_loongson(void) | |
25 | +{ | |
26 | + asm(".set\tpush\n\t" | |
27 | + ".set\tnoreorder\n\t" | |
28 | + ".set mips3\n\t" | |
29 | + "sync\n\t" | |
30 | + "nop\n\t" | |
31 | + ".set\tpop\n\t" | |
32 | + ".set mips0\n\t"); | |
33 | +} | |
34 | + | |
35 | +void __init plat_mem_setup(void) | |
36 | +{ | |
37 | + __wbflush = wbflush_loongson; | |
38 | + | |
39 | +#ifdef CONFIG_VT | |
40 | +#if defined(CONFIG_VGA_CONSOLE) | |
41 | + conswitchp = &vga_con; | |
42 | + | |
43 | + screen_info = (struct screen_info) { | |
44 | + 0, 25, /* orig-x, orig-y */ | |
45 | + 0, /* unused */ | |
46 | + 0, /* orig-video-page */ | |
47 | + 0, /* orig-video-mode */ | |
48 | + 80, /* orig-video-cols */ | |
49 | + 0, 0, 0, /* ega_ax, ega_bx, ega_cx */ | |
50 | + 25, /* orig-video-lines */ | |
51 | + VIDEO_TYPE_VGAC, /* orig-video-isVGA */ | |
52 | + 16 /* orig-video-points */ | |
53 | + }; | |
54 | +#elif defined(CONFIG_DUMMY_CONSOLE) | |
55 | + conswitchp = &dummy_con; | |
56 | +#endif | |
57 | +#endif | |
58 | +} |
arch/mips/loongson/common/time.c
1 | +/* | |
2 | + * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | |
3 | + * Author: Fuxin Zhang, zhangfx@lemote.com | |
4 | + * | |
5 | + * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
6 | + * Author: Wu Zhangjin, wuzj@lemote.com | |
7 | + * | |
8 | + * This program is free software; you can redistribute it and/or modify it | |
9 | + * under the terms of the GNU General Public License as published by the | |
10 | + * Free Software Foundation; either version 2 of the License, or (at your | |
11 | + * option) any later version. | |
12 | + */ | |
13 | +#include <asm/mc146818-time.h> | |
14 | +#include <asm/time.h> | |
15 | + | |
16 | +#include <loongson.h> | |
17 | + | |
18 | +void __init plat_time_init(void) | |
19 | +{ | |
20 | + /* setup mips r4k timer */ | |
21 | + mips_hpt_frequency = cpu_clock_freq / 2; | |
22 | +} | |
23 | + | |
24 | +unsigned long read_persistent_clock(void) | |
25 | +{ | |
26 | + return mc146818_get_cmos_time(); | |
27 | +} |
arch/mips/loongson/fuloong-2e/Makefile
... | ... | @@ -2,13 +2,7 @@ |
2 | 2 | # Makefile for Lemote Fuloong2e mini-PC board. |
3 | 3 | # |
4 | 4 | |
5 | -obj-y += setup.o init.o reset.o irq.o pci.o bonito-irq.o mem.o \ | |
6 | - env.o cmdline.o time.o machtype.o | |
7 | - | |
8 | -# | |
9 | -# Early printk support | |
10 | -# | |
11 | -obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | |
5 | +obj-y += irq.o reset.o machtype.o | |
12 | 6 | |
13 | 7 | EXTRA_CFLAGS += -Werror |
arch/mips/loongson/fuloong-2e/bonito-irq.c
1 | -/* | |
2 | - * Copyright 2001 MontaVista Software Inc. | |
3 | - * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net | |
4 | - * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org) | |
5 | - * | |
6 | - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
7 | - * Author: Fuxin Zhang, zhangfx@lemote.com | |
8 | - * | |
9 | - * This program is free software; you can redistribute it and/or modify it | |
10 | - * under the terms of the GNU General Public License as published by the | |
11 | - * Free Software Foundation; either version 2 of the License, or (at your | |
12 | - * option) any later version. | |
13 | - */ | |
14 | -#include <linux/interrupt.h> | |
15 | - | |
16 | -#include <loongson.h> | |
17 | - | |
18 | -static inline void bonito_irq_enable(unsigned int irq) | |
19 | -{ | |
20 | - BONITO_INTENSET = (1 << (irq - BONITO_IRQ_BASE)); | |
21 | - mmiowb(); | |
22 | -} | |
23 | - | |
24 | -static inline void bonito_irq_disable(unsigned int irq) | |
25 | -{ | |
26 | - BONITO_INTENCLR = (1 << (irq - BONITO_IRQ_BASE)); | |
27 | - mmiowb(); | |
28 | -} | |
29 | - | |
30 | -static struct irq_chip bonito_irq_type = { | |
31 | - .name = "bonito_irq", | |
32 | - .ack = bonito_irq_disable, | |
33 | - .mask = bonito_irq_disable, | |
34 | - .mask_ack = bonito_irq_disable, | |
35 | - .unmask = bonito_irq_enable, | |
36 | -}; | |
37 | - | |
38 | -static struct irqaction dma_timeout_irqaction = { | |
39 | - .handler = no_action, | |
40 | - .name = "dma_timeout", | |
41 | -}; | |
42 | - | |
43 | -void bonito_irq_init(void) | |
44 | -{ | |
45 | - u32 i; | |
46 | - | |
47 | - for (i = BONITO_IRQ_BASE; i < BONITO_IRQ_BASE + 32; i++) | |
48 | - set_irq_chip_and_handler(i, &bonito_irq_type, handle_level_irq); | |
49 | - | |
50 | - setup_irq(BONITO_IRQ_BASE + 10, &dma_timeout_irqaction); | |
51 | -} |
arch/mips/loongson/fuloong-2e/cmdline.c
1 | -/* | |
2 | - * Based on Ocelot Linux port, which is | |
3 | - * Copyright 2001 MontaVista Software Inc. | |
4 | - * Author: jsun@mvista.com or jsun@junsun.net | |
5 | - * | |
6 | - * Copyright 2003 ICT CAS | |
7 | - * Author: Michael Guo <guoyi@ict.ac.cn> | |
8 | - * | |
9 | - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
10 | - * Author: Fuxin Zhang, zhangfx@lemote.com | |
11 | - * | |
12 | - * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
13 | - * Author: Wu Zhangjin, wuzj@lemote.com | |
14 | - * | |
15 | - * This program is free software; you can redistribute it and/or modify it | |
16 | - * under the terms of the GNU General Public License as published by the | |
17 | - * Free Software Foundation; either version 2 of the License, or (at your | |
18 | - * option) any later version. | |
19 | - */ | |
20 | -#include <asm/bootinfo.h> | |
21 | - | |
22 | -#include <loongson.h> | |
23 | - | |
24 | -int prom_argc; | |
25 | -/* pmon passes arguments in 32bit pointers */ | |
26 | -int *_prom_argv; | |
27 | - | |
28 | -void __init prom_init_cmdline(void) | |
29 | -{ | |
30 | - int i; | |
31 | - long l; | |
32 | - | |
33 | - /* firmware arguments are initialized in head.S */ | |
34 | - prom_argc = fw_arg0; | |
35 | - _prom_argv = (int *)fw_arg1; | |
36 | - | |
37 | - /* arg[0] is "g", the rest is boot parameters */ | |
38 | - arcs_cmdline[0] = '\0'; | |
39 | - for (i = 1; i < prom_argc; i++) { | |
40 | - l = (long)_prom_argv[i]; | |
41 | - if (strlen(arcs_cmdline) + strlen(((char *)l) + 1) | |
42 | - >= sizeof(arcs_cmdline)) | |
43 | - break; | |
44 | - strcat(arcs_cmdline, ((char *)l)); | |
45 | - strcat(arcs_cmdline, " "); | |
46 | - } | |
47 | - | |
48 | - if ((strstr(arcs_cmdline, "console=")) == NULL) | |
49 | - strcat(arcs_cmdline, " console=ttyS0,115200"); | |
50 | - if ((strstr(arcs_cmdline, "root=")) == NULL) | |
51 | - strcat(arcs_cmdline, " root=/dev/hda1"); | |
52 | -} |
arch/mips/loongson/fuloong-2e/early_printk.c
1 | -/* early printk support | |
2 | - * | |
3 | - * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca> | |
4 | - * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
5 | - * Author: Wu Zhangjin, wuzj@lemote.com | |
6 | - * | |
7 | - * This program is free software; you can redistribute it and/or modify it | |
8 | - * under the terms of the GNU General Public License as published by the | |
9 | - * Free Software Foundation; either version 2 of the License, or (at your | |
10 | - * option) any later version. | |
11 | - */ | |
12 | -#include <linux/serial_reg.h> | |
13 | - | |
14 | -#include <loongson.h> | |
15 | - | |
16 | -#define UART_BASE (BONITO_PCIIO_BASE + 0x3f8) | |
17 | - | |
18 | -#define PORT(base, offset) (u8 *)(base + offset) | |
19 | - | |
20 | -static inline unsigned int serial_in(phys_addr_t base, int offset) | |
21 | -{ | |
22 | - return readb(PORT(base, offset)); | |
23 | -} | |
24 | - | |
25 | -static inline void serial_out(phys_addr_t base, int offset, int value) | |
26 | -{ | |
27 | - writeb(value, PORT(base, offset)); | |
28 | -} | |
29 | - | |
30 | -void prom_putchar(char c) | |
31 | -{ | |
32 | - phys_addr_t uart_base = | |
33 | - (phys_addr_t) ioremap_nocache(UART_BASE, 8); | |
34 | - | |
35 | - while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) | |
36 | - ; | |
37 | - | |
38 | - serial_out(uart_base, UART_TX, c); | |
39 | -} |
arch/mips/loongson/fuloong-2e/env.c
1 | -/* | |
2 | - * Based on Ocelot Linux port, which is | |
3 | - * Copyright 2001 MontaVista Software Inc. | |
4 | - * Author: jsun@mvista.com or jsun@junsun.net | |
5 | - * | |
6 | - * Copyright 2003 ICT CAS | |
7 | - * Author: Michael Guo <guoyi@ict.ac.cn> | |
8 | - * | |
9 | - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | |
10 | - * Author: Fuxin Zhang, zhangfx@lemote.com | |
11 | - * | |
12 | - * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
13 | - * Author: Wu Zhangjin, wuzj@lemote.com | |
14 | - * | |
15 | - * This program is free software; you can redistribute it and/or modify it | |
16 | - * under the terms of the GNU General Public License as published by the | |
17 | - * Free Software Foundation; either version 2 of the License, or (at your | |
18 | - * option) any later version. | |
19 | - */ | |
20 | -#include <asm/bootinfo.h> | |
21 | - | |
22 | -#include <loongson.h> | |
23 | - | |
24 | -unsigned long bus_clock, cpu_clock_freq; | |
25 | -unsigned long memsize, highmemsize; | |
26 | - | |
27 | -/* pmon passes arguments in 32bit pointers */ | |
28 | -int *_prom_envp; | |
29 | - | |
30 | -#define parse_even_earlier(res, option, p) \ | |
31 | -do { \ | |
32 | - if (strncmp(option, (char *)p, strlen(option)) == 0) \ | |
33 | - strict_strtol((char *)p + strlen(option"="), \ | |
34 | - 10, &res); \ | |
35 | -} while (0) | |
36 | - | |
37 | -void __init prom_init_env(void) | |
38 | -{ | |
39 | - long l; | |
40 | - | |
41 | - /* firmware arguments are initialized in head.S */ | |
42 | - _prom_envp = (int *)fw_arg2; | |
43 | - | |
44 | - l = (long)*_prom_envp; | |
45 | - while (l != 0) { | |
46 | - parse_even_earlier(bus_clock, "busclock", l); | |
47 | - parse_even_earlier(cpu_clock_freq, "cpuclock", l); | |
48 | - parse_even_earlier(memsize, "memsize", l); | |
49 | - parse_even_earlier(highmemsize, "highmemsize", l); | |
50 | - _prom_envp++; | |
51 | - l = (long)*_prom_envp; | |
52 | - } | |
53 | - if (memsize == 0) | |
54 | - memsize = 256; | |
55 | - | |
56 | - pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n", | |
57 | - bus_clock, cpu_clock_freq, memsize, highmemsize); | |
58 | -} |
arch/mips/loongson/fuloong-2e/init.c
1 | -/* | |
2 | - * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
3 | - * Author: Wu Zhangjin, wuzj@lemote.com | |
4 | - * | |
5 | - * This program is free software; you can redistribute it and/or modify it | |
6 | - * under the terms of the GNU General Public License as published by the | |
7 | - * Free Software Foundation; either version 2 of the License, or (at your | |
8 | - * option) any later version. | |
9 | - */ | |
10 | - | |
11 | -#include <linux/bootmem.h> | |
12 | - | |
13 | -#include <asm/bootinfo.h> | |
14 | - | |
15 | -#include <loongson.h> | |
16 | - | |
17 | -void __init prom_init(void) | |
18 | -{ | |
19 | - /* init base address of io space */ | |
20 | - set_io_port_base((unsigned long) | |
21 | - ioremap(BONITO_PCIIO_BASE, BONITO_PCIIO_SIZE)); | |
22 | - | |
23 | - prom_init_cmdline(); | |
24 | - prom_init_env(); | |
25 | - prom_init_memory(); | |
26 | -} | |
27 | - | |
28 | -void __init prom_free_prom_memory(void) | |
29 | -{ | |
30 | -} |
arch/mips/loongson/fuloong-2e/irq.c
... | ... | @@ -7,40 +7,13 @@ |
7 | 7 | * Free Software Foundation; either version 2 of the License, or (at your |
8 | 8 | * option) any later version. |
9 | 9 | */ |
10 | -#include <linux/delay.h> | |
11 | 10 | #include <linux/interrupt.h> |
12 | 11 | |
13 | 12 | #include <asm/irq_cpu.h> |
14 | 13 | #include <asm/i8259.h> |
15 | 14 | |
16 | 15 | #include <loongson.h> |
17 | -/* | |
18 | - * the first level int-handler will jump here if it is a bonito irq | |
19 | - */ | |
20 | -static void bonito_irqdispatch(void) | |
21 | -{ | |
22 | - u32 int_status; | |
23 | - int i; | |
24 | 16 | |
25 | - /* workaround the IO dma problem: let cpu looping to allow DMA finish */ | |
26 | - int_status = BONITO_INTISR; | |
27 | - if (int_status & (1 << 10)) { | |
28 | - while (int_status & (1 << 10)) { | |
29 | - udelay(1); | |
30 | - int_status = BONITO_INTISR; | |
31 | - } | |
32 | - } | |
33 | - | |
34 | - /* Get pending sources, masked by current enables */ | |
35 | - int_status = BONITO_INTISR & BONITO_INTEN; | |
36 | - | |
37 | - if (int_status != 0) { | |
38 | - i = __ffs(int_status); | |
39 | - int_status &= ~(1 << i); | |
40 | - do_IRQ(BONITO_IRQ_BASE + i); | |
41 | - } | |
42 | -} | |
43 | - | |
44 | 17 | static void i8259_irqdispatch(void) |
45 | 18 | { |
46 | 19 | int irq; |
47 | 20 | |
... | ... | @@ -52,10 +25,8 @@ |
52 | 25 | spurious_interrupt(); |
53 | 26 | } |
54 | 27 | |
55 | -asmlinkage void plat_irq_dispatch(void) | |
28 | +asmlinkage void mach_irq_dispatch(unsigned int pending) | |
56 | 29 | { |
57 | - unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM; | |
58 | - | |
59 | 30 | if (pending & CAUSEF_IP7) |
60 | 31 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); |
61 | 32 | else if (pending & CAUSEF_IP6) /* perf counter loverflow */ |
62 | 33 | |
63 | 34 | |
64 | 35 | |
... | ... | @@ -73,26 +44,15 @@ |
73 | 44 | .name = "cascade", |
74 | 45 | }; |
75 | 46 | |
76 | -void __init arch_init_irq(void) | |
47 | +void __init set_irq_trigger_mode(void) | |
77 | 48 | { |
78 | - /* | |
79 | - * Clear all of the interrupts while we change the able around a bit. | |
80 | - * int-handler is not on bootstrap | |
81 | - */ | |
82 | - clear_c0_status(ST0_IM | ST0_BEV); | |
83 | - local_irq_disable(); | |
84 | - | |
85 | 49 | /* most bonito irq should be level triggered */ |
86 | 50 | BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR | |
87 | - BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES; | |
88 | - BONITO_INTSTEER = 0; | |
51 | + BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES; | |
52 | +} | |
89 | 53 | |
90 | - /* | |
91 | - * Mask out all interrupt by writing "1" to all bit position in | |
92 | - * the interrupt reset reg. | |
93 | - */ | |
94 | - BONITO_INTENCLR = ~0; | |
95 | - | |
54 | +void __init mach_init_irq(void) | |
55 | +{ | |
96 | 56 | /* init all controller |
97 | 57 | * 0-15 ------> i8259 interrupt |
98 | 58 | * 16-23 ------> mips cpu interrupt |
arch/mips/loongson/fuloong-2e/machtype.c
1 | -/* | |
2 | - * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
3 | - * Author: Wu Zhangjin, wuzj@lemote.com | |
4 | - * | |
5 | - * This program is free software; you can redistribute it and/or modify it | |
6 | - * under the terms of the GNU General Public License as published by the | |
7 | - * Free Software Foundation; either version 2 of the License, or (at your | |
8 | - * option) any later version. | |
9 | - */ | |
10 | - | |
11 | -const char *get_system_type(void) | |
12 | -{ | |
13 | - return "lemote-fuloong-2e-box"; | |
14 | -} |
arch/mips/loongson/fuloong-2e/mem.c
1 | -/* | |
2 | - * This program is free software; you can redistribute it and/or modify it | |
3 | - * under the terms of the GNU General Public License as published by the | |
4 | - * Free Software Foundation; either version 2 of the License, or (at your | |
5 | - * option) any later version. | |
6 | - */ | |
7 | -#include <linux/fs.h> | |
8 | -#include <linux/fcntl.h> | |
9 | -#include <linux/mm.h> | |
10 | - | |
11 | -#include <asm/bootinfo.h> | |
12 | - | |
13 | -#include <loongson.h> | |
14 | - | |
15 | -void __init prom_init_memory(void) | |
16 | -{ | |
17 | - add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); | |
18 | -#ifdef CONFIG_64BIT | |
19 | - if (highmemsize > 0) | |
20 | - add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM); | |
21 | -#endif /* CONFIG_64BIT */ | |
22 | -} | |
23 | - | |
24 | -/* override of arch/mips/mm/cache.c: __uncached_access */ | |
25 | -int __uncached_access(struct file *file, unsigned long addr) | |
26 | -{ | |
27 | - if (file->f_flags & O_SYNC) | |
28 | - return 1; | |
29 | - | |
30 | - /* | |
31 | - * On the Lemote Loongson 2e system, the peripheral registers | |
32 | - * reside between 0x1000:0000 and 0x2000:0000. | |
33 | - */ | |
34 | - return addr >= __pa(high_memory) || | |
35 | - ((addr >= 0x10000000) && (addr < 0x20000000)); | |
36 | -} |
arch/mips/loongson/fuloong-2e/pci.c
1 | -/* | |
2 | - * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | |
3 | - * Author: Fuxin Zhang, zhangfx@lemote.com | |
4 | - * | |
5 | - * This program is free software; you can redistribute it and/or modify it | |
6 | - * under the terms of the GNU General Public License as published by the | |
7 | - * Free Software Foundation; either version 2 of the License, or (at your | |
8 | - * option) any later version. | |
9 | - */ | |
10 | -#include <linux/pci.h> | |
11 | - | |
12 | -#include <pci.h> | |
13 | -#include <loongson.h> | |
14 | - | |
15 | -static struct resource loongson2e_pci_mem_resource = { | |
16 | - .name = "LOONGSON2E PCI MEM", | |
17 | - .start = LOONGSON2E_PCI_MEM_START, | |
18 | - .end = LOONGSON2E_PCI_MEM_END, | |
19 | - .flags = IORESOURCE_MEM, | |
20 | -}; | |
21 | - | |
22 | -static struct resource loongson2e_pci_io_resource = { | |
23 | - .name = "LOONGSON2E PCI IO MEM", | |
24 | - .start = LOONGSON2E_PCI_IO_START, | |
25 | - .end = IO_SPACE_LIMIT, | |
26 | - .flags = IORESOURCE_IO, | |
27 | -}; | |
28 | - | |
29 | -static struct pci_controller loongson2e_pci_controller = { | |
30 | - .pci_ops = &bonito64_pci_ops, | |
31 | - .io_resource = &loongson2e_pci_io_resource, | |
32 | - .mem_resource = &loongson2e_pci_mem_resource, | |
33 | - .mem_offset = 0x00000000UL, | |
34 | - .io_offset = 0x00000000UL, | |
35 | -}; | |
36 | - | |
37 | -static void __init setup_pcimap(void) | |
38 | -{ | |
39 | - /* | |
40 | - * local to PCI mapping for CPU accessing PCI space | |
41 | - * CPU address space [256M,448M] is window for accessing pci space | |
42 | - * we set pcimap_lo[0,1,2] to map it to pci space[0M,64M], [320M,448M] | |
43 | - * | |
44 | - * pcimap: PCI_MAP2 PCI_Mem_Lo2 PCI_Mem_Lo1 PCI_Mem_Lo0 | |
45 | - * [<2G] [384M,448M] [320M,384M] [0M,64M] | |
46 | - */ | |
47 | - BONITO_PCIMAP = BONITO_PCIMAP_PCIMAP_2 | | |
48 | - BONITO_PCIMAP_WIN(2, BONITO_PCILO2_BASE) | | |
49 | - BONITO_PCIMAP_WIN(1, BONITO_PCILO1_BASE) | | |
50 | - BONITO_PCIMAP_WIN(0, 0); | |
51 | - | |
52 | - /* | |
53 | - * PCI-DMA to local mapping: [2G,2G+256M] -> [0M,256M] | |
54 | - */ | |
55 | - BONITO_PCIBASE0 = 0x80000000ul; /* base: 2G -> mmap: 0M */ | |
56 | - /* size: 256M, burst transmission, pre-fetch enable, 64bit */ | |
57 | - LOONGSON_PCI_HIT0_SEL_L = 0xc000000cul; | |
58 | - LOONGSON_PCI_HIT0_SEL_H = 0xfffffffful; | |
59 | - LOONGSON_PCI_HIT1_SEL_L = 0x00000006ul; /* set this BAR as invalid */ | |
60 | - LOONGSON_PCI_HIT1_SEL_H = 0x00000000ul; | |
61 | - LOONGSON_PCI_HIT2_SEL_L = 0x00000006ul; /* set this BAR as invalid */ | |
62 | - LOONGSON_PCI_HIT2_SEL_H = 0x00000000ul; | |
63 | - | |
64 | - /* avoid deadlock of PCI reading/writing lock operation */ | |
65 | - LOONGSON_PCI_ISR4C = 0xd2000001ul; | |
66 | - | |
67 | - /* can not change gnt to break pci transfer when device's gnt not | |
68 | - deassert for some broken device */ | |
69 | - LOONGSON_PXARB_CFG = 0x00fe0105ul; | |
70 | -} | |
71 | - | |
72 | -static int __init pcibios_init(void) | |
73 | -{ | |
74 | - setup_pcimap(); | |
75 | - | |
76 | - loongson2e_pci_controller.io_map_base = mips_io_port_base; | |
77 | - | |
78 | - register_pci_controller(&loongson2e_pci_controller); | |
79 | - | |
80 | - return 0; | |
81 | -} | |
82 | - | |
83 | -arch_initcall(pcibios_init); |
arch/mips/loongson/fuloong-2e/reset.c
1 | -/* | |
1 | +/* Board-specific reboot/shutdown routines | |
2 | + * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca> | |
3 | + * | |
4 | + * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
5 | + * Author: Wu Zhangjin, wuzj@lemote.com | |
6 | + * | |
2 | 7 | * This program is free software; you can redistribute it and/or modify it |
3 | 8 | * under the terms of the GNU General Public License as published by the |
4 | 9 | * Free Software Foundation; either version 2 of the License, or (at your |
5 | 10 | * option) any later version. |
6 | - * | |
7 | - * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | |
8 | - * Author: Fuxin Zhang, zhangfx@lemote.com | |
9 | - * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | |
10 | - * Author: Zhangjin Wu, wuzj@lemote.com | |
11 | 11 | */ |
12 | -#include <linux/init.h> | |
13 | -#include <linux/pm.h> | |
14 | 12 | |
15 | -#include <asm/reboot.h> | |
16 | - | |
17 | 13 | #include <loongson.h> |
18 | 14 | |
19 | -static void loongson2e_restart(char *command) | |
15 | +void mach_prepare_reboot(void) | |
20 | 16 | { |
21 | - /* do preparation for reboot */ | |
22 | 17 | BONITO_BONGENCFG &= ~(1 << 2); |
23 | 18 | BONITO_BONGENCFG |= (1 << 2); |
24 | - | |
25 | - /* reboot via jumping to boot base address */ | |
26 | - ((void (*)(void))ioremap_nocache(BONITO_BOOT_BASE, 4)) (); | |
27 | 19 | } |
28 | 20 | |
29 | -static void loongson2e_halt(void) | |
21 | +void mach_prepare_shutdown(void) | |
30 | 22 | { |
31 | - while (1) | |
32 | - ; | |
33 | 23 | } |
34 | - | |
35 | -static int __init mips_reboot_setup(void) | |
36 | -{ | |
37 | - _machine_restart = loongson2e_restart; | |
38 | - _machine_halt = loongson2e_halt; | |
39 | - pm_power_off = loongson2e_halt; | |
40 | - | |
41 | - return 0; | |
42 | -} | |
43 | - | |
44 | -arch_initcall(mips_reboot_setup); |
arch/mips/loongson/fuloong-2e/time.c
1 | -/* | |
2 | - * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | |
3 | - * Author: Fuxin Zhang, zhangfx@lemote.com | |
4 | - * | |
5 | - * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | |
6 | - * Author: Wu Zhangjin, wuzj@lemote.com | |
7 | - * | |
8 | - * This program is free software; you can redistribute it and/or modify it | |
9 | - * under the terms of the GNU General Public License as published by the | |
10 | - * Free Software Foundation; either version 2 of the License, or (at your | |
11 | - * option) any later version. | |
12 | - */ | |
13 | -#include <asm/mc146818-time.h> | |
14 | -#include <asm/time.h> | |
15 | - | |
16 | -#include <loongson.h> | |
17 | - | |
18 | -void __init plat_time_init(void) | |
19 | -{ | |
20 | - /* setup mips r4k timer */ | |
21 | - mips_hpt_frequency = cpu_clock_freq / 2; | |
22 | -} | |
23 | - | |
24 | -unsigned long read_persistent_clock(void) | |
25 | -{ | |
26 | - return mc146818_get_cmos_time(); | |
27 | -} |