aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-11-15 12:10:53 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-15 12:10:53 -0500
commitb84da9fa47cf6e8dfd71d673a2f744ec1cac452c (patch)
tree800a1cb1e939eb84f7e7018be64e94be5c972ca0
parent12b76f3bf336388916ddf8047156f9e9993ff4e9 (diff)
parentda34232641a91ca785a787c23c158488e459b938 (diff)
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS updates from Ralf Baechle: "These are the highlists of the main MIPS pull request for 4.4: - Add latencytop support - Support appended DTBs - VDSO support and initially use it for gettimeofday. - Drop the .MIPS.abiflags and ELF NOTE sections from vmlinux - Support for the 5KE, an internal test core. - Switch all MIPS platfroms to libata drivers. - Improved support, cleanups for ralink and Lantiq platforms. - Support for the new xilfpga platform. - A number of DTB improvments for BMIPS. - Improved support for CM and CPS. - Minor JZ4740 and BCM47xx enhancements" * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (120 commits) MIPS: idle: add case for CPU_5KE MIPS: Octeon: Support APPENDED_DTB MIPS: vmlinux: create a section for appended DTB MIPS: Clean up compat_siginfo_t MIPS: Fix PAGE_MASK definition MIPS: BMIPS: Enable GZIP ramdisk and timed printks MIPS: Add xilfpga defconfig MIPS: xilfpga: Add mipsfpga platform code MIPS: xilfpga: Add xilfpga device tree files. dt-bindings: MIPS: Document xilfpga bindings and boot style MIPS: Make MIPS_CMDLINE_DTB default MIPS: Make the kernel arguments from dtb available MIPS: Use USE_OF as the guard for appended dtb MIPS: BCM63XX: Use pr_* instead of printk MIPS: Loongson: Cleanup CONFIG_LOONGSON_SUSPEND. MIPS: lantiq: Disable xbar fpi burst mode MIPS: lantiq: Force the crossbar to big endian MIPS: lantiq: Initialize the USB core on boot MIPS: lantiq: Return correct value for fpi clock on ar9 MIPS: ralink: Add missing clock on rt305x ...
-rw-r--r--Documentation/devicetree/bindings/mips/img/xilfpga.txt83
-rw-r--r--arch/mips/Kbuild1
-rw-r--r--arch/mips/Kbuild.platforms1
-rw-r--r--arch/mips/Kconfig88
-rw-r--r--arch/mips/Kconfig.debug72
-rw-r--r--arch/mips/Makefile4
-rw-r--r--arch/mips/bcm47xx/setup.c19
-rw-r--r--arch/mips/bcm47xx/sprom.c46
-rw-r--r--arch/mips/bcm63xx/boards/board_bcm963xx.c14
-rw-r--r--arch/mips/bcm63xx/cpu.c12
-rw-r--r--arch/mips/bcm63xx/dev-pcmcia.c2
-rw-r--r--arch/mips/bcm63xx/irq.c2
-rw-r--r--arch/mips/bcm63xx/setup.c8
-rw-r--r--arch/mips/bcm63xx/timer.c2
-rw-r--r--arch/mips/bmips/setup.c1
-rw-r--r--arch/mips/boot/dts/Makefile1
-rw-r--r--arch/mips/boot/dts/brcm/bcm7346.dtsi114
-rw-r--r--arch/mips/boot/dts/brcm/bcm7358.dtsi62
-rw-r--r--arch/mips/boot/dts/brcm/bcm7360.dtsi62
-rw-r--r--arch/mips/boot/dts/brcm/bcm7362.dtsi94
-rw-r--r--arch/mips/boot/dts/brcm/bcm7425.dtsi42
-rw-r--r--arch/mips/boot/dts/brcm/bcm97346dbsmb.dts28
-rw-r--r--arch/mips/boot/dts/brcm/bcm97358svmb.dts16
-rw-r--r--arch/mips/boot/dts/brcm/bcm97360svmb.dts16
-rw-r--r--arch/mips/boot/dts/brcm/bcm97362svmb.dts20
-rw-r--r--arch/mips/boot/dts/mti/malta.dts4
-rw-r--r--arch/mips/boot/dts/xilfpga/Makefile9
-rw-r--r--arch/mips/boot/dts/xilfpga/microAptiv.dtsi21
-rw-r--r--arch/mips/boot/dts/xilfpga/nexys4ddr.dts46
-rw-r--r--arch/mips/cavium-octeon/setup.c11
-rw-r--r--arch/mips/configs/bigsur_defconfig12
-rw-r--r--arch/mips/configs/bmips_be_defconfig3
-rw-r--r--arch/mips/configs/bmips_stb_defconfig3
-rw-r--r--arch/mips/configs/capcella_defconfig6
-rw-r--r--arch/mips/configs/e55_defconfig6
-rw-r--r--arch/mips/configs/fuloong2e_defconfig14
-rw-r--r--arch/mips/configs/lasat_defconfig10
-rw-r--r--arch/mips/configs/lemote2f_defconfig11
-rw-r--r--arch/mips/configs/malta_defconfig6
-rw-r--r--arch/mips/configs/malta_kvm_defconfig16
-rw-r--r--arch/mips/configs/malta_kvm_guest_defconfig16
-rw-r--r--arch/mips/configs/malta_qemu_32r6_defconfig11
-rw-r--r--arch/mips/configs/maltaaprp_defconfig11
-rw-r--r--arch/mips/configs/maltasmvp_eva_defconfig11
-rw-r--r--arch/mips/configs/maltaup_defconfig11
-rw-r--r--arch/mips/configs/maltaup_xpa_defconfig16
-rw-r--r--arch/mips/configs/mpc30x_defconfig6
-rw-r--r--arch/mips/configs/xilfpga_defconfig40
-rw-r--r--arch/mips/include/asm/abi.h5
-rw-r--r--arch/mips/include/asm/atomic.h2
-rw-r--r--arch/mips/include/asm/bcache.h27
-rw-r--r--arch/mips/include/asm/cdmm.h11
-rw-r--r--arch/mips/include/asm/clocksource.h29
-rw-r--r--arch/mips/include/asm/compat.h62
-rw-r--r--arch/mips/include/asm/cpu-features.h6
-rw-r--r--arch/mips/include/asm/debug.h22
-rw-r--r--arch/mips/include/asm/elf.h7
-rw-r--r--arch/mips/include/asm/fw/fw.h16
-rw-r--r--arch/mips/include/asm/mach-bcm47xx/bcm47xx.h5
-rw-r--r--arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h14
-rw-r--r--arch/mips/include/asm/mach-malta/malta-dtshim.h29
-rw-r--r--arch/mips/include/asm/mach-ralink/mt7620.h8
-rw-r--r--arch/mips/include/asm/mach-ralink/ralink_regs.h17
-rw-r--r--arch/mips/include/asm/mach-ralink/rt305x.h21
-rw-r--r--arch/mips/include/asm/mach-xilfpga/irq.h18
-rw-r--r--arch/mips/include/asm/mips-cm.h78
-rw-r--r--arch/mips/include/asm/mips-cpc.h3
-rw-r--r--arch/mips/include/asm/mipsregs.h18
-rw-r--r--arch/mips/include/asm/page.h2
-rw-r--r--arch/mips/include/asm/processor.h8
-rw-r--r--arch/mips/include/asm/vdso.h139
-rw-r--r--arch/mips/include/uapi/asm/Kbuild2
-rw-r--r--arch/mips/include/uapi/asm/auxvec.h17
-rw-r--r--arch/mips/jz4740/board-qi_lb60.c13
-rw-r--r--arch/mips/kernel/Makefile1
-rw-r--r--arch/mips/kernel/cps-vec-ns16550.S202
-rw-r--r--arch/mips/kernel/cps-vec.S44
-rw-r--r--arch/mips/kernel/cpu-probe.c3
-rw-r--r--arch/mips/kernel/csrc-r4k.c44
-rw-r--r--arch/mips/kernel/idle.c17
-rw-r--r--arch/mips/kernel/mips-cm.c114
-rw-r--r--arch/mips/kernel/mips-cpc.c6
-rw-r--r--arch/mips/kernel/mips-r2-to-r6-emul.c2
-rw-r--r--arch/mips/kernel/segment.c2
-rw-r--r--arch/mips/kernel/setup.c29
-rw-r--r--arch/mips/kernel/signal.c12
-rw-r--r--arch/mips/kernel/signal32.c7
-rw-r--r--arch/mips/kernel/signal_n32.c5
-rw-r--r--arch/mips/kernel/smp-cps.c35
-rw-r--r--arch/mips/kernel/smp-gic.c2
-rw-r--r--arch/mips/kernel/spinlock_test.c4
-rw-r--r--arch/mips/kernel/stacktrace.c27
-rw-r--r--arch/mips/kernel/traps.c11
-rw-r--r--arch/mips/kernel/unaligned.c2
-rw-r--r--arch/mips/kernel/vdso.c207
-rw-r--r--arch/mips/kernel/vmlinux.lds.S15
-rw-r--r--arch/mips/kvm/locore.S8
-rw-r--r--arch/mips/lantiq/clk.c17
-rw-r--r--arch/mips/lantiq/clk.h13
-rw-r--r--arch/mips/lantiq/irq.c8
-rw-r--r--arch/mips/lantiq/prom.c2
-rw-r--r--arch/mips/lantiq/xway/clk.c180
-rw-r--r--arch/mips/lantiq/xway/prom.c35
-rw-r--r--arch/mips/lantiq/xway/reset.c196
-rw-r--r--arch/mips/lantiq/xway/sysctrl.c301
-rw-r--r--arch/mips/lib/Makefile2
-rw-r--r--arch/mips/lib/bswapdi.c15
-rw-r--r--arch/mips/lib/bswapsi.c11
-rw-r--r--arch/mips/loongson64/Kconfig5
-rw-r--r--arch/mips/loongson64/common/Makefile2
-rw-r--r--arch/mips/loongson64/lemote-2f/Makefile2
-rw-r--r--arch/mips/math-emu/me-debugfs.c2
-rw-r--r--arch/mips/mm/Makefile1
-rw-r--r--arch/mips/mm/sc-debugfs.c81
-rw-r--r--arch/mips/mm/sc-mips.c65
-rw-r--r--arch/mips/mm/tlbex.c97
-rw-r--r--arch/mips/mti-malta/Makefile15
-rw-r--r--arch/mips/mti-malta/malta-dtshim.c162
-rw-r--r--arch/mips/mti-malta/malta-init.c1
-rw-r--r--arch/mips/mti-malta/malta-memory.c131
-rw-r--r--arch/mips/mti-malta/malta-setup.c5
-rw-r--r--arch/mips/netlogic/xlp/dt.c1
-rw-r--r--arch/mips/pci/pci-rt3883.c6
-rw-r--r--arch/mips/pistachio/init.c1
-rw-r--r--arch/mips/ralink/cevt-rt3352.c2
-rw-r--r--arch/mips/ralink/early_printk.c26
-rw-r--r--arch/mips/ralink/mt7620.c63
-rw-r--r--arch/mips/ralink/of.c2
-rw-r--r--arch/mips/ralink/prom.c5
-rw-r--r--arch/mips/ralink/reset.c13
-rw-r--r--arch/mips/ralink/rt288x.c1
-rw-r--r--arch/mips/ralink/rt305x.c13
-rw-r--r--arch/mips/ralink/rt3883.c2
-rw-r--r--arch/mips/vdso/.gitignore4
-rw-r--r--arch/mips/vdso/Makefile160
-rw-r--r--arch/mips/vdso/elf.S68
-rw-r--r--arch/mips/vdso/genvdso.c293
-rw-r--r--arch/mips/vdso/genvdso.h187
-rw-r--r--arch/mips/vdso/gettimeofday.c232
-rw-r--r--arch/mips/vdso/sigreturn.S49
-rw-r--r--arch/mips/vdso/vdso.h89
-rw-r--r--arch/mips/vdso/vdso.lds.S105
-rw-r--r--arch/mips/xilfpga/Kconfig9
-rw-r--r--arch/mips/xilfpga/Makefile7
-rw-r--r--arch/mips/xilfpga/Platform3
-rw-r--r--arch/mips/xilfpga/init.c57
-rw-r--r--arch/mips/xilfpga/intc.c25
-rw-r--r--arch/mips/xilfpga/time.c41
-rw-r--r--drivers/clocksource/mips-gic-timer.c7
-rw-r--r--drivers/irqchip/irq-mips-gic.c14
-rw-r--r--include/linux/irqchip/mips-gic.h17
151 files changed, 4590 insertions, 749 deletions
diff --git a/Documentation/devicetree/bindings/mips/img/xilfpga.txt b/Documentation/devicetree/bindings/mips/img/xilfpga.txt
new file mode 100644
index 000000000000..57e7ee942166
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/img/xilfpga.txt
@@ -0,0 +1,83 @@
1Imagination University Program MIPSfpga
2=======================================
3
4Under the Imagination University Program, a microAptiv UP core has been
5released for academic usage.
6
7As we are dealing with a MIPS core instantiated on an FPGA, specifications
8are fluid and can be varied in RTL.
9
10This binding document is provided as baseline guidance for the example
11project provided by IMG.
12
13The example project runs on the Nexys4DDR board by Digilent powered by
14the ARTIX-7 FPGA by Xilinx.
15
16Relevant details about the example project and the Nexys4DDR board:
17
18- microAptiv UP core m14Kc
19- 50MHz clock speed
20- 128Mbyte DDR RAM at 0x0000_0000
21- 8Kbyte RAM at 0x1000_0000
22- axi_intc at 0x1020_0000
23- axi_uart16550 at 0x1040_0000
24- axi_gpio at 0x1060_0000
25- axi_i2c at 0x10A0_0000
26- custom_gpio at 0x10C0_0000
27- axi_ethernetlite at 0x10E0_0000
28- 8Kbyte BootRAM at 0x1FC0_0000
29
30Required properties:
31--------------------
32 - compatible: Must include "digilent,nexys4ddr","img,xilfpga".
33
34CPU nodes:
35----------
36A "cpus" node is required. Required properties:
37 - #address-cells: Must be 1.
38 - #size-cells: Must be 0.
39A CPU sub-node is also required for at least CPU 0. Required properties:
40 - device_type: Must be "cpu".
41 - compatible: Must be "mips,m14Kc".
42 - reg: Must be <0>.
43 - clocks: phandle to ext clock for fixed-clock received by MIPS core.
44
45Example:
46
47 compatible = "img,xilfpga","digilent,nexys4ddr";
48 cpus {
49 #address-cells = <1>;
50 #size-cells = <0>;
51
52 cpu0: cpu@0 {
53 device_type = "cpu";
54 compatible = "mips,m14Kc";
55 reg = <0>;
56 clocks = <&ext>;
57 };
58 };
59
60 ext: ext {
61 compatible = "fixed-clock";
62 #clock-cells = <0>;
63 clock-frequency = <50000000>;
64 };
65
66Boot protocol:
67--------------
68
69The BootRAM is a writeable "RAM" in FPGA at 0x1FC0_0000.
70This is for easy reprogrammibility via JTAG.
71
72The BootRAM initializes the cache and the axi_uart peripheral.
73
74DDR initialization is already handled by a HW IP block.
75
76When the example project bitstream is loaded, the cpu_reset button
77needs to be pressed.
78
79The bootram initializes the cache and axi_uart.
80Then outputs MIPSFPGA\n\r on the serial port on the Nexys4DDR board.
81
82At this point, the board is ready to load the Linux kernel
83vmlinux file via JTAG.
diff --git a/arch/mips/Kbuild b/arch/mips/Kbuild
index dd295335891a..5c3f688a5232 100644
--- a/arch/mips/Kbuild
+++ b/arch/mips/Kbuild
@@ -17,6 +17,7 @@ obj- := $(platform-)
17obj-y += kernel/ 17obj-y += kernel/
18obj-y += mm/ 18obj-y += mm/
19obj-y += net/ 19obj-y += net/
20obj-y += vdso/
20 21
21ifdef CONFIG_KVM 22ifdef CONFIG_KVM
22obj-y += kvm/ 23obj-y += kvm/
diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
index a424e46b50af..a96c81d1d22e 100644
--- a/arch/mips/Kbuild.platforms
+++ b/arch/mips/Kbuild.platforms
@@ -33,6 +33,7 @@ platforms += sibyte
33platforms += sni 33platforms += sni
34platforms += txx9 34platforms += txx9
35platforms += vr41xx 35platforms += vr41xx
36platforms += xilfpga
36 37
37# include the platform specific files 38# include the platform specific files
38include $(patsubst %, $(srctree)/arch/mips/%/Platform, $(platforms)) 39include $(patsubst %, $(srctree)/arch/mips/%/Platform, $(platforms))
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index e3aa5b0b4ef1..71683a853372 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -5,6 +5,7 @@ config MIPS
5 select ARCH_MIGHT_HAVE_PC_PARPORT 5 select ARCH_MIGHT_HAVE_PC_PARPORT
6 select ARCH_MIGHT_HAVE_PC_SERIO 6 select ARCH_MIGHT_HAVE_PC_SERIO
7 select ARCH_USE_CMPXCHG_LOCKREF if 64BIT 7 select ARCH_USE_CMPXCHG_LOCKREF if 64BIT
8 select ARCH_USE_BUILTIN_BSWAP
8 select HAVE_CONTEXT_TRACKING 9 select HAVE_CONTEXT_TRACKING
9 select HAVE_GENERIC_DMA_COHERENT 10 select HAVE_GENERIC_DMA_COHERENT
10 select HAVE_IDE 11 select HAVE_IDE
@@ -60,6 +61,8 @@ config MIPS
60 select SYSCTL_EXCEPTION_TRACE 61 select SYSCTL_EXCEPTION_TRACE
61 select HAVE_VIRT_CPU_ACCOUNTING_GEN 62 select HAVE_VIRT_CPU_ACCOUNTING_GEN
62 select HAVE_IRQ_TIME_ACCOUNTING 63 select HAVE_IRQ_TIME_ACCOUNTING
64 select GENERIC_TIME_VSYSCALL
65 select ARCH_CLOCKSOURCE_DATA
63 66
64menu "Machine selection" 67menu "Machine selection"
65 68
@@ -401,6 +404,28 @@ config MACH_PISTACHIO
401 help 404 help
402 This enables support for the IMG Pistachio SoC platform. 405 This enables support for the IMG Pistachio SoC platform.
403 406
407config MACH_XILFPGA
408 bool "MIPSfpga Xilinx based boards"
409 select ARCH_REQUIRE_GPIOLIB
410 select BOOT_ELF32
411 select BOOT_RAW
412 select BUILTIN_DTB
413 select CEVT_R4K
414 select COMMON_CLK
415 select CSRC_R4K
416 select IRQ_MIPS_CPU
417 select LIBFDT
418 select MIPS_CPU_SCACHE
419 select SYS_HAS_EARLY_PRINTK
420 select SYS_HAS_CPU_MIPS32_R2
421 select SYS_SUPPORTS_32BIT_KERNEL
422 select SYS_SUPPORTS_LITTLE_ENDIAN
423 select SYS_SUPPORTS_ZBOOT_UART16550
424 select USE_OF
425 select USE_GENERIC_EARLY_PRINTK_8250
426 help
427 This enables support for the IMG University Program MIPSfpga platform.
428
404config MIPS_MALTA 429config MIPS_MALTA
405 bool "MIPS Malta board" 430 bool "MIPS Malta board"
406 select ARCH_MAY_HAVE_PC_FDC 431 select ARCH_MAY_HAVE_PC_FDC
@@ -424,6 +449,7 @@ config MIPS_MALTA
424 select MIPS_L1_CACHE_SHIFT_6 449 select MIPS_L1_CACHE_SHIFT_6
425 select PCI_GT64XXX_PCI0 450 select PCI_GT64XXX_PCI0
426 select MIPS_MSC 451 select MIPS_MSC
452 select SMP_UP if SMP
427 select SWAP_IO_SPACE 453 select SWAP_IO_SPACE
428 select SYS_HAS_CPU_MIPS32_R1 454 select SYS_HAS_CPU_MIPS32_R1
429 select SYS_HAS_CPU_MIPS32_R2 455 select SYS_HAS_CPU_MIPS32_R2
@@ -449,6 +475,8 @@ config MIPS_MALTA
449 select SYS_SUPPORTS_ZBOOT 475 select SYS_SUPPORTS_ZBOOT
450 select USE_OF 476 select USE_OF
451 select ZONE_DMA32 if 64BIT 477 select ZONE_DMA32 if 64BIT
478 select BUILTIN_DTB
479 select LIBFDT
452 help 480 help
453 This enables support for the MIPS Technologies Malta evaluation 481 This enables support for the MIPS Technologies Malta evaluation
454 board. 482 board.
@@ -964,6 +992,7 @@ source "arch/mips/loongson32/Kconfig"
964source "arch/mips/loongson64/Kconfig" 992source "arch/mips/loongson64/Kconfig"
965source "arch/mips/netlogic/Kconfig" 993source "arch/mips/netlogic/Kconfig"
966source "arch/mips/paravirt/Kconfig" 994source "arch/mips/paravirt/Kconfig"
995source "arch/mips/xilfpga/Kconfig"
967 996
968endmenu 997endmenu
969 998
@@ -1036,6 +1065,9 @@ config CSRC_R4K
1036config CSRC_SB1250 1065config CSRC_SB1250
1037 bool 1066 bool
1038 1067
1068config MIPS_CLOCK_VSYSCALL
1069 def_bool CSRC_R4K || CLKSRC_MIPS_GIC
1070
1039config GPIO_TXX9 1071config GPIO_TXX9
1040 select ARCH_REQUIRE_GPIOLIB 1072 select ARCH_REQUIRE_GPIOLIB
1041 bool 1073 bool
@@ -2529,6 +2561,9 @@ choice
2529 help 2561 help
2530 Allows the configuration of the timer frequency. 2562 Allows the configuration of the timer frequency.
2531 2563
2564 config HZ_24
2565 bool "24 HZ" if SYS_SUPPORTS_24HZ || SYS_SUPPORTS_ARBIT_HZ
2566
2532 config HZ_48 2567 config HZ_48
2533 bool "48 HZ" if SYS_SUPPORTS_48HZ || SYS_SUPPORTS_ARBIT_HZ 2568 bool "48 HZ" if SYS_SUPPORTS_48HZ || SYS_SUPPORTS_ARBIT_HZ
2534 2569
@@ -2552,6 +2587,9 @@ choice
2552 2587
2553endchoice 2588endchoice
2554 2589
2590config SYS_SUPPORTS_24HZ
2591 bool
2592
2555config SYS_SUPPORTS_48HZ 2593config SYS_SUPPORTS_48HZ
2556 bool 2594 bool
2557 2595
@@ -2575,13 +2613,18 @@ config SYS_SUPPORTS_1024HZ
2575 2613
2576config SYS_SUPPORTS_ARBIT_HZ 2614config SYS_SUPPORTS_ARBIT_HZ
2577 bool 2615 bool
2578 default y if !SYS_SUPPORTS_48HZ && !SYS_SUPPORTS_100HZ && \ 2616 default y if !SYS_SUPPORTS_24HZ && \
2579 !SYS_SUPPORTS_128HZ && !SYS_SUPPORTS_250HZ && \ 2617 !SYS_SUPPORTS_48HZ && \
2580 !SYS_SUPPORTS_256HZ && !SYS_SUPPORTS_1000HZ && \ 2618 !SYS_SUPPORTS_100HZ && \
2619 !SYS_SUPPORTS_128HZ && \
2620 !SYS_SUPPORTS_250HZ && \
2621 !SYS_SUPPORTS_256HZ && \
2622 !SYS_SUPPORTS_1000HZ && \
2581 !SYS_SUPPORTS_1024HZ 2623 !SYS_SUPPORTS_1024HZ
2582 2624
2583config HZ 2625config HZ
2584 int 2626 int
2627 default 24 if HZ_24
2585 default 48 if HZ_48 2628 default 48 if HZ_48
2586 default 100 if HZ_100 2629 default 100 if HZ_100
2587 default 128 if HZ_128 2630 default 128 if HZ_128
@@ -2685,7 +2728,7 @@ config BUILTIN_DTB
2685 bool 2728 bool
2686 2729
2687choice 2730choice
2688 prompt "Kernel appended dtb support" if OF 2731 prompt "Kernel appended dtb support" if USE_OF
2689 default MIPS_NO_APPENDED_DTB 2732 default MIPS_NO_APPENDED_DTB
2690 2733
2691 config MIPS_NO_APPENDED_DTB 2734 config MIPS_NO_APPENDED_DTB
@@ -2693,6 +2736,20 @@ choice
2693 help 2736 help
2694 Do not enable appended dtb support. 2737 Do not enable appended dtb support.
2695 2738
2739 config MIPS_ELF_APPENDED_DTB
2740 bool "vmlinux"
2741 help
2742 With this option, the boot code will look for a device tree binary
2743 DTB) included in the vmlinux ELF section .appended_dtb. By default
2744 it is empty and the DTB can be appended using binutils command
2745 objcopy:
2746
2747 objcopy --update-section .appended_dtb=<filename>.dtb vmlinux
2748
2749 This is meant as a backward compatiblity convenience for those
2750 systems with a bootloader that can't be upgraded to accommodate
2751 the documented boot protocol using a device tree.
2752
2696 config MIPS_RAW_APPENDED_DTB 2753 config MIPS_RAW_APPENDED_DTB
2697 bool "vmlinux.bin" 2754 bool "vmlinux.bin"
2698 help 2755 help
@@ -2729,6 +2786,25 @@ choice
2729 if you don't intend to always append a DTB. 2786 if you don't intend to always append a DTB.
2730endchoice 2787endchoice
2731 2788
2789choice
2790 prompt "Kernel command line type" if !CMDLINE_OVERRIDE
2791 default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \
2792 !MIPS_MALTA && !MIPS_SEAD3 && \
2793 !CAVIUM_OCTEON_SOC
2794 default MIPS_CMDLINE_FROM_BOOTLOADER
2795
2796 config MIPS_CMDLINE_FROM_DTB
2797 depends on USE_OF
2798 bool "Dtb kernel arguments if available"
2799
2800 config MIPS_CMDLINE_DTB_EXTEND
2801 depends on USE_OF
2802 bool "Extend dtb kernel arguments with bootloader arguments"
2803
2804 config MIPS_CMDLINE_FROM_BOOTLOADER
2805 bool "Bootloader kernel arguments if available"
2806endchoice
2807
2732endmenu 2808endmenu
2733 2809
2734config LOCKDEP_SUPPORT 2810config LOCKDEP_SUPPORT
@@ -2739,6 +2815,10 @@ config STACKTRACE_SUPPORT
2739 bool 2815 bool
2740 default y 2816 default y
2741 2817
2818config HAVE_LATENCYTOP_SUPPORT
2819 bool
2820 default y
2821
2742config PGTABLE_LEVELS 2822config PGTABLE_LEVELS
2743 int 2823 int
2744 default 3 if 64BIT && !PAGE_SIZE_64KB 2824 default 3 if 64BIT && !PAGE_SIZE_64KB
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index e250524021ac..f0e314ceb8ba 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -113,4 +113,76 @@ config SPINLOCK_TEST
113 help 113 help
114 Add several files to the debugfs to test spinlock speed. 114 Add several files to the debugfs to test spinlock speed.
115 115
116if CPU_MIPSR6
117
118choice
119 prompt "Compact branch policy"
120 default MIPS_COMPACT_BRANCHES_OPTIMAL
121
122config MIPS_COMPACT_BRANCHES_NEVER
123 bool "Never (force delay slot branches)"
124 help
125 Pass the -mcompact-branches=never flag to the compiler in order to
126 force it to always emit branches with delay slots, and make no use
127 of the compact branch instructions introduced by MIPSr6. This is
128 useful if you suspect there may be an issue with compact branches in
129 either the compiler or the CPU.
130
131config MIPS_COMPACT_BRANCHES_OPTIMAL
132 bool "Optimal (use where beneficial)"
133 help
134 Pass the -mcompact-branches=optimal flag to the compiler in order for
135 it to make use of compact branch instructions where it deems them
136 beneficial, and use branches with delay slots elsewhere. This is the
137 default compiler behaviour, and should be used unless you have a
138 reason to choose otherwise.
139
140config MIPS_COMPACT_BRANCHES_ALWAYS
141 bool "Always (force compact branches)"
142 help
143 Pass the -mcompact-branches=always flag to the compiler in order to
144 force it to always emit compact branches, making no use of branch
145 instructions with delay slots. This can result in more compact code
146 which may be beneficial in some scenarios.
147
148endchoice
149
150endif # CPU_MIPSR6
151
152config SCACHE_DEBUGFS
153 bool "L2 cache debugfs entries"
154 depends on DEBUG_FS
155 help
156 Enable this to allow parts of the L2 cache configuration, such as
157 whether or not prefetching is enabled, to be exposed to userland
158 via debugfs.
159
160 If unsure, say N.
161
162menuconfig MIPS_CPS_NS16550
163 bool "CPS SMP NS16550 UART output"
164 depends on MIPS_CPS
165 help
166 Output debug information via an ns16550 compatible UART if exceptions
167 occur early in the boot process of a secondary core.
168
169if MIPS_CPS_NS16550
170
171config MIPS_CPS_NS16550_BASE
172 hex "UART Base Address"
173 default 0x1b0003f8 if MIPS_MALTA
174 help
175 The base address of the ns16550 compatible UART on which to output
176 debug information from the early stages of core startup.
177
178config MIPS_CPS_NS16550_SHIFT
179 int "UART Register Shift"
180 default 0 if MIPS_MALTA
181 help
182 The number of bits to shift ns16550 register indices by in order to
183 form their addresses. That is, log base 2 of the span between
184 adjacent ns16550 registers in the system.
185
186endif # MIPS_CPS_NS16550
187
116endmenu 188endmenu
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 252e347958f3..3f70ba54ae21 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -204,6 +204,10 @@ toolchain-msa := $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(
204cflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA 204cflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA
205endif 205endif
206 206
207cflags-$(CONFIG_MIPS_COMPACT_BRANCHES_NEVER) += -mcompact-branches=never
208cflags-$(CONFIG_MIPS_COMPACT_BRANCHES_OPTIMAL) += -mcompact-branches=optimal
209cflags-$(CONFIG_MIPS_COMPACT_BRANCHES_ALWAYS) += -mcompact-branches=always
210
207# 211#
208# Firmware support 212# Firmware support
209# 213#
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 17503a05938e..6d38948f0f1e 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -105,11 +105,28 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus,
105 struct ssb_init_invariants *iv) 105 struct ssb_init_invariants *iv)
106{ 106{
107 char buf[20]; 107 char buf[20];
108 int len, err;
108 109
109 /* Fill boardinfo structure */ 110 /* Fill boardinfo structure */
110 memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo)); 111 memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo));
111 112
112 bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL); 113 len = bcm47xx_nvram_getenv("boardvendor", buf, sizeof(buf));
114 if (len > 0) {
115 err = kstrtou16(strim(buf), 0, &iv->boardinfo.vendor);
116 if (err)
117 pr_warn("Couldn't parse nvram board vendor entry with value \"%s\"\n",
118 buf);
119 }
120 if (!iv->boardinfo.vendor)
121 iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
122
123 len = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
124 if (len > 0) {
125 err = kstrtou16(strim(buf), 0, &iv->boardinfo.type);
126 if (err)
127 pr_warn("Couldn't parse nvram board type entry with value \"%s\"\n",
128 buf);
129 }
113 130
114 memset(&iv->sprom, 0, sizeof(struct ssb_sprom)); 131 memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
115 bcm47xx_fill_sprom(&iv->sprom, NULL, false); 132 bcm47xx_fill_sprom(&iv->sprom, NULL, false);
diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
index 2d5c7a7f24bb..a7e569c7968e 100644
--- a/arch/mips/bcm47xx/sprom.c
+++ b/arch/mips/bcm47xx/sprom.c
@@ -60,9 +60,9 @@ static int get_nvram_var(const char *prefix, const char *postfix,
60} 60}
61 61
62#define NVRAM_READ_VAL(type) \ 62#define NVRAM_READ_VAL(type) \
63static void nvram_read_ ## type (const char *prefix, \ 63static void nvram_read_ ## type(const char *prefix, \
64 const char *postfix, const char *name, \ 64 const char *postfix, const char *name, \
65 type *val, type allset, bool fallback) \ 65 type *val, type allset, bool fallback) \
66{ \ 66{ \
67 char buf[100]; \ 67 char buf[100]; \
68 int err; \ 68 int err; \
@@ -422,7 +422,10 @@ static void bcm47xx_fill_sprom_path_r4589(struct ssb_sprom *sprom,
422 int i; 422 int i;
423 423
424 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { 424 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) {
425 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; 425 struct ssb_sprom_core_pwr_info *pwr_info;
426
427 pwr_info = &sprom->core_pwr_info[i];
428
426 snprintf(postfix, sizeof(postfix), "%i", i); 429 snprintf(postfix, sizeof(postfix), "%i", i);
427 nvram_read_u8(prefix, postfix, "maxp2ga", 430 nvram_read_u8(prefix, postfix, "maxp2ga",
428 &pwr_info->maxpwr_2g, 0, fallback); 431 &pwr_info->maxpwr_2g, 0, fallback);
@@ -470,7 +473,10 @@ static void bcm47xx_fill_sprom_path_r45(struct ssb_sprom *sprom,
470 int i; 473 int i;
471 474
472 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { 475 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) {
473 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; 476 struct ssb_sprom_core_pwr_info *pwr_info;
477
478 pwr_info = &sprom->core_pwr_info[i];
479
474 snprintf(postfix, sizeof(postfix), "%i", i); 480 snprintf(postfix, sizeof(postfix), "%i", i);
475 nvram_read_u16(prefix, postfix, "pa2gw3a", 481 nvram_read_u16(prefix, postfix, "pa2gw3a",
476 &pwr_info->pa_2g[3], 0, fallback); 482 &pwr_info->pa_2g[3], 0, fallback);
@@ -535,10 +541,11 @@ static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom,
535 nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback); 541 nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback);
536 542
537 /* The address prefix 00:90:4C is used by Broadcom in their initial 543 /* The address prefix 00:90:4C is used by Broadcom in their initial
538 configuration. When a mac address with the prefix 00:90:4C is used 544 * configuration. When a mac address with the prefix 00:90:4C is used
539 all devices from the same series are sharing the same mac address. 545 * all devices from the same series are sharing the same mac address.
540 To prevent mac address collisions we replace them with a mac address 546 * To prevent mac address collisions we replace them with a mac address
541 based on the base address. */ 547 * based on the base address.
548 */
542 if (!bcm47xx_is_valid_mac(sprom->il0mac)) { 549 if (!bcm47xx_is_valid_mac(sprom->il0mac)) {
543 u8 mac[6]; 550 u8 mac[6];
544 551
@@ -592,32 +599,23 @@ void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
592 bcm47xx_sprom_fill_auto(sprom, prefix, fallback); 599 bcm47xx_sprom_fill_auto(sprom, prefix, fallback);
593} 600}
594 601
595#ifdef CONFIG_BCM47XX_SSB
596void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
597 const char *prefix)
598{
599 nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
600 true);
601 if (!boardinfo->vendor)
602 boardinfo->vendor = SSB_BOARDVENDOR_BCM;
603
604 nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
605}
606#endif
607
608#if defined(CONFIG_BCM47XX_SSB) 602#if defined(CONFIG_BCM47XX_SSB)
609static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) 603static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
610{ 604{
611 char prefix[10]; 605 char prefix[10];
612 606
613 if (bus->bustype == SSB_BUSTYPE_PCI) { 607 switch (bus->bustype) {
608 case SSB_BUSTYPE_SSB:
609 bcm47xx_fill_sprom(out, NULL, false);
610 return 0;
611 case SSB_BUSTYPE_PCI:
614 memset(out, 0, sizeof(struct ssb_sprom)); 612 memset(out, 0, sizeof(struct ssb_sprom));
615 snprintf(prefix, sizeof(prefix), "pci/%u/%u/", 613 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
616 bus->host_pci->bus->number + 1, 614 bus->host_pci->bus->number + 1,
617 PCI_SLOT(bus->host_pci->devfn)); 615 PCI_SLOT(bus->host_pci->devfn));
618 bcm47xx_fill_sprom(out, prefix, false); 616 bcm47xx_fill_sprom(out, prefix, false);
619 return 0; 617 return 0;
620 } else { 618 default:
621 pr_warn("Unable to fill SPROM for given bustype.\n"); 619 pr_warn("Unable to fill SPROM for given bustype.\n");
622 return -EINVAL; 620 return -EINVAL;
623 } 621 }
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index 33727e7f0c79..b2097c0d2ed7 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -7,6 +7,8 @@
7 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org> 7 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/init.h> 12#include <linux/init.h>
11#include <linux/kernel.h> 13#include <linux/kernel.h>
12#include <linux/string.h> 14#include <linux/string.h>
@@ -31,7 +33,6 @@
31 33
32#include <uapi/linux/bcm933xx_hcs.h> 34#include <uapi/linux/bcm933xx_hcs.h>
33 35
34#define PFX "board_bcm963xx: "
35 36
36#define HCS_OFFSET_128K 0x20000 37#define HCS_OFFSET_128K 0x20000
37 38
@@ -740,7 +741,7 @@ int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
740 memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom)); 741 memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
741 return 0; 742 return 0;
742 } else { 743 } else {
743 printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n"); 744 pr_err("unable to fill SPROM for given bustype\n");
744 return -EINVAL; 745 return -EINVAL;
745 } 746 }
746} 747}
@@ -784,7 +785,7 @@ void __init board_prom_init(void)
784 cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]); 785 cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]);
785 else 786 else
786 strcpy(cfe_version, "unknown"); 787 strcpy(cfe_version, "unknown");
787 printk(KERN_INFO PFX "CFE version: %s\n", cfe_version); 788 pr_info("CFE version: %s\n", cfe_version);
788 789
789 bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET); 790 bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
790 791
@@ -808,8 +809,7 @@ void __init board_prom_init(void)
808 char name[17]; 809 char name[17];
809 memcpy(name, board_name, 16); 810 memcpy(name, board_name, 16);
810 name[16] = 0; 811 name[16] = 0;
811 printk(KERN_ERR PFX "unknown bcm963xx board: %s\n", 812 pr_err("unknown bcm963xx board: %s\n", name);
812 name);
813 return; 813 return;
814 } 814 }
815 815
@@ -854,7 +854,7 @@ void __init board_setup(void)
854{ 854{
855 if (!board.name[0]) 855 if (!board.name[0])
856 panic("unable to detect bcm963xx board"); 856 panic("unable to detect bcm963xx board");
857 printk(KERN_INFO PFX "board name: %s\n", board.name); 857 pr_info("board name: %s\n", board.name);
858 858
859 /* make sure we're running on expected cpu */ 859 /* make sure we're running on expected cpu */
860 if (bcm63xx_get_cpu_id() != board.expected_cpu_id) 860 if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
@@ -910,7 +910,7 @@ int __init board_register_devices(void)
910 memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN); 910 memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
911 if (ssb_arch_register_fallback_sprom( 911 if (ssb_arch_register_fallback_sprom(
912 &bcm63xx_get_fallback_sprom) < 0) 912 &bcm63xx_get_fallback_sprom) < 0)
913 pr_err(PFX "failed to register fallback SPROM\n"); 913 pr_err("failed to register fallback SPROM\n");
914 } 914 }
915#endif 915#endif
916 916
diff --git a/arch/mips/bcm63xx/cpu.c b/arch/mips/bcm63xx/cpu.c
index 307ec8b8e41c..1c7c3fbfa1f3 100644
--- a/arch/mips/bcm63xx/cpu.c
+++ b/arch/mips/bcm63xx/cpu.c
@@ -376,10 +376,10 @@ void __init bcm63xx_cpu_init(void)
376 bcm63xx_cpu_freq = detect_cpu_clock(); 376 bcm63xx_cpu_freq = detect_cpu_clock();
377 bcm63xx_memory_size = detect_memory_size(); 377 bcm63xx_memory_size = detect_memory_size();
378 378
379 printk(KERN_INFO "Detected Broadcom 0x%04x CPU revision %02x\n", 379 pr_info("Detected Broadcom 0x%04x CPU revision %02x\n",
380 bcm63xx_cpu_id, bcm63xx_cpu_rev); 380 bcm63xx_cpu_id, bcm63xx_cpu_rev);
381 printk(KERN_INFO "CPU frequency is %u MHz\n", 381 pr_info("CPU frequency is %u MHz\n",
382 bcm63xx_cpu_freq / 1000000); 382 bcm63xx_cpu_freq / 1000000);
383 printk(KERN_INFO "%uMB of RAM installed\n", 383 pr_info("%uMB of RAM installed\n",
384 bcm63xx_memory_size >> 20); 384 bcm63xx_memory_size >> 20);
385} 385}
diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c
index a551bab5ecb9..9496cd236951 100644
--- a/arch/mips/bcm63xx/dev-pcmcia.c
+++ b/arch/mips/bcm63xx/dev-pcmcia.c
@@ -139,6 +139,6 @@ int __init bcm63xx_pcmcia_register(void)
139 return platform_device_register(&bcm63xx_pcmcia_device); 139 return platform_device_register(&bcm63xx_pcmcia_device);
140 140
141out_err: 141out_err:
142 printk(KERN_ERR "unable to set pcmcia chip select\n"); 142 pr_err("unable to set pcmcia chip select\n");
143 return ret; 143 return ret;
144} 144}
diff --git a/arch/mips/bcm63xx/irq.c b/arch/mips/bcm63xx/irq.c
index 1a47ec2a0906..c96139097ae2 100644
--- a/arch/mips/bcm63xx/irq.c
+++ b/arch/mips/bcm63xx/irq.c
@@ -311,7 +311,7 @@ static int bcm63xx_external_irq_set_type(struct irq_data *d,
311 break; 311 break;
312 312
313 default: 313 default:
314 printk(KERN_ERR "bogus flow type combination given !\n"); 314 pr_err("bogus flow type combination given !\n");
315 return -EINVAL; 315 return -EINVAL;
316 } 316 }
317 317
diff --git a/arch/mips/bcm63xx/setup.c b/arch/mips/bcm63xx/setup.c
index 240fb4ffa55c..2be9caaa2085 100644
--- a/arch/mips/bcm63xx/setup.c
+++ b/arch/mips/bcm63xx/setup.c
@@ -24,7 +24,7 @@
24 24
25void bcm63xx_machine_halt(void) 25void bcm63xx_machine_halt(void)
26{ 26{
27 printk(KERN_INFO "System halted\n"); 27 pr_info("System halted\n");
28 while (1) 28 while (1)
29 ; 29 ;
30} 30}
@@ -34,7 +34,7 @@ static void bcm6348_a1_reboot(void)
34 u32 reg; 34 u32 reg;
35 35
36 /* soft reset all blocks */ 36 /* soft reset all blocks */
37 printk(KERN_INFO "soft-resetting all blocks ...\n"); 37 pr_info("soft-resetting all blocks ...\n");
38 reg = bcm_perf_readl(PERF_SOFTRESET_REG); 38 reg = bcm_perf_readl(PERF_SOFTRESET_REG);
39 reg &= ~SOFTRESET_6348_ALL; 39 reg &= ~SOFTRESET_6348_ALL;
40 bcm_perf_writel(reg, PERF_SOFTRESET_REG); 40 bcm_perf_writel(reg, PERF_SOFTRESET_REG);
@@ -46,7 +46,7 @@ static void bcm6348_a1_reboot(void)
46 mdelay(10); 46 mdelay(10);
47 47
48 /* Jump to the power on address. */ 48 /* Jump to the power on address. */
49 printk(KERN_INFO "jumping to reset vector.\n"); 49 pr_info("jumping to reset vector.\n");
50 /* set high vectors (base at 0xbfc00000 */ 50 /* set high vectors (base at 0xbfc00000 */
51 set_c0_status(ST0_BEV | ST0_ERL); 51 set_c0_status(ST0_BEV | ST0_ERL);
52 /* run uncached in kseg0 */ 52 /* run uncached in kseg0 */
@@ -110,7 +110,7 @@ void bcm63xx_machine_reboot(void)
110 if (BCMCPU_IS_6348() && (bcm63xx_get_cpu_rev() == 0xa1)) 110 if (BCMCPU_IS_6348() && (bcm63xx_get_cpu_rev() == 0xa1))
111 bcm6348_a1_reboot(); 111 bcm6348_a1_reboot();
112 112
113 printk(KERN_INFO "triggering watchdog soft-reset...\n"); 113 pr_info("triggering watchdog soft-reset...\n");
114 if (BCMCPU_IS_6328()) { 114 if (BCMCPU_IS_6328()) {
115 bcm_wdt_writel(1, WDT_SOFTRESET_REG); 115 bcm_wdt_writel(1, WDT_SOFTRESET_REG);
116 } else { 116 } else {
diff --git a/arch/mips/bcm63xx/timer.c b/arch/mips/bcm63xx/timer.c
index 5f1135981568..2110359c00e5 100644
--- a/arch/mips/bcm63xx/timer.c
+++ b/arch/mips/bcm63xx/timer.c
@@ -195,7 +195,7 @@ int bcm63xx_timer_init(void)
195 irq = bcm63xx_get_irq_number(IRQ_TIMER); 195 irq = bcm63xx_get_irq_number(IRQ_TIMER);
196 ret = request_irq(irq, timer_interrupt, 0, "bcm63xx_timer", NULL); 196 ret = request_irq(irq, timer_interrupt, 0, "bcm63xx_timer", NULL);
197 if (ret) { 197 if (ret) {
198 printk(KERN_ERR "bcm63xx_timer: failed to register irq\n"); 198 pr_err("%s: failed to register irq\n", __func__);
199 return ret; 199 return ret;
200 } 200 }
201 201
diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c
index 526ec2789bb9..5b16d2955fbb 100644
--- a/arch/mips/bmips/setup.c
+++ b/arch/mips/bmips/setup.c
@@ -157,7 +157,6 @@ void __init plat_mem_setup(void)
157 panic("no dtb found"); 157 panic("no dtb found");
158 158
159 __dt_setup_arch(dtb); 159 __dt_setup_arch(dtb);
160 strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
161 160
162 for (q = bmips_quirk_list; q->quirk_fn; q++) { 161 for (q = bmips_quirk_list; q->quirk_fn; q++) {
163 if (of_flat_dt_is_compatible(of_get_flat_dt_root(), 162 if (of_flat_dt_is_compatible(of_get_flat_dt_root(),
diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
index bac7b8dab9a4..a0bf516ec394 100644
--- a/arch/mips/boot/dts/Makefile
+++ b/arch/mips/boot/dts/Makefile
@@ -6,6 +6,7 @@ dts-dirs += mti
6dts-dirs += netlogic 6dts-dirs += netlogic
7dts-dirs += qca 7dts-dirs += qca
8dts-dirs += ralink 8dts-dirs += ralink
9dts-dirs += xilfpga
9 10
10obj-y := $(addsuffix /, $(dts-dirs)) 11obj-y := $(addsuffix /, $(dts-dirs))
11 12
diff --git a/arch/mips/boot/dts/brcm/bcm7346.dtsi b/arch/mips/boot/dts/brcm/bcm7346.dtsi
index d817bb46b934..d4bf52cfcf17 100644
--- a/arch/mips/boot/dts/brcm/bcm7346.dtsi
+++ b/arch/mips/boot/dts/brcm/bcm7346.dtsi
@@ -87,14 +87,32 @@
87 compatible = "brcm,bcm7120-l2-intc"; 87 compatible = "brcm,bcm7120-l2-intc";
88 reg = <0x406780 0x8>; 88 reg = <0x406780 0x8>;
89 89
90 brcm,int-map-mask = <0x44>; 90 brcm,int-map-mask = <0x44>, <0xf000000>;
91 brcm,int-fwd-mask = <0x70000>; 91 brcm,int-fwd-mask = <0x70000>;
92 92
93 interrupt-controller; 93 interrupt-controller;
94 #interrupt-cells = <1>; 94 #interrupt-cells = <1>;
95 95
96 interrupt-parent = <&periph_intc>; 96 interrupt-parent = <&periph_intc>;
97 interrupts = <59>; 97 interrupts = <59>, <57>;
98 interrupt-names = "upg_main", "upg_bsc";
99 };
100
101 upg_aon_irq0_intc: upg_aon_irq0_intc@408b80 {
102 compatible = "brcm,bcm7120-l2-intc";
103 reg = <0x408b80 0x8>;
104
105 brcm,int-map-mask = <0x40>, <0x8000000>, <0x100000>;
106 brcm,int-fwd-mask = <0>;
107 brcm,irq-can-wake;
108
109 interrupt-controller;
110 #interrupt-cells = <1>;
111
112 interrupt-parent = <&periph_intc>;
113 interrupts = <60>, <58>, <62>;
114 interrupt-names = "upg_main_aon", "upg_bsc_aon",
115 "upg_spi";
98 }; 116 };
99 117
100 sun_top_ctrl: syscon@404000 { 118 sun_top_ctrl: syscon@404000 {
@@ -144,6 +162,56 @@
144 status = "disabled"; 162 status = "disabled";
145 }; 163 };
146 164
165 bsca: i2c@406200 {
166 clock-frequency = <390000>;
167 compatible = "brcm,brcmstb-i2c";
168 interrupt-parent = <&upg_irq0_intc>;
169 reg = <0x406200 0x58>;
170 interrupts = <24>;
171 interrupt-names = "upg_bsca";
172 status = "disabled";
173 };
174
175 bscb: i2c@406280 {
176 clock-frequency = <390000>;
177 compatible = "brcm,brcmstb-i2c";
178 interrupt-parent = <&upg_irq0_intc>;
179 reg = <0x406280 0x58>;
180 interrupts = <25>;
181 interrupt-names = "upg_bscb";
182 status = "disabled";
183 };
184
185 bscc: i2c@406300 {
186 clock-frequency = <390000>;
187 compatible = "brcm,brcmstb-i2c";
188 interrupt-parent = <&upg_irq0_intc>;
189 reg = <0x406300 0x58>;
190 interrupts = <26>;
191 interrupt-names = "upg_bscc";
192 status = "disabled";
193 };
194
195 bscd: i2c@406380 {
196 clock-frequency = <390000>;
197 compatible = "brcm,brcmstb-i2c";
198 interrupt-parent = <&upg_irq0_intc>;
199 reg = <0x406380 0x58>;
200 interrupts = <27>;
201 interrupt-names = "upg_bscd";
202 status = "disabled";
203 };
204
205 bsce: i2c@408980 {
206 clock-frequency = <390000>;
207 compatible = "brcm,brcmstb-i2c";
208 interrupt-parent = <&upg_aon_irq0_intc>;
209 reg = <0x408980 0x58>;
210 interrupts = <27>;
211 interrupt-names = "upg_bsce";
212 status = "disabled";
213 };
214
147 enet0: ethernet@430000 { 215 enet0: ethernet@430000 {
148 phy-mode = "internal"; 216 phy-mode = "internal";
149 phy-handle = <&phy1>; 217 phy-handle = <&phy1>;
@@ -246,5 +314,47 @@
246 interrupts = <76>; 314 interrupts = <76>;
247 status = "disabled"; 315 status = "disabled";
248 }; 316 };
317
318 sata: sata@181000 {
319 compatible = "brcm,bcm7425-ahci", "brcm,sata3-ahci";
320 reg-names = "ahci", "top-ctrl";
321 reg = <0x181000 0xa9c>, <0x180020 0x1c>;
322 interrupt-parent = <&periph_intc>;
323 interrupts = <40>;
324 #address-cells = <1>;
325 #size-cells = <0>;
326 brcm,broken-ncq;
327 brcm,broken-phy;
328 status = "disabled";
329
330 sata0: sata-port@0 {
331 reg = <0>;
332 phys = <&sata_phy0>;
333 };
334
335 sata1: sata-port@1 {
336 reg = <1>;
337 phys = <&sata_phy1>;
338 };
339 };
340
341 sata_phy: sata-phy@1800000 {
342 compatible = "brcm,bcm7425-sata-phy", "brcm,phy-sata3";
343 reg = <0x180100 0x0eff>;
344 reg-names = "phy";
345 #address-cells = <1>;
346 #size-cells = <0>;
347 status = "disabled";
348
349 sata_phy0: sata-phy@0 {
350 reg = <0>;
351 #phy-cells = <0>;
352 };
353
354 sata_phy1: sata-phy@1 {
355 reg = <1>;
356 #phy-cells = <0>;
357 };
358 };
249 }; 359 };
250}; 360};
diff --git a/arch/mips/boot/dts/brcm/bcm7358.dtsi b/arch/mips/boot/dts/brcm/bcm7358.dtsi
index 277a90adc1a7..8e2501694d03 100644
--- a/arch/mips/boot/dts/brcm/bcm7358.dtsi
+++ b/arch/mips/boot/dts/brcm/bcm7358.dtsi
@@ -81,14 +81,32 @@
81 compatible = "brcm,bcm7120-l2-intc"; 81 compatible = "brcm,bcm7120-l2-intc";
82 reg = <0x406600 0x8>; 82 reg = <0x406600 0x8>;
83 83
84 brcm,int-map-mask = <0x44>; 84 brcm,int-map-mask = <0x44>, <0x7000000>;
85 brcm,int-fwd-mask = <0x70000>; 85 brcm,int-fwd-mask = <0x70000>;
86 86
87 interrupt-controller; 87 interrupt-controller;
88 #interrupt-cells = <1>; 88 #interrupt-cells = <1>;
89 89
90 interrupt-parent = <&periph_intc>; 90 interrupt-parent = <&periph_intc>;
91 interrupts = <56>; 91 interrupts = <56>, <54>;
92 interrupt-names = "upg_main", "upg_bsc";
93 };
94
95 upg_aon_irq0_intc: upg_aon_irq0_intc@408b80 {
96 compatible = "brcm,bcm7120-l2-intc";
97 reg = <0x408b80 0x8>;
98
99 brcm,int-map-mask = <0x40>, <0x8000000>, <0x100000>;
100 brcm,int-fwd-mask = <0>;
101 brcm,irq-can-wake;
102
103 interrupt-controller;
104 #interrupt-cells = <1>;
105
106 interrupt-parent = <&periph_intc>;
107 interrupts = <57>, <55>, <59>;
108 interrupt-names = "upg_main_aon", "upg_bsc_aon",
109 "upg_spi";
92 }; 110 };
93 111
94 sun_top_ctrl: syscon@404000 { 112 sun_top_ctrl: syscon@404000 {
@@ -138,6 +156,46 @@
138 status = "disabled"; 156 status = "disabled";
139 }; 157 };
140 158
159 bsca: i2c@406200 {
160 clock-frequency = <390000>;
161 compatible = "brcm,brcmstb-i2c";
162 interrupt-parent = <&upg_irq0_intc>;
163 reg = <0x406200 0x58>;
164 interrupts = <24>;
165 interrupt-names = "upg_bsca";
166 status = "disabled";
167 };
168
169 bscb: i2c@406280 {
170 clock-frequency = <390000>;
171 compatible = "brcm,brcmstb-i2c";
172 interrupt-parent = <&upg_irq0_intc>;
173 reg = <0x406280 0x58>;
174 interrupts = <25>;
175 interrupt-names = "upg_bscb";
176 status = "disabled";
177 };
178
179 bscc: i2c@406300 {
180 clock-frequency = <390000>;
181 compatible = "brcm,brcmstb-i2c";
182 interrupt-parent = <&upg_irq0_intc>;
183 reg = <0x406300 0x58>;
184 interrupts = <26>;
185 interrupt-names = "upg_bscc";
186 status = "disabled";
187 };
188
189 bscd: i2c@408980 {
190 clock-frequency = <390000>;
191 compatible = "brcm,brcmstb-i2c";
192 interrupt-parent = <&upg_aon_irq0_intc>;
193 reg = <0x408980 0x58>;
194 interrupts = <27>;
195 interrupt-names = "upg_bscd";
196 status = "disabled";
197 };
198
141 enet0: ethernet@430000 { 199 enet0: ethernet@430000 {
142 phy-mode = "internal"; 200 phy-mode = "internal";
143 phy-handle = <&phy1>; 201 phy-handle = <&phy1>;
diff --git a/arch/mips/boot/dts/brcm/bcm7360.dtsi b/arch/mips/boot/dts/brcm/bcm7360.dtsi
index 9e1e571ba346..7e5f76040fb8 100644
--- a/arch/mips/boot/dts/brcm/bcm7360.dtsi
+++ b/arch/mips/boot/dts/brcm/bcm7360.dtsi
@@ -81,14 +81,32 @@
81 compatible = "brcm,bcm7120-l2-intc"; 81 compatible = "brcm,bcm7120-l2-intc";
82 reg = <0x406600 0x8>; 82 reg = <0x406600 0x8>;
83 83
84 brcm,int-map-mask = <0x44>; 84 brcm,int-map-mask = <0x44>, <0x7000000>;
85 brcm,int-fwd-mask = <0x70000>; 85 brcm,int-fwd-mask = <0x70000>;
86 86
87 interrupt-controller; 87 interrupt-controller;
88 #interrupt-cells = <1>; 88 #interrupt-cells = <1>;
89 89
90 interrupt-parent = <&periph_intc>; 90 interrupt-parent = <&periph_intc>;
91 interrupts = <56>; 91 interrupts = <56>, <54>;
92 interrupt-names = "upg_main", "upg_bsc";
93 };
94
95 upg_aon_irq0_intc: upg_aon_irq0_intc@408b80 {
96 compatible = "brcm,bcm7120-l2-intc";
97 reg = <0x408b80 0x8>;
98
99 brcm,int-map-mask = <0x40>, <0x8000000>, <0x100000>;
100 brcm,int-fwd-mask = <0>;
101 brcm,irq-can-wake;
102
103 interrupt-controller;
104 #interrupt-cells = <1>;
105
106 interrupt-parent = <&periph_intc>;
107 interrupts = <57>, <55>, <59>;
108 interrupt-names = "upg_main_aon", "upg_bsc_aon",
109 "upg_spi";
92 }; 110 };
93 111
94 sun_top_ctrl: syscon@404000 { 112 sun_top_ctrl: syscon@404000 {
@@ -138,6 +156,46 @@
138 status = "disabled"; 156 status = "disabled";
139 }; 157 };
140 158
159 bsca: i2c@406200 {
160 clock-frequency = <390000>;
161 compatible = "brcm,brcmstb-i2c";
162 interrupt-parent = <&upg_irq0_intc>;
163 reg = <0x406200 0x58>;
164 interrupts = <24>;
165 interrupt-names = "upg_bsca";
166 status = "disabled";
167 };
168
169 bscb: i2c@406280 {
170 clock-frequency = <390000>;
171 compatible = "brcm,brcmstb-i2c";
172 interrupt-parent = <&upg_irq0_intc>;
173 reg = <0x406280 0x58>;
174 interrupts = <25>;
175 interrupt-names = "upg_bscb";
176 status = "disabled";
177 };
178
179 bscc: i2c@406300 {
180 clock-frequency = <390000>;
181 compatible = "brcm,brcmstb-i2c";
182 interrupt-parent = <&upg_irq0_intc>;
183 reg = <0x406300 0x58>;
184 interrupts = <26>;
185 interrupt-names = "upg_bscc";
186 status = "disabled";
187 };
188
189 bscd: i2c@408980 {
190 clock-frequency = <390000>;
191 compatible = "brcm,brcmstb-i2c";
192 interrupt-parent = <&upg_aon_irq0_intc>;
193 reg = <0x408980 0x58>;
194 interrupts = <27>;
195 interrupt-names = "upg_bscd";
196 status = "disabled";
197 };
198
141 enet0: ethernet@430000 { 199 enet0: ethernet@430000 {
142 phy-mode = "internal"; 200 phy-mode = "internal";
143 phy-handle = <&phy1>; 201 phy-handle = <&phy1>;
diff --git a/arch/mips/boot/dts/brcm/bcm7362.dtsi b/arch/mips/boot/dts/brcm/bcm7362.dtsi
index 6e65db86fc61..c739ea77acb0 100644
--- a/arch/mips/boot/dts/brcm/bcm7362.dtsi
+++ b/arch/mips/boot/dts/brcm/bcm7362.dtsi
@@ -87,14 +87,32 @@
87 compatible = "brcm,bcm7120-l2-intc"; 87 compatible = "brcm,bcm7120-l2-intc";
88 reg = <0x406600 0x8>; 88 reg = <0x406600 0x8>;
89 89
90 brcm,int-map-mask = <0x44>; 90 brcm,int-map-mask = <0x44>, <0x7000000>;
91 brcm,int-fwd-mask = <0x70000>; 91 brcm,int-fwd-mask = <0x70000>;
92 92
93 interrupt-controller; 93 interrupt-controller;
94 #interrupt-cells = <1>; 94 #interrupt-cells = <1>;
95 95
96 interrupt-parent = <&periph_intc>; 96 interrupt-parent = <&periph_intc>;
97 interrupts = <56>; 97 interrupts = <56>, <54>;
98 interrupt-names = "upg_main", "upg_bsc";
99 };
100
101 upg_aon_irq0_intc: upg_aon_irq0_intc@408b80 {
102 compatible = "brcm,bcm7120-l2-intc";
103 reg = <0x408b80 0x8>;
104
105 brcm,int-map-mask = <0x40>, <0x8000000>, <0x100000>;
106 brcm,int-fwd-mask = <0>;
107 brcm,irq-can-wake;
108
109 interrupt-controller;
110 #interrupt-cells = <1>;
111
112 interrupt-parent = <&periph_intc>;
113 interrupts = <57>, <55>, <59>;
114 interrupt-names = "upg_main_aon", "upg_bsc_aon",
115 "upg_spi";
98 }; 116 };
99 117
100 sun_top_ctrl: syscon@404000 { 118 sun_top_ctrl: syscon@404000 {
@@ -144,6 +162,36 @@
144 status = "disabled"; 162 status = "disabled";
145 }; 163 };
146 164
165 bsca: i2c@406200 {
166 clock-frequency = <390000>;
167 compatible = "brcm,brcmstb-i2c";
168 interrupt-parent = <&upg_irq0_intc>;
169 reg = <0x406200 0x58>;
170 interrupts = <24>;
171 interrupt-names = "upg_bsca";
172 status = "disabled";
173 };
174
175 bscb: i2c@406280 {
176 clock-frequency = <390000>;
177 compatible = "brcm,brcmstb-i2c";
178 interrupt-parent = <&upg_irq0_intc>;
179 reg = <0x406280 0x58>;
180 interrupts = <25>;
181 interrupt-names = "upg_bscb";
182 status = "disabled";
183 };
184
185 bscd: i2c@408980 {
186 clock-frequency = <390000>;
187 compatible = "brcm,brcmstb-i2c";
188 interrupt-parent = <&upg_aon_irq0_intc>;
189 reg = <0x408980 0x58>;
190 interrupts = <27>;
191 interrupt-names = "upg_bscd";
192 status = "disabled";
193 };
194
147 enet0: ethernet@430000 { 195 enet0: ethernet@430000 {
148 phy-mode = "internal"; 196 phy-mode = "internal";
149 phy-handle = <&phy1>; 197 phy-handle = <&phy1>;
@@ -189,5 +237,47 @@
189 interrupts = <66>; 237 interrupts = <66>;
190 status = "disabled"; 238 status = "disabled";
191 }; 239 };
240
241 sata: sata@181000 {
242 compatible = "brcm,bcm7425-ahci", "brcm,sata3-ahci";
243 reg-names = "ahci", "top-ctrl";
244 reg = <0x181000 0xa9c>, <0x180020 0x1c>;
245 interrupt-parent = <&periph_intc>;
246 interrupts = <86>;
247 #address-cells = <1>;
248 #size-cells = <0>;
249 brcm,broken-ncq;
250 brcm,broken-phy;
251 status = "disabled";
252
253 sata0: sata-port@0 {
254 reg = <0>;
255 phys = <&sata_phy0>;
256 };
257
258 sata1: sata-port@1 {
259 reg = <1>;
260 phys = <&sata_phy1>;
261 };
262 };
263
264 sata_phy: sata-phy@1800000 {
265 compatible = "brcm,bcm7425-sata-phy", "brcm,phy-sata3";
266 reg = <0x180100 0x0eff>;
267 reg-names = "phy";
268 #address-cells = <1>;
269 #size-cells = <0>;
270 status = "disabled";
271
272 sata_phy0: sata-phy@0 {
273 reg = <0>;
274 #phy-cells = <0>;
275 };
276
277 sata_phy1: sata-phy@1 {
278 reg = <1>;
279 #phy-cells = <0>;
280 };
281 };
192 }; 282 };
193}; 283};
diff --git a/arch/mips/boot/dts/brcm/bcm7425.dtsi b/arch/mips/boot/dts/brcm/bcm7425.dtsi
index 5b660b617ead..e24d41ab4e30 100644
--- a/arch/mips/boot/dts/brcm/bcm7425.dtsi
+++ b/arch/mips/boot/dts/brcm/bcm7425.dtsi
@@ -221,5 +221,47 @@
221 interrupts = <73>; 221 interrupts = <73>;
222 status = "disabled"; 222 status = "disabled";
223 }; 223 };
224
225 sata: sata@181000 {
226 compatible = "brcm,bcm7425-ahci", "brcm,sata3-ahci";
227 reg-names = "ahci", "top-ctrl";
228 reg = <0x181000 0xa9c>, <0x180020 0x1c>;
229 interrupt-parent = <&periph_intc>;
230 interrupts = <40>;
231 #address-cells = <1>;
232 #size-cells = <0>;
233 brcm,broken-ncq;
234 brcm,broken-phy;
235 status = "disabled";
236
237 sata0: sata-port@0 {
238 reg = <0>;
239 phys = <&sata_phy0>;
240 };
241
242 sata1: sata-port@1 {
243 reg = <1>;
244 phys = <&sata_phy1>;
245 };
246 };
247
248 sata_phy: sata-phy@1800000 {
249 compatible = "brcm,bcm7425-sata-phy", "brcm,phy-sata3";
250 reg = <0x180100 0x0eff>;
251 reg-names = "phy";
252 #address-cells = <1>;
253 #size-cells = <0>;
254 status = "disabled";
255
256 sata_phy0: sata-phy@0 {
257 reg = <0>;
258 #phy-cells = <0>;
259 };
260
261 sata_phy1: sata-phy@1 {
262 reg = <1>;
263 #phy-cells = <0>;
264 };
265 };
224 }; 266 };
225}; 267};
diff --git a/arch/mips/boot/dts/brcm/bcm97346dbsmb.dts b/arch/mips/boot/dts/brcm/bcm97346dbsmb.dts
index 3fe0445b9d37..d3d28816a027 100644
--- a/arch/mips/boot/dts/brcm/bcm97346dbsmb.dts
+++ b/arch/mips/boot/dts/brcm/bcm97346dbsmb.dts
@@ -29,6 +29,26 @@
29 status = "okay"; 29 status = "okay";
30}; 30};
31 31
32&bsca {
33 status = "okay";
34};
35
36&bscb {
37 status = "okay";
38};
39
40&bscc {
41 status = "okay";
42};
43
44&bscd {
45 status = "okay";
46};
47
48&bsce {
49 status = "okay";
50};
51
32&enet0 { 52&enet0 {
33 status = "okay"; 53 status = "okay";
34}; 54};
@@ -64,3 +84,11 @@
64&ohci3 { 84&ohci3 {
65 status = "okay"; 85 status = "okay";
66}; 86};
87
88&sata {
89 status = "okay";
90};
91
92&sata_phy {
93 status = "okay";
94};
diff --git a/arch/mips/boot/dts/brcm/bcm97358svmb.dts b/arch/mips/boot/dts/brcm/bcm97358svmb.dts
index a8dc01e30313..02ce6b429dc4 100644
--- a/arch/mips/boot/dts/brcm/bcm97358svmb.dts
+++ b/arch/mips/boot/dts/brcm/bcm97358svmb.dts
@@ -29,6 +29,22 @@
29 status = "okay"; 29 status = "okay";
30}; 30};
31 31
32&bsca {
33 status = "okay";
34};
35
36&bscb {
37 status = "okay";
38};
39
40&bscc {
41 status = "okay";
42};
43
44&bscd {
45 status = "okay";
46};
47
32&enet0 { 48&enet0 {
33 status = "okay"; 49 status = "okay";
34}; 50};
diff --git a/arch/mips/boot/dts/brcm/bcm97360svmb.dts b/arch/mips/boot/dts/brcm/bcm97360svmb.dts
index eee8b0e32681..d48462e091f1 100644
--- a/arch/mips/boot/dts/brcm/bcm97360svmb.dts
+++ b/arch/mips/boot/dts/brcm/bcm97360svmb.dts
@@ -29,6 +29,22 @@
29 status = "okay"; 29 status = "okay";
30}; 30};
31 31
32&bsca {
33 status = "okay";
34};
35
36&bscb {
37 status = "okay";
38};
39
40&bscc {
41 status = "okay";
42};
43
44&bscd {
45 status = "okay";
46};
47
32&enet0 { 48&enet0 {
33 status = "okay"; 49 status = "okay";
34}; 50};
diff --git a/arch/mips/boot/dts/brcm/bcm97362svmb.dts b/arch/mips/boot/dts/brcm/bcm97362svmb.dts
index 739c2ef5663b..3cfcaebe7f79 100644
--- a/arch/mips/boot/dts/brcm/bcm97362svmb.dts
+++ b/arch/mips/boot/dts/brcm/bcm97362svmb.dts
@@ -29,6 +29,18 @@
29 status = "okay"; 29 status = "okay";
30}; 30};
31 31
32&bsca {
33 status = "okay";
34};
35
36&bscb {
37 status = "okay";
38};
39
40&bscd {
41 status = "okay";
42};
43
32&enet0 { 44&enet0 {
33 status = "okay"; 45 status = "okay";
34}; 46};
@@ -40,3 +52,11 @@
40&ohci0 { 52&ohci0 {
41 status = "okay"; 53 status = "okay";
42}; 54};
55
56&sata {
57 status = "okay";
58};
59
60&sata_phy {
61 status = "okay";
62};
diff --git a/arch/mips/boot/dts/mti/malta.dts b/arch/mips/boot/dts/mti/malta.dts
index c678115f5b7f..b18c46637d21 100644
--- a/arch/mips/boot/dts/mti/malta.dts
+++ b/arch/mips/boot/dts/mti/malta.dts
@@ -1,5 +1,9 @@
1/dts-v1/; 1/dts-v1/;
2 2
3/memreserve/ 0x00000000 0x00001000; /* YAMON exception vectors */
4/memreserve/ 0x00001000 0x000ef000; /* YAMON */
5/memreserve/ 0x000f0000 0x00010000; /* PIIX4 ISA memory */
6
3/ { 7/ {
4 #address-cells = <1>; 8 #address-cells = <1>;
5 #size-cells = <1>; 9 #size-cells = <1>;
diff --git a/arch/mips/boot/dts/xilfpga/Makefile b/arch/mips/boot/dts/xilfpga/Makefile
new file mode 100644
index 000000000000..913a752a9ff1
--- /dev/null
+++ b/arch/mips/boot/dts/xilfpga/Makefile
@@ -0,0 +1,9 @@
1dtb-$(CONFIG_XILFPGA_NEXYS4DDR) += nexys4ddr.dtb
2
3obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
4
5# Force kbuild to make empty built-in.o if necessary
6obj- += dummy.o
7
8always := $(dtb-y)
9clean-files := *.dtb *.dtb.S
diff --git a/arch/mips/boot/dts/xilfpga/microAptiv.dtsi b/arch/mips/boot/dts/xilfpga/microAptiv.dtsi
new file mode 100644
index 000000000000..81d518e75785
--- /dev/null
+++ b/arch/mips/boot/dts/xilfpga/microAptiv.dtsi
@@ -0,0 +1,21 @@
1/ {
2 #address-cells = <1>;
3 #size-cells = <1>;
4 compatible = "img,xilfpga";
5
6 cpus {
7 #address-cells = <1>;
8 #size-cells = <0>;
9 cpu@0 {
10 device_type = "cpu";
11 compatible = "mips,m14Kc";
12 clocks = <&ext>;
13 reg = <0>;
14 };
15 };
16
17 ext: ext {
18 compatible = "fixed-clock";
19 #clock-cells = <0>;
20 };
21};
diff --git a/arch/mips/boot/dts/xilfpga/nexys4ddr.dts b/arch/mips/boot/dts/xilfpga/nexys4ddr.dts
new file mode 100644
index 000000000000..686ebd11386d
--- /dev/null
+++ b/arch/mips/boot/dts/xilfpga/nexys4ddr.dts
@@ -0,0 +1,46 @@
1/dts-v1/;
2
3#include "microAptiv.dtsi"
4
5/ {
6 compatible = "digilent,nexys4ddr";
7
8 memory {
9 device_type = "memory";
10 reg = <0x0 0x08000000>;
11 };
12
13 cpuintc: interrupt-controller@0 {
14 #address-cells = <0>;
15 #interrupt-cells = <1>;
16 interrupt-controller;
17 compatible = "mti,cpu-interrupt-controller";
18 };
19
20 axi_gpio: gpio@10600000 {
21 #gpio-cells = <1>;
22 compatible = "xlnx,xps-gpio-1.00.a";
23 gpio-controller;
24 reg = <0x10600000 0x10000>;
25 xlnx,all-inputs = <0x0>;
26 xlnx,dout-default = <0x0>;
27 xlnx,gpio-width = <0x16>;
28 xlnx,interrupt-present = <0x0>;
29 xlnx,is-dual = <0x0>;
30 xlnx,tri-default = <0xffffffff>;
31 } ;
32
33 axi_uart16550: serial@10400000 {
34 compatible = "ns16550a";
35 reg = <0x10400000 0x10000>;
36
37 reg-shift = <2>;
38 reg-offset = <0x1000>;
39
40 clocks = <&ext>;
41 };
42};
43
44&ext {
45 clock-frequency = <50000000>;
46};
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index bd634259eab9..cd7101fb6227 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -1081,6 +1081,7 @@ void __init prom_free_prom_memory(void)
1081 1081
1082int octeon_prune_device_tree(void); 1082int octeon_prune_device_tree(void);
1083 1083
1084extern const char __appended_dtb;
1084extern const char __dtb_octeon_3xxx_begin; 1085extern const char __dtb_octeon_3xxx_begin;
1085extern const char __dtb_octeon_68xx_begin; 1086extern const char __dtb_octeon_68xx_begin;
1086void __init device_tree_init(void) 1087void __init device_tree_init(void)
@@ -1088,11 +1089,19 @@ void __init device_tree_init(void)
1088 const void *fdt; 1089 const void *fdt;
1089 bool do_prune; 1090 bool do_prune;
1090 1091
1092#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
1093 if (!fdt_check_header(&__appended_dtb)) {
1094 fdt = &__appended_dtb;
1095 do_prune = false;
1096 pr_info("Using appended Device Tree.\n");
1097 } else
1098#endif
1091 if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) { 1099 if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) {
1092 fdt = phys_to_virt(octeon_bootinfo->fdt_addr); 1100 fdt = phys_to_virt(octeon_bootinfo->fdt_addr);
1093 if (fdt_check_header(fdt)) 1101 if (fdt_check_header(fdt))
1094 panic("Corrupt Device Tree passed to kernel."); 1102 panic("Corrupt Device Tree passed to kernel.");
1095 do_prune = false; 1103 do_prune = false;
1104 pr_info("Using passed Device Tree.\n");
1096 } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) { 1105 } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) {
1097 fdt = &__dtb_octeon_68xx_begin; 1106 fdt = &__dtb_octeon_68xx_begin;
1098 do_prune = true; 1107 do_prune = true;
@@ -1106,8 +1115,6 @@ void __init device_tree_init(void)
1106 if (do_prune) { 1115 if (do_prune) {
1107 octeon_prune_device_tree(); 1116 octeon_prune_device_tree();
1108 pr_info("Using internal Device Tree.\n"); 1117 pr_info("Using internal Device Tree.\n");
1109 } else {
1110 pr_info("Using passed Device Tree.\n");
1111 } 1118 }
1112 unflatten_and_copy_device_tree(); 1119 unflatten_and_copy_device_tree();
1113} 1120}
diff --git a/arch/mips/configs/bigsur_defconfig b/arch/mips/configs/bigsur_defconfig
index 1cdff6b6327d..b3e7a1b61220 100644
--- a/arch/mips/configs/bigsur_defconfig
+++ b/arch/mips/configs/bigsur_defconfig
@@ -122,20 +122,20 @@ CONFIG_EEPROM_MAX6875=y
122CONFIG_IDE=y 122CONFIG_IDE=y
123CONFIG_BLK_DEV_IDECD=y 123CONFIG_BLK_DEV_IDECD=y
124CONFIG_BLK_DEV_IDETAPE=y 124CONFIG_BLK_DEV_IDETAPE=y
125CONFIG_IDE_GENERIC=y
126CONFIG_BLK_DEV_GENERIC=y
127CONFIG_BLK_DEV_CMD64X=y
128CONFIG_BLK_DEV_IT8213=m
129CONFIG_BLK_DEV_TC86C001=m 125CONFIG_BLK_DEV_TC86C001=m
130CONFIG_BLK_DEV_SD=y 126CONFIG_BLK_DEV_SD=y
131CONFIG_CHR_DEV_ST=m 127CONFIG_CHR_DEV_ST=y
132CONFIG_BLK_DEV_SR=m 128CONFIG_BLK_DEV_SR=y
133CONFIG_BLK_DEV_SR_VENDOR=y 129CONFIG_BLK_DEV_SR_VENDOR=y
134CONFIG_CHR_DEV_SG=m 130CONFIG_CHR_DEV_SG=m
135CONFIG_CHR_DEV_SCH=m 131CONFIG_CHR_DEV_SCH=m
136CONFIG_ATA=y 132CONFIG_ATA=y
137CONFIG_SATA_SIL24=y 133CONFIG_SATA_SIL24=y
134CONFIG_PATA_CMD64X=y
135CONFIG_PATA_IT8213=m
138CONFIG_PATA_SIL680=y 136CONFIG_PATA_SIL680=y
137CONFIG_ATA_GENERIC=y
138CONFIG_PATA_LEGACY=y
139CONFIG_NETDEVICES=y 139CONFIG_NETDEVICES=y
140CONFIG_NET_ETHERNET=y 140CONFIG_NET_ETHERNET=y
141CONFIG_MII=y 141CONFIG_MII=y
diff --git a/arch/mips/configs/bmips_be_defconfig b/arch/mips/configs/bmips_be_defconfig
index f5585c8f35ad..24dcb90b0f64 100644
--- a/arch/mips/configs/bmips_be_defconfig
+++ b/arch/mips/configs/bmips_be_defconfig
@@ -8,7 +8,7 @@ CONFIG_MIPS_O32_FP64_SUPPORT=y
8# CONFIG_SWAP is not set 8# CONFIG_SWAP is not set
9CONFIG_NO_HZ=y 9CONFIG_NO_HZ=y
10CONFIG_BLK_DEV_INITRD=y 10CONFIG_BLK_DEV_INITRD=y
11# CONFIG_RD_GZIP is not set 11CONFIG_RD_GZIP=y
12CONFIG_EXPERT=y 12CONFIG_EXPERT=y
13# CONFIG_VM_EVENT_COUNTERS is not set 13# CONFIG_VM_EVENT_COUNTERS is not set
14# CONFIG_SLUB_DEBUG is not set 14# CONFIG_SLUB_DEBUG is not set
@@ -33,6 +33,7 @@ CONFIG_DEVTMPFS=y
33CONFIG_DEVTMPFS_MOUNT=y 33CONFIG_DEVTMPFS_MOUNT=y
34# CONFIG_STANDALONE is not set 34# CONFIG_STANDALONE is not set
35# CONFIG_PREVENT_FIRMWARE_BUILD is not set 35# CONFIG_PREVENT_FIRMWARE_BUILD is not set
36CONFIG_PRINTK_TIME=y
36CONFIG_BRCMSTB_GISB_ARB=y 37CONFIG_BRCMSTB_GISB_ARB=y
37CONFIG_MTD=y 38CONFIG_MTD=y
38CONFIG_MTD_CFI=y 39CONFIG_MTD_CFI=y
diff --git a/arch/mips/configs/bmips_stb_defconfig b/arch/mips/configs/bmips_stb_defconfig
index 400a47ec1ef1..4eb5d6e9cf8f 100644
--- a/arch/mips/configs/bmips_stb_defconfig
+++ b/arch/mips/configs/bmips_stb_defconfig
@@ -9,7 +9,7 @@ CONFIG_MIPS_O32_FP64_SUPPORT=y
9# CONFIG_SWAP is not set 9# CONFIG_SWAP is not set
10CONFIG_NO_HZ=y 10CONFIG_NO_HZ=y
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12# CONFIG_RD_GZIP is not set 12CONFIG_RD_GZIP=y
13CONFIG_EXPERT=y 13CONFIG_EXPERT=y
14# CONFIG_VM_EVENT_COUNTERS is not set 14# CONFIG_VM_EVENT_COUNTERS is not set
15# CONFIG_SLUB_DEBUG is not set 15# CONFIG_SLUB_DEBUG is not set
@@ -34,6 +34,7 @@ CONFIG_DEVTMPFS=y
34CONFIG_DEVTMPFS_MOUNT=y 34CONFIG_DEVTMPFS_MOUNT=y
35# CONFIG_STANDALONE is not set 35# CONFIG_STANDALONE is not set
36# CONFIG_PREVENT_FIRMWARE_BUILD is not set 36# CONFIG_PREVENT_FIRMWARE_BUILD is not set
37CONFIG_PRINTK_TIME=y
37CONFIG_BRCMSTB_GISB_ARB=y 38CONFIG_BRCMSTB_GISB_ARB=y
38CONFIG_MTD=y 39CONFIG_MTD=y
39CONFIG_MTD_CFI=y 40CONFIG_MTD_CFI=y
diff --git a/arch/mips/configs/capcella_defconfig b/arch/mips/configs/capcella_defconfig
index 5135dc0b950a..2924ba34a01b 100644
--- a/arch/mips/configs/capcella_defconfig
+++ b/arch/mips/configs/capcella_defconfig
@@ -31,9 +31,9 @@ CONFIG_NETWORK_SECMARK=y
31CONFIG_IP_SCTP=m 31CONFIG_IP_SCTP=m
32CONFIG_FW_LOADER=m 32CONFIG_FW_LOADER=m
33CONFIG_BLK_DEV_RAM=y 33CONFIG_BLK_DEV_RAM=y
34# CONFIG_MISC_DEVICES is not set 34CONFIG_BLK_DEV_SD=y
35CONFIG_IDE=y 35CONFIG_ATA=y
36CONFIG_IDE_GENERIC=y 36CONFIG_PATA_LEGACY=y
37CONFIG_NETDEVICES=y 37CONFIG_NETDEVICES=y
38CONFIG_PHYLIB=m 38CONFIG_PHYLIB=m
39CONFIG_MARVELL_PHY=m 39CONFIG_MARVELL_PHY=m
diff --git a/arch/mips/configs/e55_defconfig b/arch/mips/configs/e55_defconfig
index 0126e66d60cb..e94d266c4b97 100644
--- a/arch/mips/configs/e55_defconfig
+++ b/arch/mips/configs/e55_defconfig
@@ -14,9 +14,9 @@ CONFIG_MODVERSIONS=y
14CONFIG_MODULE_SRCVERSION_ALL=y 14CONFIG_MODULE_SRCVERSION_ALL=y
15# CONFIG_BLK_DEV_BSG is not set 15# CONFIG_BLK_DEV_BSG is not set
16CONFIG_BLK_DEV_RAM=y 16CONFIG_BLK_DEV_RAM=y
17# CONFIG_MISC_DEVICES is not set 17CONFIG_BLK_DEV_SD=y
18CONFIG_IDE=y 18CONFIG_ATA=y
19CONFIG_IDE_GENERIC=y 19CONFIG_PATA_LEGACY=y
20# CONFIG_INPUT_MOUSEDEV is not set 20# CONFIG_INPUT_MOUSEDEV is not set
21# CONFIG_INPUT_KEYBOARD is not set 21# CONFIG_INPUT_KEYBOARD is not set
22# CONFIG_INPUT_MOUSE is not set 22# CONFIG_INPUT_MOUSE is not set
diff --git a/arch/mips/configs/fuloong2e_defconfig b/arch/mips/configs/fuloong2e_defconfig
index a75c65da08b4..87435897fd50 100644
--- a/arch/mips/configs/fuloong2e_defconfig
+++ b/arch/mips/configs/fuloong2e_defconfig
@@ -34,7 +34,7 @@ CONFIG_MIPS32_N32=y
34CONFIG_PM=y 34CONFIG_PM=y
35# CONFIG_SUSPEND is not set 35# CONFIG_SUSPEND is not set
36CONFIG_HIBERNATION=y 36CONFIG_HIBERNATION=y
37CONFIG_PM_STD_PARTITION="/dev/hda3" 37CONFIG_PM_STD_PARTITION="/dev/sda3"
38CONFIG_NET=y 38CONFIG_NET=y
39CONFIG_PACKET=y 39CONFIG_PACKET=y
40CONFIG_UNIX=y 40CONFIG_UNIX=y
@@ -114,20 +114,16 @@ CONFIG_BLK_DEV_CRYPTOLOOP=m
114CONFIG_BLK_DEV_RAM=m 114CONFIG_BLK_DEV_RAM=m
115CONFIG_CDROM_PKTCDVD=m 115CONFIG_CDROM_PKTCDVD=m
116CONFIG_ATA_OVER_ETH=m 116CONFIG_ATA_OVER_ETH=m
117# CONFIG_MISC_DEVICES is not set
118CONFIG_IDE=y
119CONFIG_BLK_DEV_IDECD=y
120CONFIG_IDE_TASK_IOCTL=y
121CONFIG_IDE_GENERIC=y
122CONFIG_BLK_DEV_GENERIC=y
123CONFIG_BLK_DEV_VIA82CXXX=y
124CONFIG_SCSI=y
125CONFIG_BLK_DEV_SD=y 117CONFIG_BLK_DEV_SD=y
126CONFIG_BLK_DEV_SR=y 118CONFIG_BLK_DEV_SR=y
127CONFIG_BLK_DEV_SR_VENDOR=y 119CONFIG_BLK_DEV_SR_VENDOR=y
128CONFIG_CHR_DEV_SG=y 120CONFIG_CHR_DEV_SG=y
129CONFIG_SCSI_CONSTANTS=y 121CONFIG_SCSI_CONSTANTS=y
130# CONFIG_SCSI_LOWLEVEL is not set 122# CONFIG_SCSI_LOWLEVEL is not set
123CONFIG_ATA=y
124CONFIG_PATA_VIA=y
125CONFIG_ATA_GENERIC=y
126CONFIG_PATA_LEGACY=y
131CONFIG_NETDEVICES=y 127CONFIG_NETDEVICES=y
132CONFIG_MACVLAN=m 128CONFIG_MACVLAN=m
133CONFIG_VETH=m 129CONFIG_VETH=m
diff --git a/arch/mips/configs/lasat_defconfig b/arch/mips/configs/lasat_defconfig
index 0179c7fa014f..e620a2c3eba4 100644
--- a/arch/mips/configs/lasat_defconfig
+++ b/arch/mips/configs/lasat_defconfig
@@ -35,11 +35,11 @@ CONFIG_MTD_CHAR=y
35CONFIG_MTD_BLOCK=y 35CONFIG_MTD_BLOCK=y
36CONFIG_MTD_CFI=y 36CONFIG_MTD_CFI=y
37CONFIG_MTD_CFI_AMDSTD=y 37CONFIG_MTD_CFI_AMDSTD=y
38# CONFIG_MISC_DEVICES is not set 38CONFIG_BLK_DEV_SD=y
39CONFIG_IDE=y 39CONFIG_ATA=y
40CONFIG_IDE_GENERIC=y 40CONFIG_PATA_CMD64X=y
41CONFIG_BLK_DEV_GENERIC=y 41CONFIG_ATA_GENERIC=y
42CONFIG_BLK_DEV_CMD64X=y 42CONFIG_PATA_LEGACY=y
43CONFIG_NETDEVICES=y 43CONFIG_NETDEVICES=y
44CONFIG_NET_ETHERNET=y 44CONFIG_NET_ETHERNET=y
45CONFIG_NET_PCI=y 45CONFIG_NET_PCI=y
diff --git a/arch/mips/configs/lemote2f_defconfig b/arch/mips/configs/lemote2f_defconfig
index 54cc3853d259..004cf52d1b7d 100644
--- a/arch/mips/configs/lemote2f_defconfig
+++ b/arch/mips/configs/lemote2f_defconfig
@@ -108,16 +108,11 @@ CONFIG_BLK_DEV_LOOP=y
108CONFIG_BLK_DEV_CRYPTOLOOP=m 108CONFIG_BLK_DEV_CRYPTOLOOP=m
109CONFIG_BLK_DEV_RAM=y 109CONFIG_BLK_DEV_RAM=y
110CONFIG_BLK_DEV_RAM_SIZE=8192 110CONFIG_BLK_DEV_RAM_SIZE=8192
111# CONFIG_MISC_DEVICES is not set 111CONFIG_BLK_DEV_SD=y
112CONFIG_IDE=y
113CONFIG_IDE_TASK_IOCTL=y
114# CONFIG_IDEPCI_PCIBUS_ORDER is not set
115CONFIG_BLK_DEV_AMD74XX=y
116CONFIG_SCSI=m
117CONFIG_BLK_DEV_SD=m
118CONFIG_CHR_DEV_SG=m 112CONFIG_CHR_DEV_SG=m
119CONFIG_SCSI_MULTI_LUN=y
120# CONFIG_SCSI_LOWLEVEL is not set 113# CONFIG_SCSI_LOWLEVEL is not set
114CONFIG_ATA=y
115CONFIG_PATA_AMD=y
121CONFIG_MD=y 116CONFIG_MD=y
122CONFIG_BLK_DEV_MD=m 117CONFIG_BLK_DEV_MD=m
123CONFIG_MD_LINEAR=m 118CONFIG_MD_LINEAR=m
diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index 61a4460d67d3..5afb4840aec7 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -241,14 +241,11 @@ CONFIG_BLK_DEV_NBD=m
241CONFIG_BLK_DEV_RAM=y 241CONFIG_BLK_DEV_RAM=y
242CONFIG_CDROM_PKTCDVD=m 242CONFIG_CDROM_PKTCDVD=m
243CONFIG_ATA_OVER_ETH=m 243CONFIG_ATA_OVER_ETH=m
244CONFIG_IDE=y
245CONFIG_BLK_DEV_IDECD=y
246CONFIG_IDE_GENERIC=y
247CONFIG_RAID_ATTRS=m 244CONFIG_RAID_ATTRS=m
248CONFIG_BLK_DEV_SD=y 245CONFIG_BLK_DEV_SD=y
249CONFIG_CHR_DEV_ST=m 246CONFIG_CHR_DEV_ST=m
250CONFIG_CHR_DEV_OSST=m 247CONFIG_CHR_DEV_OSST=m
251CONFIG_BLK_DEV_SR=m 248CONFIG_BLK_DEV_SR=y
252CONFIG_BLK_DEV_SR_VENDOR=y 249CONFIG_BLK_DEV_SR_VENDOR=y
253CONFIG_CHR_DEV_SG=m 250CONFIG_CHR_DEV_SG=m
254CONFIG_SCSI_CONSTANTS=y 251CONFIG_SCSI_CONSTANTS=y
@@ -265,6 +262,7 @@ CONFIG_AIC7XXX_RESET_DELAY_MS=15000
265# CONFIG_AIC7XXX_DEBUG_ENABLE is not set 262# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
266CONFIG_ATA=y 263CONFIG_ATA=y
267CONFIG_ATA_PIIX=y 264CONFIG_ATA_PIIX=y
265CONFIG_PATA_LEGACY=y
268CONFIG_MD=y 266CONFIG_MD=y
269CONFIG_BLK_DEV_MD=m 267CONFIG_BLK_DEV_MD=m
270CONFIG_MD_LINEAR=m 268CONFIG_MD_LINEAR=m
diff --git a/arch/mips/configs/malta_kvm_defconfig b/arch/mips/configs/malta_kvm_defconfig
index d41742dd26c8..98f13879bb8f 100644
--- a/arch/mips/configs/malta_kvm_defconfig
+++ b/arch/mips/configs/malta_kvm_defconfig
@@ -248,17 +248,12 @@ CONFIG_CDROM_PKTCDVD=m
248CONFIG_ATA_OVER_ETH=m 248CONFIG_ATA_OVER_ETH=m
249CONFIG_IDE=y 249CONFIG_IDE=y
250CONFIG_BLK_DEV_IDECD=y 250CONFIG_BLK_DEV_IDECD=y
251CONFIG_IDE_GENERIC=y
252CONFIG_BLK_DEV_GENERIC=y
253CONFIG_BLK_DEV_PIIX=y
254CONFIG_BLK_DEV_IT8213=m
255CONFIG_BLK_DEV_TC86C001=m 251CONFIG_BLK_DEV_TC86C001=m
256CONFIG_RAID_ATTRS=m 252CONFIG_RAID_ATTRS=m
257CONFIG_SCSI=m 253CONFIG_BLK_DEV_SD=y
258CONFIG_BLK_DEV_SD=m
259CONFIG_CHR_DEV_ST=m 254CONFIG_CHR_DEV_ST=m
260CONFIG_CHR_DEV_OSST=m 255CONFIG_CHR_DEV_OSST=m
261CONFIG_BLK_DEV_SR=m 256CONFIG_BLK_DEV_SR=y
262CONFIG_BLK_DEV_SR_VENDOR=y 257CONFIG_BLK_DEV_SR_VENDOR=y
263CONFIG_CHR_DEV_SG=m 258CONFIG_CHR_DEV_SG=m
264CONFIG_SCSI_MULTI_LUN=y 259CONFIG_SCSI_MULTI_LUN=y
@@ -274,6 +269,13 @@ CONFIG_SCSI_AACRAID=m
274CONFIG_SCSI_AIC7XXX=m 269CONFIG_SCSI_AIC7XXX=m
275CONFIG_AIC7XXX_RESET_DELAY_MS=15000 270CONFIG_AIC7XXX_RESET_DELAY_MS=15000
276# CONFIG_AIC7XXX_DEBUG_ENABLE is not set 271# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
272CONFIG_ATA=y
273CONFIG_ATA_PIIX=y
274CONFIG_PATA_IT8213=m
275CONFIG_PATA_OLDPIIX=y
276CONFIG_PATA_MPIIX=y
277CONFIG_ATA_GENERIC=y
278CONFIG_PATA_LEGACY=y
277CONFIG_MD=y 279CONFIG_MD=y
278CONFIG_BLK_DEV_MD=m 280CONFIG_BLK_DEV_MD=m
279CONFIG_MD_LINEAR=m 281CONFIG_MD_LINEAR=m
diff --git a/arch/mips/configs/malta_kvm_guest_defconfig b/arch/mips/configs/malta_kvm_guest_defconfig
index a7806e83ea0f..3b5d5913f548 100644
--- a/arch/mips/configs/malta_kvm_guest_defconfig
+++ b/arch/mips/configs/malta_kvm_guest_defconfig
@@ -248,17 +248,12 @@ CONFIG_ATA_OVER_ETH=m
248CONFIG_VIRTIO_BLK=y 248CONFIG_VIRTIO_BLK=y
249CONFIG_IDE=y 249CONFIG_IDE=y
250CONFIG_BLK_DEV_IDECD=y 250CONFIG_BLK_DEV_IDECD=y
251CONFIG_IDE_GENERIC=y
252CONFIG_BLK_DEV_GENERIC=y
253CONFIG_BLK_DEV_PIIX=y
254CONFIG_BLK_DEV_IT8213=m
255CONFIG_BLK_DEV_TC86C001=m 251CONFIG_BLK_DEV_TC86C001=m
256CONFIG_RAID_ATTRS=m 252CONFIG_RAID_ATTRS=m
257CONFIG_SCSI=m 253CONFIG_BLK_DEV_SD=y
258CONFIG_BLK_DEV_SD=m
259CONFIG_CHR_DEV_ST=m 254CONFIG_CHR_DEV_ST=m
260CONFIG_CHR_DEV_OSST=m 255CONFIG_CHR_DEV_OSST=m
261CONFIG_BLK_DEV_SR=m 256CONFIG_BLK_DEV_SR=y
262CONFIG_BLK_DEV_SR_VENDOR=y 257CONFIG_BLK_DEV_SR_VENDOR=y
263CONFIG_CHR_DEV_SG=m 258CONFIG_CHR_DEV_SG=m
264CONFIG_SCSI_MULTI_LUN=y 259CONFIG_SCSI_MULTI_LUN=y
@@ -274,6 +269,13 @@ CONFIG_SCSI_AACRAID=m
274CONFIG_SCSI_AIC7XXX=m 269CONFIG_SCSI_AIC7XXX=m
275CONFIG_AIC7XXX_RESET_DELAY_MS=15000 270CONFIG_AIC7XXX_RESET_DELAY_MS=15000
276# CONFIG_AIC7XXX_DEBUG_ENABLE is not set 271# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
272CONFIG_ATA=y
273CONFIG_ATA_PIIX=y
274CONFIG_PATA_IT8213=m
275CONFIG_PATA_OLDPIIX=y
276CONFIG_PATA_MPIIX=y
277CONFIG_ATA_GENERIC=y
278CONFIG_PATA_LEGACY=y
277CONFIG_MD=y 279CONFIG_MD=y
278CONFIG_BLK_DEV_MD=m 280CONFIG_BLK_DEV_MD=m
279CONFIG_MD_LINEAR=m 281CONFIG_MD_LINEAR=m
diff --git a/arch/mips/configs/malta_qemu_32r6_defconfig b/arch/mips/configs/malta_qemu_32r6_defconfig
index 4bce1f8ebe98..7f50dd67aa8d 100644
--- a/arch/mips/configs/malta_qemu_32r6_defconfig
+++ b/arch/mips/configs/malta_qemu_32r6_defconfig
@@ -80,15 +80,14 @@ CONFIG_NET_CLS_IND=y
80CONFIG_DEVTMPFS=y 80CONFIG_DEVTMPFS=y
81CONFIG_BLK_DEV_LOOP=y 81CONFIG_BLK_DEV_LOOP=y
82CONFIG_BLK_DEV_CRYPTOLOOP=m 82CONFIG_BLK_DEV_CRYPTOLOOP=m
83CONFIG_IDE=y
84# CONFIG_IDE_PROC_FS is not set
85# CONFIG_IDEPCI_PCIBUS_ORDER is not set
86CONFIG_BLK_DEV_GENERIC=y
87CONFIG_BLK_DEV_PIIX=y
88CONFIG_SCSI=y
89CONFIG_BLK_DEV_SD=y 83CONFIG_BLK_DEV_SD=y
90CONFIG_CHR_DEV_SG=y 84CONFIG_CHR_DEV_SG=y
91# CONFIG_SCSI_LOWLEVEL is not set 85# CONFIG_SCSI_LOWLEVEL is not set
86CONFIG_ATA=y
87CONFIG_ATA_PIIX=y
88CONFIG_PATA_OLDPIIX=y
89CONFIG_PATA_MPIIX=y
90CONFIG_ATA_GENERIC=y
92CONFIG_NETDEVICES=y 91CONFIG_NETDEVICES=y
93# CONFIG_NET_VENDOR_3COM is not set 92# CONFIG_NET_VENDOR_3COM is not set
94# CONFIG_NET_VENDOR_ADAPTEC is not set 93# CONFIG_NET_VENDOR_ADAPTEC is not set
diff --git a/arch/mips/configs/maltaaprp_defconfig b/arch/mips/configs/maltaaprp_defconfig
index fb042ce86b4b..a9d433a17fcf 100644
--- a/arch/mips/configs/maltaaprp_defconfig
+++ b/arch/mips/configs/maltaaprp_defconfig
@@ -81,15 +81,14 @@ CONFIG_NET_CLS_IND=y
81CONFIG_DEVTMPFS=y 81CONFIG_DEVTMPFS=y
82CONFIG_BLK_DEV_LOOP=y 82CONFIG_BLK_DEV_LOOP=y
83CONFIG_BLK_DEV_CRYPTOLOOP=m 83CONFIG_BLK_DEV_CRYPTOLOOP=m
84CONFIG_IDE=y
85# CONFIG_IDE_PROC_FS is not set
86# CONFIG_IDEPCI_PCIBUS_ORDER is not set
87CONFIG_BLK_DEV_GENERIC=y
88CONFIG_BLK_DEV_PIIX=y
89CONFIG_SCSI=y
90CONFIG_BLK_DEV_SD=y 84CONFIG_BLK_DEV_SD=y
91CONFIG_CHR_DEV_SG=y 85CONFIG_CHR_DEV_SG=y
92# CONFIG_SCSI_LOWLEVEL is not set 86# CONFIG_SCSI_LOWLEVEL is not set
87CONFIG_ATA=y
88CONFIG_ATA_PIIX=y
89CONFIG_PATA_OLDPIIX=y
90CONFIG_PATA_MPIIX=y
91CONFIG_ATA_GENERIC=y
93CONFIG_NETDEVICES=y 92CONFIG_NETDEVICES=y
94# CONFIG_NET_VENDOR_3COM is not set 93# CONFIG_NET_VENDOR_3COM is not set
95# CONFIG_NET_VENDOR_ADAPTEC is not set 94# CONFIG_NET_VENDOR_ADAPTEC is not set
diff --git a/arch/mips/configs/maltasmvp_eva_defconfig b/arch/mips/configs/maltasmvp_eva_defconfig
index c83338a39917..2774ef064505 100644
--- a/arch/mips/configs/maltasmvp_eva_defconfig
+++ b/arch/mips/configs/maltasmvp_eva_defconfig
@@ -85,15 +85,14 @@ CONFIG_NET_CLS_IND=y
85CONFIG_DEVTMPFS=y 85CONFIG_DEVTMPFS=y
86CONFIG_BLK_DEV_LOOP=y 86CONFIG_BLK_DEV_LOOP=y
87CONFIG_BLK_DEV_CRYPTOLOOP=m 87CONFIG_BLK_DEV_CRYPTOLOOP=m
88CONFIG_IDE=y
89# CONFIG_IDE_PROC_FS is not set
90# CONFIG_IDEPCI_PCIBUS_ORDER is not set
91CONFIG_BLK_DEV_GENERIC=y
92CONFIG_BLK_DEV_PIIX=y
93CONFIG_SCSI=y
94CONFIG_BLK_DEV_SD=y 88CONFIG_BLK_DEV_SD=y
95CONFIG_CHR_DEV_SG=y 89CONFIG_CHR_DEV_SG=y
96# CONFIG_SCSI_LOWLEVEL is not set 90# CONFIG_SCSI_LOWLEVEL is not set
91CONFIG_ATA=y
92CONFIG_ATA_PIIX=y
93CONFIG_PATA_OLDPIIX=y
94CONFIG_PATA_MPIIX=y
95CONFIG_ATA_GENERIC=y
97CONFIG_NETDEVICES=y 96CONFIG_NETDEVICES=y
98# CONFIG_NET_VENDOR_3COM is not set 97# CONFIG_NET_VENDOR_3COM is not set
99# CONFIG_NET_VENDOR_ADAPTEC is not set 98# CONFIG_NET_VENDOR_ADAPTEC is not set
diff --git a/arch/mips/configs/maltaup_defconfig b/arch/mips/configs/maltaup_defconfig
index 62344648eb7a..9bbd2218f0bf 100644
--- a/arch/mips/configs/maltaup_defconfig
+++ b/arch/mips/configs/maltaup_defconfig
@@ -80,15 +80,14 @@ CONFIG_NET_CLS_IND=y
80CONFIG_DEVTMPFS=y 80CONFIG_DEVTMPFS=y
81CONFIG_BLK_DEV_LOOP=y 81CONFIG_BLK_DEV_LOOP=y
82CONFIG_BLK_DEV_CRYPTOLOOP=m 82CONFIG_BLK_DEV_CRYPTOLOOP=m
83CONFIG_IDE=y
84# CONFIG_IDE_PROC_FS is not set
85# CONFIG_IDEPCI_PCIBUS_ORDER is not set
86CONFIG_BLK_DEV_GENERIC=y
87CONFIG_BLK_DEV_PIIX=y
88CONFIG_SCSI=y
89CONFIG_BLK_DEV_SD=y 83CONFIG_BLK_DEV_SD=y
90CONFIG_CHR_DEV_SG=y 84CONFIG_CHR_DEV_SG=y
91# CONFIG_SCSI_LOWLEVEL is not set 85# CONFIG_SCSI_LOWLEVEL is not set
86CONFIG_ATA=y
87CONFIG_ATA_PIIX=y
88CONFIG_PATA_OLDPIIX=y
89CONFIG_PATA_MPIIX=y
90CONFIG_ATA_GENERIC=y
92CONFIG_NETDEVICES=y 91CONFIG_NETDEVICES=y
93# CONFIG_NET_VENDOR_3COM is not set 92# CONFIG_NET_VENDOR_3COM is not set
94# CONFIG_NET_VENDOR_ADAPTEC is not set 93# CONFIG_NET_VENDOR_ADAPTEC is not set
diff --git a/arch/mips/configs/maltaup_xpa_defconfig b/arch/mips/configs/maltaup_xpa_defconfig
index c388bff09148..732215732751 100644
--- a/arch/mips/configs/maltaup_xpa_defconfig
+++ b/arch/mips/configs/maltaup_xpa_defconfig
@@ -244,17 +244,12 @@ CONFIG_CDROM_PKTCDVD=m
244CONFIG_ATA_OVER_ETH=m 244CONFIG_ATA_OVER_ETH=m
245CONFIG_IDE=y 245CONFIG_IDE=y
246CONFIG_BLK_DEV_IDECD=y 246CONFIG_BLK_DEV_IDECD=y
247CONFIG_IDE_GENERIC=y
248CONFIG_BLK_DEV_GENERIC=y
249CONFIG_BLK_DEV_PIIX=y
250CONFIG_BLK_DEV_IT8213=m
251CONFIG_BLK_DEV_TC86C001=m 247CONFIG_BLK_DEV_TC86C001=m
252CONFIG_RAID_ATTRS=m 248CONFIG_RAID_ATTRS=m
253CONFIG_SCSI=m 249CONFIG_BLK_DEV_SD=y
254CONFIG_BLK_DEV_SD=m
255CONFIG_CHR_DEV_ST=m 250CONFIG_CHR_DEV_ST=m
256CONFIG_CHR_DEV_OSST=m 251CONFIG_CHR_DEV_OSST=m
257CONFIG_BLK_DEV_SR=m 252CONFIG_BLK_DEV_SR=y
258CONFIG_BLK_DEV_SR_VENDOR=y 253CONFIG_BLK_DEV_SR_VENDOR=y
259CONFIG_CHR_DEV_SG=m 254CONFIG_CHR_DEV_SG=m
260CONFIG_SCSI_CONSTANTS=y 255CONFIG_SCSI_CONSTANTS=y
@@ -269,6 +264,13 @@ CONFIG_SCSI_AACRAID=m
269CONFIG_SCSI_AIC7XXX=m 264CONFIG_SCSI_AIC7XXX=m
270CONFIG_AIC7XXX_RESET_DELAY_MS=15000 265CONFIG_AIC7XXX_RESET_DELAY_MS=15000
271# CONFIG_AIC7XXX_DEBUG_ENABLE is not set 266# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
267CONFIG_ATA=y
268CONFIG_ATA_PIIX=y
269CONFIG_PATA_IT8213=m
270CONFIG_PATA_OLDPIIX=y
271CONFIG_PATA_MPIIX=y
272CONFIG_ATA_GENERIC=y
273CONFIG_PATA_LEGACY=y
272CONFIG_MD=y 274CONFIG_MD=y
273CONFIG_BLK_DEV_MD=m 275CONFIG_BLK_DEV_MD=m
274CONFIG_MD_LINEAR=m 276CONFIG_MD_LINEAR=m
diff --git a/arch/mips/configs/mpc30x_defconfig b/arch/mips/configs/mpc30x_defconfig
index 7a346605c498..a2c045fab6c5 100644
--- a/arch/mips/configs/mpc30x_defconfig
+++ b/arch/mips/configs/mpc30x_defconfig
@@ -27,9 +27,9 @@ CONFIG_INET_XFRM_MODE_BEET=m
27CONFIG_NETWORK_SECMARK=y 27CONFIG_NETWORK_SECMARK=y
28CONFIG_CONNECTOR=m 28CONFIG_CONNECTOR=m
29CONFIG_ATA_OVER_ETH=m 29CONFIG_ATA_OVER_ETH=m
30# CONFIG_MISC_DEVICES is not set 30CONFIG_BLK_DEV_SD=y
31CONFIG_IDE=y 31CONFIG_ATA=y
32CONFIG_IDE_GENERIC=y 32CONFIG_PATA_LEGACY=y
33CONFIG_NETDEVICES=y 33CONFIG_NETDEVICES=y
34# CONFIG_NETDEV_1000 is not set 34# CONFIG_NETDEV_1000 is not set
35# CONFIG_NETDEV_10000 is not set 35# CONFIG_NETDEV_10000 is not set
diff --git a/arch/mips/configs/xilfpga_defconfig b/arch/mips/configs/xilfpga_defconfig
new file mode 100644
index 000000000000..ed1dce348320
--- /dev/null
+++ b/arch/mips/configs/xilfpga_defconfig
@@ -0,0 +1,40 @@
1CONFIG_MACH_XILFPGA=y
2# CONFIG_COMPACTION is not set
3# CONFIG_LOCALVERSION_AUTO is not set
4CONFIG_EMBEDDED=y
5# CONFIG_VM_EVENT_COUNTERS is not set
6# CONFIG_COMPAT_BRK is not set
7CONFIG_SLAB=y
8# CONFIG_BLOCK is not set
9# CONFIG_SUSPEND is not set
10# CONFIG_UEVENT_HELPER is not set
11CONFIG_DEVTMPFS=y
12CONFIG_DEVTMPFS_MOUNT=y
13# CONFIG_STANDALONE is not set
14# CONFIG_PREVENT_FIRMWARE_BUILD is not set
15# CONFIG_FW_LOADER is not set
16# CONFIG_ALLOW_DEV_COREDUMP is not set
17# CONFIG_INPUT_MOUSEDEV is not set
18# CONFIG_INPUT_KEYBOARD is not set
19# CONFIG_INPUT_MOUSE is not set
20# CONFIG_SERIO is not set
21CONFIG_VT_HW_CONSOLE_BINDING=y
22# CONFIG_UNIX98_PTYS is not set
23# CONFIG_LEGACY_PTYS is not set
24CONFIG_SERIAL_8250=y
25CONFIG_SERIAL_8250_CONSOLE=y
26CONFIG_SERIAL_OF_PLATFORM=y
27# CONFIG_HW_RANDOM is not set
28CONFIG_GPIO_SYSFS=y
29CONFIG_GPIO_XILINX=y
30# CONFIG_HWMON is not set
31# CONFIG_USB_SUPPORT is not set
32# CONFIG_MIPS_PLATFORM_DEVICES is not set
33# CONFIG_IOMMU_SUPPORT is not set
34# CONFIG_PROC_PAGE_MONITOR is not set
35# CONFIG_MISC_FILESYSTEMS is not set
36CONFIG_PANIC_ON_OOPS=y
37# CONFIG_SCHED_DEBUG is not set
38# CONFIG_FTRACE is not set
39CONFIG_CMDLINE_BOOL=y
40CONFIG_CMDLINE="console=ttyS0,115200"
diff --git a/arch/mips/include/asm/abi.h b/arch/mips/include/asm/abi.h
index 37f84078e78a..940760844e2f 100644
--- a/arch/mips/include/asm/abi.h
+++ b/arch/mips/include/asm/abi.h
@@ -11,19 +11,20 @@
11 11
12#include <asm/signal.h> 12#include <asm/signal.h>
13#include <asm/siginfo.h> 13#include <asm/siginfo.h>
14#include <asm/vdso.h>
14 15
15struct mips_abi { 16struct mips_abi {
16 int (* const setup_frame)(void *sig_return, struct ksignal *ksig, 17 int (* const setup_frame)(void *sig_return, struct ksignal *ksig,
17 struct pt_regs *regs, sigset_t *set); 18 struct pt_regs *regs, sigset_t *set);
18 const unsigned long signal_return_offset;
19 int (* const setup_rt_frame)(void *sig_return, struct ksignal *ksig, 19 int (* const setup_rt_frame)(void *sig_return, struct ksignal *ksig,
20 struct pt_regs *regs, sigset_t *set); 20 struct pt_regs *regs, sigset_t *set);
21 const unsigned long rt_signal_return_offset;
22 const unsigned long restart; 21 const unsigned long restart;
23 22
24 unsigned off_sc_fpregs; 23 unsigned off_sc_fpregs;
25 unsigned off_sc_fpc_csr; 24 unsigned off_sc_fpc_csr;
26 unsigned off_sc_used_math; 25 unsigned off_sc_used_math;
26
27 struct mips_vdso_image *vdso;
27}; 28};
28 29
29#endif /* _ASM_ABI_H */ 30#endif /* _ASM_ABI_H */
diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
index f82d3af07931..835b402e4574 100644
--- a/arch/mips/include/asm/atomic.h
+++ b/arch/mips/include/asm/atomic.h
@@ -507,7 +507,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
507 * @u: ...unless v is equal to u. 507 * @u: ...unless v is equal to u.
508 * 508 *
509 * Atomically adds @a to @v, so long as it was not @u. 509 * Atomically adds @a to @v, so long as it was not @u.
510 * Returns the old value of @v. 510 * Returns true iff @v was not @u.
511 */ 511 */
512static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) 512static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
513{ 513{
diff --git a/arch/mips/include/asm/bcache.h b/arch/mips/include/asm/bcache.h
index 8c34484cea82..a00857b135c3 100644
--- a/arch/mips/include/asm/bcache.h
+++ b/arch/mips/include/asm/bcache.h
@@ -9,6 +9,7 @@
9#ifndef _ASM_BCACHE_H 9#ifndef _ASM_BCACHE_H
10#define _ASM_BCACHE_H 10#define _ASM_BCACHE_H
11 11
12#include <linux/types.h>
12 13
13/* Some R4000 / R4400 / R4600 / R5000 machines may have a non-dma-coherent, 14/* Some R4000 / R4400 / R4600 / R5000 machines may have a non-dma-coherent,
14 chipset implemented caches. On machines with other CPUs the CPU does the 15 chipset implemented caches. On machines with other CPUs the CPU does the
@@ -18,6 +19,9 @@ struct bcache_ops {
18 void (*bc_disable)(void); 19 void (*bc_disable)(void);
19 void (*bc_wback_inv)(unsigned long page, unsigned long size); 20 void (*bc_wback_inv)(unsigned long page, unsigned long size);
20 void (*bc_inv)(unsigned long page, unsigned long size); 21 void (*bc_inv)(unsigned long page, unsigned long size);
22 void (*bc_prefetch_enable)(void);
23 void (*bc_prefetch_disable)(void);
24 bool (*bc_prefetch_is_enabled)(void);
21}; 25};
22 26
23extern void indy_sc_init(void); 27extern void indy_sc_init(void);
@@ -46,6 +50,26 @@ static inline void bc_inv(unsigned long page, unsigned long size)
46 bcops->bc_inv(page, size); 50 bcops->bc_inv(page, size);
47} 51}
48 52
53static inline void bc_prefetch_enable(void)
54{
55 if (bcops->bc_prefetch_enable)
56 bcops->bc_prefetch_enable();
57}
58
59static inline void bc_prefetch_disable(void)
60{
61 if (bcops->bc_prefetch_disable)
62 bcops->bc_prefetch_disable();
63}
64
65static inline bool bc_prefetch_is_enabled(void)
66{
67 if (bcops->bc_prefetch_is_enabled)
68 return bcops->bc_prefetch_is_enabled();
69
70 return false;
71}
72
49#else /* !defined(CONFIG_BOARD_SCACHE) */ 73#else /* !defined(CONFIG_BOARD_SCACHE) */
50 74
51/* Not R4000 / R4400 / R4600 / R5000. */ 75/* Not R4000 / R4400 / R4600 / R5000. */
@@ -54,6 +78,9 @@ static inline void bc_inv(unsigned long page, unsigned long size)
54#define bc_disable() do { } while (0) 78#define bc_disable() do { } while (0)
55#define bc_wback_inv(page, size) do { } while (0) 79#define bc_wback_inv(page, size) do { } while (0)
56#define bc_inv(page, size) do { } while (0) 80#define bc_inv(page, size) do { } while (0)
81#define bc_prefetch_enable() do { } while (0)
82#define bc_prefetch_disable() do { } while (0)
83#define bc_prefetch_is_enabled() 0
57 84
58#endif /* !defined(CONFIG_BOARD_SCACHE) */ 85#endif /* !defined(CONFIG_BOARD_SCACHE) */
59 86
diff --git a/arch/mips/include/asm/cdmm.h b/arch/mips/include/asm/cdmm.h
index bece2064cc8c..c06dbf8ba937 100644
--- a/arch/mips/include/asm/cdmm.h
+++ b/arch/mips/include/asm/cdmm.h
@@ -84,6 +84,17 @@ void mips_cdmm_driver_unregister(struct mips_cdmm_driver *);
84 module_driver(__mips_cdmm_driver, mips_cdmm_driver_register, \ 84 module_driver(__mips_cdmm_driver, mips_cdmm_driver_register, \
85 mips_cdmm_driver_unregister) 85 mips_cdmm_driver_unregister)
86 86
87/*
88 * builtin_mips_cdmm_driver() - Helper macro for drivers that don't do anything
89 * special in init and have no exit. This eliminates some boilerplate. Each
90 * driver may only use this macro once, and calling it replaces device_initcall
91 * (or in some cases, the legacy __initcall). This is meant to be a direct
92 * parallel of module_mips_cdmm_driver() above but without the __exit stuff that
93 * is not used for builtin cases.
94 */
95#define builtin_mips_cdmm_driver(__mips_cdmm_driver) \
96 builtin_driver(__mips_cdmm_driver, mips_cdmm_driver_register)
97
87/* drivers/tty/mips_ejtag_fdc.c */ 98/* drivers/tty/mips_ejtag_fdc.c */
88 99
89#ifdef CONFIG_MIPS_EJTAG_FDC_EARLYCON 100#ifdef CONFIG_MIPS_EJTAG_FDC_EARLYCON
diff --git a/arch/mips/include/asm/clocksource.h b/arch/mips/include/asm/clocksource.h
new file mode 100644
index 000000000000..3deb1d0c1a94
--- /dev/null
+++ b/arch/mips/include/asm/clocksource.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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_CLOCKSOURCE_H
12#define __ASM_CLOCKSOURCE_H
13
14#include <linux/types.h>
15
16/* VDSO clocksources. */
17#define VDSO_CLOCK_NONE 0 /* No suitable clocksource. */
18#define VDSO_CLOCK_R4K 1 /* Use the coprocessor 0 count. */
19#define VDSO_CLOCK_GIC 2 /* Use the GIC. */
20
21/**
22 * struct arch_clocksource_data - Architecture-specific clocksource information.
23 * @vdso_clock_mode: Method the VDSO should use to access the clocksource.
24 */
25struct arch_clocksource_data {
26 u8 vdso_clock_mode;
27};
28
29#endif /* __ASM_CLOCKSOURCE_H */
diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
index c4bd54a7f5ce..a9580097cba8 100644
--- a/arch/mips/include/asm/compat.h
+++ b/arch/mips/include/asm/compat.h
@@ -130,6 +130,8 @@ typedef union compat_sigval {
130 compat_uptr_t sival_ptr; 130 compat_uptr_t sival_ptr;
131} compat_sigval_t; 131} compat_sigval_t;
132 132
133/* Can't use the generic version because si_code and si_errno are swapped */
134
133#define SI_PAD_SIZE32 (128/sizeof(int) - 3) 135#define SI_PAD_SIZE32 (128/sizeof(int) - 3)
134 136
135typedef struct compat_siginfo { 137typedef struct compat_siginfo {
@@ -138,57 +140,61 @@ typedef struct compat_siginfo {
138 int si_errno; 140 int si_errno;
139 141
140 union { 142 union {
141 int _pad[SI_PAD_SIZE32]; 143 int _pad[128 / sizeof(int) - 3];
142 144
143 /* kill() */ 145 /* kill() */
144 struct { 146 struct {
145 compat_pid_t _pid; /* sender's pid */ 147 compat_pid_t _pid; /* sender's pid */
146 __compat_uid_t _uid; /* sender's uid */ 148 __compat_uid32_t _uid; /* sender's uid */
147 } _kill; 149 } _kill;
148 150
151 /* POSIX.1b timers */
152 struct {
153 compat_timer_t _tid; /* timer id */
154 int _overrun; /* overrun count */
155 compat_sigval_t _sigval; /* same as below */
156 } _timer;
157
158 /* POSIX.1b signals */
159 struct {
160 compat_pid_t _pid; /* sender's pid */
161 __compat_uid32_t _uid; /* sender's uid */
162 compat_sigval_t _sigval;
163 } _rt;
164
149 /* SIGCHLD */ 165 /* SIGCHLD */
150 struct { 166 struct {
151 compat_pid_t _pid; /* which child */ 167 compat_pid_t _pid; /* which child */
152 __compat_uid_t _uid; /* sender's uid */ 168 __compat_uid32_t _uid; /* sender's uid */
153 int _status; /* exit code */ 169 int _status; /* exit code */
154 compat_clock_t _utime; 170 compat_clock_t _utime;
155 compat_clock_t _stime; 171 compat_clock_t _stime;
156 } _sigchld; 172 } _sigchld;
157 173
158 /* IRIX SIGCHLD */
159 struct {
160 compat_pid_t _pid; /* which child */
161 compat_clock_t _utime;
162 int _status; /* exit code */
163 compat_clock_t _stime;
164 } _irix_sigchld;
165
166 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 174 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
167 struct { 175 struct {
168 s32 _addr; /* faulting insn/memory ref. */ 176 compat_uptr_t _addr; /* faulting insn/memory ref. */
177#ifdef __ARCH_SI_TRAPNO
178 int _trapno; /* TRAP # which caused the signal */
179#endif
180 short _addr_lsb; /* LSB of the reported address */
181 struct {
182 compat_uptr_t _lower;
183 compat_uptr_t _upper;
184 } _addr_bnd;
169 } _sigfault; 185 } _sigfault;
170 186
171 /* SIGPOLL, SIGXFSZ (To do ...) */ 187 /* SIGPOLL */
172 struct { 188 struct {
173 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 189 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
174 int _fd; 190 int _fd;
175 } _sigpoll; 191 } _sigpoll;
176 192
177 /* POSIX.1b timers */
178 struct {
179 timer_t _tid; /* timer id */
180 int _overrun; /* overrun count */
181 compat_sigval_t _sigval;/* same as below */
182 int _sys_private; /* not to be passed to user */
183 } _timer;
184
185 /* POSIX.1b signals */
186 struct { 193 struct {
187 compat_pid_t _pid; /* sender's pid */ 194 compat_uptr_t _call_addr; /* calling insn */
188 __compat_uid_t _uid; /* sender's uid */ 195 int _syscall; /* triggering system call number */
189 compat_sigval_t _sigval; 196 compat_uint_t _arch; /* AUDIT_ARCH_* of syscall */
190 } _rt; 197 } _sigsys;
191
192 } _sifields; 198 } _sifields;
193} compat_siginfo_t; 199} compat_siginfo_t;
194 200
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index fe67f12ac239..d1e04c943f5f 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -131,11 +131,7 @@
131#endif 131#endif
132 132
133#ifndef cpu_has_rixi 133#ifndef cpu_has_rixi
134# ifdef CONFIG_64BIT 134#define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI)
135# define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI)
136# else /* CONFIG_32BIT */
137# define cpu_has_rixi ((cpu_data[0].options & MIPS_CPU_RIXI) && !cpu_has_64bits)
138# endif
139#endif 135#endif
140 136
141#ifndef cpu_has_mmips 137#ifndef cpu_has_mmips
diff --git a/arch/mips/include/asm/debug.h b/arch/mips/include/asm/debug.h
new file mode 100644
index 000000000000..254f00deb9d5
--- /dev/null
+++ b/arch/mips/include/asm/debug.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#ifndef __MIPS_ASM_DEBUG_H__
11#define __MIPS_ASM_DEBUG_H__
12
13#include <linux/dcache.h>
14
15/*
16 * mips_debugfs_dir corresponds to the "mips" directory at the top level
17 * of the DebugFS hierarchy. MIPS-specific DebugFS entires should be
18 * placed beneath this directory.
19 */
20extern struct dentry *mips_debugfs_dir;
21
22#endif /* __MIPS_ASM_DEBUG_H__ */
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index 53b26933b12c..b01a6ff468e0 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -8,6 +8,7 @@
8#ifndef _ASM_ELF_H 8#ifndef _ASM_ELF_H
9#define _ASM_ELF_H 9#define _ASM_ELF_H
10 10
11#include <linux/auxvec.h>
11#include <linux/fs.h> 12#include <linux/fs.h>
12#include <uapi/linux/elf.h> 13#include <uapi/linux/elf.h>
13 14
@@ -419,6 +420,12 @@ extern const char *__elf_platform;
419#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) 420#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
420#endif 421#endif
421 422
423#define ARCH_DLINFO \
424do { \
425 NEW_AUX_ENT(AT_SYSINFO_EHDR, \
426 (unsigned long)current->mm->context.vdso); \
427} while (0)
428
422#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 429#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
423struct linux_binprm; 430struct linux_binprm;
424extern int arch_setup_additional_pages(struct linux_binprm *bprm, 431extern int arch_setup_additional_pages(struct linux_binprm *bprm,
diff --git a/arch/mips/include/asm/fw/fw.h b/arch/mips/include/asm/fw/fw.h
index f3e6978aad70..d0ef8b4892bb 100644
--- a/arch/mips/include/asm/fw/fw.h
+++ b/arch/mips/include/asm/fw/fw.h
@@ -10,21 +10,6 @@
10 10
11#include <asm/bootinfo.h> /* For cleaner code... */ 11#include <asm/bootinfo.h> /* For cleaner code... */
12 12
13enum fw_memtypes {
14 fw_dontuse,
15 fw_code,
16 fw_free,
17};
18
19typedef struct {
20 unsigned long base; /* Within KSEG0 */
21 unsigned int size; /* bytes */
22 enum fw_memtypes type; /* fw_memtypes */
23} fw_memblock_t;
24
25/* Maximum number of memory block descriptors. */
26#define FW_MAX_MEMBLOCKS 32
27
28extern int fw_argc; 13extern int fw_argc;
29extern int *_fw_argv; 14extern int *_fw_argv;
30extern int *_fw_envp; 15extern int *_fw_envp;
@@ -38,7 +23,6 @@ extern int *_fw_envp;
38 23
39extern void fw_init_cmdline(void); 24extern void fw_init_cmdline(void);
40extern char *fw_getcmdline(void); 25extern char *fw_getcmdline(void);
41extern fw_memblock_t *fw_getmdesc(int);
42extern void fw_meminit(void); 26extern void fw_meminit(void);
43extern char *fw_getenv(char *name); 27extern char *fw_getenv(char *name);
44extern unsigned long fw_getenvl(char *name); 28extern unsigned long fw_getenvl(char *name);
diff --git a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
index 1461c10c1c4c..71e4096a2145 100644
--- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
+++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
@@ -48,11 +48,6 @@ extern enum bcm47xx_bus_type bcm47xx_bus_type;
48void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix, 48void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
49 bool fallback); 49 bool fallback);
50 50
51#ifdef CONFIG_BCM47XX_SSB
52void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
53 const char *prefix);
54#endif
55
56void bcm47xx_set_system_type(u16 chip_id); 51void bcm47xx_set_system_type(u16 chip_id);
57 52
58#endif /* __ASM_BCM47XX_H */ 53#endif /* __ASM_BCM47XX_H */
diff --git a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
index 133336b493b6..dd6005b75e0c 100644
--- a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
+++ b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
@@ -35,6 +35,17 @@
35#define SOC_ID_VRX268_2 0x00C /* v1.2 */ 35#define SOC_ID_VRX268_2 0x00C /* v1.2 */
36#define SOC_ID_GRX288_2 0x00D /* v1.2 */ 36#define SOC_ID_GRX288_2 0x00D /* v1.2 */
37#define SOC_ID_GRX282_2 0x00E /* v1.2 */ 37#define SOC_ID_GRX282_2 0x00E /* v1.2 */
38#define SOC_ID_VRX220 0x000
39
40#define SOC_ID_ARX362 0x004
41#define SOC_ID_ARX368 0x005
42#define SOC_ID_ARX382 0x007
43#define SOC_ID_ARX388 0x008
44#define SOC_ID_URX388 0x009
45#define SOC_ID_GRX383 0x010
46#define SOC_ID_GRX369 0x011
47#define SOC_ID_GRX387 0x00F
48#define SOC_ID_GRX389 0x012
38 49
39 /* SoC Types */ 50 /* SoC Types */
40#define SOC_TYPE_DANUBE 0x01 51#define SOC_TYPE_DANUBE 0x01
@@ -43,6 +54,9 @@
43#define SOC_TYPE_VR9 0x04 /* v1.1 */ 54#define SOC_TYPE_VR9 0x04 /* v1.1 */
44#define SOC_TYPE_VR9_2 0x05 /* v1.2 */ 55#define SOC_TYPE_VR9_2 0x05 /* v1.2 */
45#define SOC_TYPE_AMAZON_SE 0x06 56#define SOC_TYPE_AMAZON_SE 0x06
57#define SOC_TYPE_AR10 0x07
58#define SOC_TYPE_GRX390 0x08
59#define SOC_TYPE_VRX220 0x09
46 60
47/* BOOT_SEL - find what boot media we have */ 61/* BOOT_SEL - find what boot media we have */
48#define BS_EXT_ROM 0x0 62#define BS_EXT_ROM 0x0
diff --git a/arch/mips/include/asm/mach-malta/malta-dtshim.h b/arch/mips/include/asm/mach-malta/malta-dtshim.h
new file mode 100644
index 000000000000..cfd777663c64
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/malta-dtshim.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Paul Burton <paul.burton@imgtec.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 __MIPS_MALTA_DTSHIM_H__
12#define __MIPS_MALTA_DTSHIM_H__
13
14#include <linux/init.h>
15
16#ifdef CONFIG_MIPS_MALTA
17
18extern void __init *malta_dt_shim(void *fdt);
19
20#else /* !CONFIG_MIPS_MALTA */
21
22static inline void *malta_dt_shim(void *fdt)
23{
24 return fdt;
25}
26
27#endif /* !CONFIG_MIPS_MALTA */
28
29#endif /* __MIPS_MALTA_DTSHIM_H__ */
diff --git a/arch/mips/include/asm/mach-ralink/mt7620.h b/arch/mips/include/asm/mach-ralink/mt7620.h
index 1976fb815fd1..455d406e8ddf 100644
--- a/arch/mips/include/asm/mach-ralink/mt7620.h
+++ b/arch/mips/include/asm/mach-ralink/mt7620.h
@@ -13,17 +13,11 @@
13#ifndef _MT7620_REGS_H_ 13#ifndef _MT7620_REGS_H_
14#define _MT7620_REGS_H_ 14#define _MT7620_REGS_H_
15 15
16enum mt762x_soc_type {
17 MT762X_SOC_UNKNOWN = 0,
18 MT762X_SOC_MT7620A,
19 MT762X_SOC_MT7620N,
20 MT762X_SOC_MT7628AN,
21};
22
23#define MT7620_SYSC_BASE 0x10000000 16#define MT7620_SYSC_BASE 0x10000000
24 17
25#define SYSC_REG_CHIP_NAME0 0x00 18#define SYSC_REG_CHIP_NAME0 0x00
26#define SYSC_REG_CHIP_NAME1 0x04 19#define SYSC_REG_CHIP_NAME1 0x04
20#define SYSC_REG_EFUSE_CFG 0x08
27#define SYSC_REG_CHIP_REV 0x0c 21#define SYSC_REG_CHIP_REV 0x0c
28#define SYSC_REG_SYSTEM_CONFIG0 0x10 22#define SYSC_REG_SYSTEM_CONFIG0 0x10
29#define SYSC_REG_SYSTEM_CONFIG1 0x14 23#define SYSC_REG_SYSTEM_CONFIG1 0x14
diff --git a/arch/mips/include/asm/mach-ralink/ralink_regs.h b/arch/mips/include/asm/mach-ralink/ralink_regs.h
index bd93014490df..4c9fba68c8b2 100644
--- a/arch/mips/include/asm/mach-ralink/ralink_regs.h
+++ b/arch/mips/include/asm/mach-ralink/ralink_regs.h
@@ -13,6 +13,23 @@
13#ifndef _RALINK_REGS_H_ 13#ifndef _RALINK_REGS_H_
14#define _RALINK_REGS_H_ 14#define _RALINK_REGS_H_
15 15
16enum ralink_soc_type {
17 RALINK_UNKNOWN = 0,
18 RT2880_SOC,
19 RT3883_SOC,
20 RT305X_SOC_RT3050,
21 RT305X_SOC_RT3052,
22 RT305X_SOC_RT3350,
23 RT305X_SOC_RT3352,
24 RT305X_SOC_RT5350,
25 MT762X_SOC_MT7620A,
26 MT762X_SOC_MT7620N,
27 MT762X_SOC_MT7621AT,
28 MT762X_SOC_MT7628AN,
29 MT762X_SOC_MT7688,
30};
31extern enum ralink_soc_type ralink_soc;
32
16extern __iomem void *rt_sysc_membase; 33extern __iomem void *rt_sysc_membase;
17extern __iomem void *rt_memc_membase; 34extern __iomem void *rt_memc_membase;
18 35
diff --git a/arch/mips/include/asm/mach-ralink/rt305x.h b/arch/mips/include/asm/mach-ralink/rt305x.h
index 96f731bac79a..2eea79331a14 100644
--- a/arch/mips/include/asm/mach-ralink/rt305x.h
+++ b/arch/mips/include/asm/mach-ralink/rt305x.h
@@ -13,25 +13,16 @@
13#ifndef _RT305X_REGS_H_ 13#ifndef _RT305X_REGS_H_
14#define _RT305X_REGS_H_ 14#define _RT305X_REGS_H_
15 15
16enum rt305x_soc_type { 16extern enum ralink_soc_type ralink_soc;
17 RT305X_SOC_UNKNOWN = 0,
18 RT305X_SOC_RT3050,
19 RT305X_SOC_RT3052,
20 RT305X_SOC_RT3350,
21 RT305X_SOC_RT3352,
22 RT305X_SOC_RT5350,
23};
24
25extern enum rt305x_soc_type rt305x_soc;
26 17
27static inline int soc_is_rt3050(void) 18static inline int soc_is_rt3050(void)
28{ 19{
29 return rt305x_soc == RT305X_SOC_RT3050; 20 return ralink_soc == RT305X_SOC_RT3050;
30} 21}
31 22
32static inline int soc_is_rt3052(void) 23static inline int soc_is_rt3052(void)
33{ 24{
34 return rt305x_soc == RT305X_SOC_RT3052; 25 return ralink_soc == RT305X_SOC_RT3052;
35} 26}
36 27
37static inline int soc_is_rt305x(void) 28static inline int soc_is_rt305x(void)
@@ -41,17 +32,17 @@ static inline int soc_is_rt305x(void)
41 32
42static inline int soc_is_rt3350(void) 33static inline int soc_is_rt3350(void)
43{ 34{
44 return rt305x_soc == RT305X_SOC_RT3350; 35 return ralink_soc == RT305X_SOC_RT3350;
45} 36}
46 37
47static inline int soc_is_rt3352(void) 38static inline int soc_is_rt3352(void)
48{ 39{
49 return rt305x_soc == RT305X_SOC_RT3352; 40 return ralink_soc == RT305X_SOC_RT3352;
50} 41}
51 42
52static inline int soc_is_rt5350(void) 43static inline int soc_is_rt5350(void)
53{ 44{
54 return rt305x_soc == RT305X_SOC_RT5350; 45 return ralink_soc == RT305X_SOC_RT5350;
55} 46}
56 47
57#define RT305X_SYSC_BASE 0x10000000 48#define RT305X_SYSC_BASE 0x10000000
diff --git a/arch/mips/include/asm/mach-xilfpga/irq.h b/arch/mips/include/asm/mach-xilfpga/irq.h
new file mode 100644
index 000000000000..0132a5b91f57
--- /dev/null
+++ b/arch/mips/include/asm/mach-xilfpga/irq.h
@@ -0,0 +1,18 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.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 __MIPS_ASM_MACH_XILFPGA_IRQ_H__
12#define __MIPS_ASM_MACH_XILFPGA_IRQ_H__
13
14#define NR_IRQS 32
15
16#include_next <irq.h>
17
18#endif /* __MIPS_ASM_MACH_XILFPGA_IRQ_H__ */
diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
index 1f1927ab4269..6516e9da5133 100644
--- a/arch/mips/include/asm/mips-cm.h
+++ b/arch/mips/include/asm/mips-cm.h
@@ -11,6 +11,7 @@
11#ifndef __MIPS_ASM_MIPS_CM_H__ 11#ifndef __MIPS_ASM_MIPS_CM_H__
12#define __MIPS_ASM_MIPS_CM_H__ 12#define __MIPS_ASM_MIPS_CM_H__
13 13
14#include <linux/bitops.h>
14#include <linux/errno.h> 15#include <linux/errno.h>
15#include <linux/io.h> 16#include <linux/io.h>
16#include <linux/types.h> 17#include <linux/types.h>
@@ -36,12 +37,12 @@ extern phys_addr_t __mips_cm_phys_base(void);
36/* 37/*
37 * mips_cm_is64 - determine CM register width 38 * mips_cm_is64 - determine CM register width
38 * 39 *
39 * The CM register width is processor and CM specific. A 64-bit processor 40 * The CM register width is determined by the version of the CM, with CM3
40 * usually has a 64-bit CM and a 32-bit one has a 32-bit CM but a 64-bit 41 * introducing 64 bit GCRs and all prior CM versions having 32 bit GCRs.
41 * processor could come with a 32-bit CM. Moreover, accesses on 64-bit CMs 42 * However we may run a kernel built for MIPS32 on a system with 64 bit GCRs,
42 * can be done either using regular 64-bit load/store instructions, or 32-bit 43 * or vice-versa. This variable indicates the width of the memory accesses
43 * load/store instruction on 32-bit register pairs. We opt for using 64-bit 44 * that the kernel will perform to GCRs, which may differ from the actual
44 * accesses on 64-bit CMs and kernels and 32-bit in any other case. 45 * width of the GCRs.
45 * 46 *
46 * It's set to 0 for 32-bit accesses and 1 for 64-bit accesses. 47 * It's set to 0 for 32-bit accesses and 1 for 64-bit accesses.
47 */ 48 */
@@ -125,7 +126,17 @@ static inline u32 read32_gcr_##name(void) \
125 \ 126 \
126static inline u64 read64_gcr_##name(void) \ 127static inline u64 read64_gcr_##name(void) \
127{ \ 128{ \
128 return __raw_readq(addr_gcr_##name()); \ 129 void __iomem *addr = addr_gcr_##name(); \
130 u64 ret; \
131 \
132 if (mips_cm_is64) { \
133 ret = __raw_readq(addr); \
134 } else { \
135 ret = __raw_readl(addr); \
136 ret |= (u64)__raw_readl(addr + 0x4) << 32; \
137 } \
138 \
139 return ret; \
129} \ 140} \
130 \ 141 \
131static inline unsigned long read_gcr_##name(void) \ 142static inline unsigned long read_gcr_##name(void) \
@@ -195,6 +206,8 @@ BUILD_CM_R_(gic_status, MIPS_CM_GCB_OFS + 0xd0)
195BUILD_CM_R_(cpc_status, MIPS_CM_GCB_OFS + 0xf0) 206BUILD_CM_R_(cpc_status, MIPS_CM_GCB_OFS + 0xf0)
196BUILD_CM_RW(l2_config, MIPS_CM_GCB_OFS + 0x130) 207BUILD_CM_RW(l2_config, MIPS_CM_GCB_OFS + 0x130)
197BUILD_CM_RW(sys_config2, MIPS_CM_GCB_OFS + 0x150) 208BUILD_CM_RW(sys_config2, MIPS_CM_GCB_OFS + 0x150)
209BUILD_CM_RW(l2_pft_control, MIPS_CM_GCB_OFS + 0x300)
210BUILD_CM_RW(l2_pft_control_b, MIPS_CM_GCB_OFS + 0x308)
198 211
199/* Core Local & Core Other register accessor functions */ 212/* Core Local & Core Other register accessor functions */
200BUILD_CM_Cx_RW(reset_release, 0x00) 213BUILD_CM_Cx_RW(reset_release, 0x00)
@@ -245,11 +258,14 @@ BUILD_CM_Cx_R_(tcid_8_priority, 0x80)
245 ((minor) << CM_GCR_REV_MINOR_SHF)) 258 ((minor) << CM_GCR_REV_MINOR_SHF))
246 259
247#define CM_REV_CM2 CM_ENCODE_REV(6, 0) 260#define CM_REV_CM2 CM_ENCODE_REV(6, 0)
261#define CM_REV_CM2_5 CM_ENCODE_REV(7, 0)
248#define CM_REV_CM3 CM_ENCODE_REV(8, 0) 262#define CM_REV_CM3 CM_ENCODE_REV(8, 0)
249 263
250/* GCR_ERROR_CAUSE register fields */ 264/* GCR_ERROR_CAUSE register fields */
251#define CM_GCR_ERROR_CAUSE_ERRTYPE_SHF 27 265#define CM_GCR_ERROR_CAUSE_ERRTYPE_SHF 27
252#define CM_GCR_ERROR_CAUSE_ERRTYPE_MSK (_ULCAST_(0x1f) << 27) 266#define CM_GCR_ERROR_CAUSE_ERRTYPE_MSK (_ULCAST_(0x1f) << 27)
267#define CM3_GCR_ERROR_CAUSE_ERRTYPE_SHF 58
268#define CM3_GCR_ERROR_CAUSE_ERRTYPE_MSK GENMASK_ULL(63, 58)
253#define CM_GCR_ERROR_CAUSE_ERRINFO_SHF 0 269#define CM_GCR_ERROR_CAUSE_ERRINFO_SHF 0
254#define CM_GCR_ERROR_CAUSE_ERRINGO_MSK (_ULCAST_(0x7ffffff) << 0) 270#define CM_GCR_ERROR_CAUSE_ERRINGO_MSK (_ULCAST_(0x7ffffff) << 0)
255 271
@@ -321,6 +337,20 @@ BUILD_CM_Cx_R_(tcid_8_priority, 0x80)
321#define CM_GCR_SYS_CONFIG2_MAXVPW_SHF 0 337#define CM_GCR_SYS_CONFIG2_MAXVPW_SHF 0
322#define CM_GCR_SYS_CONFIG2_MAXVPW_MSK (_ULCAST_(0xf) << 0) 338#define CM_GCR_SYS_CONFIG2_MAXVPW_MSK (_ULCAST_(0xf) << 0)
323 339
340/* GCR_L2_PFT_CONTROL register fields */
341#define CM_GCR_L2_PFT_CONTROL_PAGEMASK_SHF 12
342#define CM_GCR_L2_PFT_CONTROL_PAGEMASK_MSK (_ULCAST_(0xfffff) << 12)
343#define CM_GCR_L2_PFT_CONTROL_PFTEN_SHF 8
344#define CM_GCR_L2_PFT_CONTROL_PFTEN_MSK (_ULCAST_(0x1) << 8)
345#define CM_GCR_L2_PFT_CONTROL_NPFT_SHF 0
346#define CM_GCR_L2_PFT_CONTROL_NPFT_MSK (_ULCAST_(0xff) << 0)
347
348/* GCR_L2_PFT_CONTROL_B register fields */
349#define CM_GCR_L2_PFT_CONTROL_B_CEN_SHF 8
350#define CM_GCR_L2_PFT_CONTROL_B_CEN_MSK (_ULCAST_(0x1) << 8)
351#define CM_GCR_L2_PFT_CONTROL_B_PORTID_SHF 0
352#define CM_GCR_L2_PFT_CONTROL_B_PORTID_MSK (_ULCAST_(0xff) << 0)
353
324/* GCR_Cx_COHERENCE register fields */ 354/* GCR_Cx_COHERENCE register fields */
325#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_SHF 0 355#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_SHF 0
326#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_MSK (_ULCAST_(0xff) << 0) 356#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_MSK (_ULCAST_(0xff) << 0)
@@ -329,11 +359,15 @@ BUILD_CM_Cx_R_(tcid_8_priority, 0x80)
329#define CM_GCR_Cx_CONFIG_IOCUTYPE_SHF 10 359#define CM_GCR_Cx_CONFIG_IOCUTYPE_SHF 10
330#define CM_GCR_Cx_CONFIG_IOCUTYPE_MSK (_ULCAST_(0x3) << 10) 360#define CM_GCR_Cx_CONFIG_IOCUTYPE_MSK (_ULCAST_(0x3) << 10)
331#define CM_GCR_Cx_CONFIG_PVPE_SHF 0 361#define CM_GCR_Cx_CONFIG_PVPE_SHF 0
332#define CM_GCR_Cx_CONFIG_PVPE_MSK (_ULCAST_(0x1ff) << 0) 362#define CM_GCR_Cx_CONFIG_PVPE_MSK (_ULCAST_(0x3ff) << 0)
333 363
334/* GCR_Cx_OTHER register fields */ 364/* GCR_Cx_OTHER register fields */
335#define CM_GCR_Cx_OTHER_CORENUM_SHF 16 365#define CM_GCR_Cx_OTHER_CORENUM_SHF 16
336#define CM_GCR_Cx_OTHER_CORENUM_MSK (_ULCAST_(0xffff) << 16) 366#define CM_GCR_Cx_OTHER_CORENUM_MSK (_ULCAST_(0xffff) << 16)
367#define CM3_GCR_Cx_OTHER_CORE_SHF 8
368#define CM3_GCR_Cx_OTHER_CORE_MSK (_ULCAST_(0x3f) << 8)
369#define CM3_GCR_Cx_OTHER_VP_SHF 0
370#define CM3_GCR_Cx_OTHER_VP_MSK (_ULCAST_(0x7) << 0)
337 371
338/* GCR_Cx_RESET_BASE register fields */ 372/* GCR_Cx_RESET_BASE register fields */
339#define CM_GCR_Cx_RESET_BASE_BEVEXCBASE_SHF 12 373#define CM_GCR_Cx_RESET_BASE_BEVEXCBASE_SHF 12
@@ -444,4 +478,32 @@ static inline unsigned int mips_cm_vp_id(unsigned int cpu)
444 return (core * mips_cm_max_vp_width()) + vp; 478 return (core * mips_cm_max_vp_width()) + vp;
445} 479}
446 480
481#ifdef CONFIG_MIPS_CM
482
483/**
484 * mips_cm_lock_other - lock access to another core
485 * @core: the other core to be accessed
486 * @vp: the VP within the other core to be accessed
487 *
488 * Call before operating upon a core via the 'other' register region in
489 * order to prevent the region being moved during access. Must be followed
490 * by a call to mips_cm_unlock_other.
491 */
492extern void mips_cm_lock_other(unsigned int core, unsigned int vp);
493
494/**
495 * mips_cm_unlock_other - unlock access to another core
496 *
497 * Call after operating upon another core via the 'other' register region.
498 * Must be called after mips_cm_lock_other.
499 */
500extern void mips_cm_unlock_other(void);
501
502#else /* !CONFIG_MIPS_CM */
503
504static inline void mips_cm_lock_other(unsigned int core) { }
505static inline void mips_cm_unlock_other(void) { }
506
507#endif /* !CONFIG_MIPS_CM */
508
447#endif /* __MIPS_ASM_MIPS_CM_H__ */ 509#endif /* __MIPS_ASM_MIPS_CM_H__ */
diff --git a/arch/mips/include/asm/mips-cpc.h b/arch/mips/include/asm/mips-cpc.h
index f386f32702f1..e09035239e53 100644
--- a/arch/mips/include/asm/mips-cpc.h
+++ b/arch/mips/include/asm/mips-cpc.h
@@ -149,7 +149,8 @@ BUILD_CPC_Cx_RW(other, 0x10)
149 * core: the other core to be accessed 149 * core: the other core to be accessed
150 * 150 *
151 * Call before operating upon a core via the 'other' register region in 151 * Call before operating upon a core via the 'other' register region in
152 * order to prevent the region being moved during access. Must be followed 152 * order to prevent the region being moved during access. Must be called
153 * within the bounds of a mips_cm_{lock,unlock}_other pair, and followed
153 * by a call to mips_cpc_unlock_other. 154 * by a call to mips_cpc_unlock_other.
154 */ 155 */
155extern void mips_cpc_lock_other(unsigned int core); 156extern void mips_cpc_lock_other(unsigned int core);
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index c64781cf649f..e43aca183c99 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -50,7 +50,9 @@
50#define CP0_PAGEMASK $5 50#define CP0_PAGEMASK $5
51#define CP0_WIRED $6 51#define CP0_WIRED $6
52#define CP0_INFO $7 52#define CP0_INFO $7
53#define CP0_HWRENA $7, 0
53#define CP0_BADVADDR $8 54#define CP0_BADVADDR $8
55#define CP0_BADINSTR $8, 1
54#define CP0_COUNT $9 56#define CP0_COUNT $9
55#define CP0_ENTRYHI $10 57#define CP0_ENTRYHI $10
56#define CP0_COMPARE $11 58#define CP0_COMPARE $11
@@ -58,7 +60,11 @@
58#define CP0_CAUSE $13 60#define CP0_CAUSE $13
59#define CP0_EPC $14 61#define CP0_EPC $14
60#define CP0_PRID $15 62#define CP0_PRID $15
63#define CP0_EBASE $15, 1
64#define CP0_CMGCRBASE $15, 3
61#define CP0_CONFIG $16 65#define CP0_CONFIG $16
66#define CP0_CONFIG3 $16, 3
67#define CP0_CONFIG5 $16, 5
62#define CP0_LLADDR $17 68#define CP0_LLADDR $17
63#define CP0_WATCHLO $18 69#define CP0_WATCHLO $18
64#define CP0_WATCHHI $19 70#define CP0_WATCHHI $19
@@ -126,15 +132,9 @@
126#define R3K_ENTRYLO_N (_ULCAST_(1) << 11) 132#define R3K_ENTRYLO_N (_ULCAST_(1) << 11)
127 133
128/* MIPS32/64 EntryLo bit definitions */ 134/* MIPS32/64 EntryLo bit definitions */
129#ifdef CONFIG_64BIT 135#define MIPS_ENTRYLO_PFN_SHIFT 6
130/* as read by dmfc0 */ 136#define MIPS_ENTRYLO_XI (_ULCAST_(1) << (BITS_PER_LONG - 2))
131#define MIPS_ENTRYLO_XI (_ULCAST_(1) << 62) 137#define MIPS_ENTRYLO_RI (_ULCAST_(1) << (BITS_PER_LONG - 1))
132#define MIPS_ENTRYLO_RI (_ULCAST_(1) << 63)
133#else
134/* as read by mfc0 */
135#define MIPS_ENTRYLO_XI (_ULCAST_(1) << 30)
136#define MIPS_ENTRYLO_RI (_ULCAST_(1) << 31)
137#endif
138 138
139/* 139/*
140 * Values for PageMask register 140 * Values for PageMask register
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index 89dd7fed1a57..ad1fccdb8d13 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -33,7 +33,7 @@
33#define PAGE_SHIFT 16 33#define PAGE_SHIFT 16
34#endif 34#endif
35#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) 35#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
36#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1)) 36#define PAGE_MASK (~(PAGE_SIZE - 1))
37 37
38/* 38/*
39 * This is used for calculating the real page sizes 39 * This is used for calculating the real page sizes
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index 59ee6dcf6eed..3f832c3dd8f5 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -36,12 +36,6 @@ extern unsigned int vced_count, vcei_count;
36 */ 36 */
37#define HAVE_ARCH_PICK_MMAP_LAYOUT 1 37#define HAVE_ARCH_PICK_MMAP_LAYOUT 1
38 38
39/*
40 * A special page (the vdso) is mapped into all processes at the very
41 * top of the virtual memory space.
42 */
43#define SPECIAL_PAGES_SIZE PAGE_SIZE
44
45#ifdef CONFIG_32BIT 39#ifdef CONFIG_32BIT
46#ifdef CONFIG_KVM_GUEST 40#ifdef CONFIG_KVM_GUEST
47/* User space process size is limited to 1GB in KVM Guest Mode */ 41/* User space process size is limited to 1GB in KVM Guest Mode */
@@ -80,7 +74,7 @@ extern unsigned int vced_count, vcei_count;
80 74
81#endif 75#endif
82 76
83#define STACK_TOP ((TASK_SIZE & PAGE_MASK) - SPECIAL_PAGES_SIZE) 77#define STACK_TOP (TASK_SIZE & PAGE_MASK)
84 78
85/* 79/*
86 * This decides where the kernel will search for a free chunk of vm 80 * This decides where the kernel will search for a free chunk of vm
diff --git a/arch/mips/include/asm/vdso.h b/arch/mips/include/asm/vdso.h
index cca56aa40ff4..8f4ca5dd992b 100644
--- a/arch/mips/include/asm/vdso.h
+++ b/arch/mips/include/asm/vdso.h
@@ -1,29 +1,136 @@
1/* 1/*
2 * This file is subject to the terms and conditions of the GNU General Public 2 * Copyright (C) 2015 Imagination Technologies
3 * License. See the file "COPYING" in the main directory of this archive 3 * Author: Alex Smith <alex.smith@imgtec.com>
4 * for more details.
5 * 4 *
6 * Copyright (C) 2009 Cavium Networks 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.
7 */ 9 */
8 10
9#ifndef __ASM_VDSO_H 11#ifndef __ASM_VDSO_H
10#define __ASM_VDSO_H 12#define __ASM_VDSO_H
11 13
12#include <linux/types.h> 14#include <linux/mm_types.h>
13 15
16#include <asm/barrier.h>
14 17
15#ifdef CONFIG_32BIT 18/**
16struct mips_vdso { 19 * struct mips_vdso_image - Details of a VDSO image.
17 u32 signal_trampoline[2]; 20 * @data: Pointer to VDSO image data (page-aligned).
18 u32 rt_signal_trampoline[2]; 21 * @size: Size of the VDSO image data (page-aligned).
22 * @off_sigreturn: Offset of the sigreturn() trampoline.
23 * @off_rt_sigreturn: Offset of the rt_sigreturn() trampoline.
24 * @mapping: Special mapping structure.
25 *
26 * This structure contains details of a VDSO image, including the image data
27 * and offsets of certain symbols required by the kernel. It is generated as
28 * part of the VDSO build process, aside from the mapping page array, which is
29 * populated at runtime.
30 */
31struct mips_vdso_image {
32 void *data;
33 unsigned long size;
34
35 unsigned long off_sigreturn;
36 unsigned long off_rt_sigreturn;
37
38 struct vm_special_mapping mapping;
19}; 39};
20#else /* !CONFIG_32BIT */ 40
21struct mips_vdso { 41/*
22 u32 o32_signal_trampoline[2]; 42 * The following structures are auto-generated as part of the build for each
23 u32 o32_rt_signal_trampoline[2]; 43 * ABI by genvdso, see arch/mips/vdso/Makefile.
24 u32 rt_signal_trampoline[2]; 44 */
25 u32 n32_rt_signal_trampoline[2]; 45
46extern struct mips_vdso_image vdso_image;
47
48#ifdef CONFIG_MIPS32_O32
49extern struct mips_vdso_image vdso_image_o32;
50#endif
51
52#ifdef CONFIG_MIPS32_N32
53extern struct mips_vdso_image vdso_image_n32;
54#endif
55
56/**
57 * union mips_vdso_data - Data provided by the kernel for the VDSO.
58 * @xtime_sec: Current real time (seconds part).
59 * @xtime_nsec: Current real time (nanoseconds part, shifted).
60 * @wall_to_mono_sec: Wall-to-monotonic offset (seconds part).
61 * @wall_to_mono_nsec: Wall-to-monotonic offset (nanoseconds part).
62 * @seq_count: Counter to synchronise updates (odd = updating).
63 * @cs_shift: Clocksource shift value.
64 * @clock_mode: Clocksource to use for time functions.
65 * @cs_mult: Clocksource multiplier value.
66 * @cs_cycle_last: Clock cycle value at last update.
67 * @cs_mask: Clocksource mask value.
68 * @tz_minuteswest: Minutes west of Greenwich (from timezone).
69 * @tz_dsttime: Type of DST correction (from timezone).
70 *
71 * This structure contains data needed by functions within the VDSO. It is
72 * populated by the kernel and mapped read-only into user memory. The time
73 * fields are mirrors of internal data from the timekeeping infrastructure.
74 *
75 * Note: Care should be taken when modifying as the layout must remain the same
76 * for both 64- and 32-bit (for 32-bit userland on 64-bit kernel).
77 */
78union mips_vdso_data {
79 struct {
80 u64 xtime_sec;
81 u64 xtime_nsec;
82 u32 wall_to_mono_sec;
83 u32 wall_to_mono_nsec;
84 u32 seq_count;
85 u32 cs_shift;
86 u8 clock_mode;
87 u32 cs_mult;
88 u64 cs_cycle_last;
89 u64 cs_mask;
90 s32 tz_minuteswest;
91 s32 tz_dsttime;
92 };
93
94 u8 page[PAGE_SIZE];
26}; 95};
27#endif /* CONFIG_32BIT */ 96
97static inline u32 vdso_data_read_begin(const union mips_vdso_data *data)
98{
99 u32 seq;
100
101 while (true) {
102 seq = ACCESS_ONCE(data->seq_count);
103 if (likely(!(seq & 1))) {
104 /* Paired with smp_wmb() in vdso_data_write_*(). */
105 smp_rmb();
106 return seq;
107 }
108
109 cpu_relax();
110 }
111}
112
113static inline bool vdso_data_read_retry(const union mips_vdso_data *data,
114 u32 start_seq)
115{
116 /* Paired with smp_wmb() in vdso_data_write_*(). */
117 smp_rmb();
118 return unlikely(data->seq_count != start_seq);
119}
120
121static inline void vdso_data_write_begin(union mips_vdso_data *data)
122{
123 ++data->seq_count;
124
125 /* Ensure sequence update is written before other data page values. */
126 smp_wmb();
127}
128
129static inline void vdso_data_write_end(union mips_vdso_data *data)
130{
131 /* Ensure data values are written before updating sequence again. */
132 smp_wmb();
133 ++data->seq_count;
134}
28 135
29#endif /* __ASM_VDSO_H */ 136#endif /* __ASM_VDSO_H */
diff --git a/arch/mips/include/uapi/asm/Kbuild b/arch/mips/include/uapi/asm/Kbuild
index 96fe7395ed8d..f2cf41461146 100644
--- a/arch/mips/include/uapi/asm/Kbuild
+++ b/arch/mips/include/uapi/asm/Kbuild
@@ -1,9 +1,9 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4generic-y += auxvec.h
5generic-y += ipcbuf.h 4generic-y += ipcbuf.h
6 5
6header-y += auxvec.h
7header-y += bitfield.h 7header-y += bitfield.h
8header-y += bitsperlong.h 8header-y += bitsperlong.h
9header-y += break.h 9header-y += break.h
diff --git a/arch/mips/include/uapi/asm/auxvec.h b/arch/mips/include/uapi/asm/auxvec.h
new file mode 100644
index 000000000000..c9c7195272c4
--- /dev/null
+++ b/arch/mips/include/uapi/asm/auxvec.h
@@ -0,0 +1,17 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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_AUXVEC_H
12#define __ASM_AUXVEC_H
13
14/* Location of VDSO image. */
15#define AT_SYSINFO_EHDR 33
16
17#endif /* __ASM_AUXVEC_H */
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 459cb017306c..934b15b5b575 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -25,6 +25,7 @@
25#include <linux/power_supply.h> 25#include <linux/power_supply.h>
26#include <linux/power/jz4740-battery.h> 26#include <linux/power/jz4740-battery.h>
27#include <linux/power/gpio-charger.h> 27#include <linux/power/gpio-charger.h>
28#include <linux/pwm.h>
28 29
29#include <asm/mach-jz4740/gpio.h> 30#include <asm/mach-jz4740/gpio.h>
30#include <asm/mach-jz4740/jz4740_fb.h> 31#include <asm/mach-jz4740/jz4740_fb.h>
@@ -34,8 +35,6 @@
34#include <linux/regulator/fixed.h> 35#include <linux/regulator/fixed.h>
35#include <linux/regulator/machine.h> 36#include <linux/regulator/machine.h>
36 37
37#include <linux/leds_pwm.h>
38
39#include <asm/mach-jz4740/platform.h> 38#include <asm/mach-jz4740/platform.h>
40 39
41#include "clock.h" 40#include "clock.h"
@@ -399,13 +398,15 @@ static struct platform_device avt2_usb_regulator_device = {
399 } 398 }
400}; 399};
401 400
401static struct pwm_lookup qi_lb60_pwm_lookup[] = {
402 PWM_LOOKUP("jz4740-pwm", 4, "pwm-beeper", NULL, 0,
403 PWM_POLARITY_NORMAL),
404};
405
402/* beeper */ 406/* beeper */
403static struct platform_device qi_lb60_pwm_beeper = { 407static struct platform_device qi_lb60_pwm_beeper = {
404 .name = "pwm-beeper", 408 .name = "pwm-beeper",
405 .id = -1, 409 .id = -1,
406 .dev = {
407 .platform_data = (void *)4,
408 },
409}; 410};
410 411
411/* charger */ 412/* charger */
@@ -491,6 +492,8 @@ static int __init qi_lb60_init_platform_devices(void)
491 platform_device_register(&jz4740_usb_ohci_device); 492 platform_device_register(&jz4740_usb_ohci_device);
492 } 493 }
493 494
495 pwm_add_table(qi_lb60_pwm_lookup, ARRAY_SIZE(qi_lb60_pwm_lookup));
496
494 return platform_add_devices(jz_platform_devices, 497 return platform_add_devices(jz_platform_devices,
495 ARRAY_SIZE(jz_platform_devices)); 498 ARRAY_SIZE(jz_platform_devices));
496 499
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index d982be1ea1c3..68e2b7db9348 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_MIPS_MT_FPAFF) += mips-mt-fpaff.o
51obj-$(CONFIG_MIPS_MT_SMP) += smp-mt.o 51obj-$(CONFIG_MIPS_MT_SMP) += smp-mt.o
52obj-$(CONFIG_MIPS_CMP) += smp-cmp.o 52obj-$(CONFIG_MIPS_CMP) += smp-cmp.o
53obj-$(CONFIG_MIPS_CPS) += smp-cps.o cps-vec.o 53obj-$(CONFIG_MIPS_CPS) += smp-cps.o cps-vec.o
54obj-$(CONFIG_MIPS_CPS_NS16550) += cps-vec-ns16550.o
54obj-$(CONFIG_MIPS_GIC_IPI) += smp-gic.o 55obj-$(CONFIG_MIPS_GIC_IPI) += smp-gic.o
55obj-$(CONFIG_MIPS_SPRAM) += spram.o 56obj-$(CONFIG_MIPS_SPRAM) += spram.o
56 57
diff --git a/arch/mips/kernel/cps-vec-ns16550.S b/arch/mips/kernel/cps-vec-ns16550.S
new file mode 100644
index 000000000000..6d246ad05638
--- /dev/null
+++ b/arch/mips/kernel/cps-vec-ns16550.S
@@ -0,0 +1,202 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Paul Burton <paul.burton@imgtec.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 <asm/addrspace.h>
12#include <asm/asm.h>
13#include <asm/asm-offsets.h>
14#include <asm/mipsregs.h>
15#include <asm/regdef.h>
16#include <linux/serial_reg.h>
17
18#define UART_TX_OFS (UART_TX << CONFIG_MIPS_CPS_NS16550_SHIFT)
19#define UART_LSR_OFS (UART_LSR << CONFIG_MIPS_CPS_NS16550_SHIFT)
20
21/**
22 * _mips_cps_putc() - write a character to the UART
23 * @a0: ASCII character to write
24 * @t9: UART base address
25 */
26LEAF(_mips_cps_putc)
271: lw t0, UART_LSR_OFS(t9)
28 andi t0, t0, UART_LSR_TEMT
29 beqz t0, 1b
30 sb a0, UART_TX_OFS(t9)
31 jr ra
32 END(_mips_cps_putc)
33
34/**
35 * _mips_cps_puts() - write a string to the UART
36 * @a0: pointer to NULL-terminated ASCII string
37 * @t9: UART base address
38 *
39 * Write a null-terminated ASCII string to the UART.
40 */
41NESTED(_mips_cps_puts, 0, ra)
42 move s7, ra
43 move s6, a0
44
451: lb a0, 0(s6)
46 beqz a0, 2f
47 jal _mips_cps_putc
48 PTR_ADDIU s6, s6, 1
49 b 1b
50
512: jr s7
52 END(_mips_cps_puts)
53
54/**
55 * _mips_cps_putx4 - write a 4b hex value to the UART
56 * @a0: the 4b value to write to the UART
57 * @t9: UART base address
58 *
59 * Write a single hexadecimal character to the UART.
60 */
61NESTED(_mips_cps_putx4, 0, ra)
62 andi a0, a0, 0xf
63 li t0, '0'
64 blt a0, 10, 1f
65 li t0, 'a'
66 addiu a0, a0, -10
671: addu a0, a0, t0
68 b _mips_cps_putc
69 END(_mips_cps_putx4)
70
71/**
72 * _mips_cps_putx8 - write an 8b hex value to the UART
73 * @a0: the 8b value to write to the UART
74 * @t9: UART base address
75 *
76 * Write an 8 bit value (ie. 2 hexadecimal characters) to the UART.
77 */
78NESTED(_mips_cps_putx8, 0, ra)
79 move s3, ra
80 move s2, a0
81 srl a0, a0, 4
82 jal _mips_cps_putx4
83 move a0, s2
84 move ra, s3
85 b _mips_cps_putx4
86 END(_mips_cps_putx8)
87
88/**
89 * _mips_cps_putx16 - write a 16b hex value to the UART
90 * @a0: the 16b value to write to the UART
91 * @t9: UART base address
92 *
93 * Write a 16 bit value (ie. 4 hexadecimal characters) to the UART.
94 */
95NESTED(_mips_cps_putx16, 0, ra)
96 move s5, ra
97 move s4, a0
98 srl a0, a0, 8
99 jal _mips_cps_putx8
100 move a0, s4
101 move ra, s5
102 b _mips_cps_putx8
103 END(_mips_cps_putx16)
104
105/**
106 * _mips_cps_putx32 - write a 32b hex value to the UART
107 * @a0: the 32b value to write to the UART
108 * @t9: UART base address
109 *
110 * Write a 32 bit value (ie. 8 hexadecimal characters) to the UART.
111 */
112NESTED(_mips_cps_putx32, 0, ra)
113 move s7, ra
114 move s6, a0
115 srl a0, a0, 16
116 jal _mips_cps_putx16
117 move a0, s6
118 move ra, s7
119 b _mips_cps_putx16
120 END(_mips_cps_putx32)
121
122#ifdef CONFIG_64BIT
123
124/**
125 * _mips_cps_putx64 - write a 64b hex value to the UART
126 * @a0: the 64b value to write to the UART
127 * @t9: UART base address
128 *
129 * Write a 64 bit value (ie. 16 hexadecimal characters) to the UART.
130 */
131NESTED(_mips_cps_putx64, 0, ra)
132 move sp, ra
133 move s8, a0
134 dsrl32 a0, a0, 0
135 jal _mips_cps_putx32
136 move a0, s8
137 move ra, sp
138 b _mips_cps_putx32
139 END(_mips_cps_putx64)
140
141#define _mips_cps_putxlong _mips_cps_putx64
142
143#else /* !CONFIG_64BIT */
144
145#define _mips_cps_putxlong _mips_cps_putx32
146
147#endif /* !CONFIG_64BIT */
148
149/**
150 * mips_cps_bev_dump() - dump relevant exception state to UART
151 * @a0: pointer to NULL-terminated ASCII string naming the exception
152 *
153 * Write information that may be useful in debugging an exception to the
154 * UART configured by CONFIG_MIPS_CPS_NS16550_*. As this BEV exception
155 * will only be run if something goes horribly wrong very early during
156 * the bringup of a core and it is very likely to be unsafe to perform
157 * memory accesses at that point (cache state indeterminate, EVA may not
158 * be configured, coherence may be disabled) let alone have a stack,
159 * this is all written in assembly using only registers & unmapped
160 * uncached access to the UART registers.
161 */
162LEAF(mips_cps_bev_dump)
163 move s0, ra
164 move s1, a0
165
166 li t9, CKSEG1ADDR(CONFIG_MIPS_CPS_NS16550_BASE)
167
168 PTR_LA a0, str_newline
169 jal _mips_cps_puts
170 PTR_LA a0, str_bev
171 jal _mips_cps_puts
172 move a0, s1
173 jal _mips_cps_puts
174 PTR_LA a0, str_newline
175 jal _mips_cps_puts
176 PTR_LA a0, str_newline
177 jal _mips_cps_puts
178
179#define DUMP_COP0_REG(reg, name, sz, _mfc0) \
180 PTR_LA a0, 8f; \
181 jal _mips_cps_puts; \
182 _mfc0 a0, reg; \
183 jal _mips_cps_putx##sz; \
184 PTR_LA a0, str_newline; \
185 jal _mips_cps_puts; \
186 TEXT(name)
187
188 DUMP_COP0_REG(CP0_CAUSE, "Cause: 0x", 32, mfc0)
189 DUMP_COP0_REG(CP0_STATUS, "Status: 0x", 32, mfc0)
190 DUMP_COP0_REG(CP0_EBASE, "EBase: 0x", long, MFC0)
191 DUMP_COP0_REG(CP0_BADVADDR, "BadVAddr: 0x", long, MFC0)
192 DUMP_COP0_REG(CP0_BADINSTR, "BadInstr: 0x", 32, mfc0)
193
194 PTR_LA a0, str_newline
195 jal _mips_cps_puts
196 jr s0
197 END(mips_cps_bev_dump)
198
199.pushsection .data
200str_bev: .asciiz "BEV Exception: "
201str_newline: .asciiz "\r\n"
202.popsection
diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index 209ded16806b..8fd5a276cad2 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -25,14 +25,32 @@
25 25
26.set noreorder 26.set noreorder
27 27
28#ifdef CONFIG_64BIT
29# define STATUS_BITDEPS ST0_KX
30#else
31# define STATUS_BITDEPS 0
32#endif
33
34#ifdef CONFIG_MIPS_CPS_NS16550
35
36#define DUMP_EXCEP(name) \
37 PTR_LA a0, 8f; \
38 jal mips_cps_bev_dump; \
39 nop; \
40 TEXT(name)
41
42#else /* !CONFIG_MIPS_CPS_NS16550 */
43
44#define DUMP_EXCEP(name)
45
46#endif /* !CONFIG_MIPS_CPS_NS16550 */
47
28 /* 48 /*
29 * Set dest to non-zero if the core supports the MT ASE, else zero. If 49 * Set dest to non-zero if the core supports the MT ASE, else zero. If
30 * MT is not supported then branch to nomt. 50 * MT is not supported then branch to nomt.
31 */ 51 */
32 .macro has_mt dest, nomt 52 .macro has_mt dest, nomt
33 mfc0 \dest, CP0_CONFIG 53 mfc0 \dest, CP0_CONFIG, 1
34 bgez \dest, \nomt
35 mfc0 \dest, CP0_CONFIG, 1
36 bgez \dest, \nomt 54 bgez \dest, \nomt
37 mfc0 \dest, CP0_CONFIG, 2 55 mfc0 \dest, CP0_CONFIG, 2
38 bgez \dest, \nomt 56 bgez \dest, \nomt
@@ -47,11 +65,9 @@
47 65
48LEAF(mips_cps_core_entry) 66LEAF(mips_cps_core_entry)
49 /* 67 /*
50 * These first 12 bytes will be patched by cps_smp_setup to load the 68 * These first 4 bytes will be patched by cps_smp_setup to load the
51 * base address of the CM GCRs into register v1 and the CCA to use into 69 * CCA to use into register s0.
52 * register s0.
53 */ 70 */
54 .quad 0
55 .word 0 71 .word 0
56 72
57 /* Check whether we're here due to an NMI */ 73 /* Check whether we're here due to an NMI */
@@ -71,7 +87,7 @@ not_nmi:
71 mtc0 t0, CP0_CAUSE 87 mtc0 t0, CP0_CAUSE
72 88
73 /* Setup Status */ 89 /* Setup Status */
74 li t0, ST0_CU1 | ST0_CU0 90 li t0, ST0_CU1 | ST0_CU0 | ST0_BEV | STATUS_BITDEPS
75 mtc0 t0, CP0_STATUS 91 mtc0 t0, CP0_STATUS
76 92
77 /* 93 /*
@@ -151,6 +167,12 @@ dcache_done:
151 mtc0 t0, CP0_CONFIG 167 mtc0 t0, CP0_CONFIG
152 ehb 168 ehb
153 169
170 /* Calculate an uncached address for the CM GCRs */
171 MFC0 v1, CP0_CMGCRBASE
172 PTR_SLL v1, v1, 4
173 PTR_LI t0, UNCAC_BASE
174 PTR_ADDU v1, v1, t0
175
154 /* Enter the coherent domain */ 176 /* Enter the coherent domain */
155 li t0, 0xff 177 li t0, 0xff
156 sw t0, GCR_CL_COHERENCE_OFS(v1) 178 sw t0, GCR_CL_COHERENCE_OFS(v1)
@@ -188,36 +210,42 @@ dcache_done:
188 210
189.org 0x200 211.org 0x200
190LEAF(excep_tlbfill) 212LEAF(excep_tlbfill)
213 DUMP_EXCEP("TLB Fill")
191 b . 214 b .
192 nop 215 nop
193 END(excep_tlbfill) 216 END(excep_tlbfill)
194 217
195.org 0x280 218.org 0x280
196LEAF(excep_xtlbfill) 219LEAF(excep_xtlbfill)
220 DUMP_EXCEP("XTLB Fill")
197 b . 221 b .
198 nop 222 nop
199 END(excep_xtlbfill) 223 END(excep_xtlbfill)
200 224
201.org 0x300 225.org 0x300
202LEAF(excep_cache) 226LEAF(excep_cache)
227 DUMP_EXCEP("Cache")
203 b . 228 b .
204 nop 229 nop
205 END(excep_cache) 230 END(excep_cache)
206 231
207.org 0x380 232.org 0x380
208LEAF(excep_genex) 233LEAF(excep_genex)
234 DUMP_EXCEP("General")
209 b . 235 b .
210 nop 236 nop
211 END(excep_genex) 237 END(excep_genex)
212 238
213.org 0x400 239.org 0x400
214LEAF(excep_intex) 240LEAF(excep_intex)
241 DUMP_EXCEP("Interrupt")
215 b . 242 b .
216 nop 243 nop
217 END(excep_intex) 244 END(excep_intex)
218 245
219.org 0x480 246.org 0x480
220LEAF(excep_ejtag) 247LEAF(excep_ejtag)
248 DUMP_EXCEP("EJTAG")
221 PTR_LA k0, ejtag_debug_handler 249 PTR_LA k0, ejtag_debug_handler
222 jr k0 250 jr k0
223 nop 251 nop
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 09a51d091941..6b9064499bd3 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -536,8 +536,7 @@ static inline unsigned int decode_config3(struct cpuinfo_mips *c)
536 c->options |= MIPS_CPU_SEGMENTS; 536 c->options |= MIPS_CPU_SEGMENTS;
537 if (config3 & MIPS_CONF3_MSA) 537 if (config3 & MIPS_CONF3_MSA)
538 c->ases |= MIPS_ASE_MSA; 538 c->ases |= MIPS_ASE_MSA;
539 /* Only tested on 32-bit cores */ 539 if (config3 & MIPS_CONF3_PW) {
540 if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) {
541 c->htw_seq = 0; 540 c->htw_seq = 0;
542 c->options |= MIPS_CPU_HTW; 541 c->options |= MIPS_CPU_HTW;
543 } 542 }
diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
index e5ed7ada1433..1f910563fdf6 100644
--- a/arch/mips/kernel/csrc-r4k.c
+++ b/arch/mips/kernel/csrc-r4k.c
@@ -28,6 +28,43 @@ static u64 notrace r4k_read_sched_clock(void)
28 return read_c0_count(); 28 return read_c0_count();
29} 29}
30 30
31static inline unsigned int rdhwr_count(void)
32{
33 unsigned int count;
34
35 __asm__ __volatile__(
36 " .set push\n"
37 " .set mips32r2\n"
38 " rdhwr %0, $2\n"
39 " .set pop\n"
40 : "=r" (count));
41
42 return count;
43}
44
45static bool rdhwr_count_usable(void)
46{
47 unsigned int prev, curr, i;
48
49 /*
50 * Older QEMUs have a broken implementation of RDHWR for the CP0 count
51 * which always returns a constant value. Try to identify this and don't
52 * use it in the VDSO if it is broken. This workaround can be removed
53 * once the fix has been in QEMU stable for a reasonable amount of time.
54 */
55 for (i = 0, prev = rdhwr_count(); i < 100; i++) {
56 curr = rdhwr_count();
57
58 if (curr != prev)
59 return true;
60
61 prev = curr;
62 }
63
64 pr_warn("Not using R4K clocksource in VDSO due to broken RDHWR\n");
65 return false;
66}
67
31int __init init_r4k_clocksource(void) 68int __init init_r4k_clocksource(void)
32{ 69{
33 if (!cpu_has_counter || !mips_hpt_frequency) 70 if (!cpu_has_counter || !mips_hpt_frequency)
@@ -36,6 +73,13 @@ int __init init_r4k_clocksource(void)
36 /* Calculate a somewhat reasonable rating value */ 73 /* Calculate a somewhat reasonable rating value */
37 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000; 74 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
38 75
76 /*
77 * R2 onwards makes the count accessible to user mode so it can be used
78 * by the VDSO (HWREna is configured by configure_hwrena()).
79 */
80 if (cpu_has_mips_r2_r6 && rdhwr_count_usable())
81 clocksource_mips.archdata.vdso_clock_mode = VDSO_CLOCK_R4K;
82
39 clocksource_register_hz(&clocksource_mips, mips_hpt_frequency); 83 clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
40 84
41 sched_clock_register(r4k_read_sched_clock, 32, mips_hpt_frequency); 85 sched_clock_register(r4k_read_sched_clock, 32, mips_hpt_frequency);
diff --git a/arch/mips/kernel/idle.c b/arch/mips/kernel/idle.c
index ab1478d5a4db..46794d64c0bf 100644
--- a/arch/mips/kernel/idle.c
+++ b/arch/mips/kernel/idle.c
@@ -134,6 +134,16 @@ void __init check_wait(void)
134 return; 134 return;
135 } 135 }
136 136
137 /*
138 * MIPSr6 specifies that masked interrupts should unblock an executing
139 * wait instruction, and thus that it is safe for us to use
140 * r4k_wait_irqoff. Yippee!
141 */
142 if (cpu_has_mips_r6) {
143 cpu_wait = r4k_wait_irqoff;
144 return;
145 }
146
137 switch (current_cpu_type()) { 147 switch (current_cpu_type()) {
138 case CPU_R3081: 148 case CPU_R3081:
139 case CPU_R3081E: 149 case CPU_R3081E:
@@ -155,12 +165,12 @@ void __init check_wait(void)
155 case CPU_4KEC: 165 case CPU_4KEC:
156 case CPU_4KSC: 166 case CPU_4KSC:
157 case CPU_5KC: 167 case CPU_5KC:
168 case CPU_5KE:
158 case CPU_25KF: 169 case CPU_25KF:
159 case CPU_PR4450: 170 case CPU_PR4450:
160 case CPU_BMIPS3300: 171 case CPU_BMIPS3300:
161 case CPU_BMIPS4350: 172 case CPU_BMIPS4350:
162 case CPU_BMIPS4380: 173 case CPU_BMIPS4380:
163 case CPU_BMIPS5000:
164 case CPU_CAVIUM_OCTEON: 174 case CPU_CAVIUM_OCTEON:
165 case CPU_CAVIUM_OCTEON_PLUS: 175 case CPU_CAVIUM_OCTEON_PLUS:
166 case CPU_CAVIUM_OCTEON2: 176 case CPU_CAVIUM_OCTEON2:
@@ -171,7 +181,9 @@ void __init check_wait(void)
171 case CPU_XLP: 181 case CPU_XLP:
172 cpu_wait = r4k_wait; 182 cpu_wait = r4k_wait;
173 break; 183 break;
174 184 case CPU_BMIPS5000:
185 cpu_wait = r4k_wait_irqoff;
186 break;
175 case CPU_RM7000: 187 case CPU_RM7000:
176 cpu_wait = rm7k_wait_irqoff; 188 cpu_wait = rm7k_wait_irqoff;
177 break; 189 break;
@@ -196,7 +208,6 @@ void __init check_wait(void)
196 case CPU_INTERAPTIV: 208 case CPU_INTERAPTIV:
197 case CPU_M5150: 209 case CPU_M5150:
198 case CPU_QEMU_GENERIC: 210 case CPU_QEMU_GENERIC:
199 case CPU_I6400:
200 cpu_wait = r4k_wait; 211 cpu_wait = r4k_wait;
201 if (read_c0_config7() & MIPS_CONF7_WII) 212 if (read_c0_config7() & MIPS_CONF7_WII)
202 cpu_wait = r4k_wait_irqoff; 213 cpu_wait = r4k_wait_irqoff;
diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c
index b8ceee576cdf..1448c1f43d4e 100644
--- a/arch/mips/kernel/mips-cm.c
+++ b/arch/mips/kernel/mips-cm.c
@@ -9,6 +9,8 @@
9 */ 9 */
10 10
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/percpu.h>
13#include <linux/spinlock.h>
12 14
13#include <asm/mips-cm.h> 15#include <asm/mips-cm.h>
14#include <asm/mipsregs.h> 16#include <asm/mipsregs.h>
@@ -136,6 +138,9 @@ static char *cm3_causes[32] = {
136 "0x19", "0x1a", "0x1b", "0x1c", "0x1d", "0x1e", "0x1f" 138 "0x19", "0x1a", "0x1b", "0x1c", "0x1d", "0x1e", "0x1f"
137}; 139};
138 140
141static DEFINE_PER_CPU_ALIGNED(spinlock_t, cm_core_lock);
142static DEFINE_PER_CPU_ALIGNED(unsigned long, cm_core_lock_flags);
143
139phys_addr_t __mips_cm_phys_base(void) 144phys_addr_t __mips_cm_phys_base(void)
140{ 145{
141 u32 config3 = read_c0_config3(); 146 u32 config3 = read_c0_config3();
@@ -200,6 +205,7 @@ int mips_cm_probe(void)
200{ 205{
201 phys_addr_t addr; 206 phys_addr_t addr;
202 u32 base_reg; 207 u32 base_reg;
208 unsigned cpu;
203 209
204 /* 210 /*
205 * No need to probe again if we have already been 211 * No need to probe again if we have already been
@@ -247,38 +253,70 @@ int mips_cm_probe(void)
247 /* determine register width for this CM */ 253 /* determine register width for this CM */
248 mips_cm_is64 = config_enabled(CONFIG_64BIT) && (mips_cm_revision() >= CM_REV_CM3); 254 mips_cm_is64 = config_enabled(CONFIG_64BIT) && (mips_cm_revision() >= CM_REV_CM3);
249 255
256 for_each_possible_cpu(cpu)
257 spin_lock_init(&per_cpu(cm_core_lock, cpu));
258
250 return 0; 259 return 0;
251} 260}
252 261
253void mips_cm_error_report(void) 262void mips_cm_lock_other(unsigned int core, unsigned int vp)
254{ 263{
255 unsigned long revision = mips_cm_revision(); 264 unsigned curr_core;
265 u32 val;
266
267 preempt_disable();
268 curr_core = current_cpu_data.core;
269 spin_lock_irqsave(&per_cpu(cm_core_lock, curr_core),
270 per_cpu(cm_core_lock_flags, curr_core));
271
272 if (mips_cm_revision() >= CM_REV_CM3) {
273 val = core << CM3_GCR_Cx_OTHER_CORE_SHF;
274 val |= vp << CM3_GCR_Cx_OTHER_VP_SHF;
275 } else {
276 BUG_ON(vp != 0);
277 val = core << CM_GCR_Cx_OTHER_CORENUM_SHF;
278 }
279
280 write_gcr_cl_other(val);
281
256 /* 282 /*
257 * CM3 has a 64-bit Error cause register with 0:57 containing the error 283 * Ensure the core-other region reflects the appropriate core &
258 * info and 63:58 the error type. For old CMs, everything is contained 284 * VP before any accesses to it occur.
259 * in a single 32-bit register (0:26 and 31:27 respectively). Even
260 * though the cm_error is u64, we will simply ignore the upper word
261 * for CM2.
262 */ 285 */
263 u64 cm_error = read_gcr_error_cause(); 286 mb();
264 int cm_error_cause_sft = CM_GCR_ERROR_CAUSE_ERRTYPE_SHF + 287}
265 ((revision >= CM_REV_CM3) ? 31 : 0); 288
266 unsigned long cm_addr = read_gcr_error_addr(); 289void mips_cm_unlock_other(void)
267 unsigned long cm_other = read_gcr_error_mult(); 290{
291 unsigned curr_core = current_cpu_data.core;
292
293 spin_unlock_irqrestore(&per_cpu(cm_core_lock, curr_core),
294 per_cpu(cm_core_lock_flags, curr_core));
295 preempt_enable();
296}
297
298void mips_cm_error_report(void)
299{
300 u64 cm_error, cm_addr, cm_other;
301 unsigned long revision;
268 int ocause, cause; 302 int ocause, cause;
269 char buf[256]; 303 char buf[256];
270 304
271 if (!mips_cm_present()) 305 if (!mips_cm_present())
272 return; 306 return;
273 307
274 cause = cm_error >> cm_error_cause_sft; 308 revision = mips_cm_revision();
275 309
276 if (!cause)
277 /* All good */
278 return;
279
280 ocause = cm_other >> CM_GCR_ERROR_MULT_ERR2ND_SHF;
281 if (revision < CM_REV_CM3) { /* CM2 */ 310 if (revision < CM_REV_CM3) { /* CM2 */
311 cm_error = read_gcr_error_cause();
312 cm_addr = read_gcr_error_addr();
313 cm_other = read_gcr_error_mult();
314 cause = cm_error >> CM_GCR_ERROR_CAUSE_ERRTYPE_SHF;
315 ocause = cm_other >> CM_GCR_ERROR_MULT_ERR2ND_SHF;
316
317 if (!cause)
318 return;
319
282 if (cause < 16) { 320 if (cause < 16) {
283 unsigned long cca_bits = (cm_error >> 15) & 7; 321 unsigned long cca_bits = (cm_error >> 15) & 7;
284 unsigned long tr_bits = (cm_error >> 12) & 7; 322 unsigned long tr_bits = (cm_error >> 12) & 7;
@@ -310,18 +348,30 @@ void mips_cm_error_report(void)
310 } 348 }
311 pr_err("CM_ERROR=%08llx %s <%s>\n", cm_error, 349 pr_err("CM_ERROR=%08llx %s <%s>\n", cm_error,
312 cm2_causes[cause], buf); 350 cm2_causes[cause], buf);
313 pr_err("CM_ADDR =%08lx\n", cm_addr); 351 pr_err("CM_ADDR =%08llx\n", cm_addr);
314 pr_err("CM_OTHER=%08lx %s\n", cm_other, cm2_causes[ocause]); 352 pr_err("CM_OTHER=%08llx %s\n", cm_other, cm2_causes[ocause]);
315 } else { /* CM3 */ 353 } else { /* CM3 */
316 /* Used by cause == {1,2,3} */ 354 ulong core_id_bits, vp_id_bits, cmd_bits, cmd_group_bits;
317 unsigned long core_id_bits = (cm_error >> 22) & 0xf; 355 ulong cm3_cca_bits, mcp_bits, cm3_tr_bits, sched_bit;
318 unsigned long vp_id_bits = (cm_error >> 18) & 0xf; 356
319 unsigned long cmd_bits = (cm_error >> 14) & 0xf; 357 cm_error = read64_gcr_error_cause();
320 unsigned long cmd_group_bits = (cm_error >> 11) & 0xf; 358 cm_addr = read64_gcr_error_addr();
321 unsigned long cm3_cca_bits = (cm_error >> 8) & 7; 359 cm_other = read64_gcr_error_mult();
322 unsigned long mcp_bits = (cm_error >> 5) & 0xf; 360 cause = cm_error >> CM3_GCR_ERROR_CAUSE_ERRTYPE_SHF;
323 unsigned long cm3_tr_bits = (cm_error >> 1) & 0xf; 361 ocause = cm_other >> CM_GCR_ERROR_MULT_ERR2ND_SHF;
324 unsigned long sched_bit = cm_error & 0x1; 362
363 if (!cause)
364 return;
365
366 /* Used by cause == {1,2,3} */
367 core_id_bits = (cm_error >> 22) & 0xf;
368 vp_id_bits = (cm_error >> 18) & 0xf;
369 cmd_bits = (cm_error >> 14) & 0xf;
370 cmd_group_bits = (cm_error >> 11) & 0xf;
371 cm3_cca_bits = (cm_error >> 8) & 7;
372 mcp_bits = (cm_error >> 5) & 0xf;
373 cm3_tr_bits = (cm_error >> 1) & 0xf;
374 sched_bit = cm_error & 0x1;
325 375
326 if (cause == 1 || cause == 3) { /* Tag ECC */ 376 if (cause == 1 || cause == 3) { /* Tag ECC */
327 unsigned long tag_ecc = (cm_error >> 57) & 0x1; 377 unsigned long tag_ecc = (cm_error >> 57) & 0x1;
@@ -363,12 +413,14 @@ void mips_cm_error_report(void)
363 cm3_cmd_group[cmd_group_bits], 413 cm3_cmd_group[cmd_group_bits],
364 cm3_cca_bits, 1 << mcp_bits, 414 cm3_cca_bits, 1 << mcp_bits,
365 cm3_tr[cm3_tr_bits], sched_bit); 415 cm3_tr[cm3_tr_bits], sched_bit);
416 } else {
417 buf[0] = 0;
366 } 418 }
367 419
368 pr_err("CM_ERROR=%llx %s <%s>\n", cm_error, 420 pr_err("CM_ERROR=%llx %s <%s>\n", cm_error,
369 cm3_causes[cause], buf); 421 cm3_causes[cause], buf);
370 pr_err("CM_ADDR =%lx\n", cm_addr); 422 pr_err("CM_ADDR =%llx\n", cm_addr);
371 pr_err("CM_OTHER=%lx %s\n", cm_other, cm3_causes[ocause]); 423 pr_err("CM_OTHER=%llx %s\n", cm_other, cm3_causes[ocause]);
372 } 424 }
373 425
374 /* reprime cause register */ 426 /* reprime cause register */
diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
index 8af4d627b68b..566b8d2c092c 100644
--- a/arch/mips/kernel/mips-cpc.c
+++ b/arch/mips/kernel/mips-cpc.c
@@ -76,6 +76,12 @@ void mips_cpc_lock_other(unsigned int core)
76 spin_lock_irqsave(&per_cpu(cpc_core_lock, curr_core), 76 spin_lock_irqsave(&per_cpu(cpc_core_lock, curr_core),
77 per_cpu(cpc_core_lock_flags, curr_core)); 77 per_cpu(cpc_core_lock_flags, curr_core));
78 write_cpc_cl_other(core << CPC_Cx_OTHER_CORENUM_SHF); 78 write_cpc_cl_other(core << CPC_Cx_OTHER_CORENUM_SHF);
79
80 /*
81 * Ensure the core-other region reflects the appropriate core &
82 * VP before any accesses to it occur.
83 */
84 mb();
79} 85}
80 86
81void mips_cpc_unlock_other(void) 87void mips_cpc_unlock_other(void)
diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c b/arch/mips/kernel/mips-r2-to-r6-emul.c
index f2977f00911b..1f5aac7f9ec3 100644
--- a/arch/mips/kernel/mips-r2-to-r6-emul.c
+++ b/arch/mips/kernel/mips-r2-to-r6-emul.c
@@ -22,6 +22,7 @@
22#include <asm/asm.h> 22#include <asm/asm.h>
23#include <asm/branch.h> 23#include <asm/branch.h>
24#include <asm/break.h> 24#include <asm/break.h>
25#include <asm/debug.h>
25#include <asm/fpu.h> 26#include <asm/fpu.h>
26#include <asm/fpu_emulator.h> 27#include <asm/fpu_emulator.h>
27#include <asm/inst.h> 28#include <asm/inst.h>
@@ -2363,7 +2364,6 @@ static const struct file_operations mipsr2_clear_fops = {
2363 2364
2364static int __init mipsr2_init_debugfs(void) 2365static int __init mipsr2_init_debugfs(void)
2365{ 2366{
2366 extern struct dentry *mips_debugfs_dir;
2367 struct dentry *mipsr2_emul; 2367 struct dentry *mipsr2_emul;
2368 2368
2369 if (!mips_debugfs_dir) 2369 if (!mips_debugfs_dir)
diff --git a/arch/mips/kernel/segment.c b/arch/mips/kernel/segment.c
index 076ead2a9859..87bc74a5a518 100644
--- a/arch/mips/kernel/segment.c
+++ b/arch/mips/kernel/segment.c
@@ -10,6 +10,7 @@
10#include <linux/debugfs.h> 10#include <linux/debugfs.h>
11#include <linux/seq_file.h> 11#include <linux/seq_file.h>
12#include <asm/cpu.h> 12#include <asm/cpu.h>
13#include <asm/debug.h>
13#include <asm/mipsregs.h> 14#include <asm/mipsregs.h>
14 15
15static void build_segment_config(char *str, unsigned int cfg) 16static void build_segment_config(char *str, unsigned int cfg)
@@ -91,7 +92,6 @@ static const struct file_operations segments_fops = {
91 92
92static int __init segments_info(void) 93static int __init segments_info(void)
93{ 94{
94 extern struct dentry *mips_debugfs_dir;
95 struct dentry *segments; 95 struct dentry *segments;
96 96
97 if (cpu_has_segments) { 97 if (cpu_has_segments) {
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 479515109e5b..66aac55df349 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -33,11 +33,16 @@
33#include <asm/cache.h> 33#include <asm/cache.h>
34#include <asm/cdmm.h> 34#include <asm/cdmm.h>
35#include <asm/cpu.h> 35#include <asm/cpu.h>
36#include <asm/debug.h>
36#include <asm/sections.h> 37#include <asm/sections.h>
37#include <asm/setup.h> 38#include <asm/setup.h>
38#include <asm/smp-ops.h> 39#include <asm/smp-ops.h>
39#include <asm/prom.h> 40#include <asm/prom.h>
40 41
42#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
43const char __section(.appended_dtb) __appended_dtb[0x100000];
44#endif /* CONFIG_MIPS_ELF_APPENDED_DTB */
45
41struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly; 46struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
42 47
43EXPORT_SYMBOL(cpu_data); 48EXPORT_SYMBOL(cpu_data);
@@ -616,6 +621,10 @@ static void __init request_crashkernel(struct resource *res)
616} 621}
617#endif /* !defined(CONFIG_KEXEC) */ 622#endif /* !defined(CONFIG_KEXEC) */
618 623
624#define USE_PROM_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER)
625#define USE_DTB_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB)
626#define EXTEND_WITH_PROM IS_ENABLED(CONFIG_MIPS_CMDLINE_EXTEND)
627
619static void __init arch_mem_init(char **cmdline_p) 628static void __init arch_mem_init(char **cmdline_p)
620{ 629{
621 struct memblock_region *reg; 630 struct memblock_region *reg;
@@ -640,18 +649,24 @@ static void __init arch_mem_init(char **cmdline_p)
640 pr_info("Determined physical RAM map:\n"); 649 pr_info("Determined physical RAM map:\n");
641 print_memory_map(); 650 print_memory_map();
642 651
643#ifdef CONFIG_CMDLINE_BOOL 652#if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE)
644#ifdef CONFIG_CMDLINE_OVERRIDE
645 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); 653 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
646#else 654#else
655 if ((USE_PROM_CMDLINE && arcs_cmdline[0]) ||
656 (USE_DTB_CMDLINE && !boot_command_line[0]))
657 strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
658
659 if (EXTEND_WITH_PROM && arcs_cmdline[0]) {
660 strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
661 strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
662 }
663
664#if defined(CONFIG_CMDLINE_BOOL)
647 if (builtin_cmdline[0]) { 665 if (builtin_cmdline[0]) {
648 strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE); 666 strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
649 strlcat(arcs_cmdline, builtin_cmdline, COMMAND_LINE_SIZE); 667 strlcat(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
650 } 668 }
651 strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
652#endif 669#endif
653#else
654 strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
655#endif 670#endif
656 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); 671 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
657 672
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 2fec67bfc457..bf792e2839a6 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -36,7 +36,6 @@
36#include <asm/ucontext.h> 36#include <asm/ucontext.h>
37#include <asm/cpu-features.h> 37#include <asm/cpu-features.h>
38#include <asm/war.h> 38#include <asm/war.h>
39#include <asm/vdso.h>
40#include <asm/dsp.h> 39#include <asm/dsp.h>
41#include <asm/inst.h> 40#include <asm/inst.h>
42#include <asm/msa.h> 41#include <asm/msa.h>
@@ -752,16 +751,15 @@ static int setup_rt_frame(void *sig_return, struct ksignal *ksig,
752struct mips_abi mips_abi = { 751struct mips_abi mips_abi = {
753#ifdef CONFIG_TRAD_SIGNALS 752#ifdef CONFIG_TRAD_SIGNALS
754 .setup_frame = setup_frame, 753 .setup_frame = setup_frame,
755 .signal_return_offset = offsetof(struct mips_vdso, signal_trampoline),
756#endif 754#endif
757 .setup_rt_frame = setup_rt_frame, 755 .setup_rt_frame = setup_rt_frame,
758 .rt_signal_return_offset =
759 offsetof(struct mips_vdso, rt_signal_trampoline),
760 .restart = __NR_restart_syscall, 756 .restart = __NR_restart_syscall,
761 757
762 .off_sc_fpregs = offsetof(struct sigcontext, sc_fpregs), 758 .off_sc_fpregs = offsetof(struct sigcontext, sc_fpregs),
763 .off_sc_fpc_csr = offsetof(struct sigcontext, sc_fpc_csr), 759 .off_sc_fpc_csr = offsetof(struct sigcontext, sc_fpc_csr),
764 .off_sc_used_math = offsetof(struct sigcontext, sc_used_math), 760 .off_sc_used_math = offsetof(struct sigcontext, sc_used_math),
761
762 .vdso = &vdso_image,
765}; 763};
766 764
767static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) 765static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
@@ -801,11 +799,11 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
801 } 799 }
802 800
803 if (sig_uses_siginfo(&ksig->ka)) 801 if (sig_uses_siginfo(&ksig->ka))
804 ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset, 802 ret = abi->setup_rt_frame(vdso + abi->vdso->off_rt_sigreturn,
805 ksig, regs, oldset); 803 ksig, regs, oldset);
806 else 804 else
807 ret = abi->setup_frame(vdso + abi->signal_return_offset, ksig, 805 ret = abi->setup_frame(vdso + abi->vdso->off_sigreturn,
808 regs, oldset); 806 ksig, regs, oldset);
809 807
810 signal_setup_done(ret, ksig, 0); 808 signal_setup_done(ret, ksig, 0);
811} 809}
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index f7e89524e316..4909639aa35b 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -31,7 +31,6 @@
31#include <asm/ucontext.h> 31#include <asm/ucontext.h>
32#include <asm/fpu.h> 32#include <asm/fpu.h>
33#include <asm/war.h> 33#include <asm/war.h>
34#include <asm/vdso.h>
35#include <asm/dsp.h> 34#include <asm/dsp.h>
36 35
37#include "signal-common.h" 36#include "signal-common.h"
@@ -406,14 +405,12 @@ static int setup_rt_frame_32(void *sig_return, struct ksignal *ksig,
406 */ 405 */
407struct mips_abi mips_abi_32 = { 406struct mips_abi mips_abi_32 = {
408 .setup_frame = setup_frame_32, 407 .setup_frame = setup_frame_32,
409 .signal_return_offset =
410 offsetof(struct mips_vdso, o32_signal_trampoline),
411 .setup_rt_frame = setup_rt_frame_32, 408 .setup_rt_frame = setup_rt_frame_32,
412 .rt_signal_return_offset =
413 offsetof(struct mips_vdso, o32_rt_signal_trampoline),
414 .restart = __NR_O32_restart_syscall, 409 .restart = __NR_O32_restart_syscall,
415 410
416 .off_sc_fpregs = offsetof(struct sigcontext32, sc_fpregs), 411 .off_sc_fpregs = offsetof(struct sigcontext32, sc_fpregs),
417 .off_sc_fpc_csr = offsetof(struct sigcontext32, sc_fpc_csr), 412 .off_sc_fpc_csr = offsetof(struct sigcontext32, sc_fpc_csr),
418 .off_sc_used_math = offsetof(struct sigcontext32, sc_used_math), 413 .off_sc_used_math = offsetof(struct sigcontext32, sc_used_math),
414
415 .vdso = &vdso_image_o32,
419}; 416};
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c
index 0d017fdcaf07..a7bc38430500 100644
--- a/arch/mips/kernel/signal_n32.c
+++ b/arch/mips/kernel/signal_n32.c
@@ -38,7 +38,6 @@
38#include <asm/fpu.h> 38#include <asm/fpu.h>
39#include <asm/cpu-features.h> 39#include <asm/cpu-features.h>
40#include <asm/war.h> 40#include <asm/war.h>
41#include <asm/vdso.h>
42 41
43#include "signal-common.h" 42#include "signal-common.h"
44 43
@@ -151,11 +150,11 @@ static int setup_rt_frame_n32(void *sig_return, struct ksignal *ksig,
151 150
152struct mips_abi mips_abi_n32 = { 151struct mips_abi mips_abi_n32 = {
153 .setup_rt_frame = setup_rt_frame_n32, 152 .setup_rt_frame = setup_rt_frame_n32,
154 .rt_signal_return_offset =
155 offsetof(struct mips_vdso, n32_rt_signal_trampoline),
156 .restart = __NR_N32_restart_syscall, 153 .restart = __NR_N32_restart_syscall,
157 154
158 .off_sc_fpregs = offsetof(struct sigcontext, sc_fpregs), 155 .off_sc_fpregs = offsetof(struct sigcontext, sc_fpregs),
159 .off_sc_fpc_csr = offsetof(struct sigcontext, sc_fpc_csr), 156 .off_sc_fpc_csr = offsetof(struct sigcontext, sc_fpc_csr),
160 .off_sc_used_math = offsetof(struct sigcontext, sc_used_math), 157 .off_sc_used_math = offsetof(struct sigcontext, sc_used_math),
158
159 .vdso = &vdso_image_n32,
161}; 160};
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index c88937745b4e..e04c8057b882 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -8,6 +8,7 @@
8 * option) any later version. 8 * option) any later version.
9 */ 9 */
10 10
11#include <linux/delay.h>
11#include <linux/io.h> 12#include <linux/io.h>
12#include <linux/irqchip/mips-gic.h> 13#include <linux/irqchip/mips-gic.h>
13#include <linux/sched.h> 14#include <linux/sched.h>
@@ -37,8 +38,9 @@ static unsigned core_vpe_count(unsigned core)
37 if (!config_enabled(CONFIG_MIPS_MT_SMP) || !cpu_has_mipsmt) 38 if (!config_enabled(CONFIG_MIPS_MT_SMP) || !cpu_has_mipsmt)
38 return 1; 39 return 1;
39 40
40 write_gcr_cl_other(core << CM_GCR_Cx_OTHER_CORENUM_SHF); 41 mips_cm_lock_other(core, 0);
41 cfg = read_gcr_co_config() & CM_GCR_Cx_CONFIG_PVPE_MSK; 42 cfg = read_gcr_co_config() & CM_GCR_Cx_CONFIG_PVPE_MSK;
43 mips_cm_unlock_other();
42 return (cfg >> CM_GCR_Cx_CONFIG_PVPE_SHF) + 1; 44 return (cfg >> CM_GCR_Cx_CONFIG_PVPE_SHF) + 1;
43} 45}
44 46
@@ -133,11 +135,9 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
133 /* 135 /*
134 * Patch the start of mips_cps_core_entry to provide: 136 * Patch the start of mips_cps_core_entry to provide:
135 * 137 *
136 * v1 = CM base address
137 * s0 = kseg0 CCA 138 * s0 = kseg0 CCA
138 */ 139 */
139 entry_code = (u32 *)&mips_cps_core_entry; 140 entry_code = (u32 *)&mips_cps_core_entry;
140 UASM_i_LA(&entry_code, 3, (long)mips_cm_base);
141 uasm_i_addiu(&entry_code, 16, 0, cca); 141 uasm_i_addiu(&entry_code, 16, 0, cca);
142 blast_dcache_range((unsigned long)&mips_cps_core_entry, 142 blast_dcache_range((unsigned long)&mips_cps_core_entry,
143 (unsigned long)entry_code); 143 (unsigned long)entry_code);
@@ -190,10 +190,11 @@ err_out:
190 190
191static void boot_core(unsigned core) 191static void boot_core(unsigned core)
192{ 192{
193 u32 access; 193 u32 access, stat, seq_state;
194 unsigned timeout;
194 195
195 /* Select the appropriate core */ 196 /* Select the appropriate core */
196 write_gcr_cl_other(core << CM_GCR_Cx_OTHER_CORENUM_SHF); 197 mips_cm_lock_other(core, 0);
197 198
198 /* Set its reset vector */ 199 /* Set its reset vector */
199 write_gcr_co_reset_base(CKSEG1ADDR((unsigned long)mips_cps_core_entry)); 200 write_gcr_co_reset_base(CKSEG1ADDR((unsigned long)mips_cps_core_entry));
@@ -210,12 +211,36 @@ static void boot_core(unsigned core)
210 /* Reset the core */ 211 /* Reset the core */
211 mips_cpc_lock_other(core); 212 mips_cpc_lock_other(core);
212 write_cpc_co_cmd(CPC_Cx_CMD_RESET); 213 write_cpc_co_cmd(CPC_Cx_CMD_RESET);
214
215 timeout = 100;
216 while (true) {
217 stat = read_cpc_co_stat_conf();
218 seq_state = stat & CPC_Cx_STAT_CONF_SEQSTATE_MSK;
219
220 /* U6 == coherent execution, ie. the core is up */
221 if (seq_state == CPC_Cx_STAT_CONF_SEQSTATE_U6)
222 break;
223
224 /* Delay a little while before we start warning */
225 if (timeout) {
226 timeout--;
227 mdelay(10);
228 continue;
229 }
230
231 pr_warn("Waiting for core %u to start... STAT_CONF=0x%x\n",
232 core, stat);
233 mdelay(1000);
234 }
235
213 mips_cpc_unlock_other(); 236 mips_cpc_unlock_other();
214 } else { 237 } else {
215 /* Take the core out of reset */ 238 /* Take the core out of reset */
216 write_gcr_co_reset_release(0); 239 write_gcr_co_reset_release(0);
217 } 240 }
218 241
242 mips_cm_unlock_other();
243
219 /* The core is now powered up */ 244 /* The core is now powered up */
220 bitmap_set(core_power, core, 1); 245 bitmap_set(core_power, core, 1);
221} 246}
diff --git a/arch/mips/kernel/smp-gic.c b/arch/mips/kernel/smp-gic.c
index 5f0ab5bcd01e..9b63829cf929 100644
--- a/arch/mips/kernel/smp-gic.c
+++ b/arch/mips/kernel/smp-gic.c
@@ -46,9 +46,11 @@ void gic_send_ipi_single(int cpu, unsigned int action)
46 46
47 if (mips_cpc_present() && (core != current_cpu_data.core)) { 47 if (mips_cpc_present() && (core != current_cpu_data.core)) {
48 while (!cpumask_test_cpu(cpu, &cpu_coherent_mask)) { 48 while (!cpumask_test_cpu(cpu, &cpu_coherent_mask)) {
49 mips_cm_lock_other(core, 0);
49 mips_cpc_lock_other(core); 50 mips_cpc_lock_other(core);
50 write_cpc_co_cmd(CPC_Cx_CMD_PWRUP); 51 write_cpc_co_cmd(CPC_Cx_CMD_PWRUP);
51 mips_cpc_unlock_other(); 52 mips_cpc_unlock_other();
53 mips_cm_unlock_other();
52 } 54 }
53 } 55 }
54 56
diff --git a/arch/mips/kernel/spinlock_test.c b/arch/mips/kernel/spinlock_test.c
index 39f7ab7b0426..f7d86955d1b8 100644
--- a/arch/mips/kernel/spinlock_test.c
+++ b/arch/mips/kernel/spinlock_test.c
@@ -5,7 +5,7 @@
5#include <linux/debugfs.h> 5#include <linux/debugfs.h>
6#include <linux/export.h> 6#include <linux/export.h>
7#include <linux/spinlock.h> 7#include <linux/spinlock.h>
8 8#include <asm/debug.h>
9 9
10static int ss_get(void *data, u64 *val) 10static int ss_get(void *data, u64 *val)
11{ 11{
@@ -115,8 +115,6 @@ static int multi_get(void *data, u64 *val)
115 115
116DEFINE_SIMPLE_ATTRIBUTE(fops_multi, multi_get, NULL, "%llu\n"); 116DEFINE_SIMPLE_ATTRIBUTE(fops_multi, multi_get, NULL, "%llu\n");
117 117
118
119extern struct dentry *mips_debugfs_dir;
120static int __init spinlock_test(void) 118static int __init spinlock_test(void)
121{ 119{
122 struct dentry *d; 120 struct dentry *d;
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c
index 1ba775d24d38..506021f62549 100644
--- a/arch/mips/kernel/stacktrace.c
+++ b/arch/mips/kernel/stacktrace.c
@@ -12,14 +12,15 @@
12 * Save stack-backtrace addresses into a stack_trace buffer: 12 * Save stack-backtrace addresses into a stack_trace buffer:
13 */ 13 */
14static void save_raw_context_stack(struct stack_trace *trace, 14static void save_raw_context_stack(struct stack_trace *trace,
15 unsigned long reg29) 15 unsigned long reg29, int savesched)
16{ 16{
17 unsigned long *sp = (unsigned long *)reg29; 17 unsigned long *sp = (unsigned long *)reg29;
18 unsigned long addr; 18 unsigned long addr;
19 19
20 while (!kstack_end(sp)) { 20 while (!kstack_end(sp)) {
21 addr = *sp++; 21 addr = *sp++;
22 if (__kernel_text_address(addr)) { 22 if (__kernel_text_address(addr) &&
23 (savesched || !in_sched_functions(addr))) {
23 if (trace->skip > 0) 24 if (trace->skip > 0)
24 trace->skip--; 25 trace->skip--;
25 else 26 else
@@ -31,7 +32,7 @@ static void save_raw_context_stack(struct stack_trace *trace,
31} 32}
32 33
33static void save_context_stack(struct stack_trace *trace, 34static void save_context_stack(struct stack_trace *trace,
34 struct task_struct *tsk, struct pt_regs *regs) 35 struct task_struct *tsk, struct pt_regs *regs, int savesched)
35{ 36{
36 unsigned long sp = regs->regs[29]; 37 unsigned long sp = regs->regs[29];
37#ifdef CONFIG_KALLSYMS 38#ifdef CONFIG_KALLSYMS
@@ -43,20 +44,22 @@ static void save_context_stack(struct stack_trace *trace,
43 (unsigned long)task_stack_page(tsk); 44 (unsigned long)task_stack_page(tsk);
44 if (stack_page && sp >= stack_page && 45 if (stack_page && sp >= stack_page &&
45 sp <= stack_page + THREAD_SIZE - 32) 46 sp <= stack_page + THREAD_SIZE - 32)
46 save_raw_context_stack(trace, sp); 47 save_raw_context_stack(trace, sp, savesched);
47 return; 48 return;
48 } 49 }
49 do { 50 do {
50 if (trace->skip > 0) 51 if (savesched || !in_sched_functions(pc)) {
51 trace->skip--; 52 if (trace->skip > 0)
52 else 53 trace->skip--;
53 trace->entries[trace->nr_entries++] = pc; 54 else
54 if (trace->nr_entries >= trace->max_entries) 55 trace->entries[trace->nr_entries++] = pc;
55 break; 56 if (trace->nr_entries >= trace->max_entries)
57 break;
58 }
56 pc = unwind_stack(tsk, &sp, pc, &ra); 59 pc = unwind_stack(tsk, &sp, pc, &ra);
57 } while (pc); 60 } while (pc);
58#else 61#else
59 save_raw_context_stack(trace, sp); 62 save_raw_context_stack(trace, sp, savesched);
60#endif 63#endif
61} 64}
62 65
@@ -82,6 +85,6 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
82 regs->cp0_epc = tsk->thread.reg31; 85 regs->cp0_epc = tsk->thread.reg31;
83 } else 86 } else
84 prepare_frametrace(regs); 87 prepare_frametrace(regs);
85 save_context_stack(trace, tsk, regs); 88 save_context_stack(trace, tsk, regs, tsk == current);
86} 89}
87EXPORT_SYMBOL_GPL(save_stack_trace_tsk); 90EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index fdb392b27e81..886cb1976e90 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -37,6 +37,7 @@
37#include <linux/irq.h> 37#include <linux/irq.h>
38#include <linux/perf_event.h> 38#include <linux/perf_event.h>
39 39
40#include <asm/addrspace.h>
40#include <asm/bootinfo.h> 41#include <asm/bootinfo.h>
41#include <asm/branch.h> 42#include <asm/branch.h>
42#include <asm/break.h> 43#include <asm/break.h>
@@ -1856,12 +1857,14 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs)
1856{ 1857{
1857 char str[100]; 1858 char str[100];
1858 1859
1860 nmi_enter();
1859 raw_notifier_call_chain(&nmi_chain, 0, regs); 1861 raw_notifier_call_chain(&nmi_chain, 0, regs);
1860 bust_spinlocks(1); 1862 bust_spinlocks(1);
1861 snprintf(str, 100, "CPU%d NMI taken, CP0_EPC=%lx\n", 1863 snprintf(str, 100, "CPU%d NMI taken, CP0_EPC=%lx\n",
1862 smp_processor_id(), regs->cp0_epc); 1864 smp_processor_id(), regs->cp0_epc);
1863 regs->cp0_epc = read_c0_errorepc(); 1865 regs->cp0_epc = read_c0_errorepc();
1864 die(str, regs); 1866 die(str, regs);
1867 nmi_exit();
1865} 1868}
1866 1869
1867#define VECTORSPACING 0x100 /* for EI/VI mode */ 1870#define VECTORSPACING 0x100 /* for EI/VI mode */
@@ -2204,12 +2207,8 @@ void __init trap_init(void)
2204 ebase = (unsigned long) 2207 ebase = (unsigned long)
2205 __alloc_bootmem(size, 1 << fls(size), 0); 2208 __alloc_bootmem(size, 1 << fls(size), 0);
2206 } else { 2209 } else {
2207#ifdef CONFIG_KVM_GUEST 2210 ebase = CAC_BASE;
2208#define KVM_GUEST_KSEG0 0x40000000 2211
2209 ebase = KVM_GUEST_KSEG0;
2210#else
2211 ebase = CKSEG0;
2212#endif
2213 if (cpu_has_mips_r2_r6) 2212 if (cpu_has_mips_r2_r6)
2214 ebase += (read_c0_ebase() & 0x3ffff000); 2213 ebase += (read_c0_ebase() & 0x3ffff000);
2215 } 2214 }
diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c
index 990354dd6bde..490cea569d57 100644
--- a/arch/mips/kernel/unaligned.c
+++ b/arch/mips/kernel/unaligned.c
@@ -85,6 +85,7 @@
85#include <asm/branch.h> 85#include <asm/branch.h>
86#include <asm/byteorder.h> 86#include <asm/byteorder.h>
87#include <asm/cop2.h> 87#include <asm/cop2.h>
88#include <asm/debug.h>
88#include <asm/fpu.h> 89#include <asm/fpu.h>
89#include <asm/fpu_emulator.h> 90#include <asm/fpu_emulator.h>
90#include <asm/inst.h> 91#include <asm/inst.h>
@@ -2295,7 +2296,6 @@ sigbus:
2295} 2296}
2296 2297
2297#ifdef CONFIG_DEBUG_FS 2298#ifdef CONFIG_DEBUG_FS
2298extern struct dentry *mips_debugfs_dir;
2299static int __init debugfs_unaligned(void) 2299static int __init debugfs_unaligned(void)
2300{ 2300{
2301 struct dentry *d; 2301 struct dentry *d;
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index ed2a278722a9..975e99759bab 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -1,122 +1,175 @@
1/* 1/*
2 * This file is subject to the terms and conditions of the GNU General Public 2 * Copyright (C) 2015 Imagination Technologies
3 * License. See the file "COPYING" in the main directory of this archive 3 * Author: Alex Smith <alex.smith@imgtec.com>
4 * for more details.
5 * 4 *
6 * Copyright (C) 2009, 2010 Cavium Networks, Inc. 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.
7 */ 9 */
8 10
9
10#include <linux/kernel.h>
11#include <linux/err.h>
12#include <linux/sched.h>
13#include <linux/mm.h>
14#include <linux/init.h>
15#include <linux/binfmts.h> 11#include <linux/binfmts.h>
16#include <linux/elf.h> 12#include <linux/elf.h>
17#include <linux/vmalloc.h> 13#include <linux/err.h>
18#include <linux/unistd.h> 14#include <linux/init.h>
19#include <linux/random.h> 15#include <linux/ioport.h>
16#include <linux/irqchip/mips-gic.h>
17#include <linux/mm.h>
18#include <linux/sched.h>
19#include <linux/slab.h>
20#include <linux/timekeeper_internal.h>
20 21
22#include <asm/abi.h>
21#include <asm/vdso.h> 23#include <asm/vdso.h>
22#include <asm/uasm.h> 24
23#include <asm/processor.h> 25/* Kernel-provided data used by the VDSO. */
26static union mips_vdso_data vdso_data __page_aligned_data;
24 27
25/* 28/*
26 * Including <asm/unistd.h> would give use the 64-bit syscall numbers ... 29 * Mapping for the VDSO data/GIC pages. The real pages are mapped manually, as
30 * what we map and where within the area they are mapped is determined at
31 * runtime.
27 */ 32 */
28#define __NR_O32_sigreturn 4119 33static struct page *no_pages[] = { NULL };
29#define __NR_O32_rt_sigreturn 4193 34static struct vm_special_mapping vdso_vvar_mapping = {
30#define __NR_N32_rt_sigreturn 6211 35 .name = "[vvar]",
36 .pages = no_pages,
37};
31 38
32static struct page *vdso_page; 39static void __init init_vdso_image(struct mips_vdso_image *image)
33
34static void __init install_trampoline(u32 *tramp, unsigned int sigreturn)
35{ 40{
36 uasm_i_addiu(&tramp, 2, 0, sigreturn); /* li v0, sigreturn */ 41 unsigned long num_pages, i;
37 uasm_i_syscall(&tramp, 0); 42
43 BUG_ON(!PAGE_ALIGNED(image->data));
44 BUG_ON(!PAGE_ALIGNED(image->size));
45
46 num_pages = image->size / PAGE_SIZE;
47
48 for (i = 0; i < num_pages; i++) {
49 image->mapping.pages[i] =
50 virt_to_page(image->data + (i * PAGE_SIZE));
51 }
38} 52}
39 53
40static int __init init_vdso(void) 54static int __init init_vdso(void)
41{ 55{
42 struct mips_vdso *vdso; 56 init_vdso_image(&vdso_image);
43 57
44 vdso_page = alloc_page(GFP_KERNEL); 58#ifdef CONFIG_MIPS32_O32
45 if (!vdso_page) 59 init_vdso_image(&vdso_image_o32);
46 panic("Cannot allocate vdso");
47
48 vdso = vmap(&vdso_page, 1, 0, PAGE_KERNEL);
49 if (!vdso)
50 panic("Cannot map vdso");
51 clear_page(vdso);
52
53 install_trampoline(vdso->rt_signal_trampoline, __NR_rt_sigreturn);
54#ifdef CONFIG_32BIT
55 install_trampoline(vdso->signal_trampoline, __NR_sigreturn);
56#else
57 install_trampoline(vdso->n32_rt_signal_trampoline,
58 __NR_N32_rt_sigreturn);
59 install_trampoline(vdso->o32_signal_trampoline, __NR_O32_sigreturn);
60 install_trampoline(vdso->o32_rt_signal_trampoline,
61 __NR_O32_rt_sigreturn);
62#endif 60#endif
63 61
64 vunmap(vdso); 62#ifdef CONFIG_MIPS32_N32
63 init_vdso_image(&vdso_image_n32);
64#endif
65 65
66 return 0; 66 return 0;
67} 67}
68subsys_initcall(init_vdso); 68subsys_initcall(init_vdso);
69 69
70static unsigned long vdso_addr(unsigned long start) 70void update_vsyscall(struct timekeeper *tk)
71{ 71{
72 unsigned long offset = 0UL; 72 vdso_data_write_begin(&vdso_data);
73 73
74 if (current->flags & PF_RANDOMIZE) { 74 vdso_data.xtime_sec = tk->xtime_sec;
75 offset = get_random_int(); 75 vdso_data.xtime_nsec = tk->tkr_mono.xtime_nsec;
76 offset <<= PAGE_SHIFT; 76 vdso_data.wall_to_mono_sec = tk->wall_to_monotonic.tv_sec;
77 if (TASK_IS_32BIT_ADDR) 77 vdso_data.wall_to_mono_nsec = tk->wall_to_monotonic.tv_nsec;
78 offset &= 0xfffffful; 78 vdso_data.cs_shift = tk->tkr_mono.shift;
79 else 79
80 offset &= 0xffffffful; 80 vdso_data.clock_mode = tk->tkr_mono.clock->archdata.vdso_clock_mode;
81 if (vdso_data.clock_mode != VDSO_CLOCK_NONE) {
82 vdso_data.cs_mult = tk->tkr_mono.mult;
83 vdso_data.cs_cycle_last = tk->tkr_mono.cycle_last;
84 vdso_data.cs_mask = tk->tkr_mono.mask;
81 } 85 }
82 86
83 return STACK_TOP + offset; 87 vdso_data_write_end(&vdso_data);
88}
89
90void update_vsyscall_tz(void)
91{
92 if (vdso_data.clock_mode != VDSO_CLOCK_NONE) {
93 vdso_data.tz_minuteswest = sys_tz.tz_minuteswest;
94 vdso_data.tz_dsttime = sys_tz.tz_dsttime;
95 }
84} 96}
85 97
86int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) 98int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
87{ 99{
88 int ret; 100 struct mips_vdso_image *image = current->thread.abi->vdso;
89 unsigned long addr;
90 struct mm_struct *mm = current->mm; 101 struct mm_struct *mm = current->mm;
102 unsigned long gic_size, vvar_size, size, base, data_addr, vdso_addr;
103 struct vm_area_struct *vma;
104 struct resource gic_res;
105 int ret;
91 106
92 down_write(&mm->mmap_sem); 107 down_write(&mm->mmap_sem);
93 108
94 addr = vdso_addr(mm->start_stack); 109 /*
110 * Determine total area size. This includes the VDSO data itself, the
111 * data page, and the GIC user page if present. Always create a mapping
112 * for the GIC user area if the GIC is present regardless of whether it
113 * is the current clocksource, in case it comes into use later on. We
114 * only map a page even though the total area is 64K, as we only need
115 * the counter registers at the start.
116 */
117 gic_size = gic_present ? PAGE_SIZE : 0;
118 vvar_size = gic_size + PAGE_SIZE;
119 size = vvar_size + image->size;
120
121 base = get_unmapped_area(NULL, 0, size, 0, 0);
122 if (IS_ERR_VALUE(base)) {
123 ret = base;
124 goto out;
125 }
126
127 data_addr = base + gic_size;
128 vdso_addr = data_addr + PAGE_SIZE;
95 129
96 addr = get_unmapped_area(NULL, addr, PAGE_SIZE, 0, 0); 130 vma = _install_special_mapping(mm, base, vvar_size,
97 if (IS_ERR_VALUE(addr)) { 131 VM_READ | VM_MAYREAD,
98 ret = addr; 132 &vdso_vvar_mapping);
99 goto up_fail; 133 if (IS_ERR(vma)) {
134 ret = PTR_ERR(vma);
135 goto out;
100 } 136 }
101 137
102 ret = install_special_mapping(mm, addr, PAGE_SIZE, 138 /* Map GIC user page. */
103 VM_READ|VM_EXEC| 139 if (gic_size) {
104 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, 140 ret = gic_get_usm_range(&gic_res);
105 &vdso_page); 141 if (ret)
142 goto out;
143
144 ret = io_remap_pfn_range(vma, base,
145 gic_res.start >> PAGE_SHIFT,
146 gic_size,
147 pgprot_noncached(PAGE_READONLY));
148 if (ret)
149 goto out;
150 }
106 151
152 /* Map data page. */
153 ret = remap_pfn_range(vma, data_addr,
154 virt_to_phys(&vdso_data) >> PAGE_SHIFT,
155 PAGE_SIZE, PAGE_READONLY);
107 if (ret) 156 if (ret)
108 goto up_fail; 157 goto out;
158
159 /* Map VDSO image. */
160 vma = _install_special_mapping(mm, vdso_addr, image->size,
161 VM_READ | VM_EXEC |
162 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
163 &image->mapping);
164 if (IS_ERR(vma)) {
165 ret = PTR_ERR(vma);
166 goto out;
167 }
109 168
110 mm->context.vdso = (void *)addr; 169 mm->context.vdso = (void *)vdso_addr;
170 ret = 0;
111 171
112up_fail: 172out:
113 up_write(&mm->mmap_sem); 173 up_write(&mm->mmap_sem);
114 return ret; 174 return ret;
115} 175}
116
117const char *arch_vma_name(struct vm_area_struct *vma)
118{
119 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
120 return "[vdso]";
121 return NULL;
122}
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 07d32a4aea60..0a93e83cd014 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -17,7 +17,9 @@ OUTPUT_ARCH(mips)
17ENTRY(kernel_entry) 17ENTRY(kernel_entry)
18PHDRS { 18PHDRS {
19 text PT_LOAD FLAGS(7); /* RWX */ 19 text PT_LOAD FLAGS(7); /* RWX */
20#ifndef CONFIG_CAVIUM_OCTEON_SOC
20 note PT_NOTE FLAGS(4); /* R__ */ 21 note PT_NOTE FLAGS(4); /* R__ */
22#endif /* CAVIUM_OCTEON_SOC */
21} 23}
22 24
23#ifdef CONFIG_32BIT 25#ifdef CONFIG_32BIT
@@ -71,7 +73,12 @@ SECTIONS
71 __stop___dbe_table = .; 73 __stop___dbe_table = .;
72 } 74 }
73 75
74 NOTES :text :note 76#ifdef CONFIG_CAVIUM_OCTEON_SOC
77#define NOTES_HEADER
78#else /* CONFIG_CAVIUM_OCTEON_SOC */
79#define NOTES_HEADER :note
80#endif /* CONFIG_CAVIUM_OCTEON_SOC */
81 NOTES :text NOTES_HEADER
75 .dummy : { *(.dummy) } :text 82 .dummy : { *(.dummy) } :text
76 83
77 _sdata = .; /* Start of data section */ 84 _sdata = .; /* Start of data section */
@@ -132,6 +139,11 @@ SECTIONS
132 __appended_dtb = .; 139 __appended_dtb = .;
133 /* leave space for appended DTB */ 140 /* leave space for appended DTB */
134 . += 0x100000; 141 . += 0x100000;
142#elif defined(CONFIG_MIPS_ELF_APPENDED_DTB)
143 .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
144 *(.appended_dtb)
145 KEEP(*(.appended_dtb))
146 }
135#endif 147#endif
136 /* 148 /*
137 * Align to 64K in attempt to eliminate holes before the 149 * Align to 64K in attempt to eliminate holes before the
@@ -181,6 +193,7 @@ SECTIONS
181 DISCARDS 193 DISCARDS
182 /DISCARD/ : { 194 /DISCARD/ : {
183 /* ABI crap starts here */ 195 /* ABI crap starts here */
196 *(.MIPS.abiflags)
184 *(.MIPS.options) 197 *(.MIPS.options)
185 *(.options) 198 *(.options)
186 *(.pdr) 199 *(.pdr)
diff --git a/arch/mips/kvm/locore.S b/arch/mips/kvm/locore.S
index c567240386a0..7bab3a4e8f7d 100644
--- a/arch/mips/kvm/locore.S
+++ b/arch/mips/kvm/locore.S
@@ -36,14 +36,6 @@
36#define PT_HOST_USERLOCAL PT_EPC 36#define PT_HOST_USERLOCAL PT_EPC
37 37
38#define CP0_DDATA_LO $28,3 38#define CP0_DDATA_LO $28,3
39#define CP0_CONFIG3 $16,3
40#define CP0_CONFIG5 $16,5
41#define CP0_EBASE $15,1
42
43#define CP0_INTCTL $12,1
44#define CP0_SRSCTL $12,2
45#define CP0_SRSMAP $12,3
46#define CP0_HWRENA $7,0
47 39
48/* Resume Flags */ 40/* Resume Flags */
49#define RESUME_FLAG_HOST (1<<1) /* Resume host? */ 41#define RESUME_FLAG_HOST (1<<1) /* Resume host? */
diff --git a/arch/mips/lantiq/clk.c b/arch/mips/lantiq/clk.c
index 3fc2e6d70c77..a0706fd4ce0a 100644
--- a/arch/mips/lantiq/clk.c
+++ b/arch/mips/lantiq/clk.c
@@ -99,6 +99,23 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
99} 99}
100EXPORT_SYMBOL(clk_set_rate); 100EXPORT_SYMBOL(clk_set_rate);
101 101
102long clk_round_rate(struct clk *clk, unsigned long rate)
103{
104 if (unlikely(!clk_good(clk)))
105 return 0;
106 if (clk->rates && *clk->rates) {
107 unsigned long *r = clk->rates;
108
109 while (*r && (*r != rate))
110 r++;
111 if (!*r) {
112 return clk->rate;
113 }
114 }
115 return rate;
116}
117EXPORT_SYMBOL(clk_round_rate);
118
102int clk_enable(struct clk *clk) 119int clk_enable(struct clk *clk)
103{ 120{
104 if (unlikely(!clk_good(clk))) 121 if (unlikely(!clk_good(clk)))
diff --git a/arch/mips/lantiq/clk.h b/arch/mips/lantiq/clk.h
index 77e4bdb1fe8c..7376ce817eda 100644
--- a/arch/mips/lantiq/clk.h
+++ b/arch/mips/lantiq/clk.h
@@ -31,13 +31,18 @@
31#define CLOCK_240M 240000000 31#define CLOCK_240M 240000000
32#define CLOCK_250M 250000000 32#define CLOCK_250M 250000000
33#define CLOCK_266M 266666666 33#define CLOCK_266M 266666666
34#define CLOCK_288M 288888888
34#define CLOCK_300M 300000000 35#define CLOCK_300M 300000000
35#define CLOCK_333M 333333333 36#define CLOCK_333M 333333333
37#define CLOCK_360M 360000000
36#define CLOCK_393M 393215332 38#define CLOCK_393M 393215332
37#define CLOCK_400M 400000000 39#define CLOCK_400M 400000000
40#define CLOCK_432M 432000000
38#define CLOCK_450M 450000000 41#define CLOCK_450M 450000000
39#define CLOCK_500M 500000000 42#define CLOCK_500M 500000000
40#define CLOCK_600M 600000000 43#define CLOCK_600M 600000000
44#define CLOCK_666M 666666666
45#define CLOCK_720M 720000000
41 46
42/* clock out speeds */ 47/* clock out speeds */
43#define CLOCK_32_768K 32768 48#define CLOCK_32_768K 32768
@@ -80,4 +85,12 @@ extern unsigned long ltq_vr9_cpu_hz(void);
80extern unsigned long ltq_vr9_fpi_hz(void); 85extern unsigned long ltq_vr9_fpi_hz(void);
81extern unsigned long ltq_vr9_pp32_hz(void); 86extern unsigned long ltq_vr9_pp32_hz(void);
82 87
88extern unsigned long ltq_ar10_cpu_hz(void);
89extern unsigned long ltq_ar10_fpi_hz(void);
90extern unsigned long ltq_ar10_pp32_hz(void);
91
92extern unsigned long ltq_grx390_cpu_hz(void);
93extern unsigned long ltq_grx390_fpi_hz(void);
94extern unsigned long ltq_grx390_pp32_hz(void);
95
83#endif 96#endif
diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c
index 2c218c3bbca5..2e7f60c9fc5d 100644
--- a/arch/mips/lantiq/irq.c
+++ b/arch/mips/lantiq/irq.c
@@ -369,8 +369,8 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
369 if (of_address_to_resource(node, i, &res)) 369 if (of_address_to_resource(node, i, &res))
370 panic("Failed to get icu memory range"); 370 panic("Failed to get icu memory range");
371 371
372 if (request_mem_region(res.start, resource_size(&res), 372 if (!request_mem_region(res.start, resource_size(&res),
373 res.name) < 0) 373 res.name))
374 pr_err("Failed to request icu memory"); 374 pr_err("Failed to request icu memory");
375 375
376 ltq_icu_membase[i] = ioremap_nocache(res.start, 376 ltq_icu_membase[i] = ioremap_nocache(res.start,
@@ -449,8 +449,8 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
449 if (ret != exin_avail) 449 if (ret != exin_avail)
450 panic("failed to load external irq resources"); 450 panic("failed to load external irq resources");
451 451
452 if (request_mem_region(res.start, resource_size(&res), 452 if (!request_mem_region(res.start, resource_size(&res),
453 res.name) < 0) 453 res.name))
454 pr_err("Failed to request eiu memory"); 454 pr_err("Failed to request eiu memory");
455 455
456 ltq_eiu_membase = ioremap_nocache(res.start, 456 ltq_eiu_membase = ioremap_nocache(res.start,
diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c
index 0db099ecc016..297bcaa6b5d3 100644
--- a/arch/mips/lantiq/prom.c
+++ b/arch/mips/lantiq/prom.c
@@ -77,8 +77,6 @@ void __init plat_mem_setup(void)
77 * parsed resulting in our memory appearing 77 * parsed resulting in our memory appearing
78 */ 78 */
79 __dt_setup_arch(__dtb_start); 79 __dt_setup_arch(__dtb_start);
80
81 strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
82} 80}
83 81
84void __init device_tree_init(void) 82void __init device_tree_init(void)
diff --git a/arch/mips/lantiq/xway/clk.c b/arch/mips/lantiq/xway/clk.c
index 8750dc0a1bf6..07f6d5b0b65e 100644
--- a/arch/mips/lantiq/xway/clk.c
+++ b/arch/mips/lantiq/xway/clk.c
@@ -4,6 +4,7 @@
4 * by the Free Software Foundation. 4 * by the Free Software Foundation.
5 * 5 *
6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org> 6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7 * Copyright (C) 2013-2015 Lantiq Beteiligungs-GmbH & Co.KG
7 */ 8 */
8 9
9#include <linux/io.h> 10#include <linux/io.h>
@@ -25,9 +26,9 @@ static unsigned int ram_clocks[] = {
25/* legacy xway clock */ 26/* legacy xway clock */
26#define CGU_SYS 0x10 27#define CGU_SYS 0x10
27 28
28/* vr9 clock */ 29/* vr9, ar10/grx390 clock */
29#define CGU_SYS_VR9 0x0c 30#define CGU_SYS_XRX 0x0c
30#define CGU_IF_CLK_VR9 0x24 31#define CGU_IF_CLK_AR10 0x24
31 32
32unsigned long ltq_danube_fpi_hz(void) 33unsigned long ltq_danube_fpi_hz(void)
33{ 34{
@@ -87,8 +88,9 @@ unsigned long ltq_ar9_fpi_hz(void)
87 unsigned long sys = ltq_ar9_sys_hz(); 88 unsigned long sys = ltq_ar9_sys_hz();
88 89
89 if (ltq_cgu_r32(CGU_SYS) & BIT(0)) 90 if (ltq_cgu_r32(CGU_SYS) & BIT(0))
90 return sys; 91 return sys / 3;
91 return sys >> 1; 92 else
93 return sys / 2;
92} 94}
93 95
94unsigned long ltq_ar9_cpu_hz(void) 96unsigned long ltq_ar9_cpu_hz(void)
@@ -104,7 +106,7 @@ unsigned long ltq_vr9_cpu_hz(void)
104 unsigned int cpu_sel; 106 unsigned int cpu_sel;
105 unsigned long clk; 107 unsigned long clk;
106 108
107 cpu_sel = (ltq_cgu_r32(CGU_SYS_VR9) >> 4) & 0xf; 109 cpu_sel = (ltq_cgu_r32(CGU_SYS_XRX) >> 4) & 0xf;
108 110
109 switch (cpu_sel) { 111 switch (cpu_sel) {
110 case 0: 112 case 0:
@@ -145,7 +147,7 @@ unsigned long ltq_vr9_fpi_hz(void)
145 unsigned long clk; 147 unsigned long clk;
146 148
147 cpu_clk = ltq_vr9_cpu_hz(); 149 cpu_clk = ltq_vr9_cpu_hz();
148 ocp_sel = ltq_cgu_r32(CGU_SYS_VR9) & 0x3; 150 ocp_sel = ltq_cgu_r32(CGU_SYS_XRX) & 0x3;
149 151
150 switch (ocp_sel) { 152 switch (ocp_sel) {
151 case 0: 153 case 0:
@@ -174,15 +176,18 @@ unsigned long ltq_vr9_fpi_hz(void)
174 176
175unsigned long ltq_vr9_pp32_hz(void) 177unsigned long ltq_vr9_pp32_hz(void)
176{ 178{
177 unsigned int clksys = (ltq_cgu_r32(CGU_SYS) >> 16) & 3; 179 unsigned int clksys = (ltq_cgu_r32(CGU_SYS) >> 16) & 0x7;
178 unsigned long clk; 180 unsigned long clk;
179 181
180 switch (clksys) { 182 switch (clksys) {
183 case 0:
184 clk = CLOCK_500M;
185 break;
181 case 1: 186 case 1:
182 clk = CLOCK_450M; 187 clk = CLOCK_432M;
183 break; 188 break;
184 case 2: 189 case 2:
185 clk = CLOCK_300M; 190 clk = CLOCK_288M;
186 break; 191 break;
187 default: 192 default:
188 clk = CLOCK_500M; 193 clk = CLOCK_500M;
@@ -191,3 +196,158 @@ unsigned long ltq_vr9_pp32_hz(void)
191 196
192 return clk; 197 return clk;
193} 198}
199
200unsigned long ltq_ar10_cpu_hz(void)
201{
202 unsigned int clksys;
203 int cpu_fs = (ltq_cgu_r32(CGU_SYS_XRX) >> 8) & 0x1;
204 int freq_div = (ltq_cgu_r32(CGU_SYS_XRX) >> 4) & 0x7;
205
206 switch (cpu_fs) {
207 case 0:
208 clksys = CLOCK_500M;
209 break;
210 case 1:
211 clksys = CLOCK_600M;
212 break;
213 default:
214 clksys = CLOCK_500M;
215 break;
216 }
217
218 switch (freq_div) {
219 case 0:
220 return clksys;
221 case 1:
222 return clksys >> 1;
223 case 2:
224 return clksys >> 2;
225 default:
226 return clksys;
227 }
228}
229
230unsigned long ltq_ar10_fpi_hz(void)
231{
232 int freq_fpi = (ltq_cgu_r32(CGU_IF_CLK_AR10) >> 25) & 0xf;
233
234 switch (freq_fpi) {
235 case 1:
236 return CLOCK_300M;
237 case 5:
238 return CLOCK_250M;
239 case 2:
240 return CLOCK_150M;
241 case 6:
242 return CLOCK_125M;
243
244 default:
245 return CLOCK_125M;
246 }
247}
248
249unsigned long ltq_ar10_pp32_hz(void)
250{
251 unsigned int clksys = (ltq_cgu_r32(CGU_SYS) >> 16) & 0x7;
252 unsigned long clk;
253
254 switch (clksys) {
255 case 1:
256 clk = CLOCK_250M;
257 break;
258 case 4:
259 clk = CLOCK_400M;
260 break;
261 default:
262 clk = CLOCK_250M;
263 break;
264 }
265
266 return clk;
267}
268
269unsigned long ltq_grx390_cpu_hz(void)
270{
271 unsigned int clksys;
272 int cpu_fs = ((ltq_cgu_r32(CGU_SYS_XRX) >> 9) & 0x3);
273 int freq_div = ((ltq_cgu_r32(CGU_SYS_XRX) >> 4) & 0x7);
274
275 switch (cpu_fs) {
276 case 0:
277 clksys = CLOCK_600M;
278 break;
279 case 1:
280 clksys = CLOCK_666M;
281 break;
282 case 2:
283 clksys = CLOCK_720M;
284 break;
285 default:
286 clksys = CLOCK_600M;
287 break;
288 }
289
290 switch (freq_div) {
291 case 0:
292 return clksys;
293 case 1:
294 return clksys >> 1;
295 case 2:
296 return clksys >> 2;
297 default:
298 return clksys;
299 }
300}
301
302unsigned long ltq_grx390_fpi_hz(void)
303{
304 /* fpi clock is derived from ddr_clk */
305 unsigned int clksys;
306 int cpu_fs = ((ltq_cgu_r32(CGU_SYS_XRX) >> 9) & 0x3);
307 int freq_div = ((ltq_cgu_r32(CGU_SYS_XRX)) & 0x7);
308 switch (cpu_fs) {
309 case 0:
310 clksys = CLOCK_600M;
311 break;
312 case 1:
313 clksys = CLOCK_666M;
314 break;
315 case 2:
316 clksys = CLOCK_720M;
317 break;
318 default:
319 clksys = CLOCK_600M;
320 break;
321 }
322
323 switch (freq_div) {
324 case 1:
325 return clksys >> 1;
326 case 2:
327 return clksys >> 2;
328 default:
329 return clksys >> 1;
330 }
331}
332
333unsigned long ltq_grx390_pp32_hz(void)
334{
335 unsigned int clksys = (ltq_cgu_r32(CGU_SYS) >> 16) & 0x7;
336 unsigned long clk;
337
338 switch (clksys) {
339 case 1:
340 clk = CLOCK_250M;
341 break;
342 case 2:
343 clk = CLOCK_432M;
344 break;
345 case 4:
346 clk = CLOCK_400M;
347 break;
348 default:
349 clk = CLOCK_250M;
350 break;
351 }
352 return clk;
353}
diff --git a/arch/mips/lantiq/xway/prom.c b/arch/mips/lantiq/xway/prom.c
index 248429ab2622..8f6e02f1e965 100644
--- a/arch/mips/lantiq/xway/prom.c
+++ b/arch/mips/lantiq/xway/prom.c
@@ -4,6 +4,7 @@
4 * by the Free Software Foundation. 4 * by the Free Software Foundation.
5 * 5 *
6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org> 6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7 * Copyright (C) 2013-2015 Lantiq Beteiligungs-GmbH & Co.KG
7 */ 8 */
8 9
9#include <linux/export.h> 10#include <linux/export.h>
@@ -19,8 +20,11 @@
19#define SOC_TWINPASS "Twinpass" 20#define SOC_TWINPASS "Twinpass"
20#define SOC_AMAZON_SE "Amazon_SE" 21#define SOC_AMAZON_SE "Amazon_SE"
21#define SOC_AR9 "AR9" 22#define SOC_AR9 "AR9"
22#define SOC_GR9 "GR9" 23#define SOC_GR9 "GRX200"
23#define SOC_VR9 "VR9" 24#define SOC_VR9 "xRX200"
25#define SOC_VRX220 "xRX220"
26#define SOC_AR10 "xRX300"
27#define SOC_GRX390 "xRX330"
24 28
25#define COMP_DANUBE "lantiq,danube" 29#define COMP_DANUBE "lantiq,danube"
26#define COMP_TWINPASS "lantiq,twinpass" 30#define COMP_TWINPASS "lantiq,twinpass"
@@ -28,6 +32,8 @@
28#define COMP_AR9 "lantiq,ar9" 32#define COMP_AR9 "lantiq,ar9"
29#define COMP_GR9 "lantiq,gr9" 33#define COMP_GR9 "lantiq,gr9"
30#define COMP_VR9 "lantiq,vr9" 34#define COMP_VR9 "lantiq,vr9"
35#define COMP_AR10 "lantiq,ar10"
36#define COMP_GRX390 "lantiq,grx390"
31 37
32#define PART_SHIFT 12 38#define PART_SHIFT 12
33#define PART_MASK 0x0FFFFFFF 39#define PART_MASK 0x0FFFFFFF
@@ -101,6 +107,12 @@ void __init ltq_soc_detect(struct ltq_soc_info *i)
101 i->compatible = COMP_VR9; 107 i->compatible = COMP_VR9;
102 break; 108 break;
103 109
110 case SOC_ID_VRX220:
111 i->name = SOC_VRX220;
112 i->type = SOC_TYPE_VRX220;
113 i->compatible = COMP_VR9;
114 break;
115
104 case SOC_ID_GRX282_2: 116 case SOC_ID_GRX282_2:
105 case SOC_ID_GRX288_2: 117 case SOC_ID_GRX288_2:
106 i->name = SOC_GR9; 118 i->name = SOC_GR9;
@@ -108,6 +120,25 @@ void __init ltq_soc_detect(struct ltq_soc_info *i)
108 i->compatible = COMP_GR9; 120 i->compatible = COMP_GR9;
109 break; 121 break;
110 122
123 case SOC_ID_ARX362:
124 case SOC_ID_ARX368:
125 case SOC_ID_ARX382:
126 case SOC_ID_ARX388:
127 case SOC_ID_URX388:
128 i->name = SOC_AR10;
129 i->type = SOC_TYPE_AR10;
130 i->compatible = COMP_AR10;
131 break;
132
133 case SOC_ID_GRX383:
134 case SOC_ID_GRX369:
135 case SOC_ID_GRX387:
136 case SOC_ID_GRX389:
137 i->name = SOC_GRX390;
138 i->type = SOC_TYPE_GRX390;
139 i->compatible = COMP_GRX390;
140 break;
141
111 default: 142 default:
112 unreachable(); 143 unreachable();
113 break; 144 break;
diff --git a/arch/mips/lantiq/xway/reset.c b/arch/mips/lantiq/xway/reset.c
index fe68f9ae47c1..bc29bb349e94 100644
--- a/arch/mips/lantiq/xway/reset.c
+++ b/arch/mips/lantiq/xway/reset.c
@@ -4,6 +4,7 @@
4 * by the Free Software Foundation. 4 * by the Free Software Foundation.
5 * 5 *
6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org> 6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7 * Copyright (C) 2013-2015 Lantiq Beteiligungs-GmbH & Co.KG
7 */ 8 */
8 9
9#include <linux/init.h> 10#include <linux/init.h>
@@ -22,9 +23,6 @@
22 23
23#include "../prom.h" 24#include "../prom.h"
24 25
25#define ltq_rcu_w32(x, y) ltq_w32((x), ltq_rcu_membase + (y))
26#define ltq_rcu_r32(x) ltq_r32(ltq_rcu_membase + (x))
27
28/* reset request register */ 26/* reset request register */
29#define RCU_RST_REQ 0x0010 27#define RCU_RST_REQ 0x0010
30/* reset status register */ 28/* reset status register */
@@ -32,11 +30,33 @@
32/* vr9 gphy registers */ 30/* vr9 gphy registers */
33#define RCU_GFS_ADD0_XRX200 0x0020 31#define RCU_GFS_ADD0_XRX200 0x0020
34#define RCU_GFS_ADD1_XRX200 0x0068 32#define RCU_GFS_ADD1_XRX200 0x0068
33/* xRX300 gphy registers */
34#define RCU_GFS_ADD0_XRX300 0x0020
35#define RCU_GFS_ADD1_XRX300 0x0058
36#define RCU_GFS_ADD2_XRX300 0x00AC
37/* xRX330 gphy registers */
38#define RCU_GFS_ADD0_XRX330 0x0020
39#define RCU_GFS_ADD1_XRX330 0x0058
40#define RCU_GFS_ADD2_XRX330 0x00AC
41#define RCU_GFS_ADD3_XRX330 0x0264
42
43/* xbar BE flag */
44#define RCU_AHB_ENDIAN 0x004C
45#define RCU_VR9_BE_AHB1S 0x00000008
35 46
36/* reboot bit */ 47/* reboot bit */
37#define RCU_RD_GPHY0_XRX200 BIT(31) 48#define RCU_RD_GPHY0_XRX200 BIT(31)
38#define RCU_RD_SRST BIT(30) 49#define RCU_RD_SRST BIT(30)
39#define RCU_RD_GPHY1_XRX200 BIT(29) 50#define RCU_RD_GPHY1_XRX200 BIT(29)
51/* xRX300 bits */
52#define RCU_RD_GPHY0_XRX300 BIT(31)
53#define RCU_RD_GPHY1_XRX300 BIT(29)
54#define RCU_RD_GPHY2_XRX300 BIT(28)
55/* xRX330 bits */
56#define RCU_RD_GPHY0_XRX330 BIT(31)
57#define RCU_RD_GPHY1_XRX330 BIT(29)
58#define RCU_RD_GPHY2_XRX330 BIT(28)
59#define RCU_RD_GPHY3_XRX330 BIT(10)
40 60
41/* reset cause */ 61/* reset cause */
42#define RCU_STAT_SHIFT 26 62#define RCU_STAT_SHIFT 26
@@ -44,9 +64,60 @@
44#define RCU_BOOT_SEL(x) ((x >> 18) & 0x7) 64#define RCU_BOOT_SEL(x) ((x >> 18) & 0x7)
45#define RCU_BOOT_SEL_XRX200(x) (((x >> 17) & 0xf) | ((x >> 8) & 0x10)) 65#define RCU_BOOT_SEL_XRX200(x) (((x >> 17) & 0xf) | ((x >> 8) & 0x10))
46 66
67/* dwc2 USB configuration registers */
68#define RCU_USB1CFG 0x0018
69#define RCU_USB2CFG 0x0034
70
71/* USB DMA endianness bits */
72#define RCU_USBCFG_HDSEL_BIT BIT(11)
73#define RCU_USBCFG_HOST_END_BIT BIT(10)
74#define RCU_USBCFG_SLV_END_BIT BIT(9)
75
76/* USB reset bits */
77#define RCU_USBRESET 0x0010
78
79#define USBRESET_BIT BIT(4)
80
81#define RCU_USBRESET2 0x0048
82
83#define USB1RESET_BIT BIT(4)
84#define USB2RESET_BIT BIT(5)
85
86#define RCU_CFG1A 0x0038
87#define RCU_CFG1B 0x003C
88
89/* USB PMU devices */
90#define PMU_AHBM BIT(15)
91#define PMU_USB0 BIT(6)
92#define PMU_USB1 BIT(27)
93
94/* USB PHY PMU devices */
95#define PMU_USB0_P BIT(0)
96#define PMU_USB1_P BIT(26)
97
47/* remapped base addr of the reset control unit */ 98/* remapped base addr of the reset control unit */
48static void __iomem *ltq_rcu_membase; 99static void __iomem *ltq_rcu_membase;
49static struct device_node *ltq_rcu_np; 100static struct device_node *ltq_rcu_np;
101static DEFINE_SPINLOCK(ltq_rcu_lock);
102
103static void ltq_rcu_w32(uint32_t val, uint32_t reg_off)
104{
105 ltq_w32(val, ltq_rcu_membase + reg_off);
106}
107
108static uint32_t ltq_rcu_r32(uint32_t reg_off)
109{
110 return ltq_r32(ltq_rcu_membase + reg_off);
111}
112
113static void ltq_rcu_w32_mask(uint32_t clr, uint32_t set, uint32_t reg_off)
114{
115 unsigned long flags;
116
117 spin_lock_irqsave(&ltq_rcu_lock, flags);
118 ltq_rcu_w32((ltq_rcu_r32(reg_off) & ~(clr)) | (set), reg_off);
119 spin_unlock_irqrestore(&ltq_rcu_lock, flags);
120}
50 121
51/* This function is used by the watchdog driver */ 122/* This function is used by the watchdog driver */
52int ltq_reset_cause(void) 123int ltq_reset_cause(void)
@@ -67,15 +138,40 @@ unsigned char ltq_boot_select(void)
67 return RCU_BOOT_SEL(val); 138 return RCU_BOOT_SEL(val);
68} 139}
69 140
70/* reset / boot a gphy */ 141struct ltq_gphy_reset {
71static struct ltq_xrx200_gphy_reset {
72 u32 rd; 142 u32 rd;
73 u32 addr; 143 u32 addr;
74} xrx200_gphy[] = { 144};
145
146/* reset / boot a gphy */
147static struct ltq_gphy_reset xrx200_gphy[] = {
75 {RCU_RD_GPHY0_XRX200, RCU_GFS_ADD0_XRX200}, 148 {RCU_RD_GPHY0_XRX200, RCU_GFS_ADD0_XRX200},
76 {RCU_RD_GPHY1_XRX200, RCU_GFS_ADD1_XRX200}, 149 {RCU_RD_GPHY1_XRX200, RCU_GFS_ADD1_XRX200},
77}; 150};
78 151
152/* reset / boot a gphy */
153static struct ltq_gphy_reset xrx300_gphy[] = {
154 {RCU_RD_GPHY0_XRX300, RCU_GFS_ADD0_XRX300},
155 {RCU_RD_GPHY1_XRX300, RCU_GFS_ADD1_XRX300},
156 {RCU_RD_GPHY2_XRX300, RCU_GFS_ADD2_XRX300},
157};
158
159/* reset / boot a gphy */
160static struct ltq_gphy_reset xrx330_gphy[] = {
161 {RCU_RD_GPHY0_XRX330, RCU_GFS_ADD0_XRX330},
162 {RCU_RD_GPHY1_XRX330, RCU_GFS_ADD1_XRX330},
163 {RCU_RD_GPHY2_XRX330, RCU_GFS_ADD2_XRX330},
164 {RCU_RD_GPHY3_XRX330, RCU_GFS_ADD3_XRX330},
165};
166
167static void xrx200_gphy_boot_addr(struct ltq_gphy_reset *phy_regs,
168 dma_addr_t dev_addr)
169{
170 ltq_rcu_w32_mask(0, phy_regs->rd, RCU_RST_REQ);
171 ltq_rcu_w32(dev_addr, phy_regs->addr);
172 ltq_rcu_w32_mask(phy_regs->rd, 0, RCU_RST_REQ);
173}
174
79/* reset and boot a gphy. these phys only exist on xrx200 SoC */ 175/* reset and boot a gphy. these phys only exist on xrx200 SoC */
80int xrx200_gphy_boot(struct device *dev, unsigned int id, dma_addr_t dev_addr) 176int xrx200_gphy_boot(struct device *dev, unsigned int id, dma_addr_t dev_addr)
81{ 177{
@@ -86,23 +182,34 @@ int xrx200_gphy_boot(struct device *dev, unsigned int id, dma_addr_t dev_addr)
86 return -EINVAL; 182 return -EINVAL;
87 } 183 }
88 184
89 clk = clk_get_sys("1f203000.rcu", "gphy"); 185 if (of_machine_is_compatible("lantiq,vr9")) {
90 if (IS_ERR(clk)) 186 clk = clk_get_sys("1f203000.rcu", "gphy");
91 return PTR_ERR(clk); 187 if (IS_ERR(clk))
92 188 return PTR_ERR(clk);
93 clk_enable(clk); 189 clk_enable(clk);
94
95 if (id > 1) {
96 dev_err(dev, "%u is an invalid gphy id\n", id);
97 return -EINVAL;
98 } 190 }
191
99 dev_info(dev, "booting GPHY%u firmware at %X\n", id, dev_addr); 192 dev_info(dev, "booting GPHY%u firmware at %X\n", id, dev_addr);
100 193
101 ltq_rcu_w32(ltq_rcu_r32(RCU_RST_REQ) | xrx200_gphy[id].rd, 194 if (of_machine_is_compatible("lantiq,vr9")) {
102 RCU_RST_REQ); 195 if (id >= ARRAY_SIZE(xrx200_gphy)) {
103 ltq_rcu_w32(dev_addr, xrx200_gphy[id].addr); 196 dev_err(dev, "%u is an invalid gphy id\n", id);
104 ltq_rcu_w32(ltq_rcu_r32(RCU_RST_REQ) & ~xrx200_gphy[id].rd, 197 return -EINVAL;
105 RCU_RST_REQ); 198 }
199 xrx200_gphy_boot_addr(&xrx200_gphy[id], dev_addr);
200 } else if (of_machine_is_compatible("lantiq,ar10")) {
201 if (id >= ARRAY_SIZE(xrx300_gphy)) {
202 dev_err(dev, "%u is an invalid gphy id\n", id);
203 return -EINVAL;
204 }
205 xrx200_gphy_boot_addr(&xrx300_gphy[id], dev_addr);
206 } else if (of_machine_is_compatible("lantiq,grx390")) {
207 if (id >= ARRAY_SIZE(xrx330_gphy)) {
208 dev_err(dev, "%u is an invalid gphy id\n", id);
209 return -EINVAL;
210 }
211 xrx200_gphy_boot_addr(&xrx330_gphy[id], dev_addr);
212 }
106 return 0; 213 return 0;
107} 214}
108 215
@@ -200,6 +307,45 @@ static void ltq_machine_power_off(void)
200 unreachable(); 307 unreachable();
201} 308}
202 309
310static void ltq_usb_init(void)
311{
312 /* Power for USB cores 1 & 2 */
313 ltq_pmu_enable(PMU_AHBM);
314 ltq_pmu_enable(PMU_USB0);
315 ltq_pmu_enable(PMU_USB1);
316
317 ltq_rcu_w32(ltq_rcu_r32(RCU_CFG1A) | BIT(0), RCU_CFG1A);
318 ltq_rcu_w32(ltq_rcu_r32(RCU_CFG1B) | BIT(0), RCU_CFG1B);
319
320 /* Enable USB PHY power for cores 1 & 2 */
321 ltq_pmu_enable(PMU_USB0_P);
322 ltq_pmu_enable(PMU_USB1_P);
323
324 /* Configure cores to host mode */
325 ltq_rcu_w32(ltq_rcu_r32(RCU_USB1CFG) & ~RCU_USBCFG_HDSEL_BIT,
326 RCU_USB1CFG);
327 ltq_rcu_w32(ltq_rcu_r32(RCU_USB2CFG) & ~RCU_USBCFG_HDSEL_BIT,
328 RCU_USB2CFG);
329
330 /* Select DMA endianness (Host-endian: big-endian) */
331 ltq_rcu_w32((ltq_rcu_r32(RCU_USB1CFG) & ~RCU_USBCFG_SLV_END_BIT)
332 | RCU_USBCFG_HOST_END_BIT, RCU_USB1CFG);
333 ltq_rcu_w32(ltq_rcu_r32((RCU_USB2CFG) & ~RCU_USBCFG_SLV_END_BIT)
334 | RCU_USBCFG_HOST_END_BIT, RCU_USB2CFG);
335
336 /* Hard reset USB state machines */
337 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET) | USBRESET_BIT, RCU_USBRESET);
338 udelay(50 * 1000);
339 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET) & ~USBRESET_BIT, RCU_USBRESET);
340
341 /* Soft reset USB state machines */
342 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET2)
343 | USB1RESET_BIT | USB2RESET_BIT, RCU_USBRESET2);
344 udelay(50 * 1000);
345 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET2)
346 & ~(USB1RESET_BIT | USB2RESET_BIT), RCU_USBRESET2);
347}
348
203static int __init mips_reboot_setup(void) 349static int __init mips_reboot_setup(void)
204{ 350{
205 struct resource res; 351 struct resource res;
@@ -216,13 +362,21 @@ static int __init mips_reboot_setup(void)
216 if (of_address_to_resource(ltq_rcu_np, 0, &res)) 362 if (of_address_to_resource(ltq_rcu_np, 0, &res))
217 panic("Failed to get rcu memory range"); 363 panic("Failed to get rcu memory range");
218 364
219 if (request_mem_region(res.start, resource_size(&res), res.name) < 0) 365 if (!request_mem_region(res.start, resource_size(&res), res.name))
220 pr_err("Failed to request rcu memory"); 366 pr_err("Failed to request rcu memory");
221 367
222 ltq_rcu_membase = ioremap_nocache(res.start, resource_size(&res)); 368 ltq_rcu_membase = ioremap_nocache(res.start, resource_size(&res));
223 if (!ltq_rcu_membase) 369 if (!ltq_rcu_membase)
224 panic("Failed to remap core memory"); 370 panic("Failed to remap core memory");
225 371
372 if (of_machine_is_compatible("lantiq,ar9") ||
373 of_machine_is_compatible("lantiq,vr9"))
374 ltq_usb_init();
375
376 if (of_machine_is_compatible("lantiq,vr9"))
377 ltq_rcu_w32(ltq_rcu_r32(RCU_AHB_ENDIAN) | RCU_VR9_BE_AHB1S,
378 RCU_AHB_ENDIAN);
379
226 _machine_restart = ltq_machine_restart; 380 _machine_restart = ltq_machine_restart;
227 _machine_halt = ltq_machine_halt; 381 _machine_halt = ltq_machine_halt;
228 pm_power_off = ltq_machine_power_off; 382 pm_power_off = ltq_machine_power_off;
diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
index 2b15491de494..80554e8f6037 100644
--- a/arch/mips/lantiq/xway/sysctrl.c
+++ b/arch/mips/lantiq/xway/sysctrl.c
@@ -4,11 +4,13 @@
4 * by the Free Software Foundation. 4 * by the Free Software Foundation.
5 * 5 *
6 * Copyright (C) 2011-2012 John Crispin <blogic@openwrt.org> 6 * Copyright (C) 2011-2012 John Crispin <blogic@openwrt.org>
7 * Copyright (C) 2013-2015 Lantiq Beteiligungs-GmbH & Co.KG
7 */ 8 */
8 9
9#include <linux/ioport.h> 10#include <linux/ioport.h>
10#include <linux/export.h> 11#include <linux/export.h>
11#include <linux/clkdev.h> 12#include <linux/clkdev.h>
13#include <linux/spinlock.h>
12#include <linux/of.h> 14#include <linux/of.h>
13#include <linux/of_platform.h> 15#include <linux/of_platform.h>
14#include <linux/of_address.h> 16#include <linux/of_address.h>
@@ -18,16 +20,18 @@
18#include "../clk.h" 20#include "../clk.h"
19#include "../prom.h" 21#include "../prom.h"
20 22
21/* clock control register */ 23/* clock control register for legacy */
22#define CGU_IFCCR 0x0018 24#define CGU_IFCCR 0x0018
23#define CGU_IFCCR_VR9 0x0024 25#define CGU_IFCCR_VR9 0x0024
24/* system clock register */ 26/* system clock register for legacy */
25#define CGU_SYS 0x0010 27#define CGU_SYS 0x0010
26/* pci control register */ 28/* pci control register */
27#define CGU_PCICR 0x0034 29#define CGU_PCICR 0x0034
28#define CGU_PCICR_VR9 0x0038 30#define CGU_PCICR_VR9 0x0038
29/* ephy configuration register */ 31/* ephy configuration register */
30#define CGU_EPHY 0x10 32#define CGU_EPHY 0x10
33
34/* Legacy PMU register for ar9, ase, danube */
31/* power control register */ 35/* power control register */
32#define PMU_PWDCR 0x1C 36#define PMU_PWDCR 0x1C
33/* power status register */ 37/* power status register */
@@ -41,13 +45,56 @@
41/* power status register */ 45/* power status register */
42#define PWDSR(x) ((x) ? (PMU_PWDSR1) : (PMU_PWDSR)) 46#define PWDSR(x) ((x) ? (PMU_PWDSR1) : (PMU_PWDSR))
43 47
48
49/* PMU register for ar10 and grx390 */
50
51/* First register set */
52#define PMU_CLK_SR 0x20 /* status */
53#define PMU_CLK_CR_A 0x24 /* Enable */
54#define PMU_CLK_CR_B 0x28 /* Disable */
55/* Second register set */
56#define PMU_CLK_SR1 0x30 /* status */
57#define PMU_CLK_CR1_A 0x34 /* Enable */
58#define PMU_CLK_CR1_B 0x38 /* Disable */
59/* Third register set */
60#define PMU_ANA_SR 0x40 /* status */
61#define PMU_ANA_CR_A 0x44 /* Enable */
62#define PMU_ANA_CR_B 0x48 /* Disable */
63
64/* Status */
65static u32 pmu_clk_sr[] = {
66 PMU_CLK_SR,
67 PMU_CLK_SR1,
68 PMU_ANA_SR,
69};
70
71/* Enable */
72static u32 pmu_clk_cr_a[] = {
73 PMU_CLK_CR_A,
74 PMU_CLK_CR1_A,
75 PMU_ANA_CR_A,
76};
77
78/* Disable */
79static u32 pmu_clk_cr_b[] = {
80 PMU_CLK_CR_B,
81 PMU_CLK_CR1_B,
82 PMU_ANA_CR_B,
83};
84
85#define PWDCR_EN_XRX(x) (pmu_clk_cr_a[(x)])
86#define PWDCR_DIS_XRX(x) (pmu_clk_cr_b[(x)])
87#define PWDSR_XRX(x) (pmu_clk_sr[(x)])
88
44/* clock gates that we can en/disable */ 89/* clock gates that we can en/disable */
45#define PMU_USB0_P BIT(0) 90#define PMU_USB0_P BIT(0)
91#define PMU_ASE_SDIO BIT(2) /* ASE special */
46#define PMU_PCI BIT(4) 92#define PMU_PCI BIT(4)
47#define PMU_DMA BIT(5) 93#define PMU_DMA BIT(5)
48#define PMU_USB0 BIT(6) 94#define PMU_USB0 BIT(6)
49#define PMU_ASC0 BIT(7) 95#define PMU_ASC0 BIT(7)
50#define PMU_EPHY BIT(7) /* ase */ 96#define PMU_EPHY BIT(7) /* ase */
97#define PMU_USIF BIT(7) /* from vr9 until grx390 */
51#define PMU_SPI BIT(8) 98#define PMU_SPI BIT(8)
52#define PMU_DFE BIT(9) 99#define PMU_DFE BIT(9)
53#define PMU_EBU BIT(10) 100#define PMU_EBU BIT(10)
@@ -56,12 +103,15 @@
56#define PMU_AHBS BIT(13) /* vr9 */ 103#define PMU_AHBS BIT(13) /* vr9 */
57#define PMU_FPI BIT(14) 104#define PMU_FPI BIT(14)
58#define PMU_AHBM BIT(15) 105#define PMU_AHBM BIT(15)
106#define PMU_SDIO BIT(16) /* danube, ar9, vr9 */
59#define PMU_ASC1 BIT(17) 107#define PMU_ASC1 BIT(17)
60#define PMU_PPE_QSB BIT(18) 108#define PMU_PPE_QSB BIT(18)
61#define PMU_PPE_SLL01 BIT(19) 109#define PMU_PPE_SLL01 BIT(19)
110#define PMU_DEU BIT(20)
62#define PMU_PPE_TC BIT(21) 111#define PMU_PPE_TC BIT(21)
63#define PMU_PPE_EMA BIT(22) 112#define PMU_PPE_EMA BIT(22)
64#define PMU_PPE_DPLUM BIT(23) 113#define PMU_PPE_DPLUM BIT(23)
114#define PMU_PPE_DP BIT(23)
65#define PMU_PPE_DPLUS BIT(24) 115#define PMU_PPE_DPLUS BIT(24)
66#define PMU_USB1_P BIT(26) 116#define PMU_USB1_P BIT(26)
67#define PMU_USB1 BIT(27) 117#define PMU_USB1 BIT(27)
@@ -70,30 +120,59 @@
70#define PMU_GPHY BIT(30) 120#define PMU_GPHY BIT(30)
71#define PMU_PCIE_CLK BIT(31) 121#define PMU_PCIE_CLK BIT(31)
72 122
73#define PMU1_PCIE_PHY BIT(0) 123#define PMU1_PCIE_PHY BIT(0) /* vr9-specific,moved in ar10/grx390 */
74#define PMU1_PCIE_CTL BIT(1) 124#define PMU1_PCIE_CTL BIT(1)
75#define PMU1_PCIE_PDI BIT(4) 125#define PMU1_PCIE_PDI BIT(4)
76#define PMU1_PCIE_MSI BIT(5) 126#define PMU1_PCIE_MSI BIT(5)
127#define PMU1_CKE BIT(6)
128#define PMU1_PCIE1_CTL BIT(17)
129#define PMU1_PCIE1_PDI BIT(20)
130#define PMU1_PCIE1_MSI BIT(21)
131#define PMU1_PCIE2_CTL BIT(25)
132#define PMU1_PCIE2_PDI BIT(26)
133#define PMU1_PCIE2_MSI BIT(27)
134
135#define PMU_ANALOG_USB0_P BIT(0)
136#define PMU_ANALOG_USB1_P BIT(1)
137#define PMU_ANALOG_PCIE0_P BIT(8)
138#define PMU_ANALOG_PCIE1_P BIT(9)
139#define PMU_ANALOG_PCIE2_P BIT(10)
140#define PMU_ANALOG_DSL_AFE BIT(16)
141#define PMU_ANALOG_DCDC_2V5 BIT(17)
142#define PMU_ANALOG_DCDC_1VX BIT(18)
143#define PMU_ANALOG_DCDC_1V0 BIT(19)
77 144
78#define pmu_w32(x, y) ltq_w32((x), pmu_membase + (y)) 145#define pmu_w32(x, y) ltq_w32((x), pmu_membase + (y))
79#define pmu_r32(x) ltq_r32(pmu_membase + (x)) 146#define pmu_r32(x) ltq_r32(pmu_membase + (x))
80 147
148#define XBAR_ALWAYS_LAST 0x430
149#define XBAR_FPI_BURST_EN BIT(1)
150#define XBAR_AHB_BURST_EN BIT(2)
151
152#define xbar_w32(x, y) ltq_w32((x), ltq_xbar_membase + (y))
153#define xbar_r32(x) ltq_r32(ltq_xbar_membase + (x))
154
81static void __iomem *pmu_membase; 155static void __iomem *pmu_membase;
156static void __iomem *ltq_xbar_membase;
82void __iomem *ltq_cgu_membase; 157void __iomem *ltq_cgu_membase;
83void __iomem *ltq_ebu_membase; 158void __iomem *ltq_ebu_membase;
84 159
85static u32 ifccr = CGU_IFCCR; 160static u32 ifccr = CGU_IFCCR;
86static u32 pcicr = CGU_PCICR; 161static u32 pcicr = CGU_PCICR;
87 162
163static DEFINE_SPINLOCK(g_pmu_lock);
164
88/* legacy function kept alive to ease clkdev transition */ 165/* legacy function kept alive to ease clkdev transition */
89void ltq_pmu_enable(unsigned int module) 166void ltq_pmu_enable(unsigned int module)
90{ 167{
91 int err = 1000000; 168 int retry = 1000000;
92 169
170 spin_lock(&g_pmu_lock);
93 pmu_w32(pmu_r32(PMU_PWDCR) & ~module, PMU_PWDCR); 171 pmu_w32(pmu_r32(PMU_PWDCR) & ~module, PMU_PWDCR);
94 do {} while (--err && (pmu_r32(PMU_PWDSR) & module)); 172 do {} while (--retry && (pmu_r32(PMU_PWDSR) & module));
173 spin_unlock(&g_pmu_lock);
95 174
96 if (!err) 175 if (!retry)
97 panic("activating PMU module failed!"); 176 panic("activating PMU module failed!");
98} 177}
99EXPORT_SYMBOL(ltq_pmu_enable); 178EXPORT_SYMBOL(ltq_pmu_enable);
@@ -101,7 +180,15 @@ EXPORT_SYMBOL(ltq_pmu_enable);
101/* legacy function kept alive to ease clkdev transition */ 180/* legacy function kept alive to ease clkdev transition */
102void ltq_pmu_disable(unsigned int module) 181void ltq_pmu_disable(unsigned int module)
103{ 182{
183 int retry = 1000000;
184
185 spin_lock(&g_pmu_lock);
104 pmu_w32(pmu_r32(PMU_PWDCR) | module, PMU_PWDCR); 186 pmu_w32(pmu_r32(PMU_PWDCR) | module, PMU_PWDCR);
187 do {} while (--retry && (!(pmu_r32(PMU_PWDSR) & module)));
188 spin_unlock(&g_pmu_lock);
189
190 if (!retry)
191 pr_warn("deactivating PMU module failed!");
105} 192}
106EXPORT_SYMBOL(ltq_pmu_disable); 193EXPORT_SYMBOL(ltq_pmu_disable);
107 194
@@ -123,9 +210,20 @@ static int pmu_enable(struct clk *clk)
123{ 210{
124 int retry = 1000000; 211 int retry = 1000000;
125 212
126 pmu_w32(pmu_r32(PWDCR(clk->module)) & ~clk->bits, 213 if (of_machine_is_compatible("lantiq,ar10")
127 PWDCR(clk->module)); 214 || of_machine_is_compatible("lantiq,grx390")) {
128 do {} while (--retry && (pmu_r32(PWDSR(clk->module)) & clk->bits)); 215 pmu_w32(clk->bits, PWDCR_EN_XRX(clk->module));
216 do {} while (--retry &&
217 (!(pmu_r32(PWDSR_XRX(clk->module)) & clk->bits)));
218
219 } else {
220 spin_lock(&g_pmu_lock);
221 pmu_w32(pmu_r32(PWDCR(clk->module)) & ~clk->bits,
222 PWDCR(clk->module));
223 do {} while (--retry &&
224 (pmu_r32(PWDSR(clk->module)) & clk->bits));
225 spin_unlock(&g_pmu_lock);
226 }
129 227
130 if (!retry) 228 if (!retry)
131 panic("activating PMU module failed!"); 229 panic("activating PMU module failed!");
@@ -136,8 +234,24 @@ static int pmu_enable(struct clk *clk)
136/* disable a clock gate */ 234/* disable a clock gate */
137static void pmu_disable(struct clk *clk) 235static void pmu_disable(struct clk *clk)
138{ 236{
139 pmu_w32(pmu_r32(PWDCR(clk->module)) | clk->bits, 237 int retry = 1000000;
140 PWDCR(clk->module)); 238
239 if (of_machine_is_compatible("lantiq,ar10")
240 || of_machine_is_compatible("lantiq,grx390")) {
241 pmu_w32(clk->bits, PWDCR_DIS_XRX(clk->module));
242 do {} while (--retry &&
243 (pmu_r32(PWDSR_XRX(clk->module)) & clk->bits));
244 } else {
245 spin_lock(&g_pmu_lock);
246 pmu_w32(pmu_r32(PWDCR(clk->module)) | clk->bits,
247 PWDCR(clk->module));
248 do {} while (--retry &&
249 (!(pmu_r32(PWDSR(clk->module)) & clk->bits)));
250 spin_unlock(&g_pmu_lock);
251 }
252
253 if (!retry)
254 pr_warn("deactivating PMU module failed!");
141} 255}
142 256
143/* the pci enable helper */ 257/* the pci enable helper */
@@ -179,6 +293,16 @@ static void pci_ext_disable(struct clk *clk)
179 ltq_cgu_w32((1 << 31) | (1 << 30), pcicr); 293 ltq_cgu_w32((1 << 31) | (1 << 30), pcicr);
180} 294}
181 295
296static void xbar_fpi_burst_disable(void)
297{
298 u32 reg;
299
300 /* bit 1 as 1 --burst; bit 1 as 0 -- single */
301 reg = xbar_r32(XBAR_ALWAYS_LAST);
302 reg &= ~XBAR_FPI_BURST_EN;
303 xbar_w32(reg, XBAR_ALWAYS_LAST);
304}
305
182/* enable a clockout source */ 306/* enable a clockout source */
183static int clkout_enable(struct clk *clk) 307static int clkout_enable(struct clk *clk)
184{ 308{
@@ -202,8 +326,8 @@ static int clkout_enable(struct clk *clk)
202} 326}
203 327
204/* manage the clock gates via PMU */ 328/* manage the clock gates via PMU */
205static void clkdev_add_pmu(const char *dev, const char *con, 329static void clkdev_add_pmu(const char *dev, const char *con, bool deactivate,
206 unsigned int module, unsigned int bits) 330 unsigned int module, unsigned int bits)
207{ 331{
208 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 332 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
209 333
@@ -214,6 +338,13 @@ static void clkdev_add_pmu(const char *dev, const char *con,
214 clk->disable = pmu_disable; 338 clk->disable = pmu_disable;
215 clk->module = module; 339 clk->module = module;
216 clk->bits = bits; 340 clk->bits = bits;
341 if (deactivate) {
342 /*
343 * Disable it during the initialization. Module should enable
344 * when used
345 */
346 pmu_disable(clk);
347 }
217 clkdev_add(&clk->cl); 348 clkdev_add(&clk->cl);
218} 349}
219 350
@@ -312,12 +443,12 @@ void __init ltq_soc_init(void)
312 of_address_to_resource(np_ebu, 0, &res_ebu)) 443 of_address_to_resource(np_ebu, 0, &res_ebu))
313 panic("Failed to get core resources"); 444 panic("Failed to get core resources");
314 445
315 if ((request_mem_region(res_pmu.start, resource_size(&res_pmu), 446 if (!request_mem_region(res_pmu.start, resource_size(&res_pmu),
316 res_pmu.name) < 0) || 447 res_pmu.name) ||
317 (request_mem_region(res_cgu.start, resource_size(&res_cgu), 448 !request_mem_region(res_cgu.start, resource_size(&res_cgu),
318 res_cgu.name) < 0) || 449 res_cgu.name) ||
319 (request_mem_region(res_ebu.start, resource_size(&res_ebu), 450 !request_mem_region(res_ebu.start, resource_size(&res_ebu),
320 res_ebu.name) < 0)) 451 res_ebu.name))
321 pr_err("Failed to request core resources"); 452 pr_err("Failed to request core resources");
322 453
323 pmu_membase = ioremap_nocache(res_pmu.start, resource_size(&res_pmu)); 454 pmu_membase = ioremap_nocache(res_pmu.start, resource_size(&res_pmu));
@@ -328,17 +459,37 @@ void __init ltq_soc_init(void)
328 if (!pmu_membase || !ltq_cgu_membase || !ltq_ebu_membase) 459 if (!pmu_membase || !ltq_cgu_membase || !ltq_ebu_membase)
329 panic("Failed to remap core resources"); 460 panic("Failed to remap core resources");
330 461
462 if (of_machine_is_compatible("lantiq,vr9")) {
463 struct resource res_xbar;
464 struct device_node *np_xbar =
465 of_find_compatible_node(NULL, NULL,
466 "lantiq,xbar-xway");
467
468 if (!np_xbar)
469 panic("Failed to load xbar nodes from devicetree");
470 if (of_address_to_resource(np_pmu, 0, &res_xbar))
471 panic("Failed to get xbar resources");
472 if (request_mem_region(res_xbar.start, resource_size(&res_xbar),
473 res_xbar.name) < 0)
474 panic("Failed to get xbar resources");
475
476 ltq_xbar_membase = ioremap_nocache(res_xbar.start,
477 resource_size(&res_xbar));
478 if (!ltq_xbar_membase)
479 panic("Failed to remap xbar resources");
480 }
481
331 /* make sure to unprotect the memory region where flash is located */ 482 /* make sure to unprotect the memory region where flash is located */
332 ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0); 483 ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0);
333 484
334 /* add our generic xway clocks */ 485 /* add our generic xway clocks */
335 clkdev_add_pmu("10000000.fpi", NULL, 0, PMU_FPI); 486 clkdev_add_pmu("10000000.fpi", NULL, 0, 0, PMU_FPI);
336 clkdev_add_pmu("1e100400.serial", NULL, 0, PMU_ASC0); 487 clkdev_add_pmu("1e100400.serial", NULL, 0, 0, PMU_ASC0);
337 clkdev_add_pmu("1e100a00.gptu", NULL, 0, PMU_GPT); 488 clkdev_add_pmu("1e100a00.gptu", NULL, 1, 0, PMU_GPT);
338 clkdev_add_pmu("1e100bb0.stp", NULL, 0, PMU_STP); 489 clkdev_add_pmu("1e100bb0.stp", NULL, 1, 0, PMU_STP);
339 clkdev_add_pmu("1e104100.dma", NULL, 0, PMU_DMA); 490 clkdev_add_pmu("1e104100.dma", NULL, 1, 0, PMU_DMA);
340 clkdev_add_pmu("1e100800.spi", NULL, 0, PMU_SPI); 491 clkdev_add_pmu("1e100800.spi", NULL, 1, 0, PMU_SPI);
341 clkdev_add_pmu("1e105300.ebu", NULL, 0, PMU_EBU); 492 clkdev_add_pmu("1e105300.ebu", NULL, 0, 0, PMU_EBU);
342 clkdev_add_clkout(); 493 clkdev_add_clkout();
343 494
344 /* add the soc dependent clocks */ 495 /* add the soc dependent clocks */
@@ -346,14 +497,30 @@ void __init ltq_soc_init(void)
346 ifccr = CGU_IFCCR_VR9; 497 ifccr = CGU_IFCCR_VR9;
347 pcicr = CGU_PCICR_VR9; 498 pcicr = CGU_PCICR_VR9;
348 } else { 499 } else {
349 clkdev_add_pmu("1e180000.etop", NULL, 0, PMU_PPE); 500 clkdev_add_pmu("1e180000.etop", NULL, 1, 0, PMU_PPE);
350 } 501 }
351 502
352 if (!of_machine_is_compatible("lantiq,ase")) { 503 if (!of_machine_is_compatible("lantiq,ase")) {
353 clkdev_add_pmu("1e100c00.serial", NULL, 0, PMU_ASC1); 504 clkdev_add_pmu("1e100c00.serial", NULL, 0, 0, PMU_ASC1);
354 clkdev_add_pci(); 505 clkdev_add_pci();
355 } 506 }
356 507
508 if (of_machine_is_compatible("lantiq,grx390") ||
509 of_machine_is_compatible("lantiq,ar10")) {
510 clkdev_add_pmu("1e101000.usb", "phy", 1, 2, PMU_ANALOG_USB0_P);
511 clkdev_add_pmu("1e106000.usb", "phy", 1, 2, PMU_ANALOG_USB1_P);
512 /* rc 0 */
513 clkdev_add_pmu("1d900000.pcie", "phy", 1, 2, PMU_ANALOG_PCIE0_P);
514 clkdev_add_pmu("1d900000.pcie", "msi", 1, 1, PMU1_PCIE_MSI);
515 clkdev_add_pmu("1d900000.pcie", "pdi", 1, 1, PMU1_PCIE_PDI);
516 clkdev_add_pmu("1d900000.pcie", "ctl", 1, 1, PMU1_PCIE_CTL);
517 /* rc 1 */
518 clkdev_add_pmu("19000000.pcie", "phy", 1, 2, PMU_ANALOG_PCIE1_P);
519 clkdev_add_pmu("19000000.pcie", "msi", 1, 1, PMU1_PCIE1_MSI);
520 clkdev_add_pmu("19000000.pcie", "pdi", 1, 1, PMU1_PCIE1_PDI);
521 clkdev_add_pmu("19000000.pcie", "ctl", 1, 1, PMU1_PCIE1_CTL);
522 }
523
357 if (of_machine_is_compatible("lantiq,ase")) { 524 if (of_machine_is_compatible("lantiq,ase")) {
358 if (ltq_cgu_r32(CGU_SYS) & (1 << 5)) 525 if (ltq_cgu_r32(CGU_SYS) & (1 << 5))
359 clkdev_add_static(CLOCK_266M, CLOCK_133M, 526 clkdev_add_static(CLOCK_266M, CLOCK_133M,
@@ -361,28 +528,84 @@ void __init ltq_soc_init(void)
361 else 528 else
362 clkdev_add_static(CLOCK_133M, CLOCK_133M, 529 clkdev_add_static(CLOCK_133M, CLOCK_133M,
363 CLOCK_133M, CLOCK_133M); 530 CLOCK_133M, CLOCK_133M);
364 clkdev_add_cgu("1e180000.etop", "ephycgu", CGU_EPHY), 531 clkdev_add_pmu("1e101000.usb", "ctl", 1, 0, PMU_USB0);
365 clkdev_add_pmu("1e180000.etop", "ephy", 0, PMU_EPHY); 532 clkdev_add_pmu("1e101000.usb", "phy", 1, 0, PMU_USB0_P);
533 clkdev_add_pmu("1e180000.etop", "ppe", 1, 0, PMU_PPE);
534 clkdev_add_cgu("1e180000.etop", "ephycgu", CGU_EPHY);
535 clkdev_add_pmu("1e180000.etop", "ephy", 1, 0, PMU_EPHY);
536 clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_ASE_SDIO);
537 clkdev_add_pmu("1e116000.mei", "dfe", 1, 0, PMU_DFE);
538 } else if (of_machine_is_compatible("lantiq,grx390")) {
539 clkdev_add_static(ltq_grx390_cpu_hz(), ltq_grx390_fpi_hz(),
540 ltq_grx390_fpi_hz(), ltq_grx390_pp32_hz());
541 clkdev_add_pmu("1e101000.usb", "ctl", 1, 0, PMU_USB0);
542 clkdev_add_pmu("1e106000.usb", "ctl", 1, 0, PMU_USB1);
543 /* rc 2 */
544 clkdev_add_pmu("1a800000.pcie", "phy", 1, 2, PMU_ANALOG_PCIE2_P);
545 clkdev_add_pmu("1a800000.pcie", "msi", 1, 1, PMU1_PCIE2_MSI);
546 clkdev_add_pmu("1a800000.pcie", "pdi", 1, 1, PMU1_PCIE2_PDI);
547 clkdev_add_pmu("1a800000.pcie", "ctl", 1, 1, PMU1_PCIE2_CTL);
548 clkdev_add_pmu("1e108000.eth", NULL, 1, 0, PMU_SWITCH | PMU_PPE_DP);
549 clkdev_add_pmu("1da00000.usif", "NULL", 1, 0, PMU_USIF);
550 clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU);
551 } else if (of_machine_is_compatible("lantiq,ar10")) {
552 clkdev_add_static(ltq_ar10_cpu_hz(), ltq_ar10_fpi_hz(),
553 ltq_ar10_fpi_hz(), ltq_ar10_pp32_hz());
554 clkdev_add_pmu("1e101000.usb", "ctl", 1, 0, PMU_USB0);
555 clkdev_add_pmu("1e106000.usb", "ctl", 1, 0, PMU_USB1);
556 clkdev_add_pmu("1e108000.eth", NULL, 1, 0, PMU_SWITCH |
557 PMU_PPE_DP | PMU_PPE_TC);
558 clkdev_add_pmu("1da00000.usif", "NULL", 1, 0, PMU_USIF);
559 clkdev_add_pmu("1f203000.rcu", "gphy", 1, 0, PMU_GPHY);
560 clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU);
561 clkdev_add_pmu("1e116000.mei", "afe", 1, 2, PMU_ANALOG_DSL_AFE);
562 clkdev_add_pmu("1e116000.mei", "dfe", 1, 0, PMU_DFE);
366 } else if (of_machine_is_compatible("lantiq,vr9")) { 563 } else if (of_machine_is_compatible("lantiq,vr9")) {
367 clkdev_add_static(ltq_vr9_cpu_hz(), ltq_vr9_fpi_hz(), 564 clkdev_add_static(ltq_vr9_cpu_hz(), ltq_vr9_fpi_hz(),
368 ltq_vr9_fpi_hz(), ltq_vr9_pp32_hz()); 565 ltq_vr9_fpi_hz(), ltq_vr9_pp32_hz());
369 clkdev_add_pmu("1d900000.pcie", "phy", 1, PMU1_PCIE_PHY); 566 clkdev_add_pmu("1e101000.usb", "phy", 1, 0, PMU_USB0_P);
370 clkdev_add_pmu("1d900000.pcie", "bus", 0, PMU_PCIE_CLK); 567 clkdev_add_pmu("1e101000.usb", "ctl", 1, 0, PMU_USB0 | PMU_AHBM);
371 clkdev_add_pmu("1d900000.pcie", "msi", 1, PMU1_PCIE_MSI); 568 clkdev_add_pmu("1e106000.usb", "phy", 1, 0, PMU_USB1_P);
372 clkdev_add_pmu("1d900000.pcie", "pdi", 1, PMU1_PCIE_PDI); 569 clkdev_add_pmu("1e106000.usb", "ctl", 1, 0, PMU_USB1 | PMU_AHBM);
373 clkdev_add_pmu("1d900000.pcie", "ctl", 1, PMU1_PCIE_CTL); 570 clkdev_add_pmu("1d900000.pcie", "phy", 1, 1, PMU1_PCIE_PHY);
374 clkdev_add_pmu("1d900000.pcie", "ahb", 0, PMU_AHBM | PMU_AHBS); 571 clkdev_add_pmu("1d900000.pcie", "bus", 1, 0, PMU_PCIE_CLK);
375 clkdev_add_pmu("1e108000.eth", NULL, 0, 572 clkdev_add_pmu("1d900000.pcie", "msi", 1, 1, PMU1_PCIE_MSI);
573 clkdev_add_pmu("1d900000.pcie", "pdi", 1, 1, PMU1_PCIE_PDI);
574 clkdev_add_pmu("1d900000.pcie", "ctl", 1, 1, PMU1_PCIE_CTL);
575 clkdev_add_pmu(NULL, "ahb", 1, 0, PMU_AHBM | PMU_AHBS);
576
577 clkdev_add_pmu("1da00000.usif", "NULL", 1, 0, PMU_USIF);
578 clkdev_add_pmu("1e108000.eth", NULL, 1, 0,
376 PMU_SWITCH | PMU_PPE_DPLUS | PMU_PPE_DPLUM | 579 PMU_SWITCH | PMU_PPE_DPLUS | PMU_PPE_DPLUM |
377 PMU_PPE_EMA | PMU_PPE_TC | PMU_PPE_SLL01 | 580 PMU_PPE_EMA | PMU_PPE_TC | PMU_PPE_SLL01 |
378 PMU_PPE_QSB | PMU_PPE_TOP); 581 PMU_PPE_QSB | PMU_PPE_TOP);
379 clkdev_add_pmu("1f203000.rcu", "gphy", 0, PMU_GPHY); 582 clkdev_add_pmu("1f203000.rcu", "gphy", 1, 0, PMU_GPHY);
583 clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO);
584 clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU);
585 clkdev_add_pmu("1e116000.mei", "dfe", 1, 0, PMU_DFE);
380 } else if (of_machine_is_compatible("lantiq,ar9")) { 586 } else if (of_machine_is_compatible("lantiq,ar9")) {
381 clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(), 587 clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(),
382 ltq_ar9_fpi_hz(), CLOCK_250M); 588 ltq_ar9_fpi_hz(), CLOCK_250M);
383 clkdev_add_pmu("1e180000.etop", "switch", 0, PMU_SWITCH); 589 clkdev_add_pmu("1e101000.usb", "ctl", 1, 0, PMU_USB0);
590 clkdev_add_pmu("1e101000.usb", "phy", 1, 0, PMU_USB0_P);
591 clkdev_add_pmu("1e106000.usb", "ctl", 1, 0, PMU_USB1);
592 clkdev_add_pmu("1e106000.usb", "phy", 1, 0, PMU_USB1_P);
593 clkdev_add_pmu("1e180000.etop", "switch", 1, 0, PMU_SWITCH);
594 clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO);
595 clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU);
596 clkdev_add_pmu("1e116000.mei", "dfe", 1, 0, PMU_DFE);
597 clkdev_add_pmu("1e100400.serial", NULL, 1, 0, PMU_ASC0);
384 } else { 598 } else {
385 clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(), 599 clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(),
386 ltq_danube_fpi_hz(), ltq_danube_pp32_hz()); 600 ltq_danube_fpi_hz(), ltq_danube_pp32_hz());
601 clkdev_add_pmu("1e101000.usb", "ctl", 1, 0, PMU_USB0);
602 clkdev_add_pmu("1e101000.usb", "phy", 1, 0, PMU_USB0_P);
603 clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO);
604 clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU);
605 clkdev_add_pmu("1e116000.mei", "dfe", 1, 0, PMU_DFE);
606 clkdev_add_pmu("1e100400.serial", NULL, 1, 0, PMU_ASC0);
387 } 607 }
608
609 if (of_machine_is_compatible("lantiq,vr9"))
610 xbar_fpi_burst_disable();
388} 611}
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 1e9e900cd3c3..0344e575f522 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o
15obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o 15obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o
16 16
17# libgcc-style stuff needed in the kernel 17# libgcc-style stuff needed in the kernel
18obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o 18obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o
diff --git a/arch/mips/lib/bswapdi.c b/arch/mips/lib/bswapdi.c
new file mode 100644
index 000000000000..77e5f9c1f005
--- /dev/null
+++ b/arch/mips/lib/bswapdi.c
@@ -0,0 +1,15 @@
1#include <linux/module.h>
2
3unsigned long long __bswapdi2(unsigned long long u)
4{
5 return (((u) & 0xff00000000000000ull) >> 56) |
6 (((u) & 0x00ff000000000000ull) >> 40) |
7 (((u) & 0x0000ff0000000000ull) >> 24) |
8 (((u) & 0x000000ff00000000ull) >> 8) |
9 (((u) & 0x00000000ff000000ull) << 8) |
10 (((u) & 0x0000000000ff0000ull) << 24) |
11 (((u) & 0x000000000000ff00ull) << 40) |
12 (((u) & 0x00000000000000ffull) << 56);
13}
14
15EXPORT_SYMBOL(__bswapdi2);
diff --git a/arch/mips/lib/bswapsi.c b/arch/mips/lib/bswapsi.c
new file mode 100644
index 000000000000..2b302ff121d2
--- /dev/null
+++ b/arch/mips/lib/bswapsi.c
@@ -0,0 +1,11 @@
1#include <linux/module.h>
2
3unsigned int __bswapsi2(unsigned int u)
4{
5 return (((u) & 0xff000000) >> 24) |
6 (((u) & 0x00ff0000) >> 8) |
7 (((u) & 0x0000ff00) << 8) |
8 (((u) & 0x000000ff) << 24);
9}
10
11EXPORT_SYMBOL(__bswapsi2);
diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig
index 497912b38d8e..8e6e292675b2 100644
--- a/arch/mips/loongson64/Kconfig
+++ b/arch/mips/loongson64/Kconfig
@@ -120,11 +120,6 @@ config RS780_HPET
120 120
121 If unsure, say Yes. 121 If unsure, say Yes.
122 122
123config LOONGSON_SUSPEND
124 bool
125 default y
126 depends on CPU_SUPPORTS_CPUFREQ && SUSPEND
127
128config LOONGSON_UART_BASE 123config LOONGSON_UART_BASE
129 bool 124 bool
130 default y 125 default y
diff --git a/arch/mips/loongson64/common/Makefile b/arch/mips/loongson64/common/Makefile
index f2e8153e44f5..074d9cb15cd2 100644
--- a/arch/mips/loongson64/common/Makefile
+++ b/arch/mips/loongson64/common/Makefile
@@ -23,7 +23,7 @@ obj-$(CONFIG_CS5536) += cs5536/
23# Suspend Support 23# Suspend Support
24# 24#
25 25
26obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o 26obj-$(CONFIG_SUSPEND) += pm.o
27 27
28# 28#
29# Big Memory (SWIOTLB) Support 29# Big Memory (SWIOTLB) Support
diff --git a/arch/mips/loongson64/lemote-2f/Makefile b/arch/mips/loongson64/lemote-2f/Makefile
index 4f9eaa328a16..08b8abcbfef5 100644
--- a/arch/mips/loongson64/lemote-2f/Makefile
+++ b/arch/mips/loongson64/lemote-2f/Makefile
@@ -8,4 +8,4 @@ obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o
8# Suspend Support 8# Suspend Support
9# 9#
10 10
11obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o 11obj-$(CONFIG_SUSPEND) += pm.o
diff --git a/arch/mips/math-emu/me-debugfs.c b/arch/mips/math-emu/me-debugfs.c
index 506a67a98cdf..be650ed7db59 100644
--- a/arch/mips/math-emu/me-debugfs.c
+++ b/arch/mips/math-emu/me-debugfs.c
@@ -4,6 +4,7 @@
4#include <linux/init.h> 4#include <linux/init.h>
5#include <linux/percpu.h> 5#include <linux/percpu.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <asm/debug.h>
7#include <asm/fpu_emulator.h> 8#include <asm/fpu_emulator.h>
8#include <asm/local.h> 9#include <asm/local.h>
9 10
@@ -27,7 +28,6 @@ static int fpuemu_stat_get(void *data, u64 *val)
27} 28}
28DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n"); 29DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
29 30
30extern struct dentry *mips_debugfs_dir;
31static int __init debugfs_fpuemu(void) 31static int __init debugfs_fpuemu(void)
32{ 32{
33 struct dentry *d, *dir; 33 struct dentry *d, *dir;
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 67ede4ef9b8d..b4c64bd3f723 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_IP22_CPU_SCACHE) += sc-ip22.o
28obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o 28obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o
29obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o 29obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o
30obj-$(CONFIG_MIPS_CPU_SCACHE) += sc-mips.o 30obj-$(CONFIG_MIPS_CPU_SCACHE) += sc-mips.o
31obj-$(CONFIG_SCACHE_DEBUGFS) += sc-debugfs.o
diff --git a/arch/mips/mm/sc-debugfs.c b/arch/mips/mm/sc-debugfs.c
new file mode 100644
index 000000000000..5eefe3281b24
--- /dev/null
+++ b/arch/mips/mm/sc-debugfs.c
@@ -0,0 +1,81 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Paul Burton <paul.burton@imgtec.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 <asm/bcache.h>
12#include <asm/debug.h>
13#include <asm/uaccess.h>
14#include <linux/debugfs.h>
15#include <linux/init.h>
16
17static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
18 size_t count, loff_t *ppos)
19{
20 bool enabled = bc_prefetch_is_enabled();
21 char buf[3];
22
23 buf[0] = enabled ? 'Y' : 'N';
24 buf[1] = '\n';
25 buf[2] = 0;
26
27 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
28}
29
30static ssize_t sc_prefetch_write(struct file *file,
31 const char __user *user_buf,
32 size_t count, loff_t *ppos)
33{
34 char buf[32];
35 ssize_t buf_size;
36 bool enabled;
37 int err;
38
39 buf_size = min(count, sizeof(buf) - 1);
40 if (copy_from_user(buf, user_buf, buf_size))
41 return -EFAULT;
42
43 buf[buf_size] = '\0';
44 err = strtobool(buf, &enabled);
45 if (err)
46 return err;
47
48 if (enabled)
49 bc_prefetch_enable();
50 else
51 bc_prefetch_disable();
52
53 return count;
54}
55
56static const struct file_operations sc_prefetch_fops = {
57 .open = simple_open,
58 .llseek = default_llseek,
59 .read = sc_prefetch_read,
60 .write = sc_prefetch_write,
61};
62
63static int __init sc_debugfs_init(void)
64{
65 struct dentry *dir, *file;
66
67 if (!mips_debugfs_dir)
68 return -ENODEV;
69
70 dir = debugfs_create_dir("l2cache", mips_debugfs_dir);
71 if (IS_ERR(dir))
72 return PTR_ERR(dir);
73
74 file = debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir,
75 NULL, &sc_prefetch_fops);
76 if (IS_ERR(file))
77 return PTR_ERR(file);
78
79 return 0;
80}
81late_initcall(sc_debugfs_init);
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index 53ea8391f9bb..3bd0597d9c3d 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -51,11 +51,69 @@ static void mips_sc_disable(void)
51 /* L2 cache is permanently enabled */ 51 /* L2 cache is permanently enabled */
52} 52}
53 53
54static void mips_sc_prefetch_enable(void)
55{
56 unsigned long pftctl;
57
58 if (mips_cm_revision() < CM_REV_CM2_5)
59 return;
60
61 /*
62 * If there is one or more L2 prefetch unit present then enable
63 * prefetching for both code & data, for all ports.
64 */
65 pftctl = read_gcr_l2_pft_control();
66 if (pftctl & CM_GCR_L2_PFT_CONTROL_NPFT_MSK) {
67 pftctl &= ~CM_GCR_L2_PFT_CONTROL_PAGEMASK_MSK;
68 pftctl |= PAGE_MASK & CM_GCR_L2_PFT_CONTROL_PAGEMASK_MSK;
69 pftctl |= CM_GCR_L2_PFT_CONTROL_PFTEN_MSK;
70 write_gcr_l2_pft_control(pftctl);
71
72 pftctl = read_gcr_l2_pft_control_b();
73 pftctl |= CM_GCR_L2_PFT_CONTROL_B_PORTID_MSK;
74 pftctl |= CM_GCR_L2_PFT_CONTROL_B_CEN_MSK;
75 write_gcr_l2_pft_control_b(pftctl);
76 }
77}
78
79static void mips_sc_prefetch_disable(void)
80{
81 unsigned long pftctl;
82
83 if (mips_cm_revision() < CM_REV_CM2_5)
84 return;
85
86 pftctl = read_gcr_l2_pft_control();
87 pftctl &= ~CM_GCR_L2_PFT_CONTROL_PFTEN_MSK;
88 write_gcr_l2_pft_control(pftctl);
89
90 pftctl = read_gcr_l2_pft_control_b();
91 pftctl &= ~CM_GCR_L2_PFT_CONTROL_B_PORTID_MSK;
92 pftctl &= ~CM_GCR_L2_PFT_CONTROL_B_CEN_MSK;
93 write_gcr_l2_pft_control_b(pftctl);
94}
95
96static bool mips_sc_prefetch_is_enabled(void)
97{
98 unsigned long pftctl;
99
100 if (mips_cm_revision() < CM_REV_CM2_5)
101 return false;
102
103 pftctl = read_gcr_l2_pft_control();
104 if (!(pftctl & CM_GCR_L2_PFT_CONTROL_NPFT_MSK))
105 return false;
106 return !!(pftctl & CM_GCR_L2_PFT_CONTROL_PFTEN_MSK);
107}
108
54static struct bcache_ops mips_sc_ops = { 109static struct bcache_ops mips_sc_ops = {
55 .bc_enable = mips_sc_enable, 110 .bc_enable = mips_sc_enable,
56 .bc_disable = mips_sc_disable, 111 .bc_disable = mips_sc_disable,
57 .bc_wback_inv = mips_sc_wback_inv, 112 .bc_wback_inv = mips_sc_wback_inv,
58 .bc_inv = mips_sc_inv 113 .bc_inv = mips_sc_inv,
114 .bc_prefetch_enable = mips_sc_prefetch_enable,
115 .bc_prefetch_disable = mips_sc_prefetch_disable,
116 .bc_prefetch_is_enabled = mips_sc_prefetch_is_enabled,
59}; 117};
60 118
61/* 119/*
@@ -162,13 +220,13 @@ static inline int __init mips_sc_probe(void)
162 return 0; 220 return 0;
163 221
164 tmp = (config2 >> 8) & 0x0f; 222 tmp = (config2 >> 8) & 0x0f;
165 if (0 <= tmp && tmp <= 7) 223 if (tmp <= 7)
166 c->scache.sets = 64 << tmp; 224 c->scache.sets = 64 << tmp;
167 else 225 else
168 return 0; 226 return 0;
169 227
170 tmp = (config2 >> 0) & 0x0f; 228 tmp = (config2 >> 0) & 0x0f;
171 if (0 <= tmp && tmp <= 7) 229 if (tmp <= 7)
172 c->scache.ways = tmp + 1; 230 c->scache.ways = tmp + 1;
173 else 231 else
174 return 0; 232 return 0;
@@ -186,6 +244,7 @@ int mips_sc_init(void)
186 int found = mips_sc_probe(); 244 int found = mips_sc_probe();
187 if (found) { 245 if (found) {
188 mips_sc_enable(); 246 mips_sc_enable();
247 mips_sc_prefetch_enable();
189 bcops = &mips_sc_ops; 248 bcops = &mips_sc_ops;
190 } 249 }
191 return found; 250 return found;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 323d1d302f2b..32e0be27673f 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -311,6 +311,7 @@ static struct uasm_label labels[128];
311static struct uasm_reloc relocs[128]; 311static struct uasm_reloc relocs[128];
312 312
313static int check_for_high_segbits; 313static int check_for_high_segbits;
314static bool fill_includes_sw_bits;
314 315
315static unsigned int kscratch_used_mask; 316static unsigned int kscratch_used_mask;
316 317
@@ -630,8 +631,14 @@ static void build_tlb_write_entry(u32 **p, struct uasm_label **l,
630static __maybe_unused void build_convert_pte_to_entrylo(u32 **p, 631static __maybe_unused void build_convert_pte_to_entrylo(u32 **p,
631 unsigned int reg) 632 unsigned int reg)
632{ 633{
633 if (cpu_has_rixi) { 634 if (cpu_has_rixi && _PAGE_NO_EXEC) {
634 UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL)); 635 if (fill_includes_sw_bits) {
636 UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL));
637 } else {
638 UASM_i_SRL(p, reg, reg, ilog2(_PAGE_NO_EXEC));
639 UASM_i_ROTR(p, reg, reg,
640 ilog2(_PAGE_GLOBAL) - ilog2(_PAGE_NO_EXEC));
641 }
635 } else { 642 } else {
636#ifdef CONFIG_PHYS_ADDR_T_64BIT 643#ifdef CONFIG_PHYS_ADDR_T_64BIT
637 uasm_i_dsrl_safe(p, reg, reg, ilog2(_PAGE_GLOBAL)); 644 uasm_i_dsrl_safe(p, reg, reg, ilog2(_PAGE_GLOBAL));
@@ -1005,21 +1012,7 @@ static void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep)
1005 * 64bit address support (36bit on a 32bit CPU) in a 32bit 1012 * 64bit address support (36bit on a 32bit CPU) in a 32bit
1006 * Kernel is a special case. Only a few CPUs use it. 1013 * Kernel is a special case. Only a few CPUs use it.
1007 */ 1014 */
1008#ifdef CONFIG_PHYS_ADDR_T_64BIT 1015 if (config_enabled(CONFIG_PHYS_ADDR_T_64BIT) && !cpu_has_64bits) {
1009 if (cpu_has_64bits) {
1010 uasm_i_ld(p, tmp, 0, ptep); /* get even pte */
1011 uasm_i_ld(p, ptep, sizeof(pte_t), ptep); /* get odd pte */
1012 if (cpu_has_rixi) {
1013 UASM_i_ROTR(p, tmp, tmp, ilog2(_PAGE_GLOBAL));
1014 UASM_i_MTC0(p, tmp, C0_ENTRYLO0); /* load it */
1015 UASM_i_ROTR(p, ptep, ptep, ilog2(_PAGE_GLOBAL));
1016 } else {
1017 uasm_i_dsrl_safe(p, tmp, tmp, ilog2(_PAGE_GLOBAL)); /* convert to entrylo0 */
1018 UASM_i_MTC0(p, tmp, C0_ENTRYLO0); /* load it */
1019 uasm_i_dsrl_safe(p, ptep, ptep, ilog2(_PAGE_GLOBAL)); /* convert to entrylo1 */
1020 }
1021 UASM_i_MTC0(p, ptep, C0_ENTRYLO1); /* load it */
1022 } else {
1023 int pte_off_even = sizeof(pte_t) / 2; 1016 int pte_off_even = sizeof(pte_t) / 2;
1024 int pte_off_odd = pte_off_even + sizeof(pte_t); 1017 int pte_off_odd = pte_off_even + sizeof(pte_t);
1025#ifdef CONFIG_XPA 1018#ifdef CONFIG_XPA
@@ -1043,31 +1036,23 @@ static void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep)
1043 uasm_i_mthc0(p, tmp, C0_ENTRYLO0); 1036 uasm_i_mthc0(p, tmp, C0_ENTRYLO0);
1044 uasm_i_mthc0(p, ptep, C0_ENTRYLO1); 1037 uasm_i_mthc0(p, ptep, C0_ENTRYLO1);
1045#endif 1038#endif
1039 return;
1046 } 1040 }
1047#else 1041
1048 UASM_i_LW(p, tmp, 0, ptep); /* get even pte */ 1042 UASM_i_LW(p, tmp, 0, ptep); /* get even pte */
1049 UASM_i_LW(p, ptep, sizeof(pte_t), ptep); /* get odd pte */ 1043 UASM_i_LW(p, ptep, sizeof(pte_t), ptep); /* get odd pte */
1050 if (r45k_bvahwbug()) 1044 if (r45k_bvahwbug())
1051 build_tlb_probe_entry(p); 1045 build_tlb_probe_entry(p);
1052 if (cpu_has_rixi) { 1046 build_convert_pte_to_entrylo(p, tmp);
1053 UASM_i_ROTR(p, tmp, tmp, ilog2(_PAGE_GLOBAL)); 1047 if (r4k_250MHZhwbug())
1054 if (r4k_250MHZhwbug()) 1048 UASM_i_MTC0(p, 0, C0_ENTRYLO0);
1055 UASM_i_MTC0(p, 0, C0_ENTRYLO0); 1049 UASM_i_MTC0(p, tmp, C0_ENTRYLO0); /* load it */
1056 UASM_i_MTC0(p, tmp, C0_ENTRYLO0); /* load it */ 1050 build_convert_pte_to_entrylo(p, ptep);
1057 UASM_i_ROTR(p, ptep, ptep, ilog2(_PAGE_GLOBAL)); 1051 if (r45k_bvahwbug())
1058 } else { 1052 uasm_i_mfc0(p, tmp, C0_INDEX);
1059 UASM_i_SRL(p, tmp, tmp, ilog2(_PAGE_GLOBAL)); /* convert to entrylo0 */
1060 if (r4k_250MHZhwbug())
1061 UASM_i_MTC0(p, 0, C0_ENTRYLO0);
1062 UASM_i_MTC0(p, tmp, C0_ENTRYLO0); /* load it */
1063 UASM_i_SRL(p, ptep, ptep, ilog2(_PAGE_GLOBAL)); /* convert to entrylo1 */
1064 if (r45k_bvahwbug())
1065 uasm_i_mfc0(p, tmp, C0_INDEX);
1066 }
1067 if (r4k_250MHZhwbug()) 1053 if (r4k_250MHZhwbug())
1068 UASM_i_MTC0(p, 0, C0_ENTRYLO1); 1054 UASM_i_MTC0(p, 0, C0_ENTRYLO1);
1069 UASM_i_MTC0(p, ptep, C0_ENTRYLO1); /* load it */ 1055 UASM_i_MTC0(p, ptep, C0_ENTRYLO1); /* load it */
1070#endif
1071} 1056}
1072 1057
1073struct mips_huge_tlb_info { 1058struct mips_huge_tlb_info {
@@ -2299,6 +2284,10 @@ static void config_htw_params(void)
2299 /* re-initialize the PTI field including the even/odd bit */ 2284 /* re-initialize the PTI field including the even/odd bit */
2300 pwfield &= ~MIPS_PWFIELD_PTI_MASK; 2285 pwfield &= ~MIPS_PWFIELD_PTI_MASK;
2301 pwfield |= PAGE_SHIFT << MIPS_PWFIELD_PTI_SHIFT; 2286 pwfield |= PAGE_SHIFT << MIPS_PWFIELD_PTI_SHIFT;
2287 if (CONFIG_PGTABLE_LEVELS >= 3) {
2288 pwfield &= ~MIPS_PWFIELD_MDI_MASK;
2289 pwfield |= PMD_SHIFT << MIPS_PWFIELD_MDI_SHIFT;
2290 }
2302 /* Set the PTEI right shift */ 2291 /* Set the PTEI right shift */
2303 ptei = _PAGE_GLOBAL_SHIFT << MIPS_PWFIELD_PTEI_SHIFT; 2292 ptei = _PAGE_GLOBAL_SHIFT << MIPS_PWFIELD_PTEI_SHIFT;
2304 pwfield |= ptei; 2293 pwfield |= ptei;
@@ -2320,9 +2309,11 @@ static void config_htw_params(void)
2320 2309
2321 pwsize = ilog2(PTRS_PER_PGD) << MIPS_PWSIZE_GDW_SHIFT; 2310 pwsize = ilog2(PTRS_PER_PGD) << MIPS_PWSIZE_GDW_SHIFT;
2322 pwsize |= ilog2(PTRS_PER_PTE) << MIPS_PWSIZE_PTW_SHIFT; 2311 pwsize |= ilog2(PTRS_PER_PTE) << MIPS_PWSIZE_PTW_SHIFT;
2312 if (CONFIG_PGTABLE_LEVELS >= 3)
2313 pwsize |= ilog2(PTRS_PER_PMD) << MIPS_PWSIZE_MDW_SHIFT;
2323 2314
2324 /* If XPA has been enabled, PTEs are 64-bit in size. */ 2315 /* If XPA has been enabled, PTEs are 64-bit in size. */
2325 if (read_c0_pagegrain() & PG_ELPA) 2316 if (config_enabled(CONFIG_64BITS) || (read_c0_pagegrain() & PG_ELPA))
2326 pwsize |= 1; 2317 pwsize |= 1;
2327 2318
2328 write_c0_pwsize(pwsize); 2319 write_c0_pwsize(pwsize);
@@ -2360,6 +2351,41 @@ static void config_xpa_params(void)
2360#endif 2351#endif
2361} 2352}
2362 2353
2354static void check_pabits(void)
2355{
2356 unsigned long entry;
2357 unsigned pabits, fillbits;
2358
2359 if (!cpu_has_rixi || !_PAGE_NO_EXEC) {
2360 /*
2361 * We'll only be making use of the fact that we can rotate bits
2362 * into the fill if the CPU supports RIXI, so don't bother
2363 * probing this for CPUs which don't.
2364 */
2365 return;
2366 }
2367
2368 write_c0_entrylo0(~0ul);
2369 back_to_back_c0_hazard();
2370 entry = read_c0_entrylo0();
2371
2372 /* clear all non-PFN bits */
2373 entry &= ~((1 << MIPS_ENTRYLO_PFN_SHIFT) - 1);
2374 entry &= ~(MIPS_ENTRYLO_RI | MIPS_ENTRYLO_XI);
2375
2376 /* find a lower bound on PABITS, and upper bound on fill bits */
2377 pabits = fls_long(entry) + 6;
2378 fillbits = max_t(int, (int)BITS_PER_LONG - pabits, 0);
2379
2380 /* minus the RI & XI bits */
2381 fillbits -= min_t(unsigned, fillbits, 2);
2382
2383 if (fillbits >= ilog2(_PAGE_NO_EXEC))
2384 fill_includes_sw_bits = true;
2385
2386 pr_debug("Entry* registers contain %u fill bits\n", fillbits);
2387}
2388
2363void build_tlb_refill_handler(void) 2389void build_tlb_refill_handler(void)
2364{ 2390{
2365 /* 2391 /*
@@ -2370,6 +2396,7 @@ void build_tlb_refill_handler(void)
2370 static int run_once = 0; 2396 static int run_once = 0;
2371 2397
2372 output_pgtable_bits_defines(); 2398 output_pgtable_bits_defines();
2399 check_pabits();
2373 2400
2374#ifdef CONFIG_64BIT 2401#ifdef CONFIG_64BIT
2375 check_for_high_segbits = current_cpu_data.vmbits > (PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3); 2402 check_for_high_segbits = current_cpu_data.vmbits > (PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3);
diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
index ea35587a5c29..5827af77c18e 100644
--- a/arch/mips/mti-malta/Makefile
+++ b/arch/mips/mti-malta/Makefile
@@ -5,9 +5,18 @@
5# Copyright (C) 2008 Wind River Systems, Inc. 5# Copyright (C) 2008 Wind River Systems, Inc.
6# written by Ralf Baechle <ralf@linux-mips.org> 6# written by Ralf Baechle <ralf@linux-mips.org>
7# 7#
8obj-y := malta-display.o malta-dt.o malta-init.o \ 8obj-y += malta-display.o
9 malta-int.o malta-memory.o malta-platform.o \ 9obj-y += malta-dt.o
10 malta-reset.o malta-setup.o malta-time.o 10obj-y += malta-dtshim.o
11obj-y += malta-init.o
12obj-y += malta-int.o
13obj-y += malta-memory.o
14obj-y += malta-platform.o
15obj-y += malta-reset.o
16obj-y += malta-setup.o
17obj-y += malta-time.o
11 18
12obj-$(CONFIG_MIPS_CMP) += malta-amon.o 19obj-$(CONFIG_MIPS_CMP) += malta-amon.o
13obj-$(CONFIG_MIPS_MALTA_PM) += malta-pm.o 20obj-$(CONFIG_MIPS_MALTA_PM) += malta-pm.o
21
22CFLAGS_malta-dtshim.o = -I$(src)/../../../scripts/dtc/libfdt
diff --git a/arch/mips/mti-malta/malta-dtshim.c b/arch/mips/mti-malta/malta-dtshim.c
new file mode 100644
index 000000000000..f7133efc5843
--- /dev/null
+++ b/arch/mips/mti-malta/malta-dtshim.c
@@ -0,0 +1,162 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Paul Burton <paul.burton@imgtec.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/bug.h>
12#include <linux/kernel.h>
13#include <linux/libfdt.h>
14#include <linux/of_fdt.h>
15#include <linux/sizes.h>
16#include <asm/bootinfo.h>
17#include <asm/fw/fw.h>
18#include <asm/page.h>
19
20static unsigned char fdt_buf[16 << 10] __initdata;
21
22/* determined physical memory size, not overridden by command line args */
23extern unsigned long physical_memsize;
24
25#define MAX_MEM_ARRAY_ENTRIES 1
26
27static unsigned __init gen_fdt_mem_array(__be32 *mem_array, unsigned long size)
28{
29 unsigned long size_preio;
30 unsigned entries;
31
32 entries = 1;
33 mem_array[0] = cpu_to_be32(PHYS_OFFSET);
34 if (config_enabled(CONFIG_EVA)) {
35 /*
36 * The current Malta EVA configuration is "special" in that it
37 * always makes use of addresses in the upper half of the 32 bit
38 * physical address map, which gives it a contiguous region of
39 * DDR but limits it to 2GB.
40 */
41 mem_array[1] = cpu_to_be32(size);
42 } else {
43 size_preio = min_t(unsigned long, size, SZ_256M);
44 mem_array[1] = cpu_to_be32(size_preio);
45 }
46
47 BUG_ON(entries > MAX_MEM_ARRAY_ENTRIES);
48 return entries;
49}
50
51static void __init append_memory(void *fdt, int root_off)
52{
53 __be32 mem_array[2 * MAX_MEM_ARRAY_ENTRIES];
54 unsigned long memsize;
55 unsigned mem_entries;
56 int i, err, mem_off;
57 char *var, param_name[10], *var_names[] = {
58 "ememsize", "memsize",
59 };
60
61 /* if a memory node already exists, leave it alone */
62 mem_off = fdt_path_offset(fdt, "/memory");
63 if (mem_off >= 0)
64 return;
65
66 /* find memory size from the bootloader environment */
67 for (i = 0; i < ARRAY_SIZE(var_names); i++) {
68 var = fw_getenv(var_names[i]);
69 if (!var)
70 continue;
71
72 err = kstrtoul(var, 0, &physical_memsize);
73 if (!err)
74 break;
75
76 pr_warn("Failed to read the '%s' env variable '%s'\n",
77 var_names[i], var);
78 }
79
80 if (!physical_memsize) {
81 pr_warn("The bootloader didn't provide memsize: defaulting to 32MB\n");
82 physical_memsize = 32 << 20;
83 }
84
85 if (config_enabled(CONFIG_CPU_BIG_ENDIAN)) {
86 /*
87 * SOC-it swaps, or perhaps doesn't swap, when DMA'ing
88 * the last word of physical memory.
89 */
90 physical_memsize -= PAGE_SIZE;
91 }
92
93 /* default to using all available RAM */
94 memsize = physical_memsize;
95
96 /* allow the user to override the usable memory */
97 for (i = 0; i < ARRAY_SIZE(var_names); i++) {
98 snprintf(param_name, sizeof(param_name), "%s=", var_names[i]);
99 var = strstr(arcs_cmdline, param_name);
100 if (!var)
101 continue;
102
103 memsize = memparse(var + strlen(param_name), NULL);
104 }
105
106 /* if the user says there's more RAM than we thought, believe them */
107 physical_memsize = max_t(unsigned long, physical_memsize, memsize);
108
109 /* append memory to the DT */
110 mem_off = fdt_add_subnode(fdt, root_off, "memory");
111 if (mem_off < 0)
112 panic("Unable to add memory node to DT: %d", mem_off);
113
114 err = fdt_setprop_string(fdt, mem_off, "device_type", "memory");
115 if (err)
116 panic("Unable to set memory node device_type: %d", err);
117
118 mem_entries = gen_fdt_mem_array(mem_array, physical_memsize);
119 err = fdt_setprop(fdt, mem_off, "reg", mem_array,
120 mem_entries * 2 * sizeof(mem_array[0]));
121 if (err)
122 panic("Unable to set memory regs property: %d", err);
123
124 mem_entries = gen_fdt_mem_array(mem_array, memsize);
125 err = fdt_setprop(fdt, mem_off, "linux,usable-memory", mem_array,
126 mem_entries * 2 * sizeof(mem_array[0]));
127 if (err)
128 panic("Unable to set linux,usable-memory property: %d", err);
129}
130
131void __init *malta_dt_shim(void *fdt)
132{
133 int root_off, len, err;
134 const char *compat;
135
136 if (fdt_check_header(fdt))
137 panic("Corrupt DT");
138
139 err = fdt_open_into(fdt, fdt_buf, sizeof(fdt_buf));
140 if (err)
141 panic("Unable to open FDT: %d", err);
142
143 root_off = fdt_path_offset(fdt_buf, "/");
144 if (root_off < 0)
145 panic("No / node in DT");
146
147 compat = fdt_getprop(fdt_buf, root_off, "compatible", &len);
148 if (!compat)
149 panic("No root compatible property in DT: %d", len);
150
151 /* if this isn't Malta, leave the DT alone */
152 if (strncmp(compat, "mti,malta", len))
153 return fdt;
154
155 append_memory(fdt_buf, root_off);
156
157 err = fdt_pack(fdt_buf);
158 if (err)
159 panic("Unable to pack FDT: %d\n", err);
160
161 return fdt_buf;
162}
diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c
index 53c24784a2f7..571148c5fd0b 100644
--- a/arch/mips/mti-malta/malta-init.c
+++ b/arch/mips/mti-malta/malta-init.c
@@ -302,6 +302,7 @@ mips_pci_controller:
302 return; 302 return;
303 if (!register_vsmp_smp_ops()) 303 if (!register_vsmp_smp_ops())
304 return; 304 return;
305 register_up_smp_ops();
305} 306}
306 307
307void platform_early_l2_init(void) 308void platform_early_l2_init(void)
diff --git a/arch/mips/mti-malta/malta-memory.c b/arch/mips/mti-malta/malta-memory.c
index dadeb8379182..d5f8dae6a797 100644
--- a/arch/mips/mti-malta/malta-memory.c
+++ b/arch/mips/mti-malta/malta-memory.c
@@ -21,147 +21,20 @@
21#include <asm/sections.h> 21#include <asm/sections.h>
22#include <asm/fw/fw.h> 22#include <asm/fw/fw.h>
23 23
24static fw_memblock_t mdesc[FW_MAX_MEMBLOCKS];
25
26/* determined physical memory size, not overridden by command line args */ 24/* determined physical memory size, not overridden by command line args */
27unsigned long physical_memsize = 0L; 25unsigned long physical_memsize = 0L;
28 26
29fw_memblock_t * __init fw_getmdesc(int eva)
30{
31 char *memsize_str, *ememsize_str = NULL, *ptr;
32 unsigned long memsize = 0, ememsize = 0;
33 static char cmdline[COMMAND_LINE_SIZE] __initdata;
34 int tmp;
35
36 /* otherwise look in the environment */
37
38 memsize_str = fw_getenv("memsize");
39 if (memsize_str) {
40 tmp = kstrtoul(memsize_str, 0, &memsize);
41 if (tmp)
42 pr_warn("Failed to read the 'memsize' env variable.\n");
43 }
44 if (eva) {
45 /* Look for ememsize for EVA */
46 ememsize_str = fw_getenv("ememsize");
47 if (ememsize_str) {
48 tmp = kstrtoul(ememsize_str, 0, &ememsize);
49 if (tmp)
50 pr_warn("Failed to read the 'ememsize' env variable.\n");
51 }
52 }
53 if (!memsize && !ememsize) {
54 pr_warn("memsize not set in YAMON, set to default (32Mb)\n");
55 physical_memsize = 0x02000000;
56 } else {
57 if (memsize > (256 << 20)) { /* memsize should be capped to 256M */
58 pr_warn("Unsupported memsize value (0x%lx) detected! "
59 "Using 0x10000000 (256M) instead\n",
60 memsize);
61 memsize = 256 << 20;
62 }
63 /* If ememsize is set, then set physical_memsize to that */
64 physical_memsize = ememsize ? : memsize;
65 }
66
67#ifdef CONFIG_CPU_BIG_ENDIAN
68 /* SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last
69 word of physical memory */
70 physical_memsize -= PAGE_SIZE;
71#endif
72
73 /* Check the command line for a memsize directive that overrides
74 the physical/default amount */
75 strcpy(cmdline, arcs_cmdline);
76 ptr = strstr(cmdline, "memsize=");
77 if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' '))
78 ptr = strstr(ptr, " memsize=");
79 /* And now look for ememsize */
80 if (eva) {
81 ptr = strstr(cmdline, "ememsize=");
82 if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' '))
83 ptr = strstr(ptr, " ememsize=");
84 }
85
86 if (ptr)
87 memsize = memparse(ptr + 8 + (eva ? 1 : 0), &ptr);
88 else
89 memsize = physical_memsize;
90
91 /* Last 64K for HIGHMEM arithmetics */
92 if (memsize > 0x7fff0000)
93 memsize = 0x7fff0000;
94
95 memset(mdesc, 0, sizeof(mdesc));
96
97 mdesc[0].type = fw_dontuse;
98 mdesc[0].base = PHYS_OFFSET;
99 mdesc[0].size = 0x00001000;
100
101 mdesc[1].type = fw_code;
102 mdesc[1].base = mdesc[0].base + 0x00001000UL;
103 mdesc[1].size = 0x000ef000;
104
105 /*
106 * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the
107 * south bridge and PCI access always forwarded to the ISA Bus and
108 * BIOSCS# is always generated.
109 * This mean that this area can't be used as DMA memory for PCI
110 * devices.
111 */
112 mdesc[2].type = fw_dontuse;
113 mdesc[2].base = mdesc[0].base + 0x000f0000UL;
114 mdesc[2].size = 0x00010000;
115
116 mdesc[3].type = fw_dontuse;
117 mdesc[3].base = mdesc[0].base + 0x00100000UL;
118 mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) -
119 0x00100000UL;
120
121 mdesc[4].type = fw_free;
122 mdesc[4].base = mdesc[0].base + CPHYSADDR(PFN_ALIGN(&_end));
123 mdesc[4].size = memsize - CPHYSADDR(mdesc[4].base);
124
125 return &mdesc[0];
126}
127
128static void free_init_pages_eva_malta(void *begin, void *end) 27static void free_init_pages_eva_malta(void *begin, void *end)
129{ 28{
130 free_init_pages("unused kernel", __pa_symbol((unsigned long *)begin), 29 free_init_pages("unused kernel", __pa_symbol((unsigned long *)begin),
131 __pa_symbol((unsigned long *)end)); 30 __pa_symbol((unsigned long *)end));
132} 31}
133 32
134static int __init fw_memtype_classify(unsigned int type)
135{
136 switch (type) {
137 case fw_free:
138 return BOOT_MEM_RAM;
139 case fw_code:
140 return BOOT_MEM_ROM_DATA;
141 default:
142 return BOOT_MEM_RESERVED;
143 }
144}
145
146void __init fw_meminit(void) 33void __init fw_meminit(void)
147{ 34{
148 fw_memblock_t *p; 35 bool eva = config_enabled(CONFIG_EVA);
149
150 p = fw_getmdesc(config_enabled(CONFIG_EVA));
151 free_init_pages_eva = (config_enabled(CONFIG_EVA) ?
152 free_init_pages_eva_malta : NULL);
153 36
154 while (p->size) { 37 free_init_pages_eva = eva ? free_init_pages_eva_malta : NULL;
155 long type;
156 unsigned long base, size;
157
158 type = fw_memtype_classify(p->type);
159 base = p->base;
160 size = p->size;
161
162 add_memory_region(base, size, type);
163 p++;
164 }
165} 38}
166 39
167void __init prom_free_prom_memory(void) 40void __init prom_free_prom_memory(void)
diff --git a/arch/mips/mti-malta/malta-setup.c b/arch/mips/mti-malta/malta-setup.c
index 9d1e7f5ec36c..4740c82fb97a 100644
--- a/arch/mips/mti-malta/malta-setup.c
+++ b/arch/mips/mti-malta/malta-setup.c
@@ -27,6 +27,7 @@
27#include <linux/time.h> 27#include <linux/time.h>
28 28
29#include <asm/fw/fw.h> 29#include <asm/fw/fw.h>
30#include <asm/mach-malta/malta-dtshim.h>
30#include <asm/mips-cm.h> 31#include <asm/mips-cm.h>
31#include <asm/mips-boards/generic.h> 32#include <asm/mips-boards/generic.h>
32#include <asm/mips-boards/malta.h> 33#include <asm/mips-boards/malta.h>
@@ -250,8 +251,10 @@ static void __init bonito_quirks_setup(void)
250void __init plat_mem_setup(void) 251void __init plat_mem_setup(void)
251{ 252{
252 unsigned int i; 253 unsigned int i;
254 void *fdt = __dtb_start;
253 255
254 __dt_setup_arch(__dtb_start); 256 fdt = malta_dt_shim(fdt);
257 __dt_setup_arch(fdt);
255 258
256 if (config_enabled(CONFIG_EVA)) 259 if (config_enabled(CONFIG_EVA))
257 /* EVA has already been configured in mach-malta/kernel-init.h */ 260 /* EVA has already been configured in mach-malta/kernel-init.h */
diff --git a/arch/mips/netlogic/xlp/dt.c b/arch/mips/netlogic/xlp/dt.c
index a625bdb6d6aa..856a6e6d296e 100644
--- a/arch/mips/netlogic/xlp/dt.c
+++ b/arch/mips/netlogic/xlp/dt.c
@@ -87,7 +87,6 @@ void __init *xlp_dt_init(void *fdtp)
87void __init xlp_early_init_devtree(void) 87void __init xlp_early_init_devtree(void)
88{ 88{
89 __dt_setup_arch(xlp_fdt_blob); 89 __dt_setup_arch(xlp_fdt_blob);
90 strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
91} 90}
92 91
93void __init device_tree_init(void) 92void __init device_tree_init(void)
diff --git a/arch/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c
index ed6732f9aa87..53a42b07008b 100644
--- a/arch/mips/pci/pci-rt3883.c
+++ b/arch/mips/pci/pci-rt3883.c
@@ -432,8 +432,7 @@ static int rt3883_pci_probe(struct platform_device *pdev)
432 432
433 /* find the interrupt controller child node */ 433 /* find the interrupt controller child node */
434 for_each_child_of_node(np, child) { 434 for_each_child_of_node(np, child) {
435 if (of_get_property(child, "interrupt-controller", NULL) && 435 if (of_get_property(child, "interrupt-controller", NULL)) {
436 of_node_get(child)) {
437 rpc->intc_of_node = child; 436 rpc->intc_of_node = child;
438 break; 437 break;
439 } 438 }
@@ -449,8 +448,7 @@ static int rt3883_pci_probe(struct platform_device *pdev)
449 /* find the PCI host bridge child node */ 448 /* find the PCI host bridge child node */
450 for_each_child_of_node(np, child) { 449 for_each_child_of_node(np, child) {
451 if (child->type && 450 if (child->type &&
452 of_node_cmp(child->type, "pci") == 0 && 451 of_node_cmp(child->type, "pci") == 0) {
453 of_node_get(child)) {
454 rpc->pci_controller.of_node = child; 452 rpc->pci_controller.of_node = child;
455 break; 453 break;
456 } 454 }
diff --git a/arch/mips/pistachio/init.c b/arch/mips/pistachio/init.c
index 8bd8ebb20a72..96ba2cc9ad3e 100644
--- a/arch/mips/pistachio/init.c
+++ b/arch/mips/pistachio/init.c
@@ -58,7 +58,6 @@ void __init plat_mem_setup(void)
58 panic("Device-tree not present"); 58 panic("Device-tree not present");
59 59
60 __dt_setup_arch((void *)fw_arg1); 60 __dt_setup_arch((void *)fw_arg1);
61 strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
62 61
63 plat_setup_iocoherency(); 62 plat_setup_iocoherency();
64} 63}
diff --git a/arch/mips/ralink/cevt-rt3352.c b/arch/mips/ralink/cevt-rt3352.c
index a8e70a9f274b..e46f91f971c5 100644
--- a/arch/mips/ralink/cevt-rt3352.c
+++ b/arch/mips/ralink/cevt-rt3352.c
@@ -48,7 +48,7 @@ static int systick_next_event(unsigned long delta,
48 sdev = container_of(evt, struct systick_device, dev); 48 sdev = container_of(evt, struct systick_device, dev);
49 count = ioread32(sdev->membase + SYSTICK_COUNT); 49 count = ioread32(sdev->membase + SYSTICK_COUNT);
50 count = (count + delta) % SYSTICK_FREQ; 50 count = (count + delta) % SYSTICK_FREQ;
51 iowrite32(count + delta, sdev->membase + SYSTICK_COMPARE); 51 iowrite32(count, sdev->membase + SYSTICK_COMPARE);
52 52
53 return 0; 53 return 0;
54} 54}
diff --git a/arch/mips/ralink/early_printk.c b/arch/mips/ralink/early_printk.c
index 255d695ec8c6..3c59ffe5f5f5 100644
--- a/arch/mips/ralink/early_printk.c
+++ b/arch/mips/ralink/early_printk.c
@@ -25,11 +25,13 @@
25#define MT7628_CHIP_NAME1 0x20203832 25#define MT7628_CHIP_NAME1 0x20203832
26 26
27#define UART_REG_TX 0x04 27#define UART_REG_TX 0x04
28#define UART_REG_LCR 0x0c
28#define UART_REG_LSR 0x14 29#define UART_REG_LSR 0x14
29#define UART_REG_LSR_RT2880 0x1c 30#define UART_REG_LSR_RT2880 0x1c
30 31
31static __iomem void *uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE); 32static __iomem void *uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE);
32static __iomem void *chipid_membase = (__iomem void *) KSEG1ADDR(CHIPID_BASE); 33static __iomem void *chipid_membase = (__iomem void *) KSEG1ADDR(CHIPID_BASE);
34static int init_complete;
33 35
34static inline void uart_w32(u32 val, unsigned reg) 36static inline void uart_w32(u32 val, unsigned reg)
35{ 37{
@@ -47,8 +49,32 @@ static inline int soc_is_mt7628(void)
47 (__raw_readl(chipid_membase) == MT7628_CHIP_NAME1); 49 (__raw_readl(chipid_membase) == MT7628_CHIP_NAME1);
48} 50}
49 51
52static void find_uart_base(void)
53{
54 int i;
55
56 if (!soc_is_mt7628())
57 return;
58
59 for (i = 0; i < 3; i++) {
60 u32 reg = uart_r32(UART_REG_LCR + (0x100 * i));
61
62 if (!reg)
63 continue;
64
65 uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE +
66 (0x100 * i));
67 break;
68 }
69}
70
50void prom_putchar(unsigned char ch) 71void prom_putchar(unsigned char ch)
51{ 72{
73 if (!init_complete) {
74 find_uart_base();
75 init_complete = 1;
76 }
77
52 if (IS_ENABLED(CONFIG_SOC_MT7621) || soc_is_mt7628()) { 78 if (IS_ENABLED(CONFIG_SOC_MT7621) || soc_is_mt7628()) {
53 uart_w32(ch, UART_TX); 79 uart_w32(ch, UART_TX);
54 while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0) 80 while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c
index 2ea5ff6dc22e..dfb04fcedb04 100644
--- a/arch/mips/ralink/mt7620.c
+++ b/arch/mips/ralink/mt7620.c
@@ -37,8 +37,17 @@
37#define PMU1_CFG 0x8C 37#define PMU1_CFG 0x8C
38#define DIG_SW_SEL BIT(25) 38#define DIG_SW_SEL BIT(25)
39 39
40/* is this a MT7620 or a MT7628 */ 40/* clock scaling */
41enum mt762x_soc_type mt762x_soc; 41#define CLKCFG_FDIV_MASK 0x1f00
42#define CLKCFG_FDIV_USB_VAL 0x0300
43#define CLKCFG_FFRAC_MASK 0x001f
44#define CLKCFG_FFRAC_USB_VAL 0x0003
45
46/* EFUSE bits */
47#define EFUSE_MT7688 0x100000
48
49/* DRAM type bit */
50#define DRAM_TYPE_MT7628_MASK 0x1
42 51
43/* does the board have sdram or ddram */ 52/* does the board have sdram or ddram */
44static int dram_type; 53static int dram_type;
@@ -227,6 +236,12 @@ static struct rt2880_pmx_group mt7628an_pinmux_data[] = {
227 { 0 } 236 { 0 }
228}; 237};
229 238
239static inline int is_mt76x8(void)
240{
241 return ralink_soc == MT762X_SOC_MT7628AN ||
242 ralink_soc == MT762X_SOC_MT7688;
243}
244
230static __init u32 245static __init u32
231mt7620_calc_rate(u32 ref_rate, u32 mul, u32 div) 246mt7620_calc_rate(u32 ref_rate, u32 mul, u32 div)
232{ 247{
@@ -381,7 +396,7 @@ void __init ralink_clk_init(void)
381#define RINT(x) ((x) / 1000000) 396#define RINT(x) ((x) / 1000000)
382#define RFRAC(x) (((x) / 1000) % 1000) 397#define RFRAC(x) (((x) / 1000) % 1000)
383 398
384 if (mt762x_soc == MT762X_SOC_MT7628AN) { 399 if (is_mt76x8()) {
385 if (xtal_rate == MHZ(40)) 400 if (xtal_rate == MHZ(40))
386 cpu_rate = MHZ(580); 401 cpu_rate = MHZ(580);
387 else 402 else
@@ -423,6 +438,20 @@ void __init ralink_clk_init(void)
423 ralink_clk_add("10000b00.spi", sys_rate); 438 ralink_clk_add("10000b00.spi", sys_rate);
424 ralink_clk_add("10000c00.uartlite", periph_rate); 439 ralink_clk_add("10000c00.uartlite", periph_rate);
425 ralink_clk_add("10180000.wmac", xtal_rate); 440 ralink_clk_add("10180000.wmac", xtal_rate);
441
442 if (IS_ENABLED(CONFIG_USB) && is_mt76x8()) {
443 /*
444 * When the CPU goes into sleep mode, the BUS clock will be
445 * too low for USB to function properly. Adjust the busses
446 * fractional divider to fix this
447 */
448 u32 val = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG);
449
450 val &= ~(CLKCFG_FDIV_MASK | CLKCFG_FFRAC_MASK);
451 val |= CLKCFG_FDIV_USB_VAL | CLKCFG_FFRAC_USB_VAL;
452
453 rt_sysc_w32(val, SYSC_REG_CPU_SYS_CLKCFG);
454 }
426} 455}
427 456
428void __init ralink_of_remap(void) 457void __init ralink_of_remap(void)
@@ -499,20 +528,24 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
499 528
500 if (n0 == MT7620_CHIP_NAME0 && n1 == MT7620_CHIP_NAME1) { 529 if (n0 == MT7620_CHIP_NAME0 && n1 == MT7620_CHIP_NAME1) {
501 if (bga) { 530 if (bga) {
502 mt762x_soc = MT762X_SOC_MT7620A; 531 ralink_soc = MT762X_SOC_MT7620A;
503 name = "MT7620A"; 532 name = "MT7620A";
504 soc_info->compatible = "ralink,mt7620a-soc"; 533 soc_info->compatible = "ralink,mt7620a-soc";
505 } else { 534 } else {
506 mt762x_soc = MT762X_SOC_MT7620N; 535 ralink_soc = MT762X_SOC_MT7620N;
507 name = "MT7620N"; 536 name = "MT7620N";
508 soc_info->compatible = "ralink,mt7620n-soc"; 537 soc_info->compatible = "ralink,mt7620n-soc";
509#ifdef CONFIG_PCI
510 panic("mt7620n is only supported for non pci kernels");
511#endif
512 } 538 }
513 } else if (n0 == MT7620_CHIP_NAME0 && n1 == MT7628_CHIP_NAME1) { 539 } else if (n0 == MT7620_CHIP_NAME0 && n1 == MT7628_CHIP_NAME1) {
514 mt762x_soc = MT762X_SOC_MT7628AN; 540 u32 efuse = __raw_readl(sysc + SYSC_REG_EFUSE_CFG);
515 name = "MT7628AN"; 541
542 if (efuse & EFUSE_MT7688) {
543 ralink_soc = MT762X_SOC_MT7688;
544 name = "MT7688";
545 } else {
546 ralink_soc = MT762X_SOC_MT7628AN;
547 name = "MT7628AN";
548 }
516 soc_info->compatible = "ralink,mt7628an-soc"; 549 soc_info->compatible = "ralink,mt7628an-soc";
517 } else { 550 } else {
518 panic("mt762x: unknown SoC, n0:%08x n1:%08x\n", n0, n1); 551 panic("mt762x: unknown SoC, n0:%08x n1:%08x\n", n0, n1);
@@ -525,10 +558,14 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
525 (rev & CHIP_REV_ECO_MASK)); 558 (rev & CHIP_REV_ECO_MASK));
526 559
527 cfg0 = __raw_readl(sysc + SYSC_REG_SYSTEM_CONFIG0); 560 cfg0 = __raw_readl(sysc + SYSC_REG_SYSTEM_CONFIG0);
528 dram_type = (cfg0 >> SYSCFG0_DRAM_TYPE_SHIFT) & SYSCFG0_DRAM_TYPE_MASK; 561 if (is_mt76x8())
562 dram_type = cfg0 & DRAM_TYPE_MT7628_MASK;
563 else
564 dram_type = (cfg0 >> SYSCFG0_DRAM_TYPE_SHIFT) &
565 SYSCFG0_DRAM_TYPE_MASK;
529 566
530 soc_info->mem_base = MT7620_DRAM_BASE; 567 soc_info->mem_base = MT7620_DRAM_BASE;
531 if (mt762x_soc == MT762X_SOC_MT7628AN) 568 if (is_mt76x8())
532 mt7628_dram_init(soc_info); 569 mt7628_dram_init(soc_info);
533 else 570 else
534 mt7620_dram_init(soc_info); 571 mt7620_dram_init(soc_info);
@@ -541,7 +578,7 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
541 pr_info("Digital PMU set to %s control\n", 578 pr_info("Digital PMU set to %s control\n",
542 (pmu1 & DIG_SW_SEL) ? ("sw") : ("hw")); 579 (pmu1 & DIG_SW_SEL) ? ("sw") : ("hw"));
543 580
544 if (mt762x_soc == MT762X_SOC_MT7628AN) 581 if (is_mt76x8())
545 rt2880_pinmux_data = mt7628an_pinmux_data; 582 rt2880_pinmux_data = mt7628an_pinmux_data;
546 else 583 else
547 rt2880_pinmux_data = mt7620a_pinmux_data; 584 rt2880_pinmux_data = mt7620a_pinmux_data;
diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
index 0d30dcd63246..f9eda5d8f82c 100644
--- a/arch/mips/ralink/of.c
+++ b/arch/mips/ralink/of.c
@@ -74,8 +74,6 @@ void __init plat_mem_setup(void)
74 */ 74 */
75 __dt_setup_arch(__dtb_start); 75 __dt_setup_arch(__dtb_start);
76 76
77 strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
78
79 of_scan_flat_dt(early_init_dt_find_memory, NULL); 77 of_scan_flat_dt(early_init_dt_find_memory, NULL);
80 if (memory_dtb) 78 if (memory_dtb)
81 of_scan_flat_dt(early_init_dt_scan_memory, NULL); 79 of_scan_flat_dt(early_init_dt_scan_memory, NULL);
diff --git a/arch/mips/ralink/prom.c b/arch/mips/ralink/prom.c
index 09419f67da39..39a9142f71be 100644
--- a/arch/mips/ralink/prom.c
+++ b/arch/mips/ralink/prom.c
@@ -15,11 +15,16 @@
15#include <asm/bootinfo.h> 15#include <asm/bootinfo.h>
16#include <asm/addrspace.h> 16#include <asm/addrspace.h>
17 17
18#include <asm/mach-ralink/ralink_regs.h>
19
18#include "common.h" 20#include "common.h"
19 21
20struct ralink_soc_info soc_info; 22struct ralink_soc_info soc_info;
21struct rt2880_pmx_group *rt2880_pinmux_data = NULL; 23struct rt2880_pmx_group *rt2880_pinmux_data = NULL;
22 24
25enum ralink_soc_type ralink_soc;
26EXPORT_SYMBOL_GPL(ralink_soc);
27
23const char *get_system_type(void) 28const char *get_system_type(void)
24{ 29{
25 return soc_info.sys_type; 30 return soc_info.sys_type;
diff --git a/arch/mips/ralink/reset.c b/arch/mips/ralink/reset.c
index 55c7ec59df3c..ee117c4bc4a3 100644
--- a/arch/mips/ralink/reset.c
+++ b/arch/mips/ralink/reset.c
@@ -11,6 +11,7 @@
11#include <linux/pm.h> 11#include <linux/pm.h>
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/of.h> 13#include <linux/of.h>
14#include <linux/delay.h>
14#include <linux/reset-controller.h> 15#include <linux/reset-controller.h>
15 16
16#include <asm/reboot.h> 17#include <asm/reboot.h>
@@ -18,8 +19,10 @@
18#include <asm/mach-ralink/ralink_regs.h> 19#include <asm/mach-ralink/ralink_regs.h>
19 20
20/* Reset Control */ 21/* Reset Control */
21#define SYSC_REG_RESET_CTRL 0x034 22#define SYSC_REG_RESET_CTRL 0x034
22#define RSTCTL_RESET_SYSTEM BIT(0) 23
24#define RSTCTL_RESET_PCI BIT(26)
25#define RSTCTL_RESET_SYSTEM BIT(0)
23 26
24static int ralink_assert_device(struct reset_controller_dev *rcdev, 27static int ralink_assert_device(struct reset_controller_dev *rcdev,
25 unsigned long id) 28 unsigned long id)
@@ -83,6 +86,11 @@ void ralink_rst_init(void)
83 86
84static void ralink_restart(char *command) 87static void ralink_restart(char *command)
85{ 88{
89 if (IS_ENABLED(CONFIG_PCI)) {
90 rt_sysc_m32(0, RSTCTL_RESET_PCI, SYSC_REG_RESET_CTRL);
91 mdelay(50);
92 }
93
86 local_irq_disable(); 94 local_irq_disable();
87 rt_sysc_w32(RSTCTL_RESET_SYSTEM, SYSC_REG_RESET_CTRL); 95 rt_sysc_w32(RSTCTL_RESET_SYSTEM, SYSC_REG_RESET_CTRL);
88 unreachable(); 96 unreachable();
@@ -98,7 +106,6 @@ static int __init mips_reboot_setup(void)
98{ 106{
99 _machine_restart = ralink_restart; 107 _machine_restart = ralink_restart;
100 _machine_halt = ralink_halt; 108 _machine_halt = ralink_halt;
101 pm_power_off = ralink_halt;
102 109
103 return 0; 110 return 0;
104} 111}
diff --git a/arch/mips/ralink/rt288x.c b/arch/mips/ralink/rt288x.c
index 738cec865f41..844f5cd55c8f 100644
--- a/arch/mips/ralink/rt288x.c
+++ b/arch/mips/ralink/rt288x.c
@@ -119,4 +119,5 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
119 soc_info->mem_size_max = RT2880_MEM_SIZE_MAX; 119 soc_info->mem_size_max = RT2880_MEM_SIZE_MAX;
120 120
121 rt2880_pinmux_data = rt2880_pinmux_data_act; 121 rt2880_pinmux_data = rt2880_pinmux_data_act;
122 ralink_soc == RT2880_SOC;
122} 123}
diff --git a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c
index c40776ab67db..9e4572592065 100644
--- a/arch/mips/ralink/rt305x.c
+++ b/arch/mips/ralink/rt305x.c
@@ -21,8 +21,6 @@
21 21
22#include "common.h" 22#include "common.h"
23 23
24enum rt305x_soc_type rt305x_soc;
25
26static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) }; 24static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
27static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) }; 25static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
28static struct rt2880_pmx_func uartf_func[] = { 26static struct rt2880_pmx_func uartf_func[] = {
@@ -201,6 +199,7 @@ void __init ralink_clk_init(void)
201 } 199 }
202 200
203 ralink_clk_add("cpu", cpu_rate); 201 ralink_clk_add("cpu", cpu_rate);
202 ralink_clk_add("sys", sys_rate);
204 ralink_clk_add("10000b00.spi", sys_rate); 203 ralink_clk_add("10000b00.spi", sys_rate);
205 ralink_clk_add("10000100.timer", wdt_rate); 204 ralink_clk_add("10000100.timer", wdt_rate);
206 ralink_clk_add("10000120.watchdog", wdt_rate); 205 ralink_clk_add("10000120.watchdog", wdt_rate);
@@ -235,24 +234,24 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
235 234
236 icache_sets = (read_c0_config1() >> 22) & 7; 235 icache_sets = (read_c0_config1() >> 22) & 7;
237 if (icache_sets == 1) { 236 if (icache_sets == 1) {
238 rt305x_soc = RT305X_SOC_RT3050; 237 ralink_soc = RT305X_SOC_RT3050;
239 name = "RT3050"; 238 name = "RT3050";
240 soc_info->compatible = "ralink,rt3050-soc"; 239 soc_info->compatible = "ralink,rt3050-soc";
241 } else { 240 } else {
242 rt305x_soc = RT305X_SOC_RT3052; 241 ralink_soc = RT305X_SOC_RT3052;
243 name = "RT3052"; 242 name = "RT3052";
244 soc_info->compatible = "ralink,rt3052-soc"; 243 soc_info->compatible = "ralink,rt3052-soc";
245 } 244 }
246 } else if (n0 == RT3350_CHIP_NAME0 && n1 == RT3350_CHIP_NAME1) { 245 } else if (n0 == RT3350_CHIP_NAME0 && n1 == RT3350_CHIP_NAME1) {
247 rt305x_soc = RT305X_SOC_RT3350; 246 ralink_soc = RT305X_SOC_RT3350;
248 name = "RT3350"; 247 name = "RT3350";
249 soc_info->compatible = "ralink,rt3350-soc"; 248 soc_info->compatible = "ralink,rt3350-soc";
250 } else if (n0 == RT3352_CHIP_NAME0 && n1 == RT3352_CHIP_NAME1) { 249 } else if (n0 == RT3352_CHIP_NAME0 && n1 == RT3352_CHIP_NAME1) {
251 rt305x_soc = RT305X_SOC_RT3352; 250 ralink_soc = RT305X_SOC_RT3352;
252 name = "RT3352"; 251 name = "RT3352";
253 soc_info->compatible = "ralink,rt3352-soc"; 252 soc_info->compatible = "ralink,rt3352-soc";
254 } else if (n0 == RT5350_CHIP_NAME0 && n1 == RT5350_CHIP_NAME1) { 253 } else if (n0 == RT5350_CHIP_NAME0 && n1 == RT5350_CHIP_NAME1) {
255 rt305x_soc = RT305X_SOC_RT5350; 254 ralink_soc = RT305X_SOC_RT5350;
256 name = "RT5350"; 255 name = "RT5350";
257 soc_info->compatible = "ralink,rt5350-soc"; 256 soc_info->compatible = "ralink,rt5350-soc";
258 } else { 257 } else {
diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c
index 86a535c770d8..582995aaaf4e 100644
--- a/arch/mips/ralink/rt3883.c
+++ b/arch/mips/ralink/rt3883.c
@@ -153,4 +153,6 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
153 soc_info->mem_size_max = RT3883_MEM_SIZE_MAX; 153 soc_info->mem_size_max = RT3883_MEM_SIZE_MAX;
154 154
155 rt2880_pinmux_data = rt3883_pinmux_data; 155 rt2880_pinmux_data = rt3883_pinmux_data;
156
157 ralink_soc == RT3883_SOC;
156} 158}
diff --git a/arch/mips/vdso/.gitignore b/arch/mips/vdso/.gitignore
new file mode 100644
index 000000000000..5286a7d73d79
--- /dev/null
+++ b/arch/mips/vdso/.gitignore
@@ -0,0 +1,4 @@
1*.so*
2vdso-*image.c
3genvdso
4vdso*.lds
diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
new file mode 100644
index 000000000000..ef5f348f386a
--- /dev/null
+++ b/arch/mips/vdso/Makefile
@@ -0,0 +1,160 @@
1# Objects to go into the VDSO.
2obj-vdso-y := elf.o gettimeofday.o sigreturn.o
3
4# Common compiler flags between ABIs.
5ccflags-vdso := \
6 $(filter -I%,$(KBUILD_CFLAGS)) \
7 $(filter -E%,$(KBUILD_CFLAGS)) \
8 $(filter -march=%,$(KBUILD_CFLAGS))
9cflags-vdso := $(ccflags-vdso) \
10 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
11 -O2 -g -fPIC -fno-common -fno-builtin -G 0 -DDISABLE_BRANCH_PROFILING \
12 $(call cc-option, -fno-stack-protector)
13aflags-vdso := $(ccflags-vdso) \
14 $(filter -I%,$(KBUILD_CFLAGS)) \
15 $(filter -E%,$(KBUILD_CFLAGS)) \
16 -D__ASSEMBLY__ -Wa,-gdwarf-2
17
18#
19# For the pre-R6 code in arch/mips/vdso/vdso.h for locating
20# the base address of VDSO, the linker will emit a R_MIPS_PC32
21# relocation in binutils > 2.25 but it will fail with older versions
22# because that relocation is not supported for that symbol. As a result
23# of which we are forced to disable the VDSO symbols when building
24# with < 2.25 binutils on pre-R6 kernels. For more references on why we
25# can't use other methods to get the base address of VDSO please refer to
26# the comments on that file.
27#
28ifndef CONFIG_CPU_MIPSR6
29 ifeq ($(call ld-ifversion, -gt, 22400000, y),)
30 $(warning MIPS VDSO requires binutils > 2.24)
31 obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y))
32 ccflags-vdso += -DDISABLE_MIPS_VDSO
33 endif
34endif
35
36# VDSO linker flags.
37VDSO_LDFLAGS := \
38 -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \
39 -nostdlib -shared \
40 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
41 $(call cc-ldoption, -Wl$(comma)--build-id)
42
43GCOV_PROFILE := n
44
45#
46# Shared build commands.
47#
48
49quiet_cmd_vdsold = VDSO $@
50 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
51 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
52
53hostprogs-y := genvdso
54
55quiet_cmd_genvdso = GENVDSO $@
56define cmd_genvdso
57 cp $< $(<:%.dbg=%) && \
58 $(OBJCOPY) -S $< $(<:%.dbg=%) && \
59 $(obj)/genvdso $< $(<:%.dbg=%) $@ $(VDSO_NAME)
60endef
61
62#
63# Build native VDSO.
64#
65
66native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
67
68targets += $(obj-vdso-y)
69targets += vdso.lds vdso.so.dbg vdso.so vdso-image.c
70
71obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
72
73$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
74$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
75
76$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(native-abi)
77
78$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
79 $(call if_changed,vdsold)
80
81$(obj)/vdso-image.c: $(obj)/vdso.so.dbg $(obj)/genvdso FORCE
82 $(call if_changed,genvdso)
83
84obj-y += vdso-image.o
85
86#
87# Build O32 VDSO.
88#
89
90# Define these outside the ifdef to ensure they are picked up by clean.
91targets += $(obj-vdso-y:%.o=%-o32.o)
92targets += vdso-o32.lds vdso-o32.so.dbg vdso-o32.so vdso-o32-image.c
93
94ifdef CONFIG_MIPS32_O32
95
96obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
97
98$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
99$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
100
101$(obj)/%-o32.o: $(src)/%.S FORCE
102 $(call if_changed_dep,as_o_S)
103
104$(obj)/%-o32.o: $(src)/%.c FORCE
105 $(call cmd,force_checksrc)
106 $(call if_changed_rule,cc_o_c)
107
108$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := -mabi=32
109$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
110 $(call if_changed_dep,cpp_lds_S)
111
112$(obj)/vdso-o32.so.dbg: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
113 $(call if_changed,vdsold)
114
115$(obj)/vdso-o32-image.c: VDSO_NAME := o32
116$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg $(obj)/genvdso FORCE
117 $(call if_changed,genvdso)
118
119obj-y += vdso-o32-image.o
120
121endif
122
123#
124# Build N32 VDSO.
125#
126
127targets += $(obj-vdso-y:%.o=%-n32.o)
128targets += vdso-n32.lds vdso-n32.so.dbg vdso-n32.so vdso-n32-image.c
129
130ifdef CONFIG_MIPS32_N32
131
132obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
133
134$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
135$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
136
137$(obj)/%-n32.o: $(src)/%.S FORCE
138 $(call if_changed_dep,as_o_S)
139
140$(obj)/%-n32.o: $(src)/%.c FORCE
141 $(call cmd,force_checksrc)
142 $(call if_changed_rule,cc_o_c)
143
144$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := -mabi=n32
145$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
146 $(call if_changed_dep,cpp_lds_S)
147
148$(obj)/vdso-n32.so.dbg: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
149 $(call if_changed,vdsold)
150
151$(obj)/vdso-n32-image.c: VDSO_NAME := n32
152$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg $(obj)/genvdso FORCE
153 $(call if_changed,genvdso)
154
155obj-y += vdso-n32-image.o
156
157endif
158
159# FIXME: Need install rule for debug.
160# Needs to deal with dependency for generation of dbg by cmd_genvdso...
diff --git a/arch/mips/vdso/elf.S b/arch/mips/vdso/elf.S
new file mode 100644
index 000000000000..be37bbb1f061
--- /dev/null
+++ b/arch/mips/vdso/elf.S
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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 "vdso.h"
12
13#include <linux/elfnote.h>
14#include <linux/version.h>
15
16ELFNOTE_START(Linux, 0, "a")
17 .long LINUX_VERSION_CODE
18ELFNOTE_END
19
20/*
21 * The .MIPS.abiflags section must be defined with the FP ABI flags set
22 * to 'any' to be able to link with both old and new libraries.
23 * Newer toolchains are capable of automatically generating this, but we want
24 * to work with older toolchains as well. Therefore, we define the contents of
25 * this section here (under different names), and then genvdso will patch
26 * it to have the correct name and type.
27 *
28 * We base the .MIPS.abiflags section on preprocessor definitions rather than
29 * CONFIG_* because we need to match the particular ABI we are building the
30 * VDSO for.
31 *
32 * See https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking
33 * for the .MIPS.abiflags section description.
34 */
35
36 .section .mips_abiflags, "a"
37 .align 3
38__mips_abiflags:
39 .hword 0 /* version */
40 .byte __mips /* isa_level */
41
42 /* isa_rev */
43#ifdef __mips_isa_rev
44 .byte __mips_isa_rev
45#else
46 .byte 0
47#endif
48
49 /* gpr_size */
50#ifdef __mips64
51 .byte 2 /* AFL_REG_64 */
52#else
53 .byte 1 /* AFL_REG_32 */
54#endif
55
56 /* cpr1_size */
57#if (defined(__mips_isa_rev) && __mips_isa_rev >= 6) || defined(__mips64)
58 .byte 2 /* AFL_REG_64 */
59#else
60 .byte 1 /* AFL_REG_32 */
61#endif
62
63 .byte 0 /* cpr2_size (AFL_REG_NONE) */
64 .byte 0 /* fp_abi (Val_GNU_MIPS_ABI_FP_ANY) */
65 .word 0 /* isa_ext */
66 .word 0 /* ases */
67 .word 0 /* flags1 */
68 .word 0 /* flags2 */
diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
new file mode 100644
index 000000000000..530a36f465ce
--- /dev/null
+++ b/arch/mips/vdso/genvdso.c
@@ -0,0 +1,293 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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/*
12 * This tool is used to generate the real VDSO images from the raw image. It
13 * first patches up the MIPS ABI flags and GNU attributes sections defined in
14 * elf.S to have the correct name and type. It then generates a C source file
15 * to be compiled into the kernel containing the VDSO image data and a
16 * mips_vdso_image struct for it, including symbol offsets extracted from the
17 * image.
18 *
19 * We need to be passed both a stripped and unstripped VDSO image. The stripped
20 * image is compiled into the kernel, but we must also patch up the unstripped
21 * image's ABI flags sections so that it can be installed and used for
22 * debugging.
23 */
24
25#include <sys/mman.h>
26#include <sys/stat.h>
27#include <sys/types.h>
28
29#include <byteswap.h>
30#include <elf.h>
31#include <errno.h>
32#include <fcntl.h>
33#include <inttypes.h>
34#include <stdarg.h>
35#include <stdbool.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <unistd.h>
40
41/* Define these in case the system elf.h is not new enough to have them. */
42#ifndef SHT_GNU_ATTRIBUTES
43# define SHT_GNU_ATTRIBUTES 0x6ffffff5
44#endif
45#ifndef SHT_MIPS_ABIFLAGS
46# define SHT_MIPS_ABIFLAGS 0x7000002a
47#endif
48
49enum {
50 ABI_O32 = (1 << 0),
51 ABI_N32 = (1 << 1),
52 ABI_N64 = (1 << 2),
53
54 ABI_ALL = ABI_O32 | ABI_N32 | ABI_N64,
55};
56
57/* Symbols the kernel requires offsets for. */
58static struct {
59 const char *name;
60 const char *offset_name;
61 unsigned int abis;
62} vdso_symbols[] = {
63 { "__vdso_sigreturn", "off_sigreturn", ABI_O32 },
64 { "__vdso_rt_sigreturn", "off_rt_sigreturn", ABI_ALL },
65 {}
66};
67
68static const char *program_name;
69static const char *vdso_name;
70static unsigned char elf_class;
71static unsigned int elf_abi;
72static bool need_swap;
73static FILE *out_file;
74
75#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
76# define HOST_ORDER ELFDATA2LSB
77#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
78# define HOST_ORDER ELFDATA2MSB
79#endif
80
81#define BUILD_SWAP(bits) \
82 static uint##bits##_t swap_uint##bits(uint##bits##_t val) \
83 { \
84 return need_swap ? bswap_##bits(val) : val; \
85 }
86
87BUILD_SWAP(16)
88BUILD_SWAP(32)
89BUILD_SWAP(64)
90
91#define __FUNC(name, bits) name##bits
92#define _FUNC(name, bits) __FUNC(name, bits)
93#define FUNC(name) _FUNC(name, ELF_BITS)
94
95#define __ELF(x, bits) Elf##bits##_##x
96#define _ELF(x, bits) __ELF(x, bits)
97#define ELF(x) _ELF(x, ELF_BITS)
98
99/*
100 * Include genvdso.h twice with ELF_BITS defined differently to get functions
101 * for both ELF32 and ELF64.
102 */
103
104#define ELF_BITS 64
105#include "genvdso.h"
106#undef ELF_BITS
107
108#define ELF_BITS 32
109#include "genvdso.h"
110#undef ELF_BITS
111
112static void *map_vdso(const char *path, size_t *_size)
113{
114 int fd;
115 struct stat stat;
116 void *addr;
117 const Elf32_Ehdr *ehdr;
118
119 fd = open(path, O_RDWR);
120 if (fd < 0) {
121 fprintf(stderr, "%s: Failed to open '%s': %s\n", program_name,
122 path, strerror(errno));
123 return NULL;
124 }
125
126 if (fstat(fd, &stat) != 0) {
127 fprintf(stderr, "%s: Failed to stat '%s': %s\n", program_name,
128 path, strerror(errno));
129 return NULL;
130 }
131
132 addr = mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
133 0);
134 if (addr == MAP_FAILED) {
135 fprintf(stderr, "%s: Failed to map '%s': %s\n", program_name,
136 path, strerror(errno));
137 return NULL;
138 }
139
140 /* ELF32/64 header formats are the same for the bits we're checking. */
141 ehdr = addr;
142
143 if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) {
144 fprintf(stderr, "%s: '%s' is not an ELF file\n", program_name,
145 path);
146 return NULL;
147 }
148
149 elf_class = ehdr->e_ident[EI_CLASS];
150 switch (elf_class) {
151 case ELFCLASS32:
152 case ELFCLASS64:
153 break;
154 default:
155 fprintf(stderr, "%s: '%s' has invalid ELF class\n",
156 program_name, path);
157 return NULL;
158 }
159
160 switch (ehdr->e_ident[EI_DATA]) {
161 case ELFDATA2LSB:
162 case ELFDATA2MSB:
163 need_swap = ehdr->e_ident[EI_DATA] != HOST_ORDER;
164 break;
165 default:
166 fprintf(stderr, "%s: '%s' has invalid ELF data order\n",
167 program_name, path);
168 return NULL;
169 }
170
171 if (swap_uint16(ehdr->e_machine) != EM_MIPS) {
172 fprintf(stderr,
173 "%s: '%s' has invalid ELF machine (expected EM_MIPS)\n",
174 program_name, path);
175 return NULL;
176 } else if (swap_uint16(ehdr->e_type) != ET_DYN) {
177 fprintf(stderr,
178 "%s: '%s' has invalid ELF type (expected ET_DYN)\n",
179 program_name, path);
180 return NULL;
181 }
182
183 *_size = stat.st_size;
184 return addr;
185}
186
187static bool patch_vdso(const char *path, void *vdso)
188{
189 if (elf_class == ELFCLASS64)
190 return patch_vdso64(path, vdso);
191 else
192 return patch_vdso32(path, vdso);
193}
194
195static bool get_symbols(const char *path, void *vdso)
196{
197 if (elf_class == ELFCLASS64)
198 return get_symbols64(path, vdso);
199 else
200 return get_symbols32(path, vdso);
201}
202
203int main(int argc, char **argv)
204{
205 const char *dbg_vdso_path, *vdso_path, *out_path;
206 void *dbg_vdso, *vdso;
207 size_t dbg_vdso_size, vdso_size, i;
208
209 program_name = argv[0];
210
211 if (argc < 4 || argc > 5) {
212 fprintf(stderr,
213 "Usage: %s <debug VDSO> <stripped VDSO> <output file> [<name>]\n",
214 program_name);
215 return EXIT_FAILURE;
216 }
217
218 dbg_vdso_path = argv[1];
219 vdso_path = argv[2];
220 out_path = argv[3];
221 vdso_name = (argc > 4) ? argv[4] : "";
222
223 dbg_vdso = map_vdso(dbg_vdso_path, &dbg_vdso_size);
224 if (!dbg_vdso)
225 return EXIT_FAILURE;
226
227 vdso = map_vdso(vdso_path, &vdso_size);
228 if (!vdso)
229 return EXIT_FAILURE;
230
231 /* Patch both the VDSOs' ABI flags sections. */
232 if (!patch_vdso(dbg_vdso_path, dbg_vdso))
233 return EXIT_FAILURE;
234 if (!patch_vdso(vdso_path, vdso))
235 return EXIT_FAILURE;
236
237 if (msync(dbg_vdso, dbg_vdso_size, MS_SYNC) != 0) {
238 fprintf(stderr, "%s: Failed to sync '%s': %s\n", program_name,
239 dbg_vdso_path, strerror(errno));
240 return EXIT_FAILURE;
241 } else if (msync(vdso, vdso_size, MS_SYNC) != 0) {
242 fprintf(stderr, "%s: Failed to sync '%s': %s\n", program_name,
243 vdso_path, strerror(errno));
244 return EXIT_FAILURE;
245 }
246
247 out_file = fopen(out_path, "w");
248 if (!out_file) {
249 fprintf(stderr, "%s: Failed to open '%s': %s\n", program_name,
250 out_path, strerror(errno));
251 return EXIT_FAILURE;
252 }
253
254 fprintf(out_file, "/* Automatically generated - do not edit */\n");
255 fprintf(out_file, "#include <linux/linkage.h>\n");
256 fprintf(out_file, "#include <linux/mm.h>\n");
257 fprintf(out_file, "#include <asm/vdso.h>\n");
258
259 /* Write out the stripped VDSO data. */
260 fprintf(out_file,
261 "static unsigned char vdso_data[PAGE_ALIGN(%zu)] __page_aligned_data = {\n\t",
262 vdso_size);
263 for (i = 0; i < vdso_size; i++) {
264 if (!(i % 10))
265 fprintf(out_file, "\n\t");
266 fprintf(out_file, "0x%02x, ", ((unsigned char *)vdso)[i]);
267 }
268 fprintf(out_file, "\n};\n");
269
270 /* Preallocate a page array. */
271 fprintf(out_file,
272 "static struct page *vdso_pages[PAGE_ALIGN(%zu) / PAGE_SIZE];\n",
273 vdso_size);
274
275 fprintf(out_file, "struct mips_vdso_image vdso_image%s%s = {\n",
276 (vdso_name[0]) ? "_" : "", vdso_name);
277 fprintf(out_file, "\t.data = vdso_data,\n");
278 fprintf(out_file, "\t.size = PAGE_ALIGN(%zu),\n", vdso_size);
279 fprintf(out_file, "\t.mapping = {\n");
280 fprintf(out_file, "\t\t.name = \"[vdso]\",\n");
281 fprintf(out_file, "\t\t.pages = vdso_pages,\n");
282 fprintf(out_file, "\t},\n");
283
284 /* Calculate and write symbol offsets to <output file> */
285 if (!get_symbols(dbg_vdso_path, dbg_vdso)) {
286 unlink(out_path);
287 return EXIT_FAILURE;
288 }
289
290 fprintf(out_file, "};\n");
291
292 return EXIT_SUCCESS;
293}
diff --git a/arch/mips/vdso/genvdso.h b/arch/mips/vdso/genvdso.h
new file mode 100644
index 000000000000..94334727059a
--- /dev/null
+++ b/arch/mips/vdso/genvdso.h
@@ -0,0 +1,187 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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
11static inline bool FUNC(patch_vdso)(const char *path, void *vdso)
12{
13 const ELF(Ehdr) *ehdr = vdso;
14 void *shdrs;
15 ELF(Shdr) *shdr;
16 char *shstrtab, *name;
17 uint16_t sh_count, sh_entsize, i;
18 unsigned int local_gotno, symtabno, gotsym;
19 ELF(Dyn) *dyn = NULL;
20
21 shdrs = vdso + FUNC(swap_uint)(ehdr->e_shoff);
22 sh_count = swap_uint16(ehdr->e_shnum);
23 sh_entsize = swap_uint16(ehdr->e_shentsize);
24
25 shdr = shdrs + (sh_entsize * swap_uint16(ehdr->e_shstrndx));
26 shstrtab = vdso + FUNC(swap_uint)(shdr->sh_offset);
27
28 for (i = 0; i < sh_count; i++) {
29 shdr = shdrs + (i * sh_entsize);
30 name = shstrtab + swap_uint32(shdr->sh_name);
31
32 /*
33 * Ensure there are no relocation sections - ld.so does not
34 * relocate the VDSO so if there are relocations things will
35 * break.
36 */
37 switch (swap_uint32(shdr->sh_type)) {
38 case SHT_REL:
39 case SHT_RELA:
40 fprintf(stderr,
41 "%s: '%s' contains relocation sections\n",
42 program_name, path);
43 return false;
44 case SHT_DYNAMIC:
45 dyn = vdso + FUNC(swap_uint)(shdr->sh_offset);
46 break;
47 }
48
49 /* Check for existing sections. */
50 if (strcmp(name, ".MIPS.abiflags") == 0) {
51 fprintf(stderr,
52 "%s: '%s' already contains a '.MIPS.abiflags' section\n",
53 program_name, path);
54 return false;
55 }
56
57 if (strcmp(name, ".mips_abiflags") == 0) {
58 strcpy(name, ".MIPS.abiflags");
59 shdr->sh_type = swap_uint32(SHT_MIPS_ABIFLAGS);
60 shdr->sh_entsize = shdr->sh_size;
61 }
62 }
63
64 /*
65 * Ensure the GOT has no entries other than the standard 2, for the same
66 * reason we check that there's no relocation sections above.
67 * The standard two entries are:
68 * - Lazy resolver
69 * - Module pointer
70 */
71 if (dyn) {
72 local_gotno = symtabno = gotsym = 0;
73
74 while (FUNC(swap_uint)(dyn->d_tag) != DT_NULL) {
75 switch (FUNC(swap_uint)(dyn->d_tag)) {
76 /*
77 * This member holds the number of local GOT entries.
78 */
79 case DT_MIPS_LOCAL_GOTNO:
80 local_gotno = FUNC(swap_uint)(dyn->d_un.d_val);
81 break;
82 /*
83 * This member holds the number of entries in the
84 * .dynsym section.
85 */
86 case DT_MIPS_SYMTABNO:
87 symtabno = FUNC(swap_uint)(dyn->d_un.d_val);
88 break;
89 /*
90 * This member holds the index of the first dynamic
91 * symbol table entry that corresponds to an entry in
92 * the GOT.
93 */
94 case DT_MIPS_GOTSYM:
95 gotsym = FUNC(swap_uint)(dyn->d_un.d_val);
96 break;
97 }
98
99 dyn++;
100 }
101
102 if (local_gotno > 2 || symtabno - gotsym) {
103 fprintf(stderr,
104 "%s: '%s' contains unexpected GOT entries\n",
105 program_name, path);
106 return false;
107 }
108 }
109
110 return true;
111}
112
113static inline bool FUNC(get_symbols)(const char *path, void *vdso)
114{
115 const ELF(Ehdr) *ehdr = vdso;
116 void *shdrs, *symtab;
117 ELF(Shdr) *shdr;
118 const ELF(Sym) *sym;
119 char *strtab, *name;
120 uint16_t sh_count, sh_entsize, st_count, st_entsize, i, j;
121 uint64_t offset;
122 uint32_t flags;
123
124 shdrs = vdso + FUNC(swap_uint)(ehdr->e_shoff);
125 sh_count = swap_uint16(ehdr->e_shnum);
126 sh_entsize = swap_uint16(ehdr->e_shentsize);
127
128 for (i = 0; i < sh_count; i++) {
129 shdr = shdrs + (i * sh_entsize);
130
131 if (swap_uint32(shdr->sh_type) == SHT_SYMTAB)
132 break;
133 }
134
135 if (i == sh_count) {
136 fprintf(stderr, "%s: '%s' has no symbol table\n", program_name,
137 path);
138 return false;
139 }
140
141 /* Get flags */
142 flags = swap_uint32(ehdr->e_flags);
143 if (elf_class == ELFCLASS64)
144 elf_abi = ABI_N64;
145 else if (flags & EF_MIPS_ABI2)
146 elf_abi = ABI_N32;
147 else
148 elf_abi = ABI_O32;
149
150 /* Get symbol table. */
151 symtab = vdso + FUNC(swap_uint)(shdr->sh_offset);
152 st_entsize = FUNC(swap_uint)(shdr->sh_entsize);
153 st_count = FUNC(swap_uint)(shdr->sh_size) / st_entsize;
154
155 /* Get string table. */
156 shdr = shdrs + (swap_uint32(shdr->sh_link) * sh_entsize);
157 strtab = vdso + FUNC(swap_uint)(shdr->sh_offset);
158
159 /* Write offsets for symbols needed by the kernel. */
160 for (i = 0; vdso_symbols[i].name; i++) {
161 if (!(vdso_symbols[i].abis & elf_abi))
162 continue;
163
164 for (j = 0; j < st_count; j++) {
165 sym = symtab + (j * st_entsize);
166 name = strtab + swap_uint32(sym->st_name);
167
168 if (!strcmp(name, vdso_symbols[i].name)) {
169 offset = FUNC(swap_uint)(sym->st_value);
170
171 fprintf(out_file,
172 "\t.%s = 0x%" PRIx64 ",\n",
173 vdso_symbols[i].offset_name, offset);
174 break;
175 }
176 }
177
178 if (j == st_count) {
179 fprintf(stderr,
180 "%s: '%s' is missing required symbol '%s'\n",
181 program_name, path, vdso_symbols[i].name);
182 return false;
183 }
184 }
185
186 return true;
187}
diff --git a/arch/mips/vdso/gettimeofday.c b/arch/mips/vdso/gettimeofday.c
new file mode 100644
index 000000000000..ce89c9e294f9
--- /dev/null
+++ b/arch/mips/vdso/gettimeofday.c
@@ -0,0 +1,232 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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 "vdso.h"
12
13#include <linux/compiler.h>
14#include <linux/irqchip/mips-gic.h>
15#include <linux/time.h>
16
17#include <asm/clocksource.h>
18#include <asm/io.h>
19#include <asm/mips-cm.h>
20#include <asm/unistd.h>
21#include <asm/vdso.h>
22
23static __always_inline int do_realtime_coarse(struct timespec *ts,
24 const union mips_vdso_data *data)
25{
26 u32 start_seq;
27
28 do {
29 start_seq = vdso_data_read_begin(data);
30
31 ts->tv_sec = data->xtime_sec;
32 ts->tv_nsec = data->xtime_nsec >> data->cs_shift;
33 } while (vdso_data_read_retry(data, start_seq));
34
35 return 0;
36}
37
38static __always_inline int do_monotonic_coarse(struct timespec *ts,
39 const union mips_vdso_data *data)
40{
41 u32 start_seq;
42 u32 to_mono_sec;
43 u32 to_mono_nsec;
44
45 do {
46 start_seq = vdso_data_read_begin(data);
47
48 ts->tv_sec = data->xtime_sec;
49 ts->tv_nsec = data->xtime_nsec >> data->cs_shift;
50
51 to_mono_sec = data->wall_to_mono_sec;
52 to_mono_nsec = data->wall_to_mono_nsec;
53 } while (vdso_data_read_retry(data, start_seq));
54
55 ts->tv_sec += to_mono_sec;
56 timespec_add_ns(ts, to_mono_nsec);
57
58 return 0;
59}
60
61#ifdef CONFIG_CSRC_R4K
62
63static __always_inline u64 read_r4k_count(void)
64{
65 unsigned int count;
66
67 __asm__ __volatile__(
68 " .set push\n"
69 " .set mips32r2\n"
70 " rdhwr %0, $2\n"
71 " .set pop\n"
72 : "=r" (count));
73
74 return count;
75}
76
77#endif
78
79#ifdef CONFIG_CLKSRC_MIPS_GIC
80
81static __always_inline u64 read_gic_count(const union mips_vdso_data *data)
82{
83 void __iomem *gic = get_gic(data);
84 u32 hi, hi2, lo;
85
86 do {
87 hi = __raw_readl(gic + GIC_UMV_SH_COUNTER_63_32_OFS);
88 lo = __raw_readl(gic + GIC_UMV_SH_COUNTER_31_00_OFS);
89 hi2 = __raw_readl(gic + GIC_UMV_SH_COUNTER_63_32_OFS);
90 } while (hi2 != hi);
91
92 return (((u64)hi) << 32) + lo;
93}
94
95#endif
96
97static __always_inline u64 get_ns(const union mips_vdso_data *data)
98{
99 u64 cycle_now, delta, nsec;
100
101 switch (data->clock_mode) {
102#ifdef CONFIG_CSRC_R4K
103 case VDSO_CLOCK_R4K:
104 cycle_now = read_r4k_count();
105 break;
106#endif
107#ifdef CONFIG_CLKSRC_MIPS_GIC
108 case VDSO_CLOCK_GIC:
109 cycle_now = read_gic_count(data);
110 break;
111#endif
112 default:
113 return 0;
114 }
115
116 delta = (cycle_now - data->cs_cycle_last) & data->cs_mask;
117
118 nsec = (delta * data->cs_mult) + data->xtime_nsec;
119 nsec >>= data->cs_shift;
120
121 return nsec;
122}
123
124static __always_inline int do_realtime(struct timespec *ts,
125 const union mips_vdso_data *data)
126{
127 u32 start_seq;
128 u64 ns;
129
130 do {
131 start_seq = vdso_data_read_begin(data);
132
133 if (data->clock_mode == VDSO_CLOCK_NONE)
134 return -ENOSYS;
135
136 ts->tv_sec = data->xtime_sec;
137 ns = get_ns(data);
138 } while (vdso_data_read_retry(data, start_seq));
139
140 ts->tv_nsec = 0;
141 timespec_add_ns(ts, ns);
142
143 return 0;
144}
145
146static __always_inline int do_monotonic(struct timespec *ts,
147 const union mips_vdso_data *data)
148{
149 u32 start_seq;
150 u64 ns;
151 u32 to_mono_sec;
152 u32 to_mono_nsec;
153
154 do {
155 start_seq = vdso_data_read_begin(data);
156
157 if (data->clock_mode == VDSO_CLOCK_NONE)
158 return -ENOSYS;
159
160 ts->tv_sec = data->xtime_sec;
161 ns = get_ns(data);
162
163 to_mono_sec = data->wall_to_mono_sec;
164 to_mono_nsec = data->wall_to_mono_nsec;
165 } while (vdso_data_read_retry(data, start_seq));
166
167 ts->tv_sec += to_mono_sec;
168 ts->tv_nsec = 0;
169 timespec_add_ns(ts, ns + to_mono_nsec);
170
171 return 0;
172}
173
174#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
175
176/*
177 * This is behind the ifdef so that we don't provide the symbol when there's no
178 * possibility of there being a usable clocksource, because there's nothing we
179 * can do without it. When libc fails the symbol lookup it should fall back on
180 * the standard syscall path.
181 */
182int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
183{
184 const union mips_vdso_data *data = get_vdso_data();
185 struct timespec ts;
186 int ret;
187
188 ret = do_realtime(&ts, data);
189 if (ret)
190 return ret;
191
192 if (tv) {
193 tv->tv_sec = ts.tv_sec;
194 tv->tv_usec = ts.tv_nsec / 1000;
195 }
196
197 if (tz) {
198 tz->tz_minuteswest = data->tz_minuteswest;
199 tz->tz_dsttime = data->tz_dsttime;
200 }
201
202 return 0;
203}
204
205#endif /* CONFIG_CLKSRC_MIPS_GIC */
206
207int __vdso_clock_gettime(clockid_t clkid, struct timespec *ts)
208{
209 const union mips_vdso_data *data = get_vdso_data();
210 int ret;
211
212 switch (clkid) {
213 case CLOCK_REALTIME_COARSE:
214 ret = do_realtime_coarse(ts, data);
215 break;
216 case CLOCK_MONOTONIC_COARSE:
217 ret = do_monotonic_coarse(ts, data);
218 break;
219 case CLOCK_REALTIME:
220 ret = do_realtime(ts, data);
221 break;
222 case CLOCK_MONOTONIC:
223 ret = do_monotonic(ts, data);
224 break;
225 default:
226 ret = -ENOSYS;
227 break;
228 }
229
230 /* If we return -ENOSYS libc should fall back to a syscall. */
231 return ret;
232}
diff --git a/arch/mips/vdso/sigreturn.S b/arch/mips/vdso/sigreturn.S
new file mode 100644
index 000000000000..715bf5993529
--- /dev/null
+++ b/arch/mips/vdso/sigreturn.S
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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 "vdso.h"
12
13#include <uapi/asm/unistd.h>
14
15#include <asm/regdef.h>
16#include <asm/asm.h>
17
18 .section .text
19 .cfi_sections .debug_frame
20
21LEAF(__vdso_rt_sigreturn)
22 .cfi_startproc
23 .frame sp, 0, ra
24 .mask 0x00000000, 0
25 .fmask 0x00000000, 0
26 .cfi_signal_frame
27
28 li v0, __NR_rt_sigreturn
29 syscall
30
31 .cfi_endproc
32 END(__vdso_rt_sigreturn)
33
34#if _MIPS_SIM == _MIPS_SIM_ABI32
35
36LEAF(__vdso_sigreturn)
37 .cfi_startproc
38 .frame sp, 0, ra
39 .mask 0x00000000, 0
40 .fmask 0x00000000, 0
41 .cfi_signal_frame
42
43 li v0, __NR_sigreturn
44 syscall
45
46 .cfi_endproc
47 END(__vdso_sigreturn)
48
49#endif
diff --git a/arch/mips/vdso/vdso.h b/arch/mips/vdso/vdso.h
new file mode 100644
index 000000000000..cfb1be441dec
--- /dev/null
+++ b/arch/mips/vdso/vdso.h
@@ -0,0 +1,89 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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 <asm/sgidefs.h>
12
13#if _MIPS_SIM != _MIPS_SIM_ABI64 && defined(CONFIG_64BIT)
14
15/* Building 32-bit VDSO for the 64-bit kernel. Fake a 32-bit Kconfig. */
16#undef CONFIG_64BIT
17#define CONFIG_32BIT 1
18#ifndef __ASSEMBLY__
19#include <asm-generic/atomic64.h>
20#endif
21#endif
22
23#ifndef __ASSEMBLY__
24
25#include <asm/asm.h>
26#include <asm/page.h>
27#include <asm/vdso.h>
28
29static inline unsigned long get_vdso_base(void)
30{
31 unsigned long addr;
32
33 /*
34 * We can't use cpu_has_mips_r6 since it needs the cpu_data[]
35 * kernel symbol.
36 */
37#ifdef CONFIG_CPU_MIPSR6
38 /*
39 * lapc <symbol> is an alias to addiupc reg, <symbol> - .
40 *
41 * We can't use addiupc because there is no label-label
42 * support for the addiupc reloc
43 */
44 __asm__("lapc %0, _start \n"
45 : "=r" (addr) : :);
46#else
47 /*
48 * Get the base load address of the VDSO. We have to avoid generating
49 * relocations and references to the GOT because ld.so does not peform
50 * relocations on the VDSO. We use the current offset from the VDSO base
51 * and perform a PC-relative branch which gives the absolute address in
52 * ra, and take the difference. The assembler chokes on
53 * "li %0, _start - .", so embed the offset as a word and branch over
54 * it.
55 *
56 */
57
58 __asm__(
59 " .set push \n"
60 " .set noreorder \n"
61 " bal 1f \n"
62 " nop \n"
63 " .word _start - . \n"
64 "1: lw %0, 0($31) \n"
65 " " STR(PTR_ADDU) " %0, $31, %0 \n"
66 " .set pop \n"
67 : "=r" (addr)
68 :
69 : "$31");
70#endif /* CONFIG_CPU_MIPSR6 */
71
72 return addr;
73}
74
75static inline const union mips_vdso_data *get_vdso_data(void)
76{
77 return (const union mips_vdso_data *)(get_vdso_base() - PAGE_SIZE);
78}
79
80#ifdef CONFIG_CLKSRC_MIPS_GIC
81
82static inline void __iomem *get_gic(const union mips_vdso_data *data)
83{
84 return (void __iomem *)data - PAGE_SIZE;
85}
86
87#endif /* CONFIG_CLKSRC_MIPS_GIC */
88
89#endif /* __ASSEMBLY__ */
diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S
new file mode 100644
index 000000000000..8df7dd53e8e0
--- /dev/null
+++ b/arch/mips/vdso/vdso.lds.S
@@ -0,0 +1,105 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Alex Smith <alex.smith@imgtec.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 <asm/sgidefs.h>
12
13#if _MIPS_SIM == _MIPS_SIM_ABI64
14OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", "elf64-tradlittlemips")
15#elif _MIPS_SIM == _MIPS_SIM_NABI32
16OUTPUT_FORMAT("elf32-ntradlittlemips", "elf32-ntradbigmips", "elf32-ntradlittlemips")
17#else
18OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips", "elf32-tradlittlemips")
19#endif
20
21OUTPUT_ARCH(mips)
22
23SECTIONS
24{
25 PROVIDE(_start = .);
26 . = SIZEOF_HEADERS;
27
28 /*
29 * In order to retain compatibility with older toolchains we provide the
30 * ABI flags section ourself. Newer assemblers will automatically
31 * generate .MIPS.abiflags sections so we discard such input sections,
32 * and then manually define our own section here. genvdso will patch
33 * this section to have the correct name/type.
34 */
35 .mips_abiflags : { *(.mips_abiflags) } :text :abiflags
36
37 .reginfo : { *(.reginfo) } :text :reginfo
38
39 .hash : { *(.hash) } :text
40 .gnu.hash : { *(.gnu.hash) }
41 .dynsym : { *(.dynsym) }
42 .dynstr : { *(.dynstr) }
43 .gnu.version : { *(.gnu.version) }
44 .gnu.version_d : { *(.gnu.version_d) }
45 .gnu.version_r : { *(.gnu.version_r) }
46
47 .note : { *(.note.*) } :text :note
48
49 .text : { *(.text*) } :text
50 PROVIDE (__etext = .);
51 PROVIDE (_etext = .);
52 PROVIDE (etext = .);
53
54 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
55 .eh_frame : { KEEP (*(.eh_frame)) } :text
56
57 .dynamic : { *(.dynamic) } :text :dynamic
58
59 .rodata : { *(.rodata*) } :text
60
61 _end = .;
62 PROVIDE(end = .);
63
64 /DISCARD/ : {
65 *(.MIPS.abiflags)
66 *(.gnu.attributes)
67 *(.note.GNU-stack)
68 *(.data .data.* .gnu.linkonce.d.* .sdata*)
69 *(.bss .sbss .dynbss .dynsbss)
70 }
71}
72
73PHDRS
74{
75 /*
76 * Provide a PT_MIPS_ABIFLAGS header to assign the ABI flags section
77 * to. We can specify the header type directly here so no modification
78 * is needed later on.
79 */
80 abiflags 0x70000003;
81
82 /*
83 * The ABI flags header must exist directly after the PT_INTERP header,
84 * so we must explicitly place the PT_MIPS_REGINFO header after it to
85 * stop the linker putting one in at the start.
86 */
87 reginfo 0x70000000;
88
89 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
90 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
91 note PT_NOTE FLAGS(4); /* PF_R */
92 eh_frame_hdr PT_GNU_EH_FRAME;
93}
94
95VERSION
96{
97 LINUX_2.6 {
98#ifndef DISABLE_MIPS_VDSO
99 global:
100 __vdso_clock_gettime;
101 __vdso_gettimeofday;
102#endif
103 local: *;
104 };
105}
diff --git a/arch/mips/xilfpga/Kconfig b/arch/mips/xilfpga/Kconfig
new file mode 100644
index 000000000000..42a030a0edba
--- /dev/null
+++ b/arch/mips/xilfpga/Kconfig
@@ -0,0 +1,9 @@
1choice
2 prompt "Machine type"
3 depends on MACH_XILFPGA
4 default XILFPGA_NEXYS4DDR
5
6config XILFPGA_NEXYS4DDR
7 bool "Nexys4DDR by Digilent"
8
9endchoice
diff --git a/arch/mips/xilfpga/Makefile b/arch/mips/xilfpga/Makefile
new file mode 100644
index 000000000000..a4deec6fadbc
--- /dev/null
+++ b/arch/mips/xilfpga/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the Xilfpga
3#
4
5obj-y += init.o
6obj-y += intc.o
7obj-y += time.o
diff --git a/arch/mips/xilfpga/Platform b/arch/mips/xilfpga/Platform
new file mode 100644
index 000000000000..ed375afe3d39
--- /dev/null
+++ b/arch/mips/xilfpga/Platform
@@ -0,0 +1,3 @@
1platform-$(CONFIG_MACH_XILFPGA) += xilfpga/
2cflags-$(CONFIG_MACH_XILFPGA) += -I$(srctree)/arch/mips/include/asm/mach-xilfpga
3load-$(CONFIG_MACH_XILFPGA) += 0xffffffff80100000
diff --git a/arch/mips/xilfpga/init.c b/arch/mips/xilfpga/init.c
new file mode 100644
index 000000000000..ce2aee2169ac
--- /dev/null
+++ b/arch/mips/xilfpga/init.c
@@ -0,0 +1,57 @@
1/*
2 * Xilfpga platform setup
3 *
4 * Copyright (C) 2015 Imagination Technologies
5 * Author: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 */
11
12#include <linux/of_fdt.h>
13#include <linux/of_platform.h>
14
15#include <asm/prom.h>
16
17#define XILFPGA_UART_BASE 0xb0401000
18
19const char *get_system_type(void)
20{
21 return "MIPSfpga";
22}
23
24void __init plat_mem_setup(void)
25{
26 __dt_setup_arch(__dtb_start);
27 strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
28}
29
30void __init prom_init(void)
31{
32 setup_8250_early_printk_port(XILFPGA_UART_BASE, 2, 50000);
33}
34
35void __init prom_free_prom_memory(void)
36{
37}
38
39void __init device_tree_init(void)
40{
41 if (!initial_boot_params)
42 return;
43
44 unflatten_and_copy_device_tree();
45}
46
47static int __init plat_of_setup(void)
48{
49 if (!of_have_populated_dt())
50 panic("Device tree not present");
51
52 if (of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL))
53 panic("Failed to populate DT");
54
55 return 0;
56}
57arch_initcall(plat_of_setup);
diff --git a/arch/mips/xilfpga/intc.c b/arch/mips/xilfpga/intc.c
new file mode 100644
index 000000000000..c4d1a716b347
--- /dev/null
+++ b/arch/mips/xilfpga/intc.c
@@ -0,0 +1,25 @@
1/*
2 * Xilfpga interrupt controller setup
3 *
4 * Copyright (C) 2015 Imagination Technologies
5 * Author: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 */
11
12#include <linux/of.h>
13#include <linux/of_irq.h>
14
15#include <asm/irq_cpu.h>
16
17static struct of_device_id of_irq_ids[] __initdata = {
18 { .compatible = "mti,cpu-interrupt-controller", .data = mips_cpu_irq_of_init },
19 {},
20};
21
22void __init arch_init_irq(void)
23{
24 of_irq_init(of_irq_ids);
25}
diff --git a/arch/mips/xilfpga/time.c b/arch/mips/xilfpga/time.c
new file mode 100644
index 000000000000..cbb3fca7b6fa
--- /dev/null
+++ b/arch/mips/xilfpga/time.c
@@ -0,0 +1,41 @@
1/*
2 * Xilfpga clocksource/timer setup
3 *
4 * Copyright (C) 2015 Imagination Technologies
5 * Author: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 */
11
12#include <linux/clk.h>
13#include <linux/clk-provider.h>
14#include <linux/clocksource.h>
15#include <linux/of.h>
16
17#include <asm/time.h>
18
19void __init plat_time_init(void)
20{
21 struct device_node *np;
22 struct clk *clk;
23
24 of_clk_init(NULL);
25 clocksource_probe();
26
27 np = of_get_cpu_node(0, NULL);
28 if (!np) {
29 pr_err("Failed to get CPU node\n");
30 return;
31 }
32
33 clk = of_clk_get(np, 0);
34 if (IS_ERR(clk)) {
35 pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
36 return;
37 }
38
39 mips_hpt_frequency = clk_get_rate(clk) / 2;
40 clk_put(clk);
41}
diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index 02a1945e5093..89d3e4d7900c 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -140,9 +140,10 @@ static cycle_t gic_hpt_read(struct clocksource *cs)
140} 140}
141 141
142static struct clocksource gic_clocksource = { 142static struct clocksource gic_clocksource = {
143 .name = "GIC", 143 .name = "GIC",
144 .read = gic_hpt_read, 144 .read = gic_hpt_read,
145 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 145 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
146 .archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC },
146}; 147};
147 148
148static void __init __gic_clocksource_init(void) 149static void __init __gic_clocksource_init(void)
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index aeaa061f0dbf..9e17ef27a183 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -29,6 +29,7 @@ struct gic_pcpu_mask {
29 DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS); 29 DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS);
30}; 30};
31 31
32static unsigned long __gic_base_addr;
32static void __iomem *gic_base; 33static void __iomem *gic_base;
33static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; 34static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
34static DEFINE_SPINLOCK(gic_lock); 35static DEFINE_SPINLOCK(gic_lock);
@@ -301,6 +302,17 @@ int gic_get_c0_fdc_int(void)
301 GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_FDC)); 302 GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_FDC));
302} 303}
303 304
305int gic_get_usm_range(struct resource *gic_usm_res)
306{
307 if (!gic_present)
308 return -1;
309
310 gic_usm_res->start = __gic_base_addr + USM_VISIBLE_SECTION_OFS;
311 gic_usm_res->end = gic_usm_res->start + (USM_VISIBLE_SECTION_SIZE - 1);
312
313 return 0;
314}
315
304static void gic_handle_shared_int(bool chained) 316static void gic_handle_shared_int(bool chained)
305{ 317{
306 unsigned int i, intr, virq, gic_reg_step = mips_cm_is64 ? 8 : 4; 318 unsigned int i, intr, virq, gic_reg_step = mips_cm_is64 ? 8 : 4;
@@ -798,6 +810,8 @@ static void __init __gic_init(unsigned long gic_base_addr,
798{ 810{
799 unsigned int gicconfig; 811 unsigned int gicconfig;
800 812
813 __gic_base_addr = gic_base_addr;
814
801 gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size); 815 gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size);
802 816
803 gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); 817 gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG));
diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h
index 4e6861605050..ce824db48d64 100644
--- a/include/linux/irqchip/mips-gic.h
+++ b/include/linux/irqchip/mips-gic.h
@@ -9,6 +9,7 @@
9#define __LINUX_IRQCHIP_MIPS_GIC_H 9#define __LINUX_IRQCHIP_MIPS_GIC_H
10 10
11#include <linux/clocksource.h> 11#include <linux/clocksource.h>
12#include <linux/ioport.h>
12 13
13#define GIC_MAX_INTRS 256 14#define GIC_MAX_INTRS 256
14 15
@@ -245,6 +246,8 @@
245#define GIC_SHARED_TO_HWIRQ(x) (GIC_SHARED_HWIRQ_BASE + (x)) 246#define GIC_SHARED_TO_HWIRQ(x) (GIC_SHARED_HWIRQ_BASE + (x))
246#define GIC_HWIRQ_TO_SHARED(x) ((x) - GIC_SHARED_HWIRQ_BASE) 247#define GIC_HWIRQ_TO_SHARED(x) ((x) - GIC_SHARED_HWIRQ_BASE)
247 248
249#ifdef CONFIG_MIPS_GIC
250
248extern unsigned int gic_present; 251extern unsigned int gic_present;
249 252
250extern void gic_init(unsigned long gic_base_addr, 253extern void gic_init(unsigned long gic_base_addr,
@@ -264,4 +267,18 @@ extern unsigned int plat_ipi_resched_int_xlate(unsigned int);
264extern int gic_get_c0_compare_int(void); 267extern int gic_get_c0_compare_int(void);
265extern int gic_get_c0_perfcount_int(void); 268extern int gic_get_c0_perfcount_int(void);
266extern int gic_get_c0_fdc_int(void); 269extern int gic_get_c0_fdc_int(void);
270extern int gic_get_usm_range(struct resource *gic_usm_res);
271
272#else /* CONFIG_MIPS_GIC */
273
274#define gic_present 0
275
276static inline int gic_get_usm_range(struct resource *gic_usm_res)
277{
278 /* Shouldn't be called. */
279 return -1;
280}
281
282#endif /* CONFIG_MIPS_GIC */
283
267#endif /* __LINUX_IRQCHIP_MIPS_GIC_H */ 284#endif /* __LINUX_IRQCHIP_MIPS_GIC_H */